From 5befd51c2616103c0353e02915544d59c18e6019 Mon Sep 17 00:00:00 2001 From: p Date: Fri, 14 Aug 2026 17:02:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20open=5Ftab=20=E5=90=8C=E6=AD=A5=E5=88=87?= =?UTF-8?q?=E6=8D=A2+=E9=AB=98=E4=BA=AE=EF=BC=8Ccontent=20=E5=BC=82?= =?UTF-8?q?=E6=AD=A5=E5=8A=A0=E8=BD=BD=E9=81=BF=E5=85=8D=20401=20=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E6=A1=86=E9=98=BB=E5=A1=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wwwroot/index_tab.js | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/wwwroot/index_tab.js b/wwwroot/index_tab.js index 1a30ed5..5e47f8e 100644 --- a/wwwroot/index_tab.js +++ b/wwwroot/index_tab.js @@ -11,9 +11,21 @@ this.toolbar.createTool(desc); }; - // 动态打开 tab:已存在(opts.items 同名)则切换,不存在则新增 - bricks.TabPanel.prototype.open_tab = async function(desc){ - // 1. 已存在判断:opts.items 里找同名(不用 content_buffer,因 content 可能构建失败) + // 异步加载 tab 的 content(不阻塞 open_tab;401 会触发登录框,等登录后重试) + bricks.TabPanel.prototype._load_tab_content = async function(desc){ + if (this.content_buffer[desc.name]){ + if (this.cur_tab_name === desc.name) this.switch_content(this.content_buffer[desc.name]); + return; + } + var w = await bricks.widgetBuild(desc.content, this, {}); + this.content_buffer[desc.name] = w; + if (w && this.cur_tab_name === desc.name) this.switch_content(w); + }; + + // 动态打开 tab:已存在(opts.items 同名)则切换,不存在则新增。 + // 同步返回:立即创建/切换 + 高亮 tab 按钮,content 交由 _load_tab_content 异步加载, + // 避免 await widgetBuild 被 401 登录框阻塞导致 tab 不切换。 + bricks.TabPanel.prototype.open_tab = function(desc){ var existing = null; for (var i=0;i