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

@@ -8,6 +8,35 @@ const util = {
log
}
/**
* 扁平数组转树形结构
* @param {Array} data 扁平数组
* @param {String} key 主键字段名
* @param {String} pid 父节点字段名
*/
util.formatDataToTree = (data, key = 'menu_id', pid = 'parent_id') => {
if (!data || data.length <= 0) {
return []
}
const map = {}
data.forEach(value => { map[value[key]] = { ...value } })
const tree = []
data.forEach(item => {
const id = item[key]
if (map[id][pid] && map[map[id][pid]]) {
if (!map[map[id][pid]].children) {
map[map[id][pid]].children = []
}
map[map[id][pid]].children.push(map[id])
} else {
tree.push(map[id])
}
})
return tree
}
/**
* @description 更新标题
* @param {String} title 标题