From f51b253c832df83f0abc4014071c78657a8d4310 Mon Sep 17 00:00:00 2001 From: ui_beam <61094940+ui-beam-9@users.noreply.github.com> Date: Sun, 7 Jun 2026 14:27:23 +0800 Subject: [PATCH] =?UTF-8?q?fix(pluginSidebarNav):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E9=A6=96=E6=AC=A1=E7=99=BB=E5=BD=95=E5=90=8E=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E4=BE=A7=E6=A0=8F=E8=8F=9C=E5=8D=95=E4=B8=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=20(#486)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/pluginSidebarNav.ts | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/stores/pluginSidebarNav.ts b/src/stores/pluginSidebarNav.ts index b98c36fc..5659325b 100644 --- a/src/stores/pluginSidebarNav.ts +++ b/src/stores/pluginSidebarNav.ts @@ -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 { + 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() {