fix(tabpanel): 菜单重新点击时刷新 tab 内容,修复只切 tab 不更新数据

open_tab 对已存在的 tab 用缓存 content_buffer 直接 switch_content(不重新加载),
当前 tab 重新点击则直接 return,导致菜单重新点击时 tab 高亮变了但内容陈旧。
修复:已存在 tab 默认刷新(delete 缓存后重新 widgetBuild 重新请求 url 构建),
desc.refresh === false 时保留「用缓存不刷新」的旧行为。
This commit is contained in:
yumoqing 2026-08-20 17:51:28 +08:00
parent 398075ac87
commit 6cc8afba82

View File

@ -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;
}