mirror of
https://github.com/veops/cmdb.git
synced 2025-08-08 20:45:34 +08:00
前后端全面升级
This commit is contained in:
135
cmdb-ui/src/router/config.js
Normal file
135
cmdb-ui/src/router/config.js
Normal file
@@ -0,0 +1,135 @@
|
||||
/* eslint-disable */
|
||||
import { UserLayout, BasicLayout, RouteView } from '@/layouts'
|
||||
import appConfig from '@/config/app'
|
||||
import { getAppAclRouter } from './utils'
|
||||
import store from '../store'
|
||||
|
||||
export const generatorDynamicRouter = async () => {
|
||||
const packages = []
|
||||
const { apps = undefined } = store.getters.userInfo
|
||||
for (let appName of appConfig.buildModules.filter(item => item !== 'fullscreen')) {
|
||||
if (!apps || !apps.length || apps.includes(appName)) {
|
||||
const module = await import(`@/modules/${appName}/index.js`)
|
||||
const r = await module.default.route()
|
||||
|
||||
if (r.length) {
|
||||
if (module.default.name !== 'acl' && appConfig.buildAclToModules) {
|
||||
r[0].children.push(getAppAclRouter(module.default.name))
|
||||
}
|
||||
packages.push(...r)
|
||||
} else {
|
||||
if (module.default.name !== 'acl' && appConfig.buildAclToModules) {
|
||||
r.children.push(getAppAclRouter(module.default.name))
|
||||
}
|
||||
packages.push(r)
|
||||
}
|
||||
}
|
||||
}
|
||||
let routes = packages
|
||||
if (appConfig.buildModules.includes('fullscreen')) {
|
||||
routes = routes.concat([
|
||||
{
|
||||
path: '/fullscreen',
|
||||
component: BasicLayout,
|
||||
redirect: '/fullscreen/index',
|
||||
meta: { title: '大屏' },
|
||||
name: 'fullscreen',
|
||||
children: [{
|
||||
path: '/fullscreen/index',
|
||||
name: 'fullscreen_index',
|
||||
meta: { title: '大屏' },
|
||||
component: () => import(/* webpackChunkName: "fullscreen" */ '@/views/fullscreen'),
|
||||
}],
|
||||
},
|
||||
{ path: '*', redirect: '/404', hidden: true }])
|
||||
}
|
||||
routes = routes.concat([
|
||||
{ path: '*', redirect: '/404', hidden: true },
|
||||
{
|
||||
hidden: true,
|
||||
path: '/noticecenter',
|
||||
name: 'notice_center',
|
||||
component: BasicLayout,
|
||||
children: [{
|
||||
path: '/noticecenter',
|
||||
name: 'notice_center',
|
||||
meta: { title: '消息中心' },
|
||||
component: () => import(/* webpackChunkName: "setting" */ '@/views/noticeCenter/index')
|
||||
}]
|
||||
},
|
||||
{
|
||||
path: '/setting',
|
||||
component: BasicLayout,
|
||||
redirect: '/setting/companyinfo',
|
||||
meta: {},
|
||||
children: [
|
||||
{
|
||||
hidden: true,
|
||||
path: '/setting/person',
|
||||
name: 'setting_person',
|
||||
meta: { title: '个人中心', },
|
||||
component: () => import(/* webpackChunkName: "setting" */ '@/views/setting/person/index')
|
||||
},
|
||||
{
|
||||
path: '/setting/companyinfo',
|
||||
name: 'company_info',
|
||||
meta: { title: '公司信息', appName: 'backend', icon: 'ops-setting-companyInfo', selectedIcon: 'ops-setting-companyInfo-selected', permission: ['acl_admin', 'backend_admin'] },
|
||||
component: () => import(/* webpackChunkName: "setting" */ '@/views/setting/companyInfo/index')
|
||||
},
|
||||
{
|
||||
path: '/setting/companystructure',
|
||||
name: 'company_structure',
|
||||
meta: { title: '公司架构', appName: 'backend', icon: 'ops-setting-companyStructure', selectedIcon: 'ops-setting-companyStructure-selected', permission: ['acl_admin', 'backend_admin'] },
|
||||
component: () => import(/* webpackChunkName: "setting" */ '@/views/setting/companyStructure/index')
|
||||
},
|
||||
]
|
||||
},])
|
||||
return routes
|
||||
}
|
||||
|
||||
/**
|
||||
* 基础路由
|
||||
*/
|
||||
export const constantRouterMap = [
|
||||
{
|
||||
path: '/',
|
||||
redirect: appConfig.redirectTo,
|
||||
// redirect: () => { return store.getters.appRoutes[0] },
|
||||
},
|
||||
{
|
||||
path: '/user/login',
|
||||
name: 'login',
|
||||
component: () => import(/* webpackChunkName: "user" */ '@/views/user/Login'),
|
||||
},
|
||||
{
|
||||
path: '/user',
|
||||
component: UserLayout,
|
||||
redirect: '/user/login',
|
||||
hidden: true,
|
||||
children: [
|
||||
{
|
||||
path: 'register',
|
||||
name: 'register',
|
||||
component: () => import(/* webpackChunkName: "user" */ '@/views/user/Register'),
|
||||
},
|
||||
{
|
||||
path: 'register-result',
|
||||
name: 'registerResult',
|
||||
component: () => import(/* webpackChunkName: "user" */ '@/views/user/RegisterResult'),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/404',
|
||||
component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404'),
|
||||
},
|
||||
{
|
||||
path: '/403',
|
||||
component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/403'),
|
||||
},
|
||||
{
|
||||
path: '/500',
|
||||
component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/500'),
|
||||
},
|
||||
|
||||
]
|
@@ -1,20 +1,14 @@
|
||||
/* eslint-disable */
|
||||
import Vue from 'vue'
|
||||
import Router from 'vue-router'
|
||||
import { constantRouterMap } from '@/config/router.config'
|
||||
import { constantRouterMap } from '@/router/config'
|
||||
|
||||
Vue.use(Router)
|
||||
|
||||
// export default new Router({
|
||||
// mode: 'history',
|
||||
// base: process.env.BASE_URL,
|
||||
// scrollBehavior: () => ({ y: 0 }),
|
||||
// routes: constantRouterMap
|
||||
// })
|
||||
|
||||
const createRouter = () => new Router({
|
||||
mode: 'history',
|
||||
base: process.env.BASE_URL,
|
||||
scrollBehavior: () => ({ y: 0 }),
|
||||
scrollBehavior: () => ({ y: 0, x: undefined }),
|
||||
routes: constantRouterMap
|
||||
})
|
||||
|
||||
@@ -22,7 +16,7 @@ const router = createRouter()
|
||||
|
||||
export function resetRouter () {
|
||||
const newRouter = createRouter()
|
||||
router.matcher = newRouter.matcher // reset router
|
||||
router['matcher'] = newRouter['matcher'] // reset router
|
||||
}
|
||||
|
||||
export default router
|
||||
|
41
cmdb-ui/src/router/utils.js
Normal file
41
cmdb-ui/src/router/utils.js
Normal file
@@ -0,0 +1,41 @@
|
||||
import { RouteView } from '@/layouts'
|
||||
|
||||
export const getAppAclRouter = (appName) => {
|
||||
return {
|
||||
path: `/${appName}/acl`,
|
||||
name: `${appName}_acl`,
|
||||
component: RouteView,
|
||||
redirect: `/${appName}/acl/users`,
|
||||
meta: { title: '权限管理', icon: 'safety-certificate', permission: [`${appName}_admin`, 'admin'] }, // permission: 'admin'
|
||||
children: [
|
||||
{
|
||||
path: `/${appName}/acl/roles`,
|
||||
name: `${appName}_acl_roles`,
|
||||
hideChildrenInMenu: true,
|
||||
component: () => import('@/modules/acl/views/roles'),
|
||||
meta: { title: '角色管理', icon: 'team', keepAlive: true }
|
||||
},
|
||||
{
|
||||
path: `/${appName}/acl/resources`,
|
||||
name: `${appName}_acl_resources`,
|
||||
hideChildrenInMenu: true,
|
||||
component: () => import('@/modules/acl/views/resources'),
|
||||
meta: { title: '资源管理', icon: 'credit-card', keepAlive: false }
|
||||
},
|
||||
{
|
||||
path: `/${appName}/acl/resource_types`,
|
||||
name: `${appName}_acl_resource_types`,
|
||||
hideChildrenInMenu: true,
|
||||
component: () => import('@/modules/acl/views/resource_types'),
|
||||
meta: { title: '资源类型', icon: 'file-text', keepAlive: true }
|
||||
},
|
||||
{
|
||||
path: `/${appName}/acl/trigger`,
|
||||
name: `${appName}_acl_trigger`,
|
||||
hideChildrenInMenu: true,
|
||||
component: () => import('@/modules/acl/views/trigger'),
|
||||
meta: { title: '触发器', icon: 'clock-circle', keepAlive: true }
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user