refactor: remove old demo pages and static menu logic

1. 删除大量旧的示例页面、组件示例和静态菜单配置
2. 新增菜单扁平数组转树形结构工具函数
3. 重构菜单加载逻辑,改为从后端动态获取并格式化
4. 新增全局权限检查方法和自定义权限指令
5. 优化侧边栏菜单路由跳转逻辑,自动跳转第一个有权限的子页面
6. 移除路由中对旧demo模块的引用
This commit is contained in:
sheng
2026-05-27 18:07:48 +08:00
parent 0f3b5d4371
commit 2cc8329695
96 changed files with 799 additions and 4985 deletions

View File

@@ -1,4 +1,5 @@
import util from '@/libs/util.js'
import { frameInRoutes } from '@/router/routes'
export default {
methods: {
@@ -8,9 +9,43 @@ export default {
} else if (/^https:\/\/|http:\/\//.test(index)) {
util.open(index)
} else {
this.$router.push({
path: index
})
this.getRouterAuthPath(index, indexPath)
}
},
/**
* 点击菜单时进行权限过滤,查找第一个有权限的子路由
* @param {String} index 选中菜单项的 index (path)
* @param {Array} indexPath 选中菜单项的 index path
*/
getRouterAuthPath (index, indexPath) {
// 首页或子级路由直接访问
if (index === '/index' || !indexPath || indexPath.length > 1) {
this.$router.push({ path: index })
return
}
// 查找一级路由下是否存在子路由
let router = null
for (const value of frameInRoutes) {
if (value.path === index) {
router = value.children
break
}
}
// 不存在子路由则直接进入
if (!router) {
this.$router.push({ path: index })
return
}
// 存在子路由时,跳转第一个有权限的子页面
for (const value of router) {
const newPath = index + '/' + value.path
if (this.$permission(newPath)) {
this.$router.push({ path: newPath })
break
}
}
}
}