2021-07-24 20:56:37 +02:00
|
|
|
<template>
|
2021-09-29 20:16:04 +02:00
|
|
|
<div id="top" />
|
2021-09-27 12:50:26 +02:00
|
|
|
<NavBar @menuInteraction="updateHideScrollBar" />
|
2021-08-15 16:40:11 +02:00
|
|
|
<div v-if="appLoading" class="app-container">
|
|
|
|
<div class="app-loading">
|
|
|
|
<Loader />
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-09-27 12:50:26 +02:00
|
|
|
<div v-else class="app-container" :class="{ 'hide-scroll': hideScrollBar }">
|
2021-08-15 16:40:11 +02:00
|
|
|
<router-view v-if="appConfig" />
|
|
|
|
<NoConfig v-else />
|
2021-08-15 09:24:10 +02:00
|
|
|
</div>
|
2021-09-29 20:16:04 +02:00
|
|
|
<div class="container scroll">
|
|
|
|
<div
|
|
|
|
class="scroll-button"
|
|
|
|
:class="{ 'display-button': displayScrollButton }"
|
|
|
|
@click="scrollToTop"
|
|
|
|
>
|
|
|
|
<i class="fa fa-chevron-up" aria-hidden="true"></i>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-07-25 17:10:55 +02:00
|
|
|
<Footer />
|
2021-07-24 20:56:37 +02:00
|
|
|
</template>
|
|
|
|
|
2021-07-25 13:03:34 +02:00
|
|
|
<script lang="ts">
|
2021-09-27 12:50:26 +02:00
|
|
|
import {
|
|
|
|
ComputedRef,
|
|
|
|
computed,
|
|
|
|
defineComponent,
|
|
|
|
ref,
|
|
|
|
onBeforeMount,
|
2021-09-29 20:16:04 +02:00
|
|
|
onMounted,
|
2021-09-27 12:50:26 +02:00
|
|
|
} from 'vue'
|
2021-08-11 22:21:26 +02:00
|
|
|
|
2021-08-21 18:34:06 +02:00
|
|
|
import Footer from '@/components/Footer.vue'
|
2021-07-25 13:23:25 +02:00
|
|
|
import NavBar from '@/components/NavBar.vue'
|
2021-08-15 16:40:11 +02:00
|
|
|
import NoConfig from '@/components/NoConfig.vue'
|
2021-08-21 18:34:06 +02:00
|
|
|
import { ROOT_STORE } from '@/store/constants'
|
2021-10-24 20:13:28 +02:00
|
|
|
import { TAppConfig } from '@/types/application'
|
2021-08-21 18:34:06 +02:00
|
|
|
import { useStore } from '@/use/useStore'
|
2021-07-25 13:03:34 +02:00
|
|
|
|
2021-07-25 13:23:25 +02:00
|
|
|
export default defineComponent({
|
|
|
|
name: 'App',
|
|
|
|
components: {
|
2021-07-25 17:10:55 +02:00
|
|
|
Footer,
|
2021-07-25 13:23:25 +02:00
|
|
|
NavBar,
|
2021-08-15 16:40:11 +02:00
|
|
|
NoConfig,
|
2021-07-25 13:23:25 +02:00
|
|
|
},
|
2021-08-15 12:30:39 +02:00
|
|
|
setup() {
|
|
|
|
const store = useStore()
|
2021-09-27 12:50:26 +02:00
|
|
|
|
2021-10-24 20:13:28 +02:00
|
|
|
const appConfig: ComputedRef<TAppConfig> = computed(
|
2021-08-15 16:40:11 +02:00
|
|
|
() => store.getters[ROOT_STORE.GETTERS.APP_CONFIG]
|
|
|
|
)
|
|
|
|
const appLoading: ComputedRef<boolean> = computed(
|
|
|
|
() => store.getters[ROOT_STORE.GETTERS.APP_LOADING]
|
|
|
|
)
|
2021-09-27 12:50:26 +02:00
|
|
|
const hideScrollBar = ref(false)
|
2021-09-29 20:16:04 +02:00
|
|
|
const displayScrollButton = ref(false)
|
|
|
|
|
|
|
|
onBeforeMount(() =>
|
|
|
|
store.dispatch(ROOT_STORE.ACTIONS.GET_APPLICATION_CONFIG)
|
|
|
|
)
|
|
|
|
onMounted(() => scroll())
|
2021-09-27 12:50:26 +02:00
|
|
|
|
|
|
|
function updateHideScrollBar(isMenuOpen: boolean) {
|
|
|
|
hideScrollBar.value = isMenuOpen
|
|
|
|
}
|
|
|
|
|
2021-09-29 20:16:04 +02:00
|
|
|
function isScrolledToBottom(element: Element): boolean {
|
|
|
|
return (
|
|
|
|
element.getBoundingClientRect().top < window.innerHeight &&
|
|
|
|
element.getBoundingClientRect().bottom >= 0
|
|
|
|
)
|
|
|
|
}
|
|
|
|
function scroll() {
|
|
|
|
window.onscroll = () => {
|
|
|
|
let bottom = document.querySelector('#bottom')
|
|
|
|
displayScrollButton.value =
|
|
|
|
bottom !== null && isScrolledToBottom(bottom)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function scrollToTop() {
|
|
|
|
window.scrollTo({
|
|
|
|
top: 0,
|
|
|
|
behavior: 'smooth',
|
|
|
|
})
|
|
|
|
setTimeout(() => {
|
|
|
|
displayScrollButton.value = false
|
|
|
|
}, 300)
|
|
|
|
}
|
2021-09-27 12:50:26 +02:00
|
|
|
|
2021-08-15 16:40:11 +02:00
|
|
|
return {
|
|
|
|
appConfig,
|
|
|
|
appLoading,
|
2021-09-27 12:50:26 +02:00
|
|
|
hideScrollBar,
|
2021-09-29 20:16:04 +02:00
|
|
|
displayScrollButton,
|
|
|
|
scrollToTop,
|
2021-09-27 12:50:26 +02:00
|
|
|
updateHideScrollBar,
|
2021-08-15 16:40:11 +02:00
|
|
|
}
|
2021-08-15 12:30:39 +02:00
|
|
|
},
|
2021-07-25 13:23:25 +02:00
|
|
|
})
|
2021-07-25 13:03:34 +02:00
|
|
|
</script>
|
|
|
|
|
2021-09-20 12:18:40 +02:00
|
|
|
<style lang="scss" scoped>
|
2021-08-04 09:10:00 +02:00
|
|
|
@import '~@/scss/base';
|
2021-08-15 09:24:10 +02:00
|
|
|
.app-container {
|
|
|
|
height: $app-height;
|
2021-08-15 16:40:11 +02:00
|
|
|
|
2021-09-27 12:50:26 +02:00
|
|
|
&.hide-scroll {
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
|
|
|
|
2021-08-15 16:40:11 +02:00
|
|
|
.app-loading {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
height: 100%;
|
|
|
|
}
|
2021-08-15 09:24:10 +02:00
|
|
|
}
|
2021-09-29 20:16:04 +02:00
|
|
|
|
|
|
|
.scroll {
|
|
|
|
display: flex;
|
|
|
|
justify-content: flex-end;
|
|
|
|
position: fixed;
|
|
|
|
bottom: 42px;
|
|
|
|
right: -15px;
|
|
|
|
padding: 0 $default-padding * 2.5;
|
|
|
|
|
|
|
|
.scroll-button {
|
|
|
|
background-color: var(--scroll-button-bg-color);
|
|
|
|
border-radius: $border-radius;
|
|
|
|
box-shadow: 1px 1px 3px lightgrey;
|
|
|
|
display: none;
|
|
|
|
padding: 0 $default-padding;
|
|
|
|
|
|
|
|
&.display-button {
|
|
|
|
display: block;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-07-24 20:56:37 +02:00
|
|
|
</style>
|