From 53ab7fd778e99fee7dfa62b2f510426eea2bdf77 Mon Sep 17 00:00:00 2001 From: admin Date: Wed, 3 Jun 2026 13:15:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E7=9A=84=E5=8A=A8=E6=80=81=E6=B3=A8=E5=85=A5?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 创建 useSiteSettings composable 在应用启动时加载系统设置 - 从 window.__SITE_CONFIG__(后端注入)和 localStorage 初始化设置 - 修复 favicon 更新逻辑,正确移除旧 favicon 并添加新的 - 在路由守卫中设置页面标题,格式为 '页面名 - 网站名' - 简化 admin.vue 和 admin-sidebar 组件,使用统一的设置管理 Co-Authored-By: Claude Opus 4.8 --- frontend/index.html | 21 +- frontend/src/App.vue | 5 + .../src/components/admin-sidebar/index.vue | 58 ++---- frontend/src/composables/use-site-settings.ts | 194 ++++++++++++++++++ frontend/src/layouts/admin.vue | 74 +------ frontend/src/router/guard/index.ts | 8 + 6 files changed, 245 insertions(+), 115 deletions(-) create mode 100644 frontend/src/composables/use-site-settings.ts diff --git a/frontend/index.html b/frontend/index.html index 06f7b5c..0f8b936 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -5,22 +5,33 @@ - {{.SiteName}} - - - + 加载中... + - + + diff --git a/frontend/src/App.vue b/frontend/src/App.vue index f7300b6..433de34 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -4,8 +4,13 @@ import { ConfigProvider } from 'reka-ui' import Loading from '@/components/loading.vue' import { Toaster } from '@/components/ui/sonner' import { useSystemTheme } from '@/composables/use-system-theme' +import { useSiteSettings } from '@/composables/use-site-settings' useSystemTheme() +const { initSiteSettings } = useSiteSettings() + +// 在应用启动时初始化系统设置 +initSiteSettings() \ No newline at end of file diff --git a/frontend/src/router/guard/index.ts b/frontend/src/router/guard/index.ts index 11f3dc2..c2a7344 100644 --- a/frontend/src/router/guard/index.ts +++ b/frontend/src/router/guard/index.ts @@ -1,4 +1,5 @@ import type { Router } from 'vue-router' +import { useSiteSettings } from '@/composables/use-site-settings' const INSTALL_CACHE_KEY = 'app_installed' const INSTALL_CACHE_EXPIRY = 24 * 60 * 60 * 1000 @@ -93,4 +94,11 @@ export function createRouterGuard(router: Router) { return '/admin' } }) + + // 设置页面标题 + router.afterEach((to) => { + const { siteSettings, getPageTitle } = useSiteSettings() + const pageTitle = to.meta?.title as string | undefined + document.title = getPageTitle(pageTitle) + }) }