refactor(front): 删index_tab.js旧补丁——动态tab已收编入bricks框架(mobile.js的_sid+tab.js的open_tab/add_tab/show_tabcontent),模块副本会整类覆盖框架定义屏蔽TabPanel删tab/开tab修复(§16副本坑);同步清理rp.json+load_path.py的/index_tab.js权限注册(2026-09-08)

This commit is contained in:
yumoqing 2026-09-08 15:58:56 +08:00
parent 72a17f7b84
commit 8e35cec123
3 changed files with 0 additions and 90 deletions

View File

@ -12,7 +12,6 @@
"/rbac/user/logout.dspy",
"/rbac/usermenu.ui",
"/i18n_getmsgs",
"/index_tab.js",
"/appbase/menu.ui",
"/product_management/menu.ui",
"/discount/menu.ui",

View File

@ -56,7 +56,6 @@ PERMS = [
# 产线 shellsdlc/core/ops/dist index.ui须 logined产线对匿名不可见。
("/index.ui", "app", "any"),
("/todo_badge.js", "app", "any"),
("/index_tab.js", "app", "any"),
("/theme_toggle.js", "app", "any"),
# 手机端 H5 外壳2026-09-07「我的」整页底部 TabBar 第4个 Tab
("/mine.ui", "app", "logined"),

View File

@ -1,88 +0,0 @@
// pipeline-app 首页 TabPanel 动态 tab 支持
// 由 HTML shell 自动加载configuredServer.get_js_files 收集 wwwroot 下 .js
// 每个浏览器 tab 一个 session_idsessionStorage 隔离),用于多 tab 项目上下文隔离
window._sid = function(){
var sid = null;
try { sid = sessionStorage.getItem('pipeline_sid'); } catch(e){}
if(!sid){ sid = 's' + Date.now().toString(36) + Math.random().toString(36).slice(2,10); try{ sessionStorage.setItem('pipeline_sid', sid); }catch(e){} }
return sid;
};
(function(){
if (typeof bricks === 'undefined' || !bricks.TabPanel) return;
if (bricks.TabPanel.prototype._dyn_patched) return;
bricks.TabPanel.prototype._dyn_patched = true;
// 修复原生 add_tab 的 bugthis.add_removeable 不存在(应为 toolbar.add_removable
// 且 createTool 内部已调用 add_removable这里只需创建 tool 按钮
bricks.TabPanel.prototype.add_tab = function(desc){
this.toolbar.createTool(desc);
};
// 异步加载 tab 的 content不阻塞 open_tab401 会触发登录框,等登录后重试)
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<this.opts.items.length;i++){
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(existing);
}
return;
}
// 新增
desc.content = desc.content || {"widgettype":"urlwidget","options":{"url":desc.url}};
this.opts.items.push(desc);
if (this.add_tab) this.add_tab(desc);
this.cur_tab_name = desc.name;
if (this.toolbar && this.toolbar.click) this.toolbar.click(desc.name);
this._load_tab_content(desc);
};
// 修复 show_tabcontent 的 bugcur_tab_name 赋值用了未定义变量 name
bricks.TabPanel.prototype.show_tabcontent = async function(event){
var tdesc = event.params;
if (tdesc.name === this.cur_tab_name) return;
var items = this.opts.items;
for (var i=0;i<items.length;i++){
if (tdesc.name === items[i].name){
var w = this.content_buffer[tdesc.name];
if (!w){
var c = items[i].content || {"widgettype":"urlwidget","options":{"url":items[i].url}};
w = await bricks.widgetBuild(c, this, {});
if (w) this.content_buffer[tdesc.name] = w;
}
if (w){ this.cur_tab_name = tdesc.name; this.switch_content(w); }
return;
}
}
};
})();