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

@@ -10,6 +10,8 @@ import '@/assets/svg-icons'
// 国际化
import i18n from '@/i18n.js'
import store from '@/store'
// 功能插件
import pluginError from '@/plugin/error'
import pluginLog from '@/plugin/log'
@@ -28,6 +30,25 @@ export default {
Vue.prototype.$version = process.env.VUE_APP_VERSION
// 构建时间
Vue.prototype.$buildTime = process.env.VUE_APP_BUILD_TIME
// 权限检查方法
Vue.prototype.$permission = (value, type = 'menu') => {
let path = ''
const auth = store.state.d2admin.menu.authKey
switch (type) {
case 'menu':
path = value
break
case 'router':
path = value.name.replace(/-/g, '/')
path.slice(0, 1) !== '/' && (path = '/' + path)
break
}
return !!(path && Object.prototype.hasOwnProperty.call(auth, path))
}
// Element
Vue.use(ElementUI, {
i18n: (key, value) => i18n.t(key, value)