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