From c2358be9b614a8a7abf537ad83d743a122a080f9 Mon Sep 17 00:00:00 2001 From: hooray <304327508@qq.com> Date: Sun, 29 Aug 2021 19:22:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E8=88=AA=E6=A0=8F=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=89=93=E5=BC=80=E9=85=8D=E7=BD=AE=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/components/SubSidebar/index.vue | 2 +- src/store/modules/menu.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/layout/components/SubSidebar/index.vue b/src/layout/components/SubSidebar/index.vue index 675a102c..1db5feaa 100644 --- a/src/layout/components/SubSidebar/index.vue +++ b/src/layout/components/SubSidebar/index.vue @@ -7,7 +7,7 @@ }" /> - diff --git a/src/store/modules/menu.js b/src/store/modules/menu.js index edc045fa..3b904bc4 100644 --- a/src/store/modules/menu.js +++ b/src/store/modules/menu.js @@ -1,3 +1,4 @@ +import path from 'path-browserify' import { deepClone } from '@/util' import api from '@/api' @@ -116,6 +117,7 @@ function flatAsyncRoutes(routes, breadcrumb, baseUrl = '') { const state = () => ({ isGenerate: false, routes: [], + defaultOpenedPaths: [], headerActived: 0, currentRemoveRoutes: [] }) @@ -167,6 +169,7 @@ const actions = { }]) } }) + commit('setDefaultOpenedPaths', routes) resolve(routes) }) }, @@ -192,6 +195,7 @@ const actions = { }]) } }) + commit('setDefaultOpenedPaths', routes) resolve(routes) }) }) @@ -210,6 +214,16 @@ const mutations = { return item.children.length != 0 }) }, + setDefaultOpenedPaths(state, routes) { + let defaultOpenedPaths = [] + routes.map(item => { + item.meta.defaultOpened && defaultOpenedPaths.push(item.path) + item.children.map(child => { + child.meta.defaultOpened && defaultOpenedPaths.push(path.resolve(item.path, child.path)) + }) + }) + state.defaultOpenedPaths = defaultOpenedPaths + }, // 根据路由判断属于哪个头部导航 setHeaderActived(state, path) { state.routes.map((item, index) => {