diff --git a/docs/zh/sys-vuex/README.md.REMOVED.git-id b/docs/zh/sys-vuex/README.md.REMOVED.git-id index 269c6858..2bff16f7 100644 --- a/docs/zh/sys-vuex/README.md.REMOVED.git-id +++ b/docs/zh/sys-vuex/README.md.REMOVED.git-id @@ -1 +1 @@ -6d1ab0795b7a8af170734dfabddadca1da1329cf \ No newline at end of file +f3b1eed033cbfe4a90817698cf46a965e43f5bf2 \ No newline at end of file diff --git a/src/main.js b/src/main.js index ed349395..0f77dabf 100644 --- a/src/main.js +++ b/src/main.js @@ -48,7 +48,7 @@ new Vue({ render: h => h(App), created () { // 处理路由 得到每一级的路由设置 - this.getAllPageFromRoutes() + this.$store.commit('d2admin/page/init', frameInRoutes) // 设置顶栏菜单 this.$store.commit('d2admin/menu/headerSet', menuHeader) }, @@ -70,25 +70,5 @@ new Vue({ const _side = menuAside.filter(menu => menu.path === val[0].path) this.$store.commit('d2admin/menu/asideSet', _side.length > 0 ? _side[0].children : []) } - }, - methods: { - /** - * 处理路由 得到所有的页面 - */ - getAllPageFromRoutes () { - const pool = [] - const push = function (routes) { - routes.forEach(route => { - if (route.children) { - push(route.children) - } else { - const { meta, name, path } = route - pool.push({ meta, name, path }) - } - }) - } - push(frameInRoutes) - this.$store.commit('d2admin/page/poolSet', pool) - } } }).$mount('#app') diff --git a/src/store/modules/d2admin/modules/page.js b/src/store/modules/d2admin/modules/page.js index 7ac2c47b..8d88d517 100644 --- a/src/store/modules/d2admin/modules/page.js +++ b/src/store/modules/d2admin/modules/page.js @@ -293,9 +293,21 @@ export default { * @class pool * @description 保存 pool (候选池) * @param {Object} state vuex state - * @param {Array} pool pages + * @param {Array} routes routes */ - poolSet (state, pool) { + init (state, routes) { + const pool = [] + const push = function (routes) { + routes.forEach(route => { + if (route.children) { + push(route.children) + } else { + const { meta, name, path } = route + pool.push({ meta, name, path }) + } + }) + } + push(routes) state.pool = pool } }