From 36dfd8640d8c8264448044c9020e243cb5800fd1 Mon Sep 17 00:00:00 2001 From: linbin <495561397@qq.com> Date: Fri, 5 Sep 2025 23:17:55 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=BC=E8=BF=B0:=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E5=8C=BA=E5=9F=9F=E6=98=BE=E7=A4=BA=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除内容区域的标题显示,避免重复展示 - 重构updateContent函数,对不同菜单项直接使用iframe显示对应页面 - 为未指定的菜单项提供默认内容展示,保持界面一致性 --- 平台web/index.html | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/平台web/index.html b/平台web/index.html index efa87cc..c040109 100644 --- a/平台web/index.html +++ b/平台web/index.html @@ -331,6 +331,7 @@ menuItems.forEach(item => { item.addEventListener('click', function(e) { e.preventDefault(); + e.stopPropagation(); // 阻止事件冒泡到父级 // 切换子菜单的显示状态 const submenu = this.nextElementSibling; @@ -338,24 +339,27 @@ }); }); - // 为所有菜单项添加点击事件(包括子菜单项) + // 为所有菜单项添加点击事件(仅子菜单项会加载页面) const allMenuItems = document.querySelectorAll('.menu-item a, .submenu-item a'); allMenuItems.forEach(item => { item.addEventListener('click', function(e) { - // 移除所有菜单项的活动状态 - allMenuItems.forEach(i => i.classList.remove('active')); - - // 为当前点击的菜单项添加活动状态 - this.classList.add('active'); - // 获取菜单项文本 const text = this.querySelector('span').textContent; - // 更新内容区域标题 - document.querySelector('.content-header h1').textContent = text || '内容管理系统'; - - // 这里可以根据需要更新内容区域的内容 - updateContent(text); + // 只有子菜单项点击才会加载页面 + if (this.parentElement.classList.contains('submenu-item')) { + // 移除所有菜单项的活动状态 + allMenuItems.forEach(i => i.classList.remove('active')); + + // 为当前点击的菜单项添加活动状态 + this.classList.add('active'); + + // 更新内容区域标题 + document.querySelector('.content-header h1').textContent = text || '内容管理系统'; + + // 这里可以根据需要更新内容区域的内容 + updateContent(text); + } }); });