diff --git a/src/layouts/admin/index.vue b/src/layouts/admin/index.vue index 034c039..4232e39 100644 --- a/src/layouts/admin/index.vue +++ b/src/layouts/admin/index.vue @@ -58,226 +58,226 @@ const init = async () => { * 后台初始化请求,获取站点配置,动态路由等信息 */ getRouteMenu().then((res: any) => { - const arr = [ - { - id: 1, - pid: 0, - type: 'menu', - title: '控制台', - name: 'dashboard', - path: 'dashboard', - icon: 'fa fa-dashboard', - menu_type: 'tab', - url: '', - component: '/src/views/dashboard/index.vue', - keepalive: 'dashboard', - extend: 'none', - children: [] - }, - { - id: 3, - pid: 0, - type: 'menu', - title: '审计管理', - name: 'test', - path: 'test', - icon: 'el-icon-List', - menu_type: 'tab', - url: '', - component: '/src/views/dashboard/test.vue', - keepalive: 'test', - extend: 'none', - children: [ - { - id: 1, - pid: 3, - type: 'menu', - title: '审计列表', - name: 'comptroller/list', - path: 'comptroller/list', - icon: 'el-icon-List', - menu_type: 'tab', - url: '', - component: '/src/views/comptroller/list.vue', - keepalive: 'auth/role', - extend: 'none', - children: [] - } - ] - }, - { - id: 3, - pid: 0, - type: 'menu_dir', - title: '电压暂降', - name: 'voltage/sags', - path: 'voltage/sags', - icon: 'el-icon-BellFilled', - menu_type: 'tab', - url: '', - extend: 'none', - children: [ - { - id: 1, - pid: 3, - type: 'menu_dir', - title: '运行管理', - name: 'voltage/sags/operationsManagement', - path: 'voltage/sags/operationsManagement', - icon: 'fa-solid fa-bars-progress', - menu_type: 'tab', - url: '', - extend: 'none', - children: [ - { - id: 1, - pid: 3, - type: 'menu', - title: '终端运行管理', - name: 'voltage/sags/operationsManagement/index', - path: 'voltage/sags/operationsManagement/index', - icon: 'fa-solid fa-recycle', - menu_type: 'tab', - url: '', - component: '/src/views/voltage/sags/operationsManagement/index.vue', - keepalive: 'voltage/sags/operationsManagement/index', - extend: 'none', - children: [] - }, - { - id: 1, - pid: 3, - type: 'menu', - title: '终端运行统计', - name: 'voltage/sags/operationsManagement/statistics', - path: 'voltage/sags/operationsManagement/statistics', - icon: 'fa-solid fa-chart-column', - menu_type: 'tab', - url: '', - component: '/src/views/voltage/sags/operationsManagement/statistics.vue', - keepalive: 'voltage/sags/operationsManagement/statistics', - extend: 'none', - children: [] - }, - { - id: 1, - pid: 3, - type: 'menu', - title: '监测点台账信息', - name: 'voltage/sags/operationsManagement/point', - path: 'voltage/sags/operationsManagement/point', - icon: 'fa-brands fa-square-pinterest', - menu_type: 'tab', - url: '', - component: '/src/views/voltage/sags/operationsManagement/point.vue', - keepalive: 'voltage/sags/operationsManagement/point', - extend: 'none', - children: [] - } - ] - }, - { - id: 2, - pid: 3, - type: 'menu', - title: '区域', - name: 'Event-boot/Region/distribution', - path: 'Event-boot/Region/distribution', - icon: 'el-icon-Management', - menu_type: 'tab', - url: '', - component: '/src/views/Event-boot/Region/distribution.vue', - keepalive: 'Event-boot/Region/distribution', - extend: 'none', - children: [ - { - id: 2, - pid: 3, - type: 'menu', - title: '区域概览', - name: 'Region/overview', - path: 'Region/overview', - icon: 'el-icon-Promotion', - menu_type: 'tab', - url: '', - component: '/src/views/dashboard/index.vue', - keepalive: 'Region/overview', - extend: 'none', - children: [] - }, - { - id: 1, - pid: 3, - type: 'menu', - title: '监测网分布', - name: 'Region/distribution', - path: 'Region/distribution', - icon: 'el-icon-Share', - menu_type: 'tab', - url: '', - component: '/src/views/Event-boot/Region/distribution.vue', - keepalive: 'Region/distribution', - extend: 'none', - children: [] - } - ] - } - ] - }, - { - id: 2, - pid: 0, - type: 'menu_dir', - title: '权限管理', - name: 'auth', - path: 'auth', - icon: 'fa-solid fa-layer-group', - menu_type: null, - url: '', - component: '', - keepalive: 0, - extend: 'none', - children: [ - { - id: 3, - pid: 2, - type: 'menu', - title: '角色管理', - name: 'auth/role', - path: 'auth/role', - icon: 'el-icon-Avatar', - menu_type: 'tab', - url: '', - component: '/src/views/auth/role/index.vue', - keepalive: 'auth/role', - extend: 'none', - children: [] - }, - { - id: 13, - pid: 2, - type: 'menu', - title: '菜单规则管理', - name: 'auth/menu', - path: 'auth/menu', - icon: 'el-icon-Menu', - menu_type: 'tab', - url: '', - component: '/src/views/auth/menu/index.vue', - keepalive: 'auth/menu', - extend: 'none', - children: [] - } - ] - } - ] + // const arr = [ + // { + // id: 1, + // pid: 0, + // type: 'menu', + // title: '控制台', + // name: 'dashboard', + // path: 'dashboard', + // icon: 'fa fa-dashboard', + // menu_type: 'tab', + // url: '', + // component: '/src/views/dashboard/index.vue', + // keepalive: 'dashboard', + // extend: 'none', + // children: [] + // }, + // { + // id: 3, + // pid: 0, + // type: 'menu', + // title: '审计管理', + // name: 'test', + // path: 'test', + // icon: 'el-icon-List', + // menu_type: 'tab', + // url: '', + // component: '/src/views/dashboard/test.vue', + // keepalive: 'test', + // extend: 'none', + // children: [ + // { + // id: 1, + // pid: 3, + // type: 'menu', + // title: '审计列表', + // name: 'comptroller/list', + // path: 'comptroller/list', + // icon: 'el-icon-List', + // menu_type: 'tab', + // url: '', + // component: '/src/views/comptroller/list.vue', + // keepalive: 'auth/role', + // extend: 'none', + // children: [] + // } + // ] + // }, + // { + // id: 3, + // pid: 0, + // type: 'menu_dir', + // title: '电压暂降', + // name: 'voltage/sags', + // path: 'voltage/sags', + // icon: 'el-icon-BellFilled', + // menu_type: 'tab', + // url: '', + // extend: 'none', + // children: [ + // { + // id: 1, + // pid: 3, + // type: 'menu_dir', + // title: '运行管理', + // name: 'voltage/sags/operationsManagement', + // path: 'voltage/sags/operationsManagement', + // icon: 'fa-solid fa-bars-progress', + // menu_type: 'tab', + // url: '', + // extend: 'none', + // children: [ + // { + // id: 1, + // pid: 3, + // type: 'menu', + // title: '终端运行管理', + // name: 'voltage/sags/operationsManagement/index', + // path: 'voltage/sags/operationsManagement/index', + // icon: 'fa-solid fa-recycle', + // menu_type: 'tab', + // url: '', + // component: '/src/views/voltage/sags/operationsManagement/index.vue', + // keepalive: 'voltage/sags/operationsManagement/index', + // extend: 'none', + // children: [] + // }, + // { + // id: 1, + // pid: 3, + // type: 'menu', + // title: '终端运行统计', + // name: 'voltage/sags/operationsManagement/statistics', + // path: 'voltage/sags/operationsManagement/statistics', + // icon: 'fa-solid fa-chart-column', + // menu_type: 'tab', + // url: '', + // component: '/src/views/voltage/sags/operationsManagement/statistics.vue', + // keepalive: 'voltage/sags/operationsManagement/statistics', + // extend: 'none', + // children: [] + // }, + // { + // id: 1, + // pid: 3, + // type: 'menu', + // title: '监测点台账信息', + // name: 'voltage/sags/operationsManagement/point', + // path: 'voltage/sags/operationsManagement/point', + // icon: 'fa-brands fa-square-pinterest', + // menu_type: 'tab', + // url: '', + // component: '/src/views/voltage/sags/operationsManagement/point.vue', + // keepalive: 'voltage/sags/operationsManagement/point', + // extend: 'none', + // children: [] + // } + // ] + // }, + // { + // id: 2, + // pid: 3, + // type: 'menu', + // title: '区域', + // name: 'Event-boot/Region/distribution', + // path: 'Event-boot/Region/distribution', + // icon: 'el-icon-Management', + // menu_type: 'tab', + // url: '', + // component: '/src/views/Event-boot/Region/distribution.vue', + // keepalive: 'Event-boot/Region/distribution', + // extend: 'none', + // children: [ + // { + // id: 2, + // pid: 3, + // type: 'menu', + // title: '区域概览', + // name: 'Region/overview', + // path: 'Region/overview', + // icon: 'el-icon-Promotion', + // menu_type: 'tab', + // url: '', + // component: '/src/views/dashboard/index.vue', + // keepalive: 'Region/overview', + // extend: 'none', + // children: [] + // }, + // { + // id: 1, + // pid: 3, + // type: 'menu', + // title: '监测网分布', + // name: 'Region/distribution', + // path: 'Region/distribution', + // icon: 'el-icon-Share', + // menu_type: 'tab', + // url: '', + // component: '/src/views/Event-boot/Region/distribution.vue', + // keepalive: 'Region/distribution', + // extend: 'none', + // children: [] + // } + // ] + // } + // ] + // }, + // { + // id: 2, + // pid: 0, + // type: 'menu_dir', + // title: '权限管理', + // name: 'auth', + // path: 'auth', + // icon: 'fa-solid fa-layer-group', + // menu_type: null, + // url: '', + // component: '', + // keepalive: 0, + // extend: 'none', + // children: [ + // { + // id: 3, + // pid: 2, + // type: 'menu', + // title: '角色管理', + // name: 'auth/role', + // path: 'auth/role', + // icon: 'el-icon-Avatar', + // menu_type: 'tab', + // url: '', + // component: '/src/views/auth/role/index.vue', + // keepalive: 'auth/role', + // extend: 'none', + // children: [] + // }, + // { + // id: 13, + // pid: 2, + // type: 'menu', + // title: '菜单规则管理', + // name: 'auth/menu', + // path: 'auth/menu', + // icon: 'el-icon-Menu', + // menu_type: 'tab', + // url: '', + // component: '/src/views/auth/menu/index.vue', + // keepalive: 'auth/menu', + // extend: 'none', + // children: [] + // } + // ] + // } + // ] const handlerMenu = (data: any) => { data.forEach((item: any) => { - item.path = item.routeName || item.title + item.path = item.routePath item.name = item.title - item.component = '/src/views/dashboard/index.vue' + item.component = item.routeName || '/src/views/dashboard/index.vue' item.type = item.children && item.children.length > 0 ? 'menu_dir' : 'menu' item.menu_type = item.children && item.children.length > 0 ? null : 'tab' if (item.children) { @@ -287,8 +287,8 @@ const init = async () => { } handlerMenu(res.data) // handleAdminRoute(arr) - // handleAdminRoute(res.data) - handleAdminRoute([...arr, ...res.data]) + handleAdminRoute(res.data) + // handleAdminRoute([...arr, ...res.data]) // 预跳转到上次路径 if (route.params.to) { diff --git a/src/router/index.ts b/src/router/index.ts index 9fe39df..10e9bd4 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -1,6 +1,6 @@ import { createRouter, createWebHashHistory } from 'vue-router' import staticRoutes from '@/router/static' -import { useConfig } from '@/stores/config' +import { useAdminInfo } from '@/stores/adminInfo' import NProgress from 'nprogress' import { loading } from '@/utils/loading' import { ElMessage } from 'element-plus' @@ -23,7 +23,8 @@ router.beforeEach((to, from, next) => { next() } else { // 获取 token - const token = localStorage.getItem('token') + const adminInfo = useAdminInfo() + const token = adminInfo.getToken() // token 不存在 if (token === null || token === '') { ElMessage.error('您还没有登录,请先登录') diff --git a/src/utils/router.ts b/src/utils/router.ts index dbef082..fa06484 100644 --- a/src/utils/router.ts +++ b/src/utils/router.ts @@ -153,7 +153,6 @@ const handleMenuRule = (routes: any, pathPrefix = '/', type = ['menu', 'menu_dir name: routes[key].name, component: routes[key].component, meta: { - ...routes[key], id: routes[key].id, title: routes[key].title, icon: routes[key].icon, diff --git a/src/views/auth/menu/index.vue b/src/views/auth/menu/index.vue index 4b2d9f7..4ecbdf8 100644 --- a/src/views/auth/menu/index.vue +++ b/src/views/auth/menu/index.vue @@ -1,15 +1,15 @@ -