综述: 优化平台端web权限管理页面的iframe嵌入功能和菜单项点击处理

- 修改权限编辑和市场经营者创建菜单项的链接方式,从hash路由改为相对路径引用
- 新增openTabWithIframe函数,用于通过iframe方式加载子页面
- 优化菜单项点击事件处理逻辑,支持默认链接跳转行为
- 重写标签页点击事件处理函数,以支持iframe标签页的面包屑更新
- 删除权限分配.html文件
This commit is contained in:
linbin 2025-09-08 01:13:05 +08:00
parent 3321e8e979
commit 4f048ae14d
2 changed files with 15 additions and 11 deletions

View File

@ -449,7 +449,7 @@
</button>
<div class="submenu">
<a href="./权限管理/权限编辑.html" class="submenu-item" onclick="openTabWithIframe(this, '权限编辑')">权限编辑</a>
<a href="#/permission/manager" class="submenu-item" onclick="openTab(this, '市场经营者创建')">市场经营者创建</a>
<a href="./权限管理/市场经营者创建.html" class="submenu-item" onclick="openTabWithIframe(this, '市场经营者创建')">市场经营者创建</a>
</div>
</li>
<li class="menu-item">
@ -661,7 +661,6 @@
newContent.className = 'tab-content';
newContent.style.display = 'none';
newContent.innerHTML = `
<h2>${title}</h2>
<p>这里是${title}页面的内容...</p>
`;
contentArea.appendChild(newContent);
@ -701,7 +700,6 @@
newContent.className = 'tab-content';
newContent.style.display = 'none';
newContent.innerHTML = `
<h2>${title}</h2>
<iframe src="${link.href}" style="width: 100%; height: 600px; border: none;"></iframe>
`;
contentArea.appendChild(newContent);
@ -728,8 +726,7 @@
activeTab.classList.add('active');
activeContent.style.display = 'block';
// 更新面包屑导航
updateBreadcrumb(title);
// 不更新面包屑导航中的标题
}
}
@ -770,11 +767,19 @@
// 更新面包屑导航
function updateBreadcrumb(title) {
const breadcrumbItems = document.querySelectorAll('.breadcrumb-item');
if (breadcrumbItems.length >= 3) {
breadcrumbItems[2].textContent = title;
}
// 不更新面包屑导航中的标题
return;
}
// 重写标签页点击事件处理函数以支持iframe标签页的面包屑更新
document.querySelectorAll('.tab-item').forEach(tab => {
tab.onclick = () => {
const tabId = tab.getAttribute('data-tab');
// 获取标签标题用于更新面包屑
const title = tab.querySelector('.tab-title').textContent;
setActiveTab(tabId, title);
};
});
// 菜单项点击事件处理
document.querySelectorAll('.submenu-item').forEach(item => {
@ -793,8 +798,7 @@
const title = this.textContent;
this.onclick.call(this);
// 更新面包屑导航
updateBreadcrumb(title);
// 不更新面包屑导航中的标题
}
// 如果没有onclick属性允许默认行为链接跳转
});