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>
|
2024-05-24 08:17:58 +00:00
|
|
|
|
|
|
|
<script>
|
|
|
|
import EventBus from '@/layouts/AppEventBus';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
mounted() {
|
|
|
|
EventBus.on('dark-mode-toggle', this.darkModeToggleListener);
|
|
|
|
},
|
|
|
|
beforeUnmount() {
|
|
|
|
EventBus.off('dark-mode-toggle', this.darkModeToggleListener);
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
darkModeToggleListener(event) {
|
|
|
|
if (!document.startViewTransition) {
|
|
|
|
this.toggleDarkMode(event);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
document.startViewTransition(() => this.toggleDarkMode(event));
|
|
|
|
},
|
|
|
|
toggleDarkMode(event) {
|
|
|
|
const isDark = event.dark;
|
|
|
|
|
|
|
|
if (isDark) document.documentElement.classList.add('p-dark');
|
|
|
|
else document.documentElement.classList.remove('p-dark');
|
|
|
|
|
|
|
|
this.$appState.darkTheme = isDark;
|
|
|
|
|
|
|
|
EventBus.emit('dark-mode-toggle-complete');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss"></style>
|