-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.vue
130 lines (113 loc) · 2.87 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<template>
<VitePwaManifest />
<BaseMask v-if="bgIsGray" />
<NuxtPage v-if="show" />
<UpdateLinkOverlay v-if="isMobile && updatedLinkId" />
<AddLinkOverlay v-if="isMobile && addLinkOverlay" />
<PreviewOverlay v-if="!isMobile && isPreviewOverlay" />
</template>
<script setup lang="ts">
import BaseMask from '~~/components/UI/BaseMask.vue'
import { useUserStore } from '~~/stores/user/user.store'
import { storeToRefs } from 'pinia'
import { Color } from 'shared/types'
const userStore = useUserStore()
const { isMobile, isPreviewOverlay, updatedLinkId, addLinkOverlay, id } =
storeToRefs(userStore)
const route = useRoute()
const show = ref<boolean>(false)
const bgIsGray = ref<boolean>(false)
const setColors = () => {
const THEME_COLORS: Color[] = [
{ id: 1, color: 'bg-white', text: 'text-black', name: 'Air White' },
{ id: 2, color: 'bg-gray-800', text: 'text-white', name: 'Lake Black' },
{
id: 3,
color: 'bg-gradient-to-t from-indigo-500 via-purple-500 to-pink-500',
text: 'text-white',
name: 'Purple Pie'
},
{
id: 4,
color: 'bg-gradient-to-t from-gray-500 via-blue-500 to-green-500',
text: 'text-white',
name: 'Green Grass'
},
{
id: 5,
color: 'bg-gradient-to-t from-orange-500 via-green-500 to-red-500',
text: 'text-white',
name: 'Traffic Lights'
},
{
id: 6,
color: 'bg-gradient-to-b from-blue-800 via-blue-500 to-green-500',
text: 'text-white',
name: 'Blue Sky'
},
{
id: 7,
color: 'bg-gradient-to-t from-lime-500 via-indigo-700 to-amber-500',
text: 'text-white',
name: 'Soft Horizon'
},
{
id: 8,
color: 'bg-gradient-to-t from-gray-800 to-emerald-500',
text: 'text-white',
name: 'Tinted Lake'
}
]
return THEME_COLORS
}
const checkPath = (path: string) => {
if (path == '/' || path == '/register') {
bgIsGray.value = false
return
}
bgIsGray.value = true
}
watch(
() => route.fullPath,
(path) => {
checkPath(path)
}
)
watch(
() => isPreviewOverlay.value,
(value) => {
let id = null
if (route.fullPath === '/admin') {
id = 'AdminPage'
} else if (route.fullPath === '/admin/appearance') {
id = 'AppearancePage'
} else if (route.fullPath === 'admin/settings') {
id = 'SettingsPage'
}
if (!id) return
userStore.hidePageOverflow(value, id)
}
)
onMounted(async () => {
updatedLinkId.value = 0
addLinkOverlay.value = false
isPreviewOverlay.value = false
isMobile.value = false
try {
if (id.value) {
await userStore.hasSessionExpired()
await userStore.getUser()
await userStore.getAllLinks()
}
} catch (error) {
console.log(error)
}
checkPath(route.fullPath)
if ('ontouchstart' in window) {
isMobile.value = true
}
setTimeout(() => {
show.value = true
}, 1)
})
</script>