2022-09-06 11:52:18 +00:00
|
|
|
<template>
|
2022-09-14 14:26:41 +00:00
|
|
|
<NuxtLayout :name="layout">
|
|
|
|
<NuxtPage />
|
|
|
|
</NuxtLayout>
|
2022-09-06 11:52:18 +00:00
|
|
|
</template>
|
2022-09-06 13:53:29 +00:00
|
|
|
|
|
|
|
<script>
|
2022-09-09 10:25:14 +00:00
|
|
|
import EventBus from '@/layouts/AppEventBus';
|
2023-01-30 22:50:55 +00:00
|
|
|
import News from '@/assets/data/news.json';
|
2022-09-09 14:35:31 +00:00
|
|
|
|
2022-09-09 10:25:14 +00:00
|
|
|
export default {
|
|
|
|
themeChangeListener: null,
|
|
|
|
newsActivate: null,
|
|
|
|
data() {
|
|
|
|
return {
|
2022-09-14 14:26:41 +00:00
|
|
|
layout: 'custom'
|
|
|
|
};
|
2022-09-13 11:29:45 +00:00
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
$route: {
|
|
|
|
immediate: true,
|
|
|
|
handler(to) {
|
|
|
|
if (to.name === 'index') {
|
2022-09-14 14:26:41 +00:00
|
|
|
this.layout = 'custom';
|
|
|
|
} else {
|
2022-09-13 11:29:45 +00:00
|
|
|
this.layout = 'default';
|
|
|
|
}
|
|
|
|
}
|
2022-09-09 10:25:14 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
2023-01-30 22:50:55 +00:00
|
|
|
this.newsActivate = () => {
|
|
|
|
this.$appState.announcement = News;
|
|
|
|
const itemString = localStorage.getItem(this.$appState.storageKey);
|
2022-12-08 12:26:57 +00:00
|
|
|
|
2023-01-30 22:50:55 +00:00
|
|
|
if (itemString) {
|
|
|
|
const item = JSON.parse(itemString);
|
2022-12-08 12:26:57 +00:00
|
|
|
|
2023-01-30 22:50:55 +00:00
|
|
|
if (!item.hiddenNews || item.hiddenNews !== News.id)
|
2022-09-09 10:25:14 +00:00
|
|
|
this.$appState.newsActive = true;
|
2023-01-30 22:50:55 +00:00
|
|
|
|
|
|
|
else this.$appState.newsActive = false;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.$appState.newsActive = true;
|
|
|
|
}
|
|
|
|
};
|
2022-09-09 10:25:14 +00:00
|
|
|
|
|
|
|
this.themeChangeListener = (event) => {
|
|
|
|
const elementId = 'theme-link';
|
|
|
|
const linkElement = document.getElementById(elementId);
|
|
|
|
const cloneLinkElement = linkElement.cloneNode(true);
|
|
|
|
const newThemeUrl = linkElement.getAttribute('href').replace(this.$appState.theme, event.theme);
|
|
|
|
|
|
|
|
cloneLinkElement.setAttribute('id', elementId + '-clone');
|
|
|
|
cloneLinkElement.setAttribute('href', newThemeUrl);
|
|
|
|
cloneLinkElement.addEventListener('load', () => {
|
|
|
|
linkElement.remove();
|
|
|
|
cloneLinkElement.setAttribute('id', elementId);
|
|
|
|
});
|
2022-12-13 10:23:13 +00:00
|
|
|
linkElement.parentNode?.insertBefore(cloneLinkElement, linkElement.nextSibling);
|
2022-09-14 14:26:41 +00:00
|
|
|
|
2022-09-09 10:25:14 +00:00
|
|
|
this.$appState.theme = event.theme;
|
|
|
|
this.$appState.darkTheme = event.dark;
|
|
|
|
};
|
|
|
|
|
|
|
|
EventBus.on('theme-change', this.themeChangeListener);
|
2023-01-30 22:50:55 +00:00
|
|
|
EventBus.on('news-activate', this.newsActivate);
|
2022-09-09 10:25:14 +00:00
|
|
|
},
|
|
|
|
beforeUnmount() {
|
|
|
|
EventBus.off('theme-change', this.themeChangeListener);
|
2023-01-30 22:50:55 +00:00
|
|
|
EventBus.off('news-activate', this.newsActivate);
|
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
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
@import '@/assets/styles/landing/landing.scss';
|
|
|
|
@import '@/assets/styles/app/app.scss';
|
|
|
|
</style>
|