2026-01-16 22:04:12 +08:00
|
|
|
<template>
|
|
|
|
|
<div>
|
2026-04-07 11:01:11 +08:00
|
|
|
<!-- SEO 组件 -->
|
|
|
|
|
<Seo />
|
|
|
|
|
|
2026-01-16 22:04:12 +08:00
|
|
|
<el-config-provider :value-on-clear="() => null" :locale="locale">
|
|
|
|
|
<NuxtLayout>
|
|
|
|
|
<NuxtPage />
|
|
|
|
|
</NuxtLayout>
|
|
|
|
|
</el-config-provider>
|
2026-04-07 11:01:11 +08:00
|
|
|
|
|
|
|
|
<!-- 百度统计组件 -->
|
|
|
|
|
<BaiduAnalytics />
|
2026-01-16 22:04:12 +08:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2026-04-07 11:01:11 +08:00
|
|
|
// @ts-ignore
|
2026-01-16 22:04:12 +08:00
|
|
|
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
|
2026-04-07 11:01:11 +08:00
|
|
|
// @ts-ignore
|
2026-01-16 22:04:12 +08:00
|
|
|
import en from 'element-plus/dist/locale/en.mjs'
|
|
|
|
|
import type { Language } from 'element-plus/es/locale'
|
2026-04-07 11:01:11 +08:00
|
|
|
import { onMounted, computed } from 'vue'
|
|
|
|
|
import { initDark, getDark } from './utils/dark'
|
|
|
|
|
import { useHead } from 'nuxt/app'
|
2026-01-16 22:04:12 +08:00
|
|
|
|
|
|
|
|
// modules import mark, Please do not remove.
|
2026-04-07 11:01:11 +08:00
|
|
|
import { useSystemStore } from './stores/system'
|
|
|
|
|
import { useMemberStore } from './stores/member'
|
|
|
|
|
|
2026-01-16 22:04:12 +08:00
|
|
|
const systemStore = useSystemStore()
|
|
|
|
|
const locale = computed(() => (systemStore.lang === 'zh-cn' ? zhCn : en))
|
|
|
|
|
|
2026-04-07 11:01:11 +08:00
|
|
|
// 在服务器端渲染时就设置正确的 dark 类
|
|
|
|
|
useHead({
|
|
|
|
|
htmlAttrs: {
|
|
|
|
|
class: getDark() ? 'dark' : ''
|
|
|
|
|
}
|
|
|
|
|
})
|
2026-01-16 22:04:12 +08:00
|
|
|
|
2026-04-07 11:01:11 +08:00
|
|
|
// 仅在客户端执行,避免 SSR 时清空持久化的 token
|
|
|
|
|
if (import.meta.client) {
|
|
|
|
|
const memberStore = useMemberStore()
|
|
|
|
|
// 如果有 token 但没有 refreshToken(比如旧数据),清除它
|
|
|
|
|
if (memberStore.token && !memberStore.refreshToken) {
|
|
|
|
|
memberStore.token = ''
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-01-16 22:04:12 +08:00
|
|
|
|
2026-04-07 11:01:11 +08:00
|
|
|
onMounted(async () => {
|
|
|
|
|
await systemStore.getSiteInfoFn()
|
|
|
|
|
// 初始化语言设置
|
|
|
|
|
systemStore.initLanguage()
|
|
|
|
|
// 初始化暗黑模式(确保客户端与服务器端保持一致)
|
|
|
|
|
initDark()
|
|
|
|
|
})
|
2026-01-16 22:04:12 +08:00
|
|
|
</script>
|