diff --git a/klp-ui/src/assets/styles/sidebar.scss b/klp-ui/src/assets/styles/sidebar.scss index b7d564e68..b8d69cbee 100644 --- a/klp-ui/src/assets/styles/sidebar.scss +++ b/klp-ui/src/assets/styles/sidebar.scss @@ -91,7 +91,7 @@ .el-menu-item, .el-submenu__title { // 明确默认状态样式(关键修复) - background: transparent !important; + background: transparent; box-shadow: none !important; position: relative; @@ -318,4 +318,5 @@ font-size: 12px; } + // 叶子页面无标识 \ No newline at end of file diff --git a/klp-ui/src/layout/components/Sidebar/Item.vue b/klp-ui/src/layout/components/Sidebar/Item.vue index acf39df6c..23c3ca452 100644 --- a/klp-ui/src/layout/components/Sidebar/Item.vue +++ b/klp-ui/src/layout/components/Sidebar/Item.vue @@ -18,6 +18,11 @@ export default { }, render(h, context) { const { icon, title, hasChildren } = context.props + // 函数式组件中 :style 绑定不会进 props,需要从 context.data.style 读取 + const customStyle = context.data.style || {} + if (Object.keys(customStyle).length > 0) { + console.log('[Item] ✅ 收到 style:', customStyle, '| title:', title) + } const vnodes = [] if (icon) { @@ -40,7 +45,25 @@ export default { ) } - return vnodes + return ( + + {vnodes} + + ) } } + + diff --git a/klp-ui/src/layout/components/Sidebar/SidebarItem.vue b/klp-ui/src/layout/components/Sidebar/SidebarItem.vue index 6c5d4021e..60d39e8b9 100644 --- a/klp-ui/src/layout/components/Sidebar/SidebarItem.vue +++ b/klp-ui/src/layout/components/Sidebar/SidebarItem.vue @@ -4,14 +4,14 @@ @@ -20,14 +20,14 @@ - + - + {{ item._title }} @@ -34,6 +34,7 @@ :to="item._fullPath" class="sub-nav__item" :class="{ 'is-active': isActive(item) }" + :style="item._style" > {{ item._title }} @@ -160,7 +161,18 @@ export default { _ownPath: ownPath, _fullPath: routeFullPath, _title: title, - _hasChildren: hasChildren + _hasChildren: hasChildren, + _style: (() => { + const s = c.meta && c.meta.style + if (s) { + try { + return JSON.parse(s) + } catch (e) { + return {} + } + } + return {} + })() } if (hasChildren) { item._children = this.buildItems(c.children, ownPath) diff --git a/klp-ui/src/store/modules/permission.js b/klp-ui/src/store/modules/permission.js index 5d11f93ae..512229fbc 100644 --- a/klp-ui/src/store/modules/permission.js +++ b/klp-ui/src/store/modules/permission.js @@ -44,6 +44,18 @@ const permission = { return new Promise(resolve => { // 向后端请求路由数据 getRouters().then(res => { + // 调试:检查后端路由数据 + const logMetaStyle = (arr, depth = 0) => { + arr.forEach(item => { + const title = (item.meta && item.meta.title) || item.name || '' + const styleVal = item.meta && item.meta.style + console.log('[permission] depth=' + depth, title, 'meta.style=', styleVal) + if (item.children) logMetaStyle(item.children, depth + 1) + }) + } + console.log('[permission] === getRouters 原始数据 ===') + logMetaStyle(res.data) + console.log('[permission] === getRouters 数据结束 ===') const sdata = JSON.parse(JSON.stringify(res.data)) const rdata = JSON.parse(JSON.stringify(res.data)) const sidebarRoutes = filterAsyncRouter(sdata) diff --git a/klp-ui/src/views/system/menu/index.vue b/klp-ui/src/views/system/menu/index.vue index 6c2fe9395..825f71f4c 100644 --- a/klp-ui/src/views/system/menu/index.vue +++ b/klp-ui/src/views/system/menu/index.vue @@ -231,6 +231,17 @@ + + + + + + + + 菜单样式 + + +