style:路由
Showing
8 changed files
with
45 additions
and
23 deletions
1 | import request from '@/utils/request' | 1 | import request from '@/utils/request' |
2 | import SERVER from './config' | 2 | import SERVER from './config' |
3 | // export function getMenuInfo () { | ||
4 | // return request({ | ||
5 | // url: SERVER.SERVERAPI + '/rest/user/getUserMenus', | ||
6 | // method: 'get', | ||
7 | // }) | ||
8 | // } | ||
3 | export function getMenuInfo () { | 9 | export function getMenuInfo () { |
4 | return request({ | 10 | return request({ |
5 | url: SERVER.SERVERAPI + '/rest/user/getUserMenus', | 11 | url: SERVER.SERVERCAI + '/rest/user/getUserAuthorizationMenus', |
6 | method: 'get', | 12 | method: 'get', |
7 | }) | 13 | }) |
8 | } | 14 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | <template> | 1 | <template> |
2 | <div v-if="!item.hidden"> | 2 | <div v-if="!item.hidden"> |
3 | <template v-if="hasOneShowingChild(item.children,item) && (!onlyOneChild.children||onlyOneChild.noShowingChildren)"> | 3 | <template |
4 | v-if="hasOneShowingChild(item.children, item) && (!onlyOneChild.children || onlyOneChild.noShowingChildren)"> | ||
4 | <app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path)"> | 5 | <app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path)"> |
5 | <el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}"> | 6 | <el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{ 'submenu-title-noDropdown': !isNest }"> |
6 | <item :icon="onlyOneChild.meta.icon||(item.meta&&item.meta.icon)" :title="onlyOneChild.meta.title" | 7 | <item :icon="onlyOneChild.meta.icon || (item.meta && item.meta.icon)" :title="onlyOneChild.meta.title" |
7 | class="menu-icon" /> | 8 | class="menu-icon" /> |
8 | </el-menu-item> | 9 | </el-menu-item> |
9 | </app-link> | 10 | </app-link> | ... | ... |
1 | <template> | 1 | <template> |
2 | <div> | 2 | <div> |
3 | <el-scrollbar wrap-class="scrollbar-wrapper"> | 3 | <el-scrollbar wrap-class="scrollbar-wrapper"> |
4 | <el-menu :default-active="activeMenu" :background-color="variables.menuBg" :text-color="variables.menuText" | 4 | <el-menu router :default-active="activeMenu" :background-color="variables.menuBg" :text-color="variables.menuText" |
5 | :unique-opened="true" :active-text-color="variables.menuActiveText" :collapse-transition="false" | 5 | :unique-opened="true" @open="handleOpen" :active-text-color="variables.menuActiveText" |
6 | mode="vertical"> | 6 | :collapse-transition="false" mode="vertical"> |
7 | <!-- 权限菜单 --> | 7 | <!-- 权限菜单 --> |
8 | <sidebar-item v-for="route in permission_routes" :key="route.path" :item="route" :base-path="route.path" /> | 8 | <sidebar-item v-for="route in permission_routes" :key="route.path" :item="route" :base-path="route.path" /> |
9 | <!-- 菜单全部展示 --> | 9 | <!-- 菜单全部展示 --> |
... | @@ -26,7 +26,6 @@ export default { | ... | @@ -26,7 +26,6 @@ export default { |
26 | activeMenu () { | 26 | activeMenu () { |
27 | const route = this.$route | 27 | const route = this.$route |
28 | const { meta, path } = route | 28 | const { meta, path } = route |
29 | // if set path, the sidebar will highlight the path you set | ||
30 | if (meta.activeMenu) { | 29 | if (meta.activeMenu) { |
31 | return meta.activeMenu | 30 | return meta.activeMenu |
32 | } | 31 | } |
... | @@ -39,5 +38,15 @@ export default { | ... | @@ -39,5 +38,15 @@ export default { |
39 | return asyncRoutes | 38 | return asyncRoutes |
40 | }, | 39 | }, |
41 | }, | 40 | }, |
41 | methods: { | ||
42 | handleOpen (key, keyPath) { | ||
43 | let that = this | ||
44 | this.permission_routes.forEach(element => { | ||
45 | if (element.path == key) { | ||
46 | that.$router.push({ path: element.redirect }) | ||
47 | } | ||
48 | }) | ||
49 | } | ||
50 | }, | ||
42 | } | 51 | } |
43 | </script> | 52 | </script> | ... | ... |
... | @@ -21,6 +21,7 @@ router.beforeEach(async (to, from, next) => { | ... | @@ -21,6 +21,7 @@ router.beforeEach(async (to, from, next) => { |
21 | } else { | 21 | } else { |
22 | const { result: getMenuData } = await getMenuInfo() | 22 | const { result: getMenuData } = await getMenuInfo() |
23 | const accessRoutes = await store.dispatch('permission/generateRoutes', getMenuData) | 23 | const accessRoutes = await store.dispatch('permission/generateRoutes', getMenuData) |
24 | console.log(accessRoutes); | ||
24 | router.addRoutes(accessRoutes) | 25 | router.addRoutes(accessRoutes) |
25 | next({ ...to, replace: true }) | 26 | next({ ...to, replace: true }) |
26 | } | 27 | } | ... | ... |
... | @@ -40,9 +40,13 @@ export const constantRoutes = [ | ... | @@ -40,9 +40,13 @@ export const constantRoutes = [ |
40 | name: 'workFrameView', | 40 | name: 'workFrameView', |
41 | hidden: true, | 41 | hidden: true, |
42 | meta: { title: '发起申请' } | 42 | meta: { title: '发起申请' } |
43 | } | 43 | }, |
44 | { | ||
45 | path: '*', | ||
46 | component: () => import('@/views/error-page/404'), | ||
47 | hidden: true | ||
48 | }, | ||
44 | ] | 49 | ] |
45 | |||
46 | /** | 50 | /** |
47 | * asyncRoutes | 51 | * asyncRoutes |
48 | * the routes that need to be dynamically loaded based on user roles | 52 | * the routes that need to be dynamically loaded based on user roles |
... | @@ -68,8 +72,7 @@ export const asyncRoutes = [ | ... | @@ -68,8 +72,7 @@ export const asyncRoutes = [ |
68 | parentId: null, | 72 | parentId: null, |
69 | component: Layout, | 73 | component: Layout, |
70 | meta: { title: '业务办理', icon: 'ywbl' }, | 74 | meta: { title: '业务办理', icon: 'ywbl' }, |
71 | redirect: '/ywbl/ywsq/ywsq', | 75 | redirect: '/ywbl/ywsq', |
72 | alwaysShow: true, | ||
73 | name: 'ywbl', | 76 | name: 'ywbl', |
74 | children: [ | 77 | children: [ |
75 | { | 78 | { | ... | ... |
... | @@ -3,16 +3,24 @@ export default function filterAsyncRouter (routers) { | ... | @@ -3,16 +3,24 @@ export default function filterAsyncRouter (routers) { |
3 | routers.forEach(item => { | 3 | routers.forEach(item => { |
4 | if (!item.children) { | 4 | if (!item.children) { |
5 | delete item.children | 5 | delete item.children |
6 | delete item.redirect | ||
7 | } | 6 | } |
7 | item.path = JSON.parse(item.metadata).path | ||
8 | if (!item.parentId) { | 8 | if (!item.parentId) { |
9 | item.component = Layout | 9 | item.component = Layout |
10 | } else { | 10 | } else { |
11 | item.component = loadView(item.uri) | 11 | item.component = loadView(item.uri) |
12 | } | 12 | } |
13 | item.meta.icon = item.icon | 13 | item.meta = { |
14 | title: item.name, | ||
15 | icon: item.icon | ||
16 | } | ||
14 | if (item.children) { | 17 | if (item.children) { |
15 | item.children = filterAsyncRouter(item.children) | 18 | item.children = filterAsyncRouter(item.children) |
19 | if (item.path !== '/') { | ||
20 | item.redirect = item.path + '/' + item.children[0].path | ||
21 | } else { | ||
22 | item.redirect = '/' + item.children[0].path | ||
23 | } | ||
16 | } | 24 | } |
17 | }) | 25 | }) |
18 | return routers | 26 | return routers | ... | ... |
... | @@ -45,14 +45,7 @@ module.exports = { | ... | @@ -45,14 +45,7 @@ module.exports = { |
45 | '^/api': '' | 45 | '^/api': '' |
46 | } | 46 | } |
47 | } | 47 | } |
48 | // '': { | 48 | } |
49 | // target: process.env.VUE_APP_API_BASE_URL, | ||
50 | // changeOrigin: true, | ||
51 | // pathRewrite: { | ||
52 | // '^': '' | ||
53 | // } | ||
54 | // } | ||
55 | }, | ||
56 | }, | 49 | }, |
57 | css: { | 50 | css: { |
58 | extract: false, // 是否使用css分离插件 ExtractTextPlugin | 51 | extract: false, // 是否使用css分离插件 ExtractTextPlugin | ... | ... |
-
Please register or sign in to post a comment