Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FLIPPED-AURORA
gin-vue-admin
提交
072bf62e
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,发现更多精彩内容 >>
提交
072bf62e
编写于
1月 24, 2021
作者:
Mr.奇淼(
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加menu可配置是否自动关闭功能 增加单页面刷新功能
上级
477a18b5
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
217 addition
and
115 deletion
+217
-115
server/model/sys_base_menu.go
server/model/sys_base_menu.go
+1
-0
web/src/store/module/router.js
web/src/store/module/router.js
+0
-1
web/src/view/layout/aside/historyComponent/history.vue
web/src/view/layout/aside/historyComponent/history.vue
+188
-106
web/src/view/layout/index.vue
web/src/view/layout/index.vue
+11
-4
web/src/view/layout/search/search.vue
web/src/view/layout/search/search.vue
+10
-4
web/src/view/superAdmin/menu/menu.vue
web/src/view/superAdmin/menu/menu.vue
+7
-0
未找到文件。
server/model/sys_base_menu.go
浏览文件 @
072bf62e
...
...
@@ -24,6 +24,7 @@ type Meta struct {
DefaultMenu
bool
`json:"defaultMenu" gorm:"comment:是否是基础路由(开发中)"`
Title
string
`json:"title" gorm:"comment:菜单名"`
Icon
string
`json:"icon" gorm:"comment:菜单图标"`
CloseTab
bool
`json:"closeTab" gorm:"comment:自动关闭tab"`
}
type
SysBaseMenuParameter
struct
{
...
...
web/src/store/module/router.js
浏览文件 @
072bf62e
...
...
@@ -8,7 +8,6 @@ const formatRouter = (routes) => {
if
((
!
item
.
children
||
item
.
children
.
every
(
ch
=>
ch
.
hidden
))
&&
item
.
name
!=
'
404
'
)
{
routerList
.
push
({
label
:
item
.
meta
.
title
,
value
:
item
.
name
})
}
item
.
meta
.
hidden
=
item
.
hidden
if
(
item
.
children
&&
item
.
children
.
length
>
0
)
{
formatRouter
(
item
.
children
)
}
...
...
web/src/view/layout/aside/historyComponent/history.vue
浏览文件 @
072bf62e
...
...
@@ -9,9 +9,9 @@
v-model=
"activeValue"
>
<el-tab-pane
:key=
"item.name"
:key=
"item.name
+ JSON.stringify(item.query)+JSON.stringify(item.params)
"
:label=
"item.meta.title"
:name=
"item.name"
:name=
"item.name
+ JSON.stringify(item.query)+JSON.stringify(item.params)
"
:tab=
"item"
v-for=
"item in historys"
></el-tab-pane>
...
...
@@ -27,73 +27,75 @@
</div>
</
template
>
<
script
>
import
{
mapGetters
}
from
"
vuex
"
import
{
mapGetters
}
from
"
vuex
"
;
export
default
{
name
:
'
HistoryComponent
'
,
name
:
"
HistoryComponent
"
,
data
()
{
return
{
historys
:
[],
activeValue
:
''
,
activeValue
:
""
,
contextMenuVisible
:
false
,
left
:
0
,
top
:
0
,
isCollapse
:
false
,
isMobile
:
false
,
rightActive
:
''
}
rightActive
:
""
}
;
},
computed
:{
...
mapGetters
(
"
user
"
,[
"
userInfo
"
]),
defaultRouter
(){
return
this
.
userInfo
.
authority
.
defaultRouter
computed
:
{
...
mapGetters
(
"
user
"
,
[
"
userInfo
"
]),
defaultRouter
()
{
return
this
.
userInfo
.
authority
.
defaultRouter
;
}
},
created
()
{
this
.
activeValue
=
this
.
defaultRouter
this
.
$bus
.
on
(
'
mobile
'
,
isMobile
=>
{
this
.
isMobile
=
isMobile
})
this
.
$bus
.
on
(
'
collapse
'
,
isCollapse
=>
{
this
.
isCollapse
=
isCollapse
})
this
.
$bus
.
on
(
"
mobile
"
,
isMobile
=>
{
this
.
isMobile
=
isMobile
;
});
this
.
$bus
.
on
(
"
collapse
"
,
isCollapse
=>
{
this
.
isCollapse
=
isCollapse
;
});
const
initHistorys
=
[
{
name
:
this
.
defaultRouter
,
meta
:
{
title
:
'
首页
'
}
title
:
"
首页
"
},
query
:
{},
params
:
{}
}
]
]
;
this
.
historys
=
JSON
.
parse
(
sessionStorage
.
getItem
(
'
historys
'
))
||
initHistorys
this
.
setTab
(
this
.
$route
)
JSON
.
parse
(
sessionStorage
.
getItem
(
"
historys
"
))
||
initHistorys
;
this
.
activeValue
=
window
.
sessionStorage
.
getItem
(
"
activeValue
"
);
this
.
setTab
(
this
.
$route
);
},
beforeDestroy
()
{
this
.
$bus
.
off
(
'
collapse
'
)
this
.
$bus
.
off
(
'
mobile
'
)
this
.
$bus
.
off
(
"
collapse
"
);
this
.
$bus
.
off
(
"
mobile
"
);
},
methods
:
{
openContextMenu
(
e
)
{
if
(
this
.
historys
.
length
==
1
&&
this
.
$route
.
name
==
this
.
defaultRouter
)
{
return
false
return
false
;
}
if
(
e
.
srcElement
.
id
)
{
this
.
contextMenuVisible
=
true
let
width
this
.
contextMenuVisible
=
true
;
let
width
;
if
(
this
.
isCollapse
)
{
width
=
54
width
=
54
;
}
else
{
width
=
220
width
=
220
;
}
if
(
this
.
isMobile
)
{
width
=
0
width
=
0
;
}
this
.
left
=
e
.
clientX
-
width
this
.
top
=
e
.
clientY
+
10
this
.
rightActive
=
e
.
srcElement
.
id
.
split
(
'
-
'
)[
1
]
this
.
left
=
e
.
clientX
-
width
;
this
.
top
=
e
.
clientY
+
10
;
this
.
rightActive
=
e
.
srcElement
.
id
.
split
(
"
-
"
)[
1
];
}
},
closeAll
()
{
...
...
@@ -101,115 +103,197 @@ export default {
{
name
:
this
.
defaultRouter
,
meta
:
{
title
:
'
首页
'
}
title
:
"
首页
"
},
query
:
{},
params
:
{}
}
]
this
.
$router
.
push
({
name
:
this
.
defaultRouter
})
this
.
contextMenuVisible
=
false
sessionStorage
.
setItem
(
'
historys
'
,
JSON
.
stringify
(
this
.
historys
))
]
;
this
.
$router
.
push
({
name
:
this
.
defaultRouter
})
;
this
.
contextMenuVisible
=
false
;
sessionStorage
.
setItem
(
"
historys
"
,
JSON
.
stringify
(
this
.
historys
));
},
closeLeft
()
{
let
right
const
rightIndex
=
this
.
historys
.
findIndex
(
item
=>
{
if
(
item
.
name
==
this
.
rightActive
){
right
=
item
}
return
item
.
name
==
this
.
rightActive
let
right
;
const
rightIndex
=
this
.
historys
.
findIndex
(
item
=>
{
if
(
item
.
name
+
JSON
.
stringify
(
item
.
query
)
+
JSON
.
stringify
(
item
.
params
)
==
this
.
rightActive
)
{
right
=
item
;
}
)
return
(
item
.
name
+
JSON
.
stringify
(
item
.
query
)
+
JSON
.
stringify
(
item
.
params
)
==
this
.
rightActive
);
});
const
activeIndex
=
this
.
historys
.
findIndex
(
item
=>
item
.
name
==
this
.
activeValue
)
this
.
historys
.
splice
(
0
,
rightIndex
)
item
=>
item
.
name
+
JSON
.
stringify
(
item
.
query
)
+
JSON
.
stringify
(
item
.
params
)
==
this
.
activeValue
);
this
.
historys
.
splice
(
0
,
rightIndex
);
if
(
rightIndex
>
activeIndex
)
{
this
.
$router
.
push
(
right
)
this
.
$router
.
push
(
right
)
;
}
sessionStorage
.
setItem
(
'
historys
'
,
JSON
.
stringify
(
this
.
historys
))
sessionStorage
.
setItem
(
"
historys
"
,
JSON
.
stringify
(
this
.
historys
));
},
closeRight
()
{
let
right
const
leftIndex
=
this
.
historys
.
findIndex
(
item
=>
{
if
(
item
.
name
==
this
.
rightActive
){
right
=
item
}
return
item
.
name
==
this
.
rightActive
let
right
;
const
leftIndex
=
this
.
historys
.
findIndex
(
item
=>
{
if
(
item
.
name
+
JSON
.
stringify
(
item
.
query
)
+
JSON
.
stringify
(
item
.
params
)
==
this
.
rightActive
)
{
right
=
item
;
}
)
return
(
item
.
name
+
JSON
.
stringify
(
item
.
query
)
+
JSON
.
stringify
(
item
.
params
)
==
this
.
rightActive
);
});
const
activeIndex
=
this
.
historys
.
findIndex
(
item
=>
item
.
name
==
this
.
activeValue
)
this
.
historys
.
splice
(
leftIndex
+
1
,
this
.
historys
.
length
)
item
=>
item
.
name
+
JSON
.
stringify
(
item
.
query
)
+
JSON
.
stringify
(
item
.
params
)
==
this
.
activeValue
);
this
.
historys
.
splice
(
leftIndex
+
1
,
this
.
historys
.
length
);
if
(
leftIndex
<
activeIndex
)
{
this
.
$router
.
push
(
right
)
this
.
$router
.
push
(
right
)
;
}
sessionStorage
.
setItem
(
'
historys
'
,
JSON
.
stringify
(
this
.
historys
))
sessionStorage
.
setItem
(
"
historys
"
,
JSON
.
stringify
(
this
.
historys
));
},
closeOther
()
{
let
right
this
.
historys
=
this
.
historys
.
filter
(
item
=>
{
if
(
item
.
name
==
this
.
rightActive
){
right
=
item
}
return
item
.
name
==
this
.
rightActive
let
right
;
this
.
historys
=
this
.
historys
.
filter
(
item
=>
{
if
(
item
.
name
+
JSON
.
stringify
(
item
.
query
)
+
JSON
.
stringify
(
item
.
params
)
==
this
.
rightActive
)
{
right
=
item
;
}
)
this
.
$router
.
push
(
right
)
sessionStorage
.
setItem
(
'
historys
'
,
JSON
.
stringify
(
this
.
historys
))
return
(
item
.
name
+
JSON
.
stringify
(
item
.
query
)
+
JSON
.
stringify
(
item
.
params
)
==
this
.
rightActive
);
});
this
.
$router
.
push
(
right
);
sessionStorage
.
setItem
(
"
historys
"
,
JSON
.
stringify
(
this
.
historys
));
},
isSame
(
route1
,
route2
)
{
if
(
route1
.
name
!=
route2
.
name
)
{
return
false
;
}
for
(
let
key
in
route1
.
query
)
{
if
(
route1
.
query
[
key
]
!=
route2
.
query
[
key
])
{
return
false
;
}
}
for
(
let
key
in
route1
.
params
)
{
if
(
route1
.
params
[
key
]
!=
route2
.
params
[
key
])
{
return
false
;
}
}
return
true
;
},
setTab
(
route
)
{
if
(
!
this
.
historys
.
some
(
item
=>
item
.
name
==
route
.
name
))
{
const
obj
=
{}
obj
.
name
=
route
.
name
obj
.
meta
=
route
.
meta
obj
.
query
=
route
.
query
obj
.
params
=
route
.
params
this
.
historys
.
push
(
obj
)
if
(
!
this
.
historys
.
some
(
item
=>
this
.
isSame
(
item
,
route
)
))
{
const
obj
=
{}
;
obj
.
name
=
route
.
name
;
obj
.
meta
=
route
.
meta
;
obj
.
query
=
route
.
query
;
obj
.
params
=
route
.
params
;
this
.
historys
.
push
(
obj
)
;
}
this
.
activeValue
=
this
.
$route
.
name
window
.
sessionStorage
.
setItem
(
"
activeValue
"
,
this
.
$route
.
name
+
JSON
.
stringify
(
this
.
$route
.
query
)
+
JSON
.
stringify
(
this
.
$route
.
params
)
);
},
changeTab
(
component
)
{
const
tab
=
component
.
$attrs
.
tab
this
.
$router
.
push
({
name
:
tab
.
name
,
query
:
tab
.
query
,
params
:
tab
.
params
})
const
tab
=
component
.
$attrs
.
tab
;
this
.
$router
.
push
({
name
:
tab
.
name
,
query
:
tab
.
query
,
params
:
tab
.
params
});
},
removeTab
(
tab
)
{
const
index
=
this
.
historys
.
findIndex
(
item
=>
item
.
name
==
tab
)
if
(
this
.
$route
.
name
==
tab
)
{
const
index
=
this
.
historys
.
findIndex
(
item
=>
item
.
name
+
JSON
.
stringify
(
item
.
query
)
+
JSON
.
stringify
(
item
.
params
)
==
tab
);
if
(
this
.
$route
.
name
+
JSON
.
stringify
(
this
.
$route
.
query
)
+
JSON
.
stringify
(
this
.
$route
.
params
)
==
tab
)
{
if
(
this
.
historys
.
length
==
1
)
{
this
.
$router
.
push
({
name
:
this
.
defaultRouter
})
this
.
$router
.
push
({
name
:
this
.
defaultRouter
})
;
}
else
{
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
});
}
else
{
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
});
}
}
}
this
.
historys
.
splice
(
index
,
1
)
this
.
historys
.
splice
(
index
,
1
)
;
}
},
watch
:
{
contextMenuVisible
()
{
if
(
this
.
contextMenuVisible
)
{
document
.
body
.
addEventListener
(
'
click
'
,
()
=>
{
this
.
contextMenuVisible
=
false
})
document
.
body
.
addEventListener
(
"
click
"
,
()
=>
{
this
.
contextMenuVisible
=
false
;
})
;
}
else
{
document
.
body
.
removeEventListener
(
'
click
'
,
()
=>
{
this
.
contextMenuVisible
=
false
})
document
.
body
.
removeEventListener
(
"
click
"
,
()
=>
{
this
.
contextMenuVisible
=
false
;
})
;
}
},
$route
(
to
)
{
this
.
historys
=
this
.
historys
.
filter
(
item
=>
!
item
.
meta
.
hidden
)
this
.
setTab
(
to
)
sessionStorage
.
setItem
(
'
historys
'
,
JSON
.
stringify
(
this
.
historys
))
$route
(
to
,
now
)
{
this
.
historys
=
this
.
historys
.
filter
(
item
=>
!
item
.
meta
.
closeTab
);
this
.
setTab
(
to
);
sessionStorage
.
setItem
(
"
historys
"
,
JSON
.
stringify
(
this
.
historys
));
this
.
activeValue
=
window
.
sessionStorage
.
getItem
(
"
activeValue
"
);
if
(
now
&&
to
&&
now
.
name
==
to
.
name
)
{
this
.
$bus
.
$emit
(
"
reload
"
);
}
}
}
}
}
;
</
script
>
<
style
lang=
"scss"
>
.contextmenu
{
...
...
@@ -234,6 +318,4 @@ export default {
background
:
#f2f2f2
;
cursor
:
pointer
;
}
</
style
>
\ No newline at end of file
web/src/view/layout/index.vue
浏览文件 @
072bf62e
...
...
@@ -36,7 +36,7 @@
<el-col
:xs=
"12"
:lg=
"9"
:md=
"9"
:sm=
"14"
:xl=
"9"
>
<div
class=
"fl-right right-box"
>
<Search
/>
<Screenfull
class=
"screenfull"
></Screenfull>
<Screenfull
class=
"screenfull"
:style=
"
{cursor:'pointer'}"
>
</Screenfull>
<el-dropdown>
<span
class=
"header-avatar"
>
<CustomPic/>
...
...
@@ -67,11 +67,11 @@
</transition>
<transition
mode=
"out-in"
name=
"el-fade-in-linear"
>
<keep-alive>
<router-view
v-loading=
"loadingFlag"
element-loading-text=
"正在加载中"
class=
"admin-box"
v-if=
"$route.meta.keepAlive"
></router-view>
<router-view
v-loading=
"loadingFlag"
element-loading-text=
"正在加载中"
class=
"admin-box"
v-if=
"$route.meta.keepAlive
&& reloadFlag
"
></router-view>
</keep-alive>
</transition>
<transition
mode=
"out-in"
name=
"el-fade-in-linear"
>
<router-view
v-loading=
"loadingFlag"
element-loading-text=
"正在加载中"
class=
"admin-box"
v-if=
"!$route.meta.keepAlive
"
></router-view>
<router-view
v-loading=
"loadingFlag"
element-loading-text=
"正在加载中"
class=
"admin-box"
v-if=
"!$route.meta.keepAlive && reloadFlag
"
></router-view>
</transition>
<BottomInfo
/>
</el-main>
...
...
@@ -98,7 +98,7 @@ export default {
isMobile
:
false
,
isShadowBg
:
false
,
loadingFlag
:
false
,
reloadFlag
:
true
,
value
:
''
}
},
...
...
@@ -112,6 +112,12 @@ export default {
},
methods
:
{
...
mapActions
(
'
user
'
,
[
'
LoginOut
'
]),
reload
(){
this
.
reloadFlag
=
false
this
.
$nextTick
(()
=>
{
this
.
reloadFlag
=
true
})
},
totalCollapse
()
{
this
.
isCollapse
=
!
this
.
isCollapse
this
.
isSider
=
!
this
.
isCollapse
...
...
@@ -153,6 +159,7 @@ export default {
}
this
.
$bus
.
emit
(
'
collapse
'
,
this
.
isCollapse
)
this
.
$bus
.
emit
(
'
mobile
'
,
this
.
isMobile
)
this
.
$bus
.
on
(
"
reload
"
,
this
.
reload
)
this
.
$bus
.
on
(
"
showLoading
"
,()
=>
{
this
.
loadingFlag
=
true
})
...
...
web/src/view/layout/search/search.vue
浏览文件 @
072bf62e
...
...
@@ -19,8 +19,14 @@
</el-select>
</div>
</transition>
<div
:style=
"
{display:'inline-block',float:'right',width:'31px',textAlign:'left',fontSize:'16px',paddingTop:'2px'}"
class="user-box"
>
<i
@
click=
"$bus.$emit('reload')"
:style=
"
{cursor:'pointer'}" class="el-icon-refresh" />
</div>
<div
:style=
"
{display:'inline-block',float:'right'}" class="user-box">
<i
@
click=
"showSearch()"
class=
"el-icon-search search-icon"
></i>
<i
:style=
"
{cursor:'pointer'}"
@click="showSearch()" class="el-icon-search search-icon">
</i>
</div>
</div>
</
template
>
...
...
@@ -48,9 +54,9 @@ export default {
},
showSearch
()
{
this
.
show
=
true
;
this
.
$nextTick
(()
=>
{
this
.
$refs
[
'
search-input
'
].
focus
()
})
this
.
$nextTick
(()
=>
{
this
.
$refs
[
"
search-input
"
].
focus
();
})
;
}
}
};
...
...
web/src/view/superAdmin/menu/menu.vue
浏览文件 @
072bf62e
...
...
@@ -117,6 +117,12 @@
<el-option
:value=
"true"
label=
"是"
></el-option>
</el-select>
</el-form-item>
<el-form-item
label=
"closeTab"
prop=
"meta.closeTab"
style=
"width:30%"
>
<el-select
placeholder=
"是否自动关闭tab"
v-model=
"form.meta.closeTab"
>
<el-option
:value=
"false"
label=
"否"
></el-option>
<el-option
:value=
"true"
label=
"是"
></el-option>
</el-select>
</el-form-item>
</el-form>
<div
class=
"warning"
>
新增菜单需要在角色管理内配置权限才可使用
</div>
<div>
...
...
@@ -209,6 +215,7 @@ export default {
title
:
""
,
icon
:
""
,
defaultMenu
:
false
,
closeTab
:
false
,
keepAlive
:
false
},
parameters
:
[]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录