Skip to content

Commit 7b52618

Browse files
author
pixel
committed
增加路由搜索功能 左侧菜单栏增加图标
1 parent f2a0f97 commit 7b52618

File tree

4 files changed

+200
-152
lines changed

4 files changed

+200
-152
lines changed

web/src/store/module/router.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ import { asyncRouterHandle } from '@/utils/asyncRouter';
22

33
import { asyncMenu } from '@/api/menu'
44

5-
5+
const routerList = []
66
const formatRouter = (routes) => {
77
routes && routes.map(item => {
8+
if ((!item.children || item.children.every(ch => ch.hidden)) && item.name != '404') {
9+
routerList.push({ label: item.meta.title, value: item.name })
10+
}
811
item.meta.hidden = item.hidden
912
if (item.children && item.children.length > 0) {
1013
formatRouter(item.children)
@@ -15,9 +18,13 @@ const formatRouter = (routes) => {
1518
export const router = {
1619
namespaced: true,
1720
state: {
18-
asyncRouters: []
21+
asyncRouters: [],
22+
routerList: routerList,
1923
},
2024
mutations: {
25+
setRouterList(state, routerList) {
26+
state.routerList = routerList
27+
},
2128
// 设置动态路由
2229
setAsyncRouter(state, asyncRouters) {
2330
state.asyncRouters = asyncRouters
@@ -55,13 +62,17 @@ export const router = {
5562
})
5663
asyncRouterHandle(baseRouter)
5764
commit('setAsyncRouter', baseRouter)
65+
commit('setRouterList', routerList)
5866
return true
5967
}
6068
},
6169
getters: {
6270
// 获取动态路由
6371
asyncRouters(state) {
6472
return state.asyncRouters
73+
},
74+
routerList(state) {
75+
return state.routerList
6576
}
6677
}
6778
}

web/src/view/layout/aside/historyComponent/history.vue

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ export default {
3636
left: 0,
3737
top: 0,
3838
isCollapse: false,
39-
isMobile:false,
39+
isMobile: false,
4040
rightActive: ''
4141
}
4242
},
4343
created() {
44-
this.$bus.on('mobile',(isMobile)=>{
44+
this.$bus.on('mobile', isMobile => {
4545
this.isMobile = isMobile
4646
})
47-
this.$bus.on('collapse',(isCollapse)=>{
47+
this.$bus.on('collapse', isCollapse => {
4848
this.isCollapse = isCollapse
4949
})
5050
const initHistorys = [
@@ -60,7 +60,7 @@ export default {
6060
this.setTab(this.$route)
6161
},
6262
63-
beforeDestroy(){
63+
beforeDestroy() {
6464
this.$bus.off('collapse')
6565
this.$bus.off('mobile')
6666
},
@@ -77,7 +77,7 @@ export default {
7777
} else {
7878
width = 220
7979
}
80-
if(this.isMobile){
80+
if (this.isMobile) {
8181
width = 0
8282
}
8383
this.left = e.clientX - width
@@ -118,7 +118,7 @@ export default {
118118
const activeIndex = this.historys.findIndex(
119119
item => item.name == this.activeValue
120120
)
121-
this.historys.splice(leftIndex+1, this.historys.length)
121+
this.historys.splice(leftIndex + 1, this.historys.length)
122122
if (leftIndex < activeIndex) {
123123
this.$router.push({ name: this.rightActive })
124124
}
@@ -202,4 +202,9 @@ export default {
202202
background: #f2f2f2;
203203
cursor: pointer;
204204
}
205+
.router-history {
206+
background: #fff;
207+
padding: 0 6px;
208+
border-top: 1px solid #dcdcdc;
209+
}
205210
</style>

0 commit comments

Comments
 (0)