mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-06-16 13:11:22 +08:00
fix(pluginSidebarNav): 修复首次登录后插件侧栏菜单不显示的问题 (#486)
This commit is contained in:
@@ -26,18 +26,32 @@ export const usePluginSidebarNavStore = defineStore('pluginSidebarNav', {
|
||||
if (this.inflight) {
|
||||
return this.inflight
|
||||
}
|
||||
this.inflight = (async () => {
|
||||
this.inflight = this._doFetchSidebarNav()
|
||||
return this.inflight
|
||||
},
|
||||
|
||||
async _doFetchSidebarNav(): Promise<void> {
|
||||
const maxRetries = 1
|
||||
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
||||
try {
|
||||
const res = await api.get('plugin/sidebar_nav')
|
||||
if (!this.inflight) return
|
||||
this.items = Array.isArray(res) ? res : []
|
||||
} catch {
|
||||
this.items = []
|
||||
} finally {
|
||||
this.loaded = true
|
||||
this.inflight = null
|
||||
return
|
||||
} catch (e) {
|
||||
if (attempt < maxRetries) {
|
||||
// 短暂延迟后重试,应对登录后导航过渡期的请求中断
|
||||
await new Promise(resolve => setTimeout(resolve, 500))
|
||||
if (!this.inflight) return
|
||||
}
|
||||
}
|
||||
})()
|
||||
return this.inflight
|
||||
}
|
||||
// 重试全部失败,不缓存失败状态以允许后续调用方再次尝试
|
||||
if (!this.inflight) return
|
||||
this.items = []
|
||||
this.inflight = null
|
||||
},
|
||||
|
||||
reset() {
|
||||
|
||||
Reference in New Issue
Block a user