From afef4f2793b7cfa5a6f2ca3ea6b1e35ca5c5049f Mon Sep 17 00:00:00 2001 From: pixel <303176530@qq.com> Date: Thu, 28 May 2020 22:08:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=B7=AF=E7=94=B1=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E5=8A=9F=E8=83=BD=20=E5=B7=A6=E4=BE=A7=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E6=A0=8F=E5=A2=9E=E5=8A=A0=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/store/module/router.js | 15 +- .../layout/aside/historyComponent/history.vue | 17 +- web/src/view/layout/index.vue | 250 ++++++++---------- web/src/view/layout/search/search.vue | 70 +++++ 4 files changed, 200 insertions(+), 152 deletions(-) create mode 100644 web/src/view/layout/search/search.vue diff --git a/web/src/store/module/router.js b/web/src/store/module/router.js index e6dac8e7..6685e4bc 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 2190ac50..5d8adb93 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 08b1d310..d4f2501e 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

+