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
This commit is contained in:
liyang
2018-08-22 08:52:25 +08:00
parent a5afbdd276
commit 3704f6b682
3 changed files with 16 additions and 24 deletions

View File

@@ -1 +1 @@
6d1ab0795b7a8af170734dfabddadca1da1329cf f3b1eed033cbfe4a90817698cf46a965e43f5bf2

View File

@@ -48,7 +48,7 @@ new Vue({
render: h => h(App), render: h => h(App),
created () { created () {
// 处理路由 得到每一级的路由设置 // 处理路由 得到每一级的路由设置
this.getAllPageFromRoutes() this.$store.commit('d2admin/page/init', frameInRoutes)
// 设置顶栏菜单 // 设置顶栏菜单
this.$store.commit('d2admin/menu/headerSet', menuHeader) this.$store.commit('d2admin/menu/headerSet', menuHeader)
}, },
@@ -70,25 +70,5 @@ new Vue({
const _side = menuAside.filter(menu => menu.path === val[0].path) const _side = menuAside.filter(menu => menu.path === val[0].path)
this.$store.commit('d2admin/menu/asideSet', _side.length > 0 ? _side[0].children : []) 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') }).$mount('#app')

View File

@@ -293,9 +293,21 @@ export default {
* @class pool * @class pool
* @description 保存 pool (候选池) * @description 保存 pool (候选池)
* @param {Object} state vuex state * @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 state.pool = pool
} }
} }