|
@@ -43,7 +43,8 @@ const state = {
|
|
|
const mutations = {
|
|
const mutations = {
|
|
|
SET_ROUTES: (state, routes) => {
|
|
SET_ROUTES: (state, routes) => {
|
|
|
state.addRoutes = routes
|
|
state.addRoutes = routes
|
|
|
- state.routes = constantRoutes.concat(routes)
|
|
|
|
|
|
|
+ // state.routes = constantRoutes.concat(routes)
|
|
|
|
|
+ state.routes = routes
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -55,15 +56,16 @@ const mutations = {
|
|
|
*/
|
|
*/
|
|
|
export function generaMenu(routes, data) {
|
|
export function generaMenu(routes, data) {
|
|
|
data.forEach(item => {
|
|
data.forEach(item => {
|
|
|
|
|
+
|
|
|
const menu = {
|
|
const menu = {
|
|
|
- path: item.routePath,
|
|
|
|
|
|
|
+ path: '/' + item.routePath,
|
|
|
component: Layout,
|
|
component: Layout,
|
|
|
hidden: item.show === 0, // 状态为0的隐藏
|
|
hidden: item.show === 0, // 状态为0的隐藏
|
|
|
redirect: item.routePath,
|
|
redirect: item.routePath,
|
|
|
children: [],
|
|
children: [],
|
|
|
name: item.name,
|
|
name: item.name,
|
|
|
meta: {
|
|
meta: {
|
|
|
- title: item.name,
|
|
|
|
|
|
|
+ title: item.metaTitle,
|
|
|
icon: item.icon
|
|
icon: item.icon
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -71,7 +73,9 @@ const mutations = {
|
|
|
if (item.child) {
|
|
if (item.child) {
|
|
|
generaMenu(menu.children, item.child)
|
|
generaMenu(menu.children, item.child)
|
|
|
}
|
|
}
|
|
|
- routes.push(menu)
|
|
|
|
|
|
|
+ // if (item.routePath != 'dashboard/index') {
|
|
|
|
|
+ routes.push(menu)
|
|
|
|
|
+ // }
|
|
|
})
|
|
})
|
|
|
return routes
|
|
return routes
|
|
|
}
|
|
}
|
|
@@ -84,7 +88,44 @@ const actions = {
|
|
|
let accessedRoutes
|
|
let accessedRoutes
|
|
|
roles = ['admin']
|
|
roles = ['admin']
|
|
|
let baseInfo = JSON.parse(localStorage.getItem('baseInfo'))
|
|
let baseInfo = JSON.parse(localStorage.getItem('baseInfo'))
|
|
|
- let apiMenu = baseInfo.menu
|
|
|
|
|
|
|
+ // let apiMenu = baseInfo.menu---调试先写固定
|
|
|
|
|
+ let apiMenu = [
|
|
|
|
|
+ {
|
|
|
|
|
+ "name":"控制台",
|
|
|
|
|
+ "class":"",
|
|
|
|
|
+ "icon":"el-icon-guide",
|
|
|
|
|
+ "controller":"dashboard",
|
|
|
|
|
+ "action":"index",
|
|
|
|
|
+ "routePath":"dashboard/index",
|
|
|
|
|
+ "show":1,
|
|
|
|
|
+ "metaTitle": 'dashboard',
|
|
|
|
|
+ "child":[
|
|
|
|
|
+
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "name":"商城管理",
|
|
|
|
|
+ "class":"",
|
|
|
|
|
+ "icon":"el-icon-goods",
|
|
|
|
|
+ "controller":"shop",
|
|
|
|
|
+ "action":"",
|
|
|
|
|
+ "routePath":"shop",
|
|
|
|
|
+ "metaTitle":'shop',
|
|
|
|
|
+ "show":1,
|
|
|
|
|
+ "child":[
|
|
|
|
|
+ {
|
|
|
|
|
+ "name":"商品列表",
|
|
|
|
|
+ "class":"",
|
|
|
|
|
+ "icon":"",
|
|
|
|
|
+ "controller":"shop",
|
|
|
|
|
+ "action":"index",
|
|
|
|
|
+ "routePath":"shop/index",
|
|
|
|
|
+ "show":1,
|
|
|
|
|
+ "metaTitle": 'indexShop'
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
let formatMenu = generaMenu([], apiMenu)
|
|
let formatMenu = generaMenu([], apiMenu)
|
|
|
accessedRoutes = formatMenu //filterAsyncRoutes(asyncRoutes, roles)
|
|
accessedRoutes = formatMenu //filterAsyncRoutes(asyncRoutes, roles)
|
|
|
commit('SET_ROUTES', accessedRoutes)
|
|
commit('SET_ROUTES', accessedRoutes)
|