From 6cc8afba828197dc1202e8ace29c013dc5620ec6 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 20 Aug 2026 17:51:28 +0800 Subject: [PATCH] =?UTF-8?q?fix(tabpanel):=20=E8=8F=9C=E5=8D=95=E9=87=8D?= =?UTF-8?q?=E6=96=B0=E7=82=B9=E5=87=BB=E6=97=B6=E5=88=B7=E6=96=B0=20tab=20?= =?UTF-8?q?=E5=86=85=E5=AE=B9=EF=BC=8C=E4=BF=AE=E5=A4=8D=E5=8F=AA=E5=88=87?= =?UTF-8?q?=20tab=20=E4=B8=8D=E6=9B=B4=E6=96=B0=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit open_tab 对已存在的 tab 用缓存 content_buffer 直接 switch_content(不重新加载), 当前 tab 重新点击则直接 return,导致菜单重新点击时 tab 高亮变了但内容陈旧。 修复:已存在 tab 默认刷新(delete 缓存后重新 widgetBuild 重新请求 url 构建), desc.refresh === false 时保留「用缓存不刷新」的旧行为。 --- wwwroot/index_tab.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/wwwroot/index_tab.js b/wwwroot/index_tab.js index 5e47f8e..96ef03d 100644 --- a/wwwroot/index_tab.js +++ b/wwwroot/index_tab.js @@ -31,12 +31,21 @@ if (this.opts.items[i].name === desc.name){ existing = this.opts.items[i]; break; } } if (existing){ + // 已存在的 tab:切换 + 刷新内容。重新点击菜单时数据已变, + // 若只切 tab 用缓存 content_buffer 会显示陈旧数据。默认刷新(重新构建), + // desc.refresh === false 时保留「用缓存不刷新」的旧行为。 + var need_refresh = desc.refresh !== false; if (desc.name !== this.cur_tab_name){ this.cur_tab_name = desc.name; + if (this.toolbar && this.toolbar.click) this.toolbar.click(desc.name); + } + if (need_refresh){ + delete this.content_buffer[desc.name]; + this._load_tab_content(existing); + } else { var w = this.content_buffer[desc.name]; if (w) this.switch_content(w); - else this._load_tab_content(desc); - if (this.toolbar && this.toolbar.click) this.toolbar.click(desc.name); + else this._load_tab_content(existing); } return; }