2022-09-06 11:52:18 +00:00
|
|
|
<template>
|
2023-10-10 05:41:15 +00:00
|
|
|
<NuxtLayout>
|
2022-09-14 14:26:41 +00:00
|
|
|
<NuxtPage />
|
|
|
|
</NuxtLayout>
|
2022-09-06 11:52:18 +00:00
|
|
|
</template>
|
2022-09-06 13:53:29 +00:00
|
|
|
|
|
|
|
<script>
|
2023-02-28 08:29:30 +00:00
|
|
|
import EventBus from '@/layouts/AppEventBus';
|
2022-09-09 14:35:31 +00:00
|
|
|
|
2022-09-09 10:25:14 +00:00
|
|
|
export default {
|
2023-10-15 04:10:40 +00:00
|
|
|
watch: {
|
|
|
|
$route: {
|
|
|
|
handler(to) {
|
|
|
|
if (to.name === 'index') {
|
2023-11-20 08:33:43 +00:00
|
|
|
this.themeChangeListener({ theme: this.$appState.darkTheme ? 'lara-dark-green' : 'lara-light-green', dark: this.$appState.darkTheme });
|
2023-10-15 04:10:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2023-12-30 22:26:14 +00:00
|
|
|
created() {
|
|
|
|
useServerHead({
|
|
|
|
link: [
|
|
|
|
{
|
|
|
|
id: 'theme-link',
|
|
|
|
rel: 'stylesheet',
|
|
|
|
href: '/themes/lara-light-green/theme.css'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'home-table-link',
|
|
|
|
rel: 'stylesheet',
|
|
|
|
href: '/styles/landing/themes/lara-light-green/theme.css'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
});
|
|
|
|
},
|
2022-09-09 10:25:14 +00:00
|
|
|
mounted() {
|
2023-12-30 22:26:14 +00:00
|
|
|
const preferredColorScheme = localStorage.getItem(this.$appState.colorSchemeKey);
|
|
|
|
const prefersDarkColorScheme = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
2023-12-26 21:35:16 +00:00
|
|
|
|
2023-12-30 22:26:14 +00:00
|
|
|
if ((preferredColorScheme === null && prefersDarkColorScheme) || preferredColorScheme === 'dark') {
|
|
|
|
this.applyTheme({ theme: 'lara-dark-green', dark: true });
|
|
|
|
}
|
2022-09-09 10:25:14 +00:00
|
|
|
|
|
|
|
EventBus.on('theme-change', this.themeChangeListener);
|
|
|
|
},
|
|
|
|
beforeUnmount() {
|
|
|
|
EventBus.off('theme-change', this.themeChangeListener);
|
2023-12-26 21:35:16 +00:00
|
|
|
},
|
|
|
|
methods: {
|
2023-12-30 22:26:14 +00:00
|
|
|
themeChangeListener(event) {
|
|
|
|
if (!document.startViewTransition) {
|
|
|
|
this.applyTheme(event);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
document.startViewTransition(() => this.applyTheme(event));
|
|
|
|
},
|
2023-12-26 21:35:16 +00:00
|
|
|
applyTheme(event) {
|
|
|
|
this.$primevue.changeTheme(this.$appState.theme, event.theme, 'theme-link', () => {
|
|
|
|
this.$appState.theme = event.theme;
|
|
|
|
this.$appState.darkTheme = event.dark;
|
2023-12-30 22:26:14 +00:00
|
|
|
|
2023-12-26 21:35:16 +00:00
|
|
|
EventBus.emit('theme-change-complete', { theme: event.theme, dark: event.dark });
|
|
|
|
});
|
|
|
|
}
|
2022-09-09 10:25:14 +00:00
|
|
|
}
|
2022-09-14 14:26:41 +00:00
|
|
|
};
|
|
|
|
</script>
|
2022-12-09 09:02:20 +00:00
|
|
|
|
2023-09-25 11:09:54 +00:00
|
|
|
<style lang="scss"></style>
|