角色列表添加
This commit is contained in:
@@ -58,235 +58,234 @@ 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/govern/log/debug.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/govern/setting/app/index.vue',
|
||||
keepalive: 'test',
|
||||
extend: 'none',
|
||||
children: [
|
||||
{
|
||||
id: 1,
|
||||
pid: 3,
|
||||
type: 'menu',
|
||||
title: '图表1',
|
||||
name: 'comptroller/list1',
|
||||
path: 'comptroller/list1',
|
||||
icon: 'el-icon-List',
|
||||
menu_type: 'tab',
|
||||
url: '',
|
||||
component: '/src/views/govern/user/roleCode/index.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/Event-boot/Region/overview.vue',
|
||||
keepalive: 'Region/overview',
|
||||
extend: 'none',
|
||||
children: []
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
pid: 3,
|
||||
type: 'menu',
|
||||
title: '区域统计',
|
||||
name: 'Region/statistics',
|
||||
path: 'Region/statistics',
|
||||
icon: 'el-icon-Promotion',
|
||||
menu_type: 'tab',
|
||||
url: '',
|
||||
component: '/src/views/Event-boot/Region/statistics.vue',
|
||||
keepalive: 'Region/statistics',
|
||||
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/govern/log/debug.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/govern/setting/app/index.vue',
|
||||
// keepalive: 'test',
|
||||
// extend: 'none',
|
||||
// children: [
|
||||
// {
|
||||
// id: 1,
|
||||
// pid: 3,
|
||||
// type: 'menu',
|
||||
// title: '图表1',
|
||||
// name: 'comptroller/list1',
|
||||
// path: 'comptroller/list1',
|
||||
// icon: 'el-icon-List',
|
||||
// menu_type: 'tab',
|
||||
// url: '',
|
||||
// component: '/src/views/govern/user/roleCode/index.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/Event-boot/Region/overview.vue',
|
||||
// keepalive: 'Region/overview',
|
||||
// extend: 'none',
|
||||
// children: []
|
||||
// },
|
||||
// {
|
||||
// id: 2,
|
||||
// pid: 3,
|
||||
// type: 'menu',
|
||||
// title: '区域统计',
|
||||
// name: 'Region/statistics',
|
||||
// path: 'Region/statistics',
|
||||
// icon: 'el-icon-Promotion',
|
||||
// menu_type: 'tab',
|
||||
// url: '',
|
||||
// component: '/src/views/Event-boot/Region/statistics.vue',
|
||||
// keepalive: 'Region/statistics',
|
||||
// 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.routePath
|
||||
@@ -301,10 +300,7 @@ const init = async () => {
|
||||
})
|
||||
}
|
||||
handlerMenu(res.data)
|
||||
// handleAdminRoute(arr)
|
||||
// handleAdminRoute(res.data)
|
||||
handleAdminRoute([...arr, ...res.data])
|
||||
|
||||
handleAdminRoute(res.data)
|
||||
// 预跳转到上次路径
|
||||
if (route.params.to) {
|
||||
const lastRoute = JSON.parse(route.params.to as string)
|
||||
@@ -316,9 +312,7 @@ const init = async () => {
|
||||
}
|
||||
|
||||
// 跳转到第一个菜单
|
||||
console.log(navTabs.state.tabsViewRoutes)
|
||||
let firstRoute = getFirstRoute(navTabs.state.tabsViewRoutes)
|
||||
console.log(firstRoute)
|
||||
if (firstRoute) routePush(firstRoute.path)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,25 +1,22 @@
|
||||
<template>
|
||||
<el-main class='layout-main'>
|
||||
<el-scrollbar class='layout-main-scrollbar' :style='layoutMainScrollbarStyle()' ref='mainScrollbarRef'>
|
||||
<router-view v-slot='{ Component }'>
|
||||
<transition :name='config.layout.mainAnimation' mode='out-in'>
|
||||
<keep-alive :include='state.keepAliveComponentNameList'>
|
||||
<component :is='Component' :key='state.componentKey' />
|
||||
</keep-alive>
|
||||
</transition>
|
||||
</router-view>
|
||||
</el-scrollbar>
|
||||
<el-main class="layout-main" :style="mainHeight()">
|
||||
<router-view v-slot="{ Component }">
|
||||
<transition :name="config.layout.mainAnimation" mode="out-in">
|
||||
<keep-alive :include="state.keepAliveComponentNameList">
|
||||
<component :is="Component" :key="state.componentKey" />
|
||||
</keep-alive>
|
||||
</transition>
|
||||
</router-view>
|
||||
</el-main>
|
||||
</template>
|
||||
|
||||
<script setup lang='ts'>
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, watch, onBeforeMount, onUnmounted, nextTick, provide } from 'vue'
|
||||
import { useRoute, type RouteLocationNormalized } from 'vue-router'
|
||||
import { mainHeight as layoutMainScrollbarStyle } from '@/utils/layout'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import useCurrentInstance from '@/utils/useCurrentInstance'
|
||||
import { useConfig } from '@/stores/config'
|
||||
import { useNavTabs } from '@/stores/navTabs'
|
||||
import type { ScrollbarInstance } from 'element-plus'
|
||||
|
||||
defineOptions({
|
||||
name: 'layout/main'
|
||||
@@ -30,7 +27,6 @@ const { proxy } = useCurrentInstance()
|
||||
const route = useRoute()
|
||||
const config = useConfig()
|
||||
const navTabs = useNavTabs()
|
||||
const mainScrollbarRef = ref<ScrollbarInstance>()
|
||||
|
||||
const state: {
|
||||
componentKey: string
|
||||
@@ -40,7 +36,7 @@ const state: {
|
||||
keepAliveComponentNameList: []
|
||||
})
|
||||
|
||||
const addKeepAliveComponentName = function(keepAliveName: string | undefined) {
|
||||
const addKeepAliveComponentName = function (keepAliveName: string | undefined) {
|
||||
if (keepAliveName) {
|
||||
let exist = state.keepAliveComponentNameList.find((name: string) => {
|
||||
return name === keepAliveName
|
||||
@@ -52,7 +48,9 @@ const addKeepAliveComponentName = function(keepAliveName: string | undefined) {
|
||||
|
||||
onBeforeMount(() => {
|
||||
proxy.eventBus.on('onTabViewRefresh', (menu: RouteLocationNormalized) => {
|
||||
state.keepAliveComponentNameList = state.keepAliveComponentNameList.filter((name: string) => menu.meta.keepalive !== name)
|
||||
state.keepAliveComponentNameList = state.keepAliveComponentNameList.filter(
|
||||
(name: string) => menu.meta.keepalive !== name
|
||||
)
|
||||
state.componentKey = ''
|
||||
nextTick(() => {
|
||||
state.componentKey = menu.path
|
||||
@@ -60,7 +58,9 @@ onBeforeMount(() => {
|
||||
})
|
||||
})
|
||||
proxy.eventBus.on('onTabViewClose', (menu: RouteLocationNormalized) => {
|
||||
state.keepAliveComponentNameList = state.keepAliveComponentNameList.filter((name: string) => menu.meta.keepalive !== name)
|
||||
state.keepAliveComponentNameList = state.keepAliveComponentNameList.filter(
|
||||
(name: string) => menu.meta.keepalive !== name
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -74,7 +74,6 @@ onMounted(() => {
|
||||
if (typeof navTabs.state.activeRoute?.meta.keepalive == 'string') {
|
||||
addKeepAliveComponentName(navTabs.state.activeRoute?.meta.keepalive)
|
||||
}
|
||||
console.log(state.keepAliveComponentNameList)
|
||||
})
|
||||
|
||||
watch(
|
||||
@@ -87,10 +86,9 @@ watch(
|
||||
}
|
||||
)
|
||||
|
||||
provide('mainScrollbarRef', mainScrollbarRef)
|
||||
</script>
|
||||
|
||||
<style scoped lang='scss'>
|
||||
<style scoped lang="scss">
|
||||
.layout-container .layout-main {
|
||||
padding: 0 !important;
|
||||
overflow: hidden;
|
||||
|
||||
Reference in New Issue
Block a user