This commit is contained in:
Your Name
2026-04-07 18:13:03 +08:00
parent a780356908
commit fdf714f833
397 changed files with 15086 additions and 1043 deletions
+14 -8
View File
@@ -5,19 +5,25 @@ import useAppStore from '@/stores/modules/app'
export default function createInitGuard(router: Router) {
router.beforeEach(async () => {
const appStore = useAppStore()
if (Object.keys(appStore.config).length == 0) {
// 获取配置
if (appStore.configFetchAttempted) {
return
}
appStore.$patch({ configFetchAttempted: true })
try {
const data: any = await appStore.getConfig()
// 设置网站logo
let favicon: HTMLLinkElement = document.querySelector('link[rel="icon"]')!
if (favicon) {
if (favicon && data?.web_favicon) {
favicon.href = data.web_favicon
}
favicon = document.createElement('link')
favicon.rel = 'icon'
favicon.href = data.web_favicon
document.head.appendChild(favicon)
if (data?.web_favicon) {
favicon = document.createElement('link')
favicon.rel = 'icon'
favicon.href = data.web_favicon
document.head.appendChild(favicon)
}
} catch {
// getConfig 失败时不再重试,避免与路由守卫形成无限请求
}
})
}