| | |
| | | import auth from '@/plugins/auth'
|
| | | import router, { constantRoutes, dynamicRoutes } from '@/router'
|
| | | import router, { constantRoutes, dynamicRoutes, financialRoutes } from '@/router'
|
| | | import { getRouters } from '@/api/menu'
|
| | | import Layout from '@/layout/index'
|
| | | import ParentView from '@/components/ParentView'
|
| | |
| | | const asyncRoutes = filterDynamicRoutes(dynamicRoutes)
|
| | | asyncRoutes.forEach(route => { router.addRoute(route) })
|
| | | this.setRoutes(rewriteRoutes)
|
| | | this.setSidebarRouters(constantRoutes.concat(sidebarRoutes))
|
| | | this.setDefaultRoutes(sidebarRoutes)
|
| | | this.setTopbarRoutes(defaultRoutes)
|
| | | // 将财务管理路由合并到侧边栏
|
| | | this.setSidebarRouters(constantRoutes.concat(sidebarRoutes).concat(financialRoutes))
|
| | | this.setDefaultRoutes(sidebarRoutes.concat(financialRoutes))
|
| | | this.setTopbarRoutes(defaultRoutes.concat(financialRoutes))
|
| | | // 添加财务管理模块路由
|
| | | financialRoutes.forEach(route => {
|
| | | router.addRoute(route)
|
| | | })
|
| | | resolve(rewriteRoutes)
|
| | | })
|
| | | })
|
| | |
| | |
|
| | | function filterChildren(childrenMap, lastRouter = false) {
|
| | | var children = []
|
| | | childrenMap.forEach((el, index) => {
|
| | | if (el.children && el.children.length) {
|
| | | if (el.component === 'ParentView' && !lastRouter) {
|
| | | el.children.forEach(c => {
|
| | | c.path = el.path + '/' + c.path
|
| | | if (c.children && c.children.length) {
|
| | | children = children.concat(filterChildren(c.children, c))
|
| | | return
|
| | | }
|
| | | children.push(c)
|
| | | })
|
| | | return
|
| | | }
|
| | | childrenMap.forEach(el => {
|
| | | el.path = lastRouter ? lastRouter.path + '/' + el.path : el.path
|
| | | if (el.children && el.children.length && el.component === 'ParentView') {
|
| | | children = children.concat(filterChildren(el.children, el))
|
| | | } else {
|
| | | children.push(el)
|
| | | }
|
| | | if (lastRouter) {
|
| | | el.path = lastRouter.path + '/' + el.path
|
| | | if (el.children && el.children.length) {
|
| | | children = children.concat(filterChildren(el.children, el))
|
| | | return
|
| | | }
|
| | | }
|
| | | children = children.concat(el)
|
| | | })
|
| | | return children
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | export const loadView = (view) => {
|
| | | let res;
|
| | | let res
|
| | | for (const path in modules) {
|
| | | const dir = path.split('views/')[1].split('.vue')[0];
|
| | | const dir = path.split('views/')[1].split('.vue')[0]
|
| | | if (dir === view) {
|
| | | res = () => modules[path]();
|
| | | res = () => modules[path]()
|
| | | }
|
| | | }
|
| | | return res;
|
| | | return res
|
| | | }
|
| | |
|
| | | export default usePermissionStore
|