From 3321e8e979dbb75b086ce4b0217cd8d9ba4d7577 Mon Sep 17 00:00:00 2001 From: linbin <495561397@qq.com> Date: Mon, 8 Sep 2025 00:53:22 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=BC=E8=BF=B0:=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E7=AB=AFweb=E6=9D=83=E9=99=90=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E9=A1=B5=E9=9D=A2=E7=9A=84iframe=E5=B5=8C=E5=85=A5?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改权限编辑菜单项的链接方式,从hash路由改为相对路径引用 - 新增openTabWithIframe函数,用于通过iframe方式加载子页面 - 优化菜单项点击事件处理逻辑,支持默认链接跳转行为 - 为iframe标签页添加基础样式支持 --- 平台端web/index.html | 65 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 12 deletions(-) diff --git a/平台端web/index.html b/平台端web/index.html index 8ced12a..228f471 100644 --- a/平台端web/index.html +++ b/平台端web/index.html @@ -448,7 +448,7 @@ @@ -670,6 +670,46 @@ setActiveTab(tabId, title); } + // 通过iframe打开标签页 + function openTabWithIframe(link, title) { + const tabId = title.toLowerCase().replace(/\s+/g, '-'); + + // 检查标签页是否已存在 + const existingTab = document.querySelector(`[data-tab="${tabId}"]`); + if (existingTab) { + // 激活已存在的标签页 + setActiveTab(tabId, title); + return; + } + + // 创建新标签页 + const tabsContainer = document.querySelector('.tabs-container'); + const newTab = document.createElement('div'); + newTab.className = 'tab-item'; + newTab.setAttribute('data-tab', tabId); + newTab.innerHTML = ` + ${title} + × + `; + newTab.onclick = () => setActiveTab(tabId, title); + tabsContainer.appendChild(newTab); + + // 创建新内容区域,使用iframe嵌入页面 + const contentArea = document.querySelector('.content-container'); + const newContent = document.createElement('div'); + newContent.id = `tab-content-${tabId}`; + newContent.className = 'tab-content'; + newContent.style.display = 'none'; + newContent.innerHTML = ` +

${title}

+ + `; + contentArea.appendChild(newContent); + + // 激活新标签页 + setActiveTab(tabId, title); + } + // 设置活动标签页 function setActiveTab(tabId, title) { // 移除所有标签页的活动状态 @@ -739,23 +779,24 @@ // 菜单项点击事件处理 document.querySelectorAll('.submenu-item').forEach(item => { item.addEventListener('click', function(e) { - e.preventDefault(); - - // 移除其他菜单项的激活状态 - document.querySelectorAll('.submenu-item.active').forEach(activeItem => { - activeItem.classList.remove('active'); - }); - - // 激活当前菜单项 - this.classList.add('active'); - - // 如果有onclick属性,执行它 + // 如果有onclick属性,阻止默认行为并执行onclick if (this.onclick) { + e.preventDefault(); + + // 移除其他菜单项的激活状态 + document.querySelectorAll('.submenu-item.active').forEach(activeItem => { + activeItem.classList.remove('active'); + }); + + // 激活当前菜单项 + this.classList.add('active'); + const title = this.textContent; this.onclick.call(this); // 更新面包屑导航 updateBreadcrumb(title); } + // 如果没有onclick属性,允许默认行为(链接跳转) }); });