-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.vue
69 lines (63 loc) · 1.45 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
<template>
<div id="app" class="bg-bg">
<n-config-provider
:theme="theme"
:theme-overrides="themeOverrides"
:locale="locale"
:date-locale="dateLocale"
>
<n-message-provider
placement="bottom-right"
:keep-alive-on-hover="true"
:duration="3000"
closable
>
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
</n-message-provider>
<CookieConsent />
</n-config-provider>
</div>
</template>
<script lang="ts" setup>
import { lightTheme, darkTheme, enUS, dateEnUS } from 'naive-ui';
const $i18n = useI18n();
window.$i18n = $i18n;
const lang = computed(() => {
return $i18n.locale.value;
});
const locale = computed(() => {
switch ($i18n.locale.value) {
case 'en':
return enUS;
default:
return enUS;
}
});
const dateLocale = computed(() => {
switch ($i18n.locale.value) {
case 'en':
return dateEnUS;
default:
return dateEnUS;
}
});
/** Theme switcher dark/light mode
const prefersTheme =
localStorage.getItem('theme') === 'dark' ||
(!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme:dark)').matches);
*/
const prefersDarkTheme = true;
const themeName = prefersDarkTheme ? 'dark' : 'light';
localStorage.setItem('theme', themeName);
const theme = computed(() => {
return prefersDarkTheme ? darkTheme : lightTheme;
});
useHead({
htmlAttrs: {
class: themeName,
lang,
},
});
</script>