-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.vue
61 lines (58 loc) · 1.94 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
<script setup>
const showNotification = ref(false)
if (useRuntimeConfig().public.NODE_ENV === 'production') {
onMounted(async () => {
if ('serviceWorker' in navigator) {
const { Workbox } = await import('workbox-window')
const workbox = new Workbox('/sw.js')
workbox.addEventListener('installed', (event) => {
// If we don't do this we'll be displaying the notification after the initial installation, which isn't perferred.
if (event.isUpdate) {
// whatever logic you want to use to notify the user that they need to refresh the page.
showNotification.value = true
// trigerUpdate
}
})
workbox.register()
}
})
}
function handleError(err) {
console.error(err)
}
const links = [
{ text: 'Home', to: '/' },
{ text: 'Batting Stats', to: '/batting-stats/' },
{ text: 'Fielding Stats', to: '/fielding-stats/' },
{ text: 'Pitching Stats', to: '/pitching-stats/' },
{ text: 'Changelog', to: '/changelog/' },
{ text: 'NABA Dump', to: 'https://naba-dump.fly.dev' },
{ text: 'Github', to: 'https://github.com/Twitch0125/naba-hub' },
]
</script>
<template>
<div
class="flow-layout mx-auto px flow-sm lg:flow max-w-screen-lg font-sans"
>
<Html class="bg-base h-screen" />
<Title> NABA Hub </Title>
<NuxtLoadingIndicator />
<nav class="space-x [&>a:not([aria-current=page])]:text-secondary">
<NuxtLink v-for="link in links" :key="link.to" class="hover:underline" active-class="font-bold" :to="link.to">
{{ link.text }}
</NuxtLink>
</nav>
<UpdateNotification v-if="showNotification" @update:model-value="showNotification = $event" />
<NuxtErrorBoundary @error="handleError">
<NuxtPage />
<template #error="{ error }">
<div>
<p>Oops, something went wrong:</p>
<pre>
{{ error }}
</pre>
</div>
</template>
</NuxtErrorBoundary>
</div>
</template>