From d695d81ed430ab1adb8f3eca1a4d8bf62977a6fb Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 7 Jan 2026 10:09:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B5=8F=E8=A7=88=E5=99=A8=E6=A0=87?= =?UTF-8?q?=E9=A2=98=E4=BD=BF=E7=94=A8=E9=85=8D=E7=BD=AE=E7=9A=84=E7=BD=91?= =?UTF-8?q?=E7=AB=99=E5=90=8D=E7=A7=B0=E8=80=8C=E9=9D=9E=E7=A1=AC=E7=BC=96?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/main.ts | 16 +++++++++++++++- frontend/src/router/index.ts | 7 +++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/frontend/src/main.ts b/frontend/src/main.ts index d778cd0..bf61760 100644 --- a/frontend/src/main.ts +++ b/frontend/src/main.ts @@ -2,6 +2,7 @@ import { createApp } from 'vue' import { createPinia } from 'pinia' import router from './router' import App from './App.vue' +import { useSiteSettingsStore } from './stores/siteSettings' // 引入 Ant Design Vue 样式 import 'ant-design-vue/dist/reset.css' @@ -9,9 +10,22 @@ import 'ant-design-vue/dist/reset.css' import './styles/index.scss' const app = createApp(App) +const pinia = createPinia() -app.use(createPinia()) +app.use(pinia) app.use(router) +// 初始化网站设置并设置标题 +const siteSettingsStore = useSiteSettingsStore() +siteSettingsStore.loadSiteSettings().then(() => { + document.title = siteSettingsStore.siteName || 'DesignHub' +}).catch(() => { + // 如果加载失败,尝试从 localStorage 读取 + const siteName = localStorage.getItem('siteName') + if (siteName) { + document.title = siteName + } +}) + app.mount('#app') diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index a018980..4dae471 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -1,6 +1,7 @@ import { createRouter, createWebHistory } from 'vue-router' import type { RouteRecordRaw } from 'vue-router' import { useAuthStore } from '@/stores/auth' +import { useSiteSettingsStore } from '@/stores/siteSettings' const routes: RouteRecordRaw[] = [ { @@ -228,8 +229,10 @@ const router = createRouter({ // 路由守卫 router.beforeEach(async (to, from, next) => { - // 设置页面标题 - document.title = `${to.meta.title || ''} - DesignHub` + // 设置页面标题(使用配置的网站名称) + const siteSettingsStore = useSiteSettingsStore() + const siteName = siteSettingsStore.siteName || 'DesignHub' + document.title = to.meta.title ? `${to.meta.title} - ${siteName}` : siteName // 身份验证逻辑 const authStore = useAuthStore()