permission_routes.js
1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import util from '@/libs/util.js'
import router from '@router'
import { getNavigation } from '@/api/navigation.js'
const getState = () => {
return {
navigation: [],
routerList:[]
}
}
const state = getState()
const mutations = {
GET_NAVIGATION: (state,navigation) => {
state.navigation = navigation
}
}
const actions = {
// 在这里处理后台返回的数据加载左边菜单栏
getMenus({ commit }) {
return new Promise((resolve, reject) => {
getNavigation().then(response => {
commit('GET_NAVIGATION', response.data)
// filterAsyncRoutes(data.menuList)
util.cookies.set('navigation-1',response.data.slice(0,1))
util.cookies.set('navigation',response.data.slice(1))
router.push('/panel')
resolve()
}).catch(error => {
reject(error)
})
})
},
}
// 在这里处理路由表信息
export function filterAsyncRoutes(routes) {
routes.map(v => {
const { path, name } = v
// 重新构建路由对象
const item = {
path,
name,
component: () => import(`@/views/${component}`),
// redirect,
}
})
}
export default {
namespaced: true,
state,
mutations,
actions
}