go-admin-ui的菜单分割线设计思路和代码实现

devtools/2024/9/24 11:01:28/

在菜单管理添加分割线,类似这种:

思路:利用空间结构和数据特点来唯一区分出分割线,来划分业务区域

<template><div><h1>Split Line Controller</h1><ul><li v-for="route in displayedRoutes" :key="route.path">{{ route.meta?.title || '' }} - {{ route.hidden ? '隐藏' : '显示' }}<ul v-if="filteredChildren(route).length"><li v-for="child in filteredChildren(route)" :key="child.path">------ {{ child.meta?.title || '' }} - {{ child.hidden ? '隐藏' : '显示' }}</li></ul></li></ul></div>
</template><script>
export default {name: "SplitLineController",data() {return {routes: [{"path": "/redirect","hidden": true,"children": [{"path": "/redirect/:path*"}]},{"path": "/login","hidden": true},{"path": "/auth-redirect","hidden": true},{"path": "/404","hidden": true},{"path": "/401","hidden": true},{"path": "/","redirect": "/home-page","hidden": true,"children": [{"path": "home-page","name": "HomePage","meta": {"title": "欢迎页","icon": "home-page"}}]},{"path": "/profile","redirect": "/profile/index","hidden": true,"children": [{"path": "index","name": "Profile","meta": {"title": "个人中心","icon": "user"}}]},{"path": "/home-page","hidden": false,"children": [],"name": "HomePage","meta": {"title": "首页","icon": "home-page"}},{"path": "/permission","hidden": true,"children": [{"path": "/permission/my-application","hidden": false,"children": [],"name": "MyApplicationManage","meta": {"title": "我的申请","icon": "api-monitor"}}],"name": "","meta": {"title": "权限申请","icon": "access"}},{"path": "","hidden": false,"children": [],"name": "","meta": {"title": "xx业务分割线1","icon": ""}},{"path": "/apple","hidden": false,"children": [{"path": "/apple/tree","hidden": false,"children": [],"name": "tree","meta": {"title": "苹果树木","icon": "nested"}},{"path": "/apple/leaf","hidden": false,"children": [],"name": "leaf","meta": {"title": "苹果叶子","icon": "alarm-settings"}}],"name": "AppleContent","meta": {"title": "苹果内容质量","icon": "list"}},{"path": "/banana","hidden": false,"children": [{"path": "/banana/tree","hidden": false,"children": [],"name": "tree","meta": {"title": "香蕉树木","icon": "size"}},{"path": "/banana/leaf","hidden": false,"children": [],"name": "leaf","meta": {"title": "香蕉叶子","icon": "edit"}},],"name": "","meta": {"title": "香蕉评级后台","icon": "peoples"}},{"path": "","hidden": false,"children": [],"name": "","meta": {"title": "xx业务分割线2","icon": ""}},{"path": "/cat","hidden": false,"children": [{"path": "/cat/live","hidden": false,"children": [],"name": "Live","meta": {"title": "猫","icon": "build"}},{"path": "/dog/live","hidden": false,"children": [],"name": "LiveComDistributionMange","meta": {"title": "狗","icon": "api-server"}}],"name": "","meta": {"title": "宠物管理","icon": "build"}},{"path": "","hidden": false,"children": [],"name": "","meta": {"title": "xx管理分割线3","icon": ""}},{"path": "/person","hidden": false,"children": [{"path": "/person/myself","hidden": false,"children": [],"name": "SysBusinessUserManage","meta": {"title": "我的介绍","icon": "people"}}],"name": "Admin","meta": {"title": "系统管理","icon": "api-server"}}],displayedRoutes: []};},methods: {controlSplits(routes) {let displayedRoutes = JSON.parse(JSON.stringify(routes)); // 深拷贝以保持原始结构for (let i = 0; i < displayedRoutes.length; i++) {const currentRoute = displayedRoutes[i];if (this.isSplitLine(currentRoute)) {let hasVisibleSibling = false;for (let j = i + 1; j < displayedRoutes.length; j++) {const nextRoute = displayedRoutes[j];if (this.isSplitLine(nextRoute)) break;if (!nextRoute.hidden) {hasVisibleSibling = true;break;}}currentRoute.hidden = !hasVisibleSibling;}}return displayedRoutes;},isSplitLine(route) {return route.path === "" && !route.component && route.meta && !route.meta.icon;},filteredChildren(route) {if (route.children) {return route.children.filter(child => !child.hidden);}return [];}},created() {this.displayedRoutes = this.controlSplits(this.routes);}
};
</script><style scoped>
h1 {font-size: 20px;
}ul {list-style-type: none;padding: 0;
}
</style>


http://www.ppmy.cn/devtools/116455.html

相关文章

Flink系列知识之:Checkpoint原理

Flink系列知识之&#xff1a;Checkpoint原理 在介绍checkpoint的执行流程之前&#xff0c;需要先明白Flink中状态的存储机制&#xff0c;因为状态对于检查点的持续备份至关重要。 State Backends分类 下图显示了Flink中三个内置的状态存储种类。MemoryStateBackend和FsState…

【Linux】系统字符集无法修改,单独修改vim后的文件字符集

系统字符集无法修改&#xff0c;单独修改vim后的文件字符集 环境&#xff1a; 系统字符集 rootuos:~# locale LANGzh_CN.gb18030 LANGUAGEzh_CN LC_CTYPE"zh_CN.gb18030" LC_NUMERIC"zh_CN.gb18030" LC_TIME"zh_CN.gb18030" LC_COLLATE"…

HTML、CSS

初识web前端 web标准 Web标准也称为网页标准&#xff0c;由一系列的标准组成&#xff0c;大部分由W3C (World Wide Web Consortium&#xff0c;万维网联盟) 负责制定。三个组成部分: HTML: 负责网页的结构(页面元素和内容)。CSS: 负责网页的表现(页面元素的外观、位置等页面样…

css允许换行,且换行超出后省略号隐藏

在这里插入代码片.ellipsis-style { width: 200px; /* 设置一个固定宽度&#xff0c;以便触发省略号效果 / display: -webkit-box; -webkit-line-clamp: 3; / 设置显示的行数&#xff0c;这里是 3 行 */ -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellip…

阿里开源多模态大模型Ovis1.6,重塑出海电商AI格局

阿里开源Ovis1.6&#xff1a;多模态领域再夺第一 阿里再一次证明了自己在多模态领域的实力。这一次&#xff0c;阿里国际AI团队开源的多模态大模型Ovis1.6&#xff0c;不仅成功开源&#xff0c;还在多模态评测基准OpenCompass上击败了Qwen2VL-7B、InternVL2-26B和MiniCPM-V-2.…

论文阅读--Planning-oriented Autonomous Driving(二)

自动驾驶框架的各种设计比较。 ( a )大多数工业解决方案针对不同的任务部署不同的模型。 ( b )多任务学习方案共享一个具有分割任务头的主干。 ( c )端到端范式将感知和预测模块统一起来。以往的尝试要么采用( c.1 )中对规划的直接优化&#xff0c;要么采用( c.2 )中的部分元…

OpenCV特征检测(12)检测图像中的潜在角点函数preCornerDetect()的使用

操作系统&#xff1a;ubuntu22.04 OpenCV版本&#xff1a;OpenCV4.9 IDE:Visual Studio Code 编程语言&#xff1a;C11 算法描述 计算用于角点检测的特征图。 该函数计算源图像的基于复杂空间导数的函数 dst ( D x src ) 2 ⋅ D y y src ( D y src ) 2 ⋅ D x x src − 2 …

cisco网络安全技术第2章测试及考试

测试 1、通过思科 IOS CLI 提供哪些工具来启动安全审计并在有或没有管理员输入的情况下进行推荐的配置更改&#xff1f; 思科 AutoSecure 2、可以配置 SNMP 实施的哪个元素来响应请求以及转发通知&#xff1f; SNMP 代理 3、哪两项任务与路由器加固相关联&#xff1f;&…