Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FLIPPED-AURORA
gin-vue-admin
提交
057163b3
G
gin-vue-admin
项目概览
FLIPPED-AURORA
/
gin-vue-admin
大约 1 年 前同步成功
通知
332
Star
18154
Fork
5505
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gin-vue-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
057163b3
编写于
1月 14, 2021
作者:
Mr.奇淼(
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
支持不同角色自定义首页
上级
39bdd95f
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
56 addition
and
16 deletion
+56
-16
server/model/sys_authority.go
server/model/sys_authority.go
+1
-0
web/src/permission.js
web/src/permission.js
+2
-2
web/src/store/module/router.js
web/src/store/module/router.js
+4
-1
web/src/store/module/user.js
web/src/store/module/user.js
+5
-2
web/src/view/layout/aside/historyComponent/history.vue
web/src/view/layout/aside/historyComponent/history.vue
+19
-9
web/src/view/superAdmin/authority/components/menus.vue
web/src/view/superAdmin/authority/components/menus.vue
+25
-2
未找到文件。
server/model/sys_authority.go
浏览文件 @
057163b3
...
@@ -14,4 +14,5 @@ type SysAuthority struct {
...
@@ -14,4 +14,5 @@ type SysAuthority struct {
DataAuthorityId
[]
SysAuthority
`json:"dataAuthorityId" gorm:"many2many:sys_data_authority_id"`
DataAuthorityId
[]
SysAuthority
`json:"dataAuthorityId" gorm:"many2many:sys_data_authority_id"`
Children
[]
SysAuthority
`json:"children" gorm:"-"`
Children
[]
SysAuthority
`json:"children" gorm:"-"`
SysBaseMenus
[]
SysBaseMenu
`json:"menus" gorm:"many2many:sys_authority_menus;"`
SysBaseMenus
[]
SysBaseMenu
`json:"menus" gorm:"many2many:sys_authority_menus;"`
DefaultRouter
string
`json:"defaultRouter" gorm:"comment:默认菜单;default:dashboard"`
}
}
web/src/permission.js
浏览文件 @
057163b3
...
@@ -13,7 +13,7 @@ router.beforeEach(async(to, from, next) => {
...
@@ -13,7 +13,7 @@ router.beforeEach(async(to, from, next) => {
document
.
title
=
getPageTitle
(
to
.
meta
.
title
)
document
.
title
=
getPageTitle
(
to
.
meta
.
title
)
if
(
whiteList
.
indexOf
(
to
.
name
)
>
-
1
)
{
if
(
whiteList
.
indexOf
(
to
.
name
)
>
-
1
)
{
if
(
token
)
{
if
(
token
)
{
next
({
path
:
'
/layout/dashboard
'
})
next
({
name
:
store
.
getters
[
"
user/userInfo
"
].
authority
.
defaultRouter
})
}
else
{
}
else
{
next
()
next
()
}
}
...
@@ -21,7 +21,7 @@ router.beforeEach(async(to, from, next) => {
...
@@ -21,7 +21,7 @@ router.beforeEach(async(to, from, next) => {
// 不在白名单中并且已经登陆的时候
// 不在白名单中并且已经登陆的时候
if
(
token
)
{
if
(
token
)
{
// 添加flag防止多次获取动态路由和栈溢出
// 添加flag防止多次获取动态路由和栈溢出
if
(
!
asyncRouterFlag
)
{
if
(
!
asyncRouterFlag
&&
store
.
getters
[
'
router/asyncRouters
'
].
length
==
0
)
{
asyncRouterFlag
++
asyncRouterFlag
++
await
store
.
dispatch
(
'
router/SetAsyncRouter
'
)
await
store
.
dispatch
(
'
router/SetAsyncRouter
'
)
const
asyncRouters
=
store
.
getters
[
'
router/asyncRouters
'
]
const
asyncRouters
=
store
.
getters
[
'
router/asyncRouters
'
]
...
...
web/src/store/module/router.js
浏览文件 @
057163b3
...
@@ -28,7 +28,7 @@ export const router = {
...
@@ -28,7 +28,7 @@ export const router = {
// 设置动态路由
// 设置动态路由
setAsyncRouter
(
state
,
asyncRouters
)
{
setAsyncRouter
(
state
,
asyncRouters
)
{
state
.
asyncRouters
=
asyncRouters
state
.
asyncRouters
=
asyncRouters
}
}
,
},
},
actions
:
{
actions
:
{
// 从后台获取动态路由
// 从后台获取动态路由
...
@@ -73,6 +73,9 @@ export const router = {
...
@@ -73,6 +73,9 @@ export const router = {
},
},
routerList
(
state
)
{
routerList
(
state
)
{
return
state
.
routerList
return
state
.
routerList
},
defaultRouter
(
state
)
{
return
state
.
defaultRouter
}
}
}
}
}
}
\ No newline at end of file
web/src/store/module/user.js
浏览文件 @
057163b3
...
@@ -35,16 +35,19 @@ export const user = {
...
@@ -35,16 +35,19 @@ export const user = {
}
}
},
},
actions
:
{
actions
:
{
async
LoginIn
({
commit
},
loginInfo
)
{
async
LoginIn
({
commit
,
dispatch
,
rootGetters
,
getters
},
loginInfo
)
{
const
res
=
await
login
(
loginInfo
)
const
res
=
await
login
(
loginInfo
)
if
(
res
.
code
==
0
)
{
if
(
res
.
code
==
0
)
{
commit
(
'
setUserInfo
'
,
res
.
data
.
user
)
commit
(
'
setUserInfo
'
,
res
.
data
.
user
)
commit
(
'
setToken
'
,
res
.
data
.
token
)
commit
(
'
setToken
'
,
res
.
data
.
token
)
await
dispatch
(
'
router/SetAsyncRouter
'
,
{},
{
root
:
true
})
const
asyncRouters
=
rootGetters
[
'
router/asyncRouters
'
]
router
.
addRoutes
(
asyncRouters
)
const
redirect
=
router
.
history
.
current
.
query
.
redirect
const
redirect
=
router
.
history
.
current
.
query
.
redirect
if
(
redirect
)
{
if
(
redirect
)
{
router
.
push
({
path
:
redirect
})
router
.
push
({
path
:
redirect
})
}
else
{
}
else
{
router
.
push
({
path
:
'
/layout/dashboard
'
})
router
.
push
({
name
:
getters
[
"
userInfo
"
].
authority
.
defaultRouter
})
}
}
return
true
return
true
}
}
...
...
web/src/view/layout/aside/historyComponent/history.vue
浏览文件 @
057163b3
<
template
>
<
template
>
<div
class=
"router-history"
>
<div
class=
"router-history"
>
<el-tabs
<el-tabs
:closable=
"!(historys.length==1&&this.$route.name==
'dashboard'
)"
:closable=
"!(historys.length==1&&this.$route.name==
defaultRouter
)"
@
contextmenu.prevent.native=
"openContextMenu($event)"
@
contextmenu.prevent.native=
"openContextMenu($event)"
@
tab-click=
"changeTab"
@
tab-click=
"changeTab"
@
tab-remove=
"removeTab"
@
tab-remove=
"removeTab"
...
@@ -27,12 +27,14 @@
...
@@ -27,12 +27,14 @@
</div>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
import
{
mapGetters
}
from
"
vuex
"
export
default
{
export
default
{
name
:
'
HistoryComponent
'
,
name
:
'
HistoryComponent
'
,
data
()
{
data
()
{
return
{
return
{
historys
:
[],
historys
:
[],
activeValue
:
'
dashboard
'
,
activeValue
:
''
,
contextMenuVisible
:
false
,
contextMenuVisible
:
false
,
left
:
0
,
left
:
0
,
top
:
0
,
top
:
0
,
...
@@ -41,7 +43,15 @@ export default {
...
@@ -41,7 +43,15 @@ export default {
rightActive
:
''
rightActive
:
''
}
}
},
},
computed
:{
...
mapGetters
(
"
user
"
,[
"
userInfo
"
]),
defaultRouter
(){
return
this
.
userInfo
.
authority
.
defaultRouter
}
},
created
()
{
created
()
{
this
.
activeValue
=
this
.
defaultRouter
this
.
$bus
.
on
(
'
mobile
'
,
isMobile
=>
{
this
.
$bus
.
on
(
'
mobile
'
,
isMobile
=>
{
this
.
isMobile
=
isMobile
this
.
isMobile
=
isMobile
})
})
...
@@ -50,9 +60,9 @@ export default {
...
@@ -50,9 +60,9 @@ export default {
})
})
const
initHistorys
=
[
const
initHistorys
=
[
{
{
name
:
'
dashboard
'
,
name
:
this
.
defaultRouter
,
meta
:
{
meta
:
{
title
:
'
仪表盘
'
title
:
'
首页
'
}
}
}
}
]
]
...
@@ -67,7 +77,7 @@ export default {
...
@@ -67,7 +77,7 @@ export default {
},
},
methods
:
{
methods
:
{
openContextMenu
(
e
)
{
openContextMenu
(
e
)
{
if
(
this
.
historys
.
length
==
1
&&
this
.
$route
.
name
==
'
dashboard
'
)
{
if
(
this
.
historys
.
length
==
1
&&
this
.
$route
.
name
==
this
.
defaultRouter
)
{
return
false
return
false
}
}
if
(
e
.
srcElement
.
id
)
{
if
(
e
.
srcElement
.
id
)
{
...
@@ -89,13 +99,13 @@ export default {
...
@@ -89,13 +99,13 @@ export default {
closeAll
()
{
closeAll
()
{
this
.
historys
=
[
this
.
historys
=
[
{
{
name
:
'
dashboard
'
,
name
:
this
.
defaultRouter
,
meta
:
{
meta
:
{
title
:
'
仪表盘
'
title
:
'
首页
'
}
}
}
}
]
]
this
.
$router
.
push
({
name
:
'
dashboard
'
})
this
.
$router
.
push
({
name
:
this
.
defaultRouter
})
this
.
contextMenuVisible
=
false
this
.
contextMenuVisible
=
false
sessionStorage
.
setItem
(
'
historys
'
,
JSON
.
stringify
(
this
.
historys
))
sessionStorage
.
setItem
(
'
historys
'
,
JSON
.
stringify
(
this
.
historys
))
},
},
...
@@ -169,7 +179,7 @@ export default {
...
@@ -169,7 +179,7 @@ export default {
const
index
=
this
.
historys
.
findIndex
(
item
=>
item
.
name
==
tab
)
const
index
=
this
.
historys
.
findIndex
(
item
=>
item
.
name
==
tab
)
if
(
this
.
$route
.
name
==
tab
)
{
if
(
this
.
$route
.
name
==
tab
)
{
if
(
this
.
historys
.
length
==
1
)
{
if
(
this
.
historys
.
length
==
1
)
{
this
.
$router
.
push
({
name
:
'
dashboard
'
})
this
.
$router
.
push
({
name
:
this
.
defaultRouter
})
}
else
{
}
else
{
if
(
index
<
this
.
historys
.
length
-
1
)
{
if
(
index
<
this
.
historys
.
length
-
1
)
{
this
.
$router
.
push
({
name
:
this
.
historys
[
index
+
1
].
name
,
query
:
this
.
historys
[
index
+
1
].
query
,
params
:
this
.
historys
[
index
+
1
].
params
})
this
.
$router
.
push
({
name
:
this
.
historys
[
index
+
1
].
name
,
query
:
this
.
historys
[
index
+
1
].
query
,
params
:
this
.
historys
[
index
+
1
].
params
})
...
...
web/src/view/superAdmin/authority/components/menus.vue
浏览文件 @
057163b3
...
@@ -13,12 +13,28 @@
...
@@ -13,12 +13,28 @@
node-key=
"ID"
node-key=
"ID"
ref=
"menuTree"
ref=
"menuTree"
show-checkbox
show-checkbox
></el-tree>
>
<span
class=
"custom-tree-node"
slot-scope=
"
{ node , data }">
<span>
{{
node
.
label
}}
</span>
<span>
<el-button
type=
"text"
size=
"mini"
:style=
"
{color:row.defaultRouter == data.name?'#E6A23C':'#85ce61'}"
:disabled="!node.checked"
@click="() => setDefault(data)">
{{
row
.
defaultRouter
==
data
.
name
?
"
首页
"
:
"
设为首页
"
}}
</el-button>
</span>
</span>
</el-tree>
</div>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
import
{
getBaseMenuTree
,
getMenuAuthority
,
addMenuAuthority
}
from
'
@/api/menu
'
import
{
getBaseMenuTree
,
getMenuAuthority
,
addMenuAuthority
}
from
'
@/api/menu
'
import
{
updateAuthority
,
}
from
"
@/api/authority
"
;
export
default
{
export
default
{
name
:
'
Menus
'
,
name
:
'
Menus
'
,
props
:
{
props
:
{
...
@@ -43,6 +59,13 @@ export default {
...
@@ -43,6 +59,13 @@ export default {
}
}
},
},
methods
:
{
methods
:
{
async
setDefault
(
data
){
const
res
=
await
updateAuthority
({
authorityId
:
this
.
row
.
authorityId
,
AuthorityName
:
this
.
row
.
authorityName
,
parentId
:
this
.
row
.
parentId
,
defaultRouter
:
data
.
name
})
if
(
res
.
code
==
0
){
this
.
$message
({
type
:
"
success
"
,
message
:
"
设置成功
"
})
this
.
row
.
defaultRouter
=
res
.
data
.
authority
.
defaultRouter
}
},
nodeChange
(){
nodeChange
(){
this
.
needConfirm
=
true
this
.
needConfirm
=
true
},
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录