diff --git a/web/src/store/module/router.js b/web/src/store/module/router.js index e6dac8e773debbd371fa6a3f3f5d7cac79092e15..6685e4bcc204bcb63fb5face20a0799e45b78194 100644 --- a/web/src/store/module/router.js +++ b/web/src/store/module/router.js @@ -2,9 +2,12 @@ import { asyncRouterHandle } from '@/utils/asyncRouter'; import { asyncMenu } from '@/api/menu' - +const routerList = [] const formatRouter = (routes) => { routes && routes.map(item => { + 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) @@ -15,9 +18,13 @@ const formatRouter = (routes) => { export const router = { namespaced: true, state: { - asyncRouters: [] + asyncRouters: [], + routerList: routerList, }, mutations: { + setRouterList(state, routerList) { + state.routerList = routerList + }, // 设置动态路由 setAsyncRouter(state, asyncRouters) { state.asyncRouters = asyncRouters @@ -55,6 +62,7 @@ export const router = { }) asyncRouterHandle(baseRouter) commit('setAsyncRouter', baseRouter) + commit('setRouterList', routerList) return true } }, @@ -62,6 +70,9 @@ export const router = { // 获取动态路由 asyncRouters(state) { return state.asyncRouters + }, + routerList(state) { + return state.routerList } } } \ No newline at end of file diff --git a/web/src/view/layout/aside/historyComponent/history.vue b/web/src/view/layout/aside/historyComponent/history.vue index 2190ac505c200985d0c6908250d03263f255063f..5d8adb935ed7645c035a13a40e4bfc45cb4a6564 100644 --- a/web/src/view/layout/aside/historyComponent/history.vue +++ b/web/src/view/layout/aside/historyComponent/history.vue @@ -36,15 +36,15 @@ export default { left: 0, top: 0, isCollapse: false, - isMobile:false, + isMobile: false, rightActive: '' } }, created() { - this.$bus.on('mobile',(isMobile)=>{ + this.$bus.on('mobile', isMobile => { this.isMobile = isMobile }) - this.$bus.on('collapse',(isCollapse)=>{ + this.$bus.on('collapse', isCollapse => { this.isCollapse = isCollapse }) const initHistorys = [ @@ -60,7 +60,7 @@ export default { this.setTab(this.$route) }, - beforeDestroy(){ + beforeDestroy() { this.$bus.off('collapse') this.$bus.off('mobile') }, @@ -77,7 +77,7 @@ export default { } else { width = 220 } - if(this.isMobile){ + if (this.isMobile) { width = 0 } this.left = e.clientX - width @@ -118,7 +118,7 @@ export default { const activeIndex = this.historys.findIndex( item => item.name == this.activeValue ) - this.historys.splice(leftIndex+1, this.historys.length) + this.historys.splice(leftIndex + 1, this.historys.length) if (leftIndex < activeIndex) { this.$router.push({ name: this.rightActive }) } @@ -202,4 +202,9 @@ export default { background: #f2f2f2; cursor: pointer; } +.router-history { + background: #fff; + padding: 0 6px; + border-top: 1px solid #dcdcdc; +} \ No newline at end of file diff --git a/web/src/view/layout/index.vue b/web/src/view/layout/index.vue index 08b1d3105f27a1429664c9c65f494a27468377bb..d4f2501e5b40a942ec599de70239da96b5514e6e 100644 --- a/web/src/view/layout/index.vue +++ b/web/src/view/layout/index.vue @@ -3,18 +3,18 @@ -
- -

Gin-Vue-Admin

-
+
+ +

Gin-Vue-Admin

+