d8e430de by 任超

style:路由

1 parent 07f01d83
export default {
SERVERAPI: '/service-bdcdj9'
SERVERAPI: '/service-bdcdj9',
SERVERCAI: 'service-cai'
}
\ No newline at end of file
......
import request from '@/utils/request'
import SERVER from './config'
// export function getMenuInfo () {
// return request({
// url: SERVER.SERVERAPI + '/rest/user/getUserMenus',
// method: 'get',
// })
// }
export function getMenuInfo () {
return request({
url: SERVER.SERVERAPI + '/rest/user/getUserMenus',
url: SERVER.SERVERCAI + '/rest/user/getUserAuthorizationMenus',
method: 'get',
})
}
\ No newline at end of file
......
<template>
<div v-if="!item.hidden">
<template v-if="hasOneShowingChild(item.children,item) && (!onlyOneChild.children||onlyOneChild.noShowingChildren)">
<template
v-if="hasOneShowingChild(item.children, item) && (!onlyOneChild.children || onlyOneChild.noShowingChildren)">
<app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path)">
<el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}">
<item :icon="onlyOneChild.meta.icon||(item.meta&&item.meta.icon)" :title="onlyOneChild.meta.title"
<el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{ 'submenu-title-noDropdown': !isNest }">
<item :icon="onlyOneChild.meta.icon || (item.meta && item.meta.icon)" :title="onlyOneChild.meta.title"
class="menu-icon" />
</el-menu-item>
</app-link>
......
<template>
<div>
<el-scrollbar wrap-class="scrollbar-wrapper">
<el-menu :default-active="activeMenu" :background-color="variables.menuBg" :text-color="variables.menuText"
:unique-opened="true" :active-text-color="variables.menuActiveText" :collapse-transition="false"
mode="vertical">
<el-menu router :default-active="activeMenu" :background-color="variables.menuBg" :text-color="variables.menuText"
:unique-opened="true" @open="handleOpen" :active-text-color="variables.menuActiveText"
:collapse-transition="false" mode="vertical">
<!-- 权限菜单 -->
<sidebar-item v-for="route in permission_routes" :key="route.path" :item="route" :base-path="route.path" />
<!-- 菜单全部展示 -->
......@@ -26,7 +26,6 @@ export default {
activeMenu () {
const route = this.$route
const { meta, path } = route
// if set path, the sidebar will highlight the path you set
if (meta.activeMenu) {
return meta.activeMenu
}
......@@ -39,5 +38,15 @@ export default {
return asyncRoutes
},
},
methods: {
handleOpen (key, keyPath) {
let that = this
this.permission_routes.forEach(element => {
if (element.path == key) {
that.$router.push({ path: element.redirect })
}
})
}
},
}
</script>
......
......@@ -21,6 +21,7 @@ router.beforeEach(async (to, from, next) => {
} else {
const { result: getMenuData } = await getMenuInfo()
const accessRoutes = await store.dispatch('permission/generateRoutes', getMenuData)
console.log(accessRoutes);
router.addRoutes(accessRoutes)
next({ ...to, replace: true })
}
......
......@@ -40,9 +40,13 @@ export const constantRoutes = [
name: 'workFrameView',
hidden: true,
meta: { title: '发起申请' }
}
},
{
path: '*',
component: () => import('@/views/error-page/404'),
hidden: true
},
]
/**
* asyncRoutes
* the routes that need to be dynamically loaded based on user roles
......@@ -68,8 +72,7 @@ export const asyncRoutes = [
parentId: null,
component: Layout,
meta: { title: '业务办理', icon: 'ywbl' },
redirect: '/ywbl/ywsq/ywsq',
alwaysShow: true,
redirect: '/ywbl/ywsq',
name: 'ywbl',
children: [
{
......
......@@ -3,16 +3,24 @@ export default function filterAsyncRouter (routers) {
routers.forEach(item => {
if (!item.children) {
delete item.children
delete item.redirect
}
item.path = JSON.parse(item.metadata).path
if (!item.parentId) {
item.component = Layout
} else {
item.component = loadView(item.uri)
}
item.meta.icon = item.icon
item.meta = {
title: item.name,
icon: item.icon
}
if (item.children) {
item.children = filterAsyncRouter(item.children)
if (item.path !== '/') {
item.redirect = item.path + '/' + item.children[0].path
} else {
item.redirect = '/' + item.children[0].path
}
}
})
return routers
......
......@@ -45,14 +45,7 @@ module.exports = {
'^/api': ''
}
}
// '': {
// target: process.env.VUE_APP_API_BASE_URL,
// changeOrigin: true,
// pathRewrite: {
// '^': ''
// }
// }
},
}
},
css: {
extract: false, // 是否使用css分离插件 ExtractTextPlugin
......