fix(frontend): refresh custom page document title

This commit is contained in:
milesians
2026-06-18 12:30:21 +08:00
parent 4a5665da5b
commit 952be8711b
5 changed files with 85 additions and 24 deletions
+10 -2
View File
@@ -70,12 +70,20 @@ export async function setLocale(locale: string): Promise<void> {
document.documentElement.setAttribute('lang', locale)
// 同步更新浏览器页签标题,使其跟随语言切换
const { resolveDocumentTitle } = await import('@/router/title')
const { resolveRouteDocumentTitle } = await import('@/router/title')
const { default: router } = await import('@/router')
const { useAppStore } = await import('@/stores/app')
const { useAuthStore } = await import('@/stores/auth')
const { useAdminSettingsStore } = await import('@/stores/adminSettings')
const route = router.currentRoute.value
const appStore = useAppStore()
document.title = resolveDocumentTitle(route.meta.title, appStore.siteName, route.meta.titleKey as string)
const authStore = useAuthStore()
const adminSettingsStore = useAdminSettingsStore()
const customMenuItems = [
...(appStore.cachedPublicSettings?.custom_menu_items ?? []),
...(authStore.isAdmin ? adminSettingsStore.customMenuItems : []),
]
document.title = resolveRouteDocumentTitle(route, appStore.siteName, customMenuItems)
}
export function getLocale(): LocaleCode {