import router from "@/route/router";
|
import MainLayout from '@/layout/main/MainLayout.vue';
|
import Vue from "vue";
|
import { get, post } from "@/util/request";
|
|
const organization = {
|
path: 'organization',
|
name: '/organization',
|
component: () => import(/* webpackChunkName: "form" */ '@/views/system/organization.vue'),
|
meta: {
|
routerGuard: true,
|
title: '组织管理',
|
},
|
}
|
|
const usermanage = {
|
path: 'users',
|
name: '/users',
|
component: () => import(/* webpackChunkName: "widgets" */ '@/views/usermanage/index.vue'),
|
meta: {
|
title: '账户管理',
|
routerGuard: true,
|
},
|
}
|
|
const logmanage = {
|
path: '/systems/log',
|
name: '/systems/log',
|
component: () => import('@/views/systemset/logmanage.vue'),
|
meta: {
|
routerGuard: true,
|
title: '日志管理'
|
}
|
}
|
|
const dictionaryManage = {
|
path: '/systems/Dictionary',
|
name: '/systems/Dictionary',
|
component: () => import('@/views/systemset/dictionaryManage.vue'),
|
meta: {
|
routerGuard: true,
|
title: '字典管理'
|
}
|
}
|
|
const role = {
|
path: 'role',
|
name: '/authority/role',
|
component: () => import(/* webpackChunkName: "list" */ '@/views/list/Query.vue'),
|
meta: {
|
title: '角色配置',
|
routerGuard: true
|
},
|
}
|
|
|
const menu = {
|
path: 'menu',
|
name: '/authority/menu',
|
component: () => import(/* webpackChunkName: "list" */ '@/views/list/Menu.vue'),
|
meta: {
|
title: '菜单配置',
|
routerGuard: true,
|
},
|
}
|
const unit = {
|
path: 'unit',
|
name: '/authority/unit',
|
component: () => import(/* webpackChunkName: "list" */ '@/views/list/Unit.vue'),
|
meta: {
|
title: '系统管理',
|
routerGuard: true
|
},
|
}
|
|
const webMenu = {
|
path: 'wMenu',
|
name: '/wMenu/wMenu',
|
component: () => import(/* webpackChunkName: "dashboard" */ '@/views/menu/webMenu.vue'),
|
meta: {
|
routerGuard: true,
|
title: '前端菜单配置'
|
},
|
}
|
|
const sensor = {
|
path: 'sensor',
|
name: '/sensor',
|
component: () => import(/* webpackChunkName: "dashboard" */ '@/views/sensor/sensor.vue'),
|
meta: {
|
routerGuard: true,
|
title: '传感器配置'
|
},
|
}
|
|
const sensorBasic = {
|
path: 'sensorBasic',
|
name: '/sensor/sensorBasic',
|
component: () => import(/* webpackChunkName: "dashboard" */ '@/views/list/sensorsBasic.vue'),
|
meta: {
|
routerGuard: true,
|
title: '基本信息'
|
},
|
}
|
|
const sensorChangeUnit = {
|
path: 'sensorChangeUnit',
|
name: '/sensor/sensorChangeUnit',
|
component: () => import(/* webpackChunkName: "dashboard" */ '@/views/list/sensorChangeUnit.vue'),
|
meta: {
|
routerGuard: true,
|
title: '单位转换'
|
},
|
}
|
|
const basic = {
|
path: 'basic',
|
name: '/device/basic',
|
component: () => import(/* webpackChunkName: "list" */ '@/views/list/devicesBasic.vue'),
|
meta: {
|
routerGuard: true,
|
title: '设备配置'
|
},
|
}
|
|
const specialDevice = {
|
path: 'specialDevice',
|
name: '/device/specialDevice',
|
component: () => import(/* webpackChunkName: "list" */ '@/views/list/specialDevice.vue'),
|
meta: {
|
routerGuard: true,
|
title: '特殊设备'
|
},
|
}
|
|
const deviceVersion = {
|
path: 'deviceVersion',
|
name: '/device/deviceVersion',
|
component: () => import(/* webpackChunkName: "list" */ '@/views/list/devicesVersion.vue'),
|
meta: {
|
routerGuard: true,
|
title: '型号配置'
|
},
|
}
|
|
const deviceMonitorPoint = {
|
path: 'deviceMonitorPoint',
|
name: '/device/deviceMonitorPoint',
|
component: () => import(/* webpackChunkName: "list" */ '@/views/list/devicesMonitorPoint.vue'),
|
meta: {
|
routerGuard: true,
|
title: '监测站点管理'
|
},
|
}
|
const govMonitorPoint = {
|
path: 'govMonitorPoint',
|
name: '/device/govMonitorPoint',
|
component: () => import(/* webpackChunkName: "list" */ '@/views/device/govMonitorPoint.vue'),
|
meta: {
|
routerGuard: true,
|
title: '政府站点'
|
},
|
}
|
const areaConfiguration = {
|
path: 'areaConfiguration',
|
name: '/device/areaConfiguration',
|
component: () => import(/* webpackChunkName: "list" */ '@/views/device/areaConfiguration.vue'),
|
meta: {
|
routerGuard: true,
|
title: '图形扩展区域配置'
|
},
|
}
|
const routerMap = {
|
organization: organization,
|
users: usermanage,
|
log: logmanage,
|
dictionary: dictionaryManage,
|
role: role,
|
unit: unit,
|
menuq: menu,
|
wMenu: webMenu,
|
sensor: sensor,
|
sensorBasic: sensorBasic,
|
sensorChangeUnit: sensorChangeUnit,
|
basic: basic,
|
deviceVersion: deviceVersion,
|
deviceMonitorPoint: deviceMonitorPoint,
|
specialDevice: specialDevice,
|
govMonitorPoint: govMonitorPoint,
|
areaConfiguration: areaConfiguration
|
}
|
|
|
function getMenus(token: any) {
|
get('getAccountInfo', {}).then((res: any) => {
|
if (res.data.code === -3) {
|
Vue.prototype.$message.warning(res.data.message, 2)
|
sessionStorage.clear()
|
router.push('/passport/login')
|
} else {
|
sessionStorage.setItem('userName', res.data.data.userName)
|
sessionStorage.setItem('menuData', JSON.stringify(res.data.data.menus))
|
sessionStorage.setItem('router', JSON.stringify(router.options.routes))
|
let rout = JSON.parse((sessionStorage.getItem('router')))
|
if (rout.length === 3) {
|
routerDynamic()
|
} else {
|
return
|
}
|
}
|
})
|
}
|
|
function routerDynamic() {
|
let menuData = []
|
setTimeout(() => {
|
menuData = JSON.parse((sessionStorage.getItem('menuData')))
|
let rout = JSON.parse((sessionStorage.getItem('router')))
|
const currentRoutes = router.options.routes
|
if (menuData !== null) {
|
menuData.forEach((element: any) => {
|
element.meta = {
|
title: element.name,
|
icon: 'profile'
|
}
|
|
element.component = MainLayout
|
element.path = '/' + element.url
|
element.name = '/' + element.url
|
delete element.order
|
delete element.id
|
let child = []
|
if (element.children) {
|
delete element.url
|
child = element.children
|
element.redirect = element.children[0].url
|
delete element.children
|
element.children = []
|
} else {
|
element.redirect = element.url + '' + element.path
|
delete element.url
|
element.children = []
|
}
|
if (currentRoutes) {
|
currentRoutes.splice(currentRoutes.length, 0, element)
|
}
|
if (child.length > 0) {
|
child.forEach((c: any) => {
|
let path = c.url.substr(element.path.length, c.url.length)
|
let temp = routerMap[path]
|
if (temp) {
|
currentRoutes[currentRoutes.length - 1].children.push(temp)
|
}
|
})
|
} else {
|
let path = element.path.substr(1, element.path.length)
|
let temp = routerMap[path]
|
if (temp) {
|
currentRoutes[currentRoutes.length - 1].children.push(temp)
|
}
|
}
|
|
|
})
|
// const temp = {
|
// path: '*',
|
// redirect: '/notFound/404'
|
// }
|
// temp.meta = {
|
// title: '404',
|
// }
|
// currentRoutes[currentRoutes.length - 1].children.push(temp)
|
}
|
router.addRoutes(currentRoutes)
|
}, 400)
|
}
|
|
export default getMenus
|