From 3704f6b682ebd10140c40073f7e0e0a5fe58ef41 Mon Sep 17 00:00:00 2001 From: liyang <1711467488@qq.com> Date: Wed, 22 Aug 2018 08:52:25 +0800 Subject: [PATCH] d2admin/page/init Former-commit-id: 0fd794e5361859434b21a1cc49e2d72f489f5de0 [formerly 0fd794e5361859434b21a1cc49e2d72f489f5de0 [formerly 0fd794e5361859434b21a1cc49e2d72f489f5de0 [formerly 0fd794e5361859434b21a1cc49e2d72f489f5de0 [formerly d72d1e502f4b303799f630b8237dc216f72a7633 [formerly 157500ee60819d56bbb9b3f882cceae092d59894]]]]] Former-commit-id: ded1d89da759f04bcf3d61f170b9112248a60042 Former-commit-id: b018fb280b8677482c7b025683fac80b409c45a8 Former-commit-id: 8541a3fba946b54cae9766ffb0544619a82e3567 [formerly caf5ea8972da4c79e5a4f3198bed949bb4dee38d] Former-commit-id: bdb47e4a3a6b9f2dba19477fc4f9b71f7c3de8f6 Former-commit-id: 8142c4a779c57e7c611ebbaf433473e3be38f142 Former-commit-id: 6f553015bf1b25ff7e32876949ee6bf6e891434f Former-commit-id: cab17f36b8c0121898fcf6c8286620426be42d04 Former-commit-id: 3a194a2c9cd3044ea1ab6ae2f7c29d5a6f105ae2 --- docs/zh/sys-vuex/README.md.REMOVED.git-id | 2 +- src/main.js | 22 +--------------------- src/store/modules/d2admin/modules/page.js | 16 ++++++++++++++-- 3 files changed, 16 insertions(+), 24 deletions(-) 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 } }