Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
smart_gov_platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
smart_gov_platform
Commits
c3f7131d
Commit
c3f7131d
authored
Oct 13, 2023
by
“yiyousong”
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 添加菜单权限
parent
753cdc8b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
126 additions
and
88 deletions
+126
-88
base-manager-ui/admin/src/layouts/Layouts.vue
base-manager-ui/admin/src/layouts/Layouts.vue
+1
-1
base-manager-ui/admin/src/main.js
base-manager-ui/admin/src/main.js
+0
-1
base-manager-ui/admin/src/router/config.js
base-manager-ui/admin/src/router/config.js
+1
-0
base-manager-ui/admin/src/router/index.js
base-manager-ui/admin/src/router/index.js
+49
-17
base-manager-ui/admin/src/store/modules/setting.js
base-manager-ui/admin/src/store/modules/setting.js
+75
-69
No files found.
base-manager-ui/admin/src/layouts/Layouts.vue
View file @
c3f7131d
base-manager-ui/admin/src/main.js
View file @
c3f7131d
...
@@ -63,7 +63,6 @@ Vue.config.productionTip = false;
...
@@ -63,7 +63,6 @@ Vue.config.productionTip = false;
// Vue.use(Viser)
// Vue.use(Viser)
Vue
.
use
(
Plugins
);
Vue
.
use
(
Plugins
);
Vue
.
use
(
VueResource
);
Vue
.
use
(
VueResource
);
bootstrap
({
router
,
store
,
i18n
,
message
:
Vue
.
prototype
.
$message
});
bootstrap
({
router
,
store
,
i18n
,
message
:
Vue
.
prototype
.
$message
});
new
Vue
({
new
Vue
({
...
...
base-manager-ui/admin/src/router/config.js
View file @
c3f7131d
...
@@ -161,6 +161,7 @@ const options = {
...
@@ -161,6 +161,7 @@ const options = {
name
:
"
部署模块管理
"
,
name
:
"
部署模块管理
"
,
meta
:
{
meta
:
{
icon
:
"
appstore
"
,
icon
:
"
appstore
"
,
roles
:
[
"
admin
"
],
},
},
component
:
()
=>
import
(
"
@/pages/basicset/deploy/deploy
"
),
component
:
()
=>
import
(
"
@/pages/basicset/deploy/deploy
"
),
},
},
...
...
base-manager-ui/admin/src/router/index.js
View file @
c3f7131d
import
Vue
from
'
vue
'
import
Vue
from
"
vue
"
;
import
Router
from
'
vue-router
'
import
Router
from
"
vue-router
"
;
import
{
formatRoutes
}
from
'
@/utils/routerUtil
'
import
{
formatRoutes
}
from
"
@/utils/routerUtil
"
;
import
store
from
"
@/store
"
;
Vue
.
use
(
Router
)
Vue
.
use
(
Router
)
;
//解决重复路由报错
//解决重复路由报错
const
originalPush
=
Router
.
prototype
.
push
const
originalPush
=
Router
.
prototype
.
push
;
// 修改原型对象中的push方法
// 修改原型对象中的push方法
Router
.
prototype
.
push
=
function
push
(
location
)
{
Router
.
prototype
.
push
=
function
push
(
location
)
{
return
originalPush
.
call
(
this
,
location
).
catch
(
err
=>
err
)
return
originalPush
.
call
(
this
,
location
).
catch
(
(
err
)
=>
err
);
}
}
;
// 不需要登录拦截的路由配置
// 不需要登录拦截的路由配置
const
loginIgnore
=
{
const
loginIgnore
=
{
names
:
[
'
404
'
,
'
403
'
],
//根据路由名称匹配
names
:
[
"
404
"
,
"
403
"
],
//根据路由名称匹配
paths
:
[
'
/login
'
],
//根据路由fullPath匹配
paths
:
[
"
/login
"
],
//根据路由fullPath匹配
/**
/**
* 判断路由是否包含在该配置中
* 判断路由是否包含在该配置中
* @param route vue-router 的 route 对象
* @param route vue-router 的 route 对象
* @returns {boolean}
* @returns {boolean}
*/
*/
includes
(
route
)
{
includes
(
route
)
{
return
this
.
names
.
includes
(
route
.
name
)
||
this
.
paths
.
includes
(
route
.
path
)
return
this
.
names
.
includes
(
route
.
name
)
||
this
.
paths
.
includes
(
route
.
path
)
;
}
}
,
}
}
;
/**
/**
* 初始化路由实例
* 初始化路由实例
...
@@ -30,8 +30,40 @@ const loginIgnore = {
...
@@ -30,8 +30,40 @@ const loginIgnore = {
* @returns {VueRouter}
* @returns {VueRouter}
*/
*/
function
initRouter
(
isAsync
)
{
function
initRouter
(
isAsync
)
{
const
options
=
isAsync
?
require
(
'
./async/config.async
'
).
default
:
require
(
'
./config
'
).
default
let
role
=
store
.
getters
[
"
site/userInfo
"
].
name
;
formatRoutes
(
options
.
routes
)
if
(
!
role
)
return
;
return
new
Router
(
options
)
const
options
=
isAsync
?
require
(
"
./async/config.async
"
).
default
:
require
(
"
./config
"
).
default
;
formatRoutes
(
options
.
routes
);
options
.
routes
=
calcRouters
(
options
.
routes
,
role
);
return
new
Router
(
options
);
}
// 判断权限
function
permission
(
router
,
role
)
{
if
(
router
.
meta
&&
router
.
meta
.
roles
)
{
return
router
.
meta
.
roles
.
includes
(
role
);
}
else
{
return
true
;
}
}
// 计算动态路由
function
calcRouters
(
dynamicRouter
,
role
)
{
// 过滤
let
res
=
dynamicRouter
.
filter
((
v
)
=>
{
// 判断是否有权限访问此路由
if
(
permission
(
v
,
role
))
{
// 判断有没有子路由
if
(
v
.
children
)
{
// 递归
v
.
children
=
calcRouters
(
v
.
children
,
role
);
}
return
true
;
}
else
{
return
false
;
}
});
return
res
;
}
}
export
{
loginIgnore
,
initRouter
}
export
{
loginIgnore
,
initRouter
};
base-manager-ui/admin/src/store/modules/setting.js
View file @
c3f7131d
import
config
from
'
@/config
'
import
config
from
"
@/config
"
;
import
{
ADMIN
}
from
'
@/config/default
'
import
{
ADMIN
}
from
"
@/config/default
"
;
import
{
formatFullPath
}
from
'
@/utils/i18n
'
import
{
formatFullPath
}
from
"
@/utils/i18n
"
;
import
{
filterMenu
}
from
'
@/utils/authority-utils
'
import
{
filterMenu
}
from
"
@/utils/authority-utils
"
;
import
{
getLocalSetting
}
from
'
@/utils/themeUtil
'
import
{
getLocalSetting
}
from
"
@/utils/themeUtil
"
;
import
deepClone
from
'
lodash.clonedeep
'
import
deepClone
from
"
lodash.clonedeep
"
;
const
localSetting
=
getLocalSetting
(
true
)
const
localSetting
=
getLocalSetting
(
true
)
;
// console.log(localSetting)
// console.log(localSetting)
const
customTitlesStr
=
sessionStorage
.
getItem
(
process
.
env
.
VUE_APP_TBAS_TITLES_KEY
)
const
customTitlesStr
=
sessionStorage
.
getItem
(
const
customTitles
=
(
customTitlesStr
&&
JSON
.
parse
(
customTitlesStr
))
||
[]
process
.
env
.
VUE_APP_TBAS_TITLES_KEY
);
const
customTitles
=
(
customTitlesStr
&&
JSON
.
parse
(
customTitlesStr
))
||
[];
export
default
{
export
default
{
namespaced
:
true
,
namespaced
:
true
,
...
@@ -20,96 +22,100 @@ export default {
...
@@ -20,96 +22,100 @@ export default {
activatedFirst
:
undefined
,
activatedFirst
:
undefined
,
customTitles
,
customTitles
,
...
config
,
...
config
,
...
localSetting
...
localSetting
,
},
},
getters
:
{
getters
:
{
menuData
(
state
,
getters
,
rootState
)
{
menuData
(
state
,
getters
,
rootState
)
{
if
(
state
.
filterMenu
)
{
if
(
state
.
filterMenu
)
{
const
{
permissions
,
roles
}
=
rootState
.
account
const
{
permissions
,
roles
}
=
rootState
.
account
;
return
filterMenu
(
deepClone
(
state
.
menuData
),
permissions
,
roles
)
console
.
log
(
permissions
,
roles
);
return
filterMenu
(
deepClone
(
state
.
menuData
),
permissions
,
roles
);
}
}
return
state
.
menuData
return
state
.
menuData
;
},
},
firstMenu
(
state
,
getters
)
{
firstMenu
(
state
,
getters
)
{
const
{
menuData
}
=
getters
const
{
menuData
}
=
getters
;
if
(
menuData
.
length
>
0
&&
!
menuData
[
0
].
fullPath
)
{
if
(
menuData
.
length
>
0
&&
!
menuData
[
0
].
fullPath
)
{
formatFullPath
(
menuData
)
formatFullPath
(
menuData
)
;
}
}
return
menuData
.
map
(
item
=>
{
return
menuData
.
map
(
(
item
)
=>
{
const
menuItem
=
{
...
item
}
const
menuItem
=
{
...
item
}
;
delete
menuItem
.
children
delete
menuItem
.
children
;
return
menuItem
return
menuItem
;
})
})
;
},
},
subMenu
(
state
)
{
subMenu
(
state
)
{
const
{
menuData
,
activatedFirst
}
=
state
const
{
menuData
,
activatedFirst
}
=
state
;
if
(
menuData
.
length
>
0
&&
!
menuData
[
0
].
fullPath
)
{
if
(
menuData
.
length
>
0
&&
!
menuData
[
0
].
fullPath
)
{
formatFullPath
(
menuData
)
formatFullPath
(
menuData
);
}
const
current
=
menuData
.
find
(
menu
=>
menu
.
fullPath
===
activatedFirst
)
return
current
&&
current
.
children
||
[]
}
}
const
current
=
menuData
.
find
((
menu
)
=>
menu
.
fullPath
===
activatedFirst
);
return
(
current
&&
current
.
children
)
||
[];
},
},
},
mutations
:
{
mutations
:
{
setDevice
(
state
,
isMobile
)
{
setDevice
(
state
,
isMobile
)
{
state
.
isMobile
=
isMobile
state
.
isMobile
=
isMobile
;
},
},
setTheme
(
state
,
theme
)
{
setTheme
(
state
,
theme
)
{
// console.log(theme)
// console.log(theme)
state
.
theme
=
theme
state
.
theme
=
theme
;
},
},
setLayout
(
state
,
layout
)
{
setLayout
(
state
,
layout
)
{
state
.
layout
=
layout
state
.
layout
=
layout
;
},
},
setMultiPage
(
state
,
multiPage
)
{
setMultiPage
(
state
,
multiPage
)
{
state
.
multiPage
=
multiPage
state
.
multiPage
=
multiPage
;
},
},
setAnimate
(
state
,
animate
)
{
setAnimate
(
state
,
animate
)
{
state
.
animate
=
animate
state
.
animate
=
animate
;
},
},
setWeekMode
(
state
,
weekMode
)
{
setWeekMode
(
state
,
weekMode
)
{
state
.
weekMode
=
weekMode
state
.
weekMode
=
weekMode
;
},
},
setFixedHeader
(
state
,
fixedHeader
)
{
setFixedHeader
(
state
,
fixedHeader
)
{
state
.
fixedHeader
=
fixedHeader
state
.
fixedHeader
=
fixedHeader
;
},
},
setFixedSideBar
(
state
,
fixedSideBar
)
{
setFixedSideBar
(
state
,
fixedSideBar
)
{
state
.
fixedSideBar
=
fixedSideBar
state
.
fixedSideBar
=
fixedSideBar
;
},
},
setLang
(
state
,
lang
)
{
setLang
(
state
,
lang
)
{
state
.
lang
=
lang
state
.
lang
=
lang
;
},
},
setHideSetting
(
state
,
hideSetting
)
{
setHideSetting
(
state
,
hideSetting
)
{
state
.
hideSetting
=
hideSetting
state
.
hideSetting
=
hideSetting
;
},
},
correctPageMinHeight
(
state
,
minHeight
)
{
correctPageMinHeight
(
state
,
minHeight
)
{
state
.
pageMinHeight
+=
minHeight
state
.
pageMinHeight
+=
minHeight
;
},
},
setMenuData
(
state
,
menuData
)
{
setMenuData
(
state
,
menuData
)
{
state
.
menuData
=
menuData
state
.
menuData
=
menuData
;
},
},
setAsyncRoutes
(
state
,
asyncRoutes
)
{
setAsyncRoutes
(
state
,
asyncRoutes
)
{
state
.
asyncRoutes
=
asyncRoutes
state
.
asyncRoutes
=
asyncRoutes
;
},
},
setPageWidth
(
state
,
pageWidth
)
{
setPageWidth
(
state
,
pageWidth
)
{
state
.
pageWidth
=
pageWidth
state
.
pageWidth
=
pageWidth
;
},
},
setActivatedFirst
(
state
,
activatedFirst
)
{
setActivatedFirst
(
state
,
activatedFirst
)
{
state
.
activatedFirst
=
activatedFirst
state
.
activatedFirst
=
activatedFirst
;
},
},
setFixedTabs
(
state
,
fixedTabs
)
{
setFixedTabs
(
state
,
fixedTabs
)
{
state
.
fixedTabs
=
fixedTabs
state
.
fixedTabs
=
fixedTabs
;
},
},
setCustomTitle
(
state
,
{
path
,
title
})
{
setCustomTitle
(
state
,
{
path
,
title
})
{
if
(
title
)
{
if
(
title
)
{
const
obj
=
state
.
customTitles
.
find
(
item
=>
item
.
path
===
path
)
const
obj
=
state
.
customTitles
.
find
(
(
item
)
=>
item
.
path
===
path
);
if
(
obj
)
{
if
(
obj
)
{
obj
.
title
=
title
obj
.
title
=
title
;
}
else
{
}
else
{
state
.
customTitles
.
push
({
path
,
title
})
state
.
customTitles
.
push
({
path
,
title
});
}
sessionStorage
.
setItem
(
process
.
env
.
VUE_APP_TBAS_TITLES_KEY
,
JSON
.
stringify
(
state
.
customTitles
))
}
}
sessionStorage
.
setItem
(
process
.
env
.
VUE_APP_TBAS_TITLES_KEY
,
JSON
.
stringify
(
state
.
customTitles
)
);
}
}
}
},
}
},
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment