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