forked from Hanziness/FocusTide
-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.vue
56 lines (50 loc) · 1.14 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
<script setup lang="ts">
import { swPath } from 'virtual:pwa'
import { useSettings } from '~~/stores/settings'
if (!process.server) {
useHead({
link: [
{
rel: 'manifest',
href: '/app_manifest.json'
},
{
rel: 'apple-touch-icon',
href: '/icons/icon-apple-192.png'
}
],
meta: [
{ name: 'theme-color', content: '#F87171' }
]
})
onMounted(() => {
if (typeof window !== 'undefined') {
if ('serviceWorker' in navigator) {
const registerSw = () => {
console.debug(`Registering service worker at /${swPath}`)
navigator.serviceWorker.register(`/${swPath}`)
}
if (document.readyState === 'complete') {
registerSw()
} else {
window.addEventListener('load', registerSw)
}
}
}
})
}
const settingsStore = useSettings()
const isDarkMode = computed(() => settingsStore.visuals.darkMode)
watch(isDarkMode, (newDarkMode) => {
useHead({
bodyAttrs: {
class: newDarkMode ? 'dark' : undefined
}
})
})
</script>
<template>
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
</template>