新增
This commit is contained in:
@@ -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 失败时不再重试,避免与路由守卫形成无限请求
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user