Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
bdc
/
bdcdj-web
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
d8e430de
authored
2022-11-03 15:42:52 +0800
by
任超
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
style:路由
1 parent
07f01d83
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
45 additions
and
23 deletions
src/api/config.js
src/api/user.js
src/layout/components/Sidebar/SidebarItem.vue
src/layout/components/Sidebar/index.vue
src/permission.js
src/router/index.js
src/utils/asyncRouter.js
vue.config.js
src/api/config.js
View file @
d8e430d
export
default
{
SERVERAPI
:
'/service-bdcdj9'
SERVERAPI
:
'/service-bdcdj9'
,
SERVERCAI
:
'service-cai'
}
\ No newline at end of file
...
...
src/api/user.js
View file @
d8e430d
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
.
SERVER
API
+
'/rest/user/getUser
Menus'
,
url
:
SERVER
.
SERVER
CAI
+
'/rest/user/getUserAuthorization
Menus'
,
method
:
'get'
,
})
}
\ No newline at end of file
...
...
src/layout/components/Sidebar/SidebarItem.vue
View file @
d8e430d
<
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>
...
...
src/layout/components/Sidebar/index.vue
View file @
d8e430d
<
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
>
...
...
src/permission.js
View file @
d8e430d
...
...
@@ -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
})
}
...
...
src/router/index.js
View file @
d8e430d
...
...
@@ -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
:
[
{
...
...
src/utils/asyncRouter.js
View file @
d8e430d
...
...
@@ -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
...
...
vue.config.js
View file @
d8e430d
...
...
@@ -45,14 +45,7 @@ module.exports = {
'^/api'
:
''
}
}
// '': {
// target: process.env.VUE_APP_API_BASE_URL,
// changeOrigin: true,
// pathRewrite: {
// '^': ''
// }
// }
},
}
},
css
:
{
extract
:
false
,
// 是否使用css分离插件 ExtractTextPlugin
...
...
Please
register
or
sign in
to post a comment