forked from danieldeusing/jesse-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.vue
63 lines (51 loc) · 1.3 KB
/
app.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<template>
<ClientOnly>
<NuxtLoadingIndicator />
<NuxtLayout>
<Nav v-if="useMainStore().isAuthenticated" />
<Login v-if="showLogin" />
<Loading v-else-if="loading" />
<NuxtPage v-else />
</NuxtLayout>
<UNotifications />
</ClientOnly>
</template>
<script setup lang="ts">
import { useMainStore } from '~/stores/mainStore'
import { useSocketStore } from '~/stores/websocketStore'
const showLogin = ref(false)
const loading = ref(true)
const settings = computed(() => useMainStore().settings)
const authToken = computed(() => useMainStore().authToken)
const initiated = computed(() => useMainStore().initiated)
if (useMainStore().isAuthenticated) {
if (useMainStore().initiated) {
loading.value = false
}
useSocketStore().initiate()
setTimeout(() => {
useMainStore().initiate()
}, 300)
}
else {
showLogin.value = true
useMainStore().initiated = false
}
watch(authToken, (newValue, oldValue) => {
if (newValue !== oldValue) {
useMainStore().initiate()
}
})
watch(initiated, (newValue) => {
if (newValue) {
loading.value = false
}
})
watch(settings, () => {
useMainStore().updateConfig()
}, { deep: true })
onMounted(() => {
document.documentElement.classList.add('h-full', 'bg-gray-50')
document.body.classList.add('h-full')
})
</script>