diff --git a/litemall-admin/src/router/index.js b/litemall-admin/src/router/index.js index bfe81aad..8930c5cf 100644 --- a/litemall-admin/src/router/index.js +++ b/litemall-admin/src/router/index.js @@ -82,6 +82,7 @@ export const asyncRouterMap = [ path: '/user', component: Layout, redirect: 'noredirect', + alwaysShow: true, name: 'userManage', meta: { title: '用户管理', @@ -92,37 +93,61 @@ export const asyncRouterMap = [ path: 'user', component: () => import('@/views/user/user'), name: 'user', - meta: { title: '会员管理', noCache: true } + meta: { + perms: ['GET /admin/user/list', 'POST /admin/user/create', 'POST /admin/user/update'], + title: '会员管理', + noCache: true + } }, { path: 'address', component: () => import('@/views/user/address'), name: 'address', - meta: { title: '收货地址', noCache: true } + meta: { + perms: ['GET /admin/address/list'], + title: '收货地址', + noCache: true + } }, { path: 'collect', component: () => import('@/views/user/collect'), name: 'collect', - meta: { title: '会员收藏', noCache: true } + meta: { + perms: ['GET /admin/collect/list'], + title: '会员收藏', + noCache: true + } }, { path: 'footprint', component: () => import('@/views/user/footprint'), name: 'footprint', - meta: { title: '会员足迹', noCache: true } + meta: { + perms: ['GET /admin/footprint/list'], + title: '会员足迹', + noCache: true + } }, { path: 'history', component: () => import('@/views/user/history'), name: 'history', - meta: { title: '搜索历史', noCache: true } + meta: { + perms: ['GET /admin/history/list'], + title: '搜索历史', + noCache: true + } }, { path: 'feedback', component: () => import('@/views/user/feedback'), name: 'feedback', - meta: { title: '意见反馈', noCache: true } + meta: { + perms: ['GET /admin/feedback/list'], + title: '意见反馈', + noCache: true + } } ] }, @@ -131,6 +156,7 @@ export const asyncRouterMap = [ path: '/mall', component: Layout, redirect: 'noredirect', + alwaysShow: true, name: 'mallManage', meta: { title: '商场管理', @@ -141,37 +167,60 @@ export const asyncRouterMap = [ path: 'region', component: () => import('@/views/mall/region'), name: 'region', - meta: { title: '行政区域', noCache: true } + meta: { + title: '行政区域', + noCache: true + } }, { path: 'brand', component: () => import('@/views/mall/brand'), name: 'brand', - meta: { title: '品牌制造商', noCache: true } + meta: { + perms: ['GET /admin/brand/list', 'POST /admin/brand/create', 'GET /admin/brand/read', 'POST /admin/brand/update', 'POST /admin/brand/delete'], + title: '品牌制造商', + noCache: true + } }, { path: 'category', component: () => import('@/views/mall/category'), name: 'category', - meta: { title: '商品类目', noCache: true } + meta: { + perms: ['GET /admin/category/list', 'POST /admin/category/create', 'GET /admin/category/read', 'POST /admin/category/update', 'POST /admin/category/delete'], + title: '商品类目', + noCache: true + } }, { path: 'order', component: () => import('@/views/mall/order'), name: 'order', - meta: { title: '订单管理', noCache: true } + meta: { + perms: ['GET /admin/order/list', 'GET /admin/order/detail', 'POST /admin/order/ordership', 'POST /admin/order/orderrefund', 'POST /admin/order/orderreply'], + title: '订单管理', + noCache: true + } }, { path: 'issue', component: () => import('@/views/mall/issue'), name: 'issue', - meta: { title: '通用问题', noCache: true } + meta: { + perms: ['GET /admin/issue/list', 'POST /admin/issue/create', 'GET /admin/issue/read', 'POST /admin/issue/update', 'POST /admin/issue/delete'], + title: '通用问题', + noCache: true + } }, { path: 'keyword', component: () => import('@/views/mall/keyword'), name: 'keyword', - meta: { title: '关键词', noCache: true } + meta: { + perms: ['GET /admin/keyword/list', 'POST /admin/keyword/create', 'GET /admin/keyword/read', 'POST /admin/keyword/update', 'POST /admin/keyword/delete'], + title: '关键词', + noCache: true + } } ] }, @@ -180,6 +229,7 @@ export const asyncRouterMap = [ path: '/goods', component: Layout, redirect: 'noredirect', + alwaysShow: true, name: 'goodsManage', meta: { title: '商品管理', @@ -190,26 +240,42 @@ export const asyncRouterMap = [ path: 'list', component: () => import('@/views/goods/list'), name: 'goodsList', - meta: { title: '商品列表', noCache: true } + meta: { + perms: ['GET /admin/goods/list', 'POST /admin/goods/delete'], + title: '商品列表', + noCache: true + } }, { path: 'create', component: () => import('@/views/goods/create'), name: 'goodsCreate', - meta: { title: '商品上架', noCache: true } + meta: { + perms: ['POST /admin/goods/create'], + title: '商品上架', + noCache: true + } }, { path: 'edit', component: () => import('@/views/goods/edit'), name: 'goodsEdit', - meta: { title: '商品编辑', noCache: true }, + meta: { + perms: ['GET /admin/goods/detail', 'POST /admin/goods/update', 'POST /admin/goods/catAndBrand'], + title: '商品编辑', + noCache: true + }, hidden: true }, { path: 'comment', component: () => import('@/views/goods/comment'), name: 'goodsComment', - meta: { title: '商品评论', noCache: true } + meta: { + perms: ['GET /admin/comment/list', 'POST /admin/comment/delete'], + title: '商品评论', + noCache: true + } } ] }, @@ -217,6 +283,7 @@ export const asyncRouterMap = [ path: '/promotion', component: Layout, redirect: 'noredirect', + alwaysShow: true, name: 'promotionManage', meta: { title: '推广管理', @@ -227,38 +294,62 @@ export const asyncRouterMap = [ path: 'ad', component: () => import('@/views/promotion/ad'), name: 'ad', - meta: { title: '广告管理', noCache: true } + meta: { + perms: ['GET /admin/ad/list', 'POST /admin/ad/create', 'GET /admin/ad/read', 'POST /admin/ad/update', 'POST /admin/ad/delete'], + title: '广告管理', + noCache: true + } }, { path: 'coupon', component: () => import('@/views/promotion/coupon'), name: 'coupon', - meta: { title: '优惠券管理', noCache: true } + meta: { + perms: ['GET /admin/coupon/list', 'POST /admin/coupon/create', 'POST /admin/coupon/update', 'POST /admin/coupon/delete'], + title: '优惠券管理', + noCache: true + } }, { path: 'couponDetail', component: () => import('@/views/promotion/couponDetail'), name: 'couponDetail', - meta: { title: '优惠券详情', noCache: true }, + meta: { + perms: ['GET /admin/coupon/list', 'GET /admin/coupon/listuser'], + title: '优惠券详情', + noCache: true + }, hidden: true }, { path: 'topic', component: () => import('@/views/promotion/topic'), name: 'topic', - meta: { title: '专题管理', noCache: true } + meta: { + perms: ['GET /admin/topic/list', 'POST /admin/topic/create', 'GET /admin/topic/read', 'POST /admin/topic/update', 'POST /admin/topic/delete'], + title: '专题管理', + noCache: true + } }, { path: 'groupon-rule', component: () => import('@/views/promotion/grouponRule'), name: 'grouponRule', - meta: { title: '团购规则', noCache: true } + meta: { + perms: ['GET /admin/groupon/list', 'POST /admin/groupon/create', 'POST /admin/groupon/update', 'POST /admin/groupon/delete'], + title: '团购规则', + noCache: true + } }, { path: 'groupon-activity', component: () => import('@/views/promotion/grouponActivity'), name: 'grouponActivity', - meta: { title: '团购活动', noCache: true } + meta: { + perms: ['GET /admin/groupon/listRecord'], + title: '团购活动', + noCache: true + } } ] }, @@ -267,6 +358,7 @@ export const asyncRouterMap = [ path: '/sys', component: Layout, redirect: 'noredirect', + alwaysShow: true, name: 'sysManage', meta: { title: '系统管理', @@ -277,19 +369,31 @@ export const asyncRouterMap = [ path: 'admin', component: () => import('@/views/sys/admin'), name: 'admin', - meta: { title: '管理员', noCache: true } + meta: { + perms: ['GET /admin/admin/list', 'POST /admin/admin/create', 'POST /admin/admin/update', 'POST /admin/admin/delete'], + title: '管理员', + noCache: true + } }, { path: 'role', component: () => import('@/views/sys/role'), name: 'role', - meta: { title: '角色管理', noCache: true } + meta: { + perms: ['GET /admin/role/list', 'POST /admin/role/create', 'POST /admin/role/update', 'POST /admin/role/delete', 'GET /admin/role/permissions', 'POST /admin/role/permissions'], + title: '角色管理', + noCache: true + } }, { path: 'os', component: () => import('@/views/sys/os'), name: 'os', - meta: { title: '对象存储', noCache: true } + meta: { + perms: ['GET /admin/os/list', 'POST /admin/os/create', 'POST /admin/os/update', 'POST /admin/os/delete'], + title: '对象存储', + noCache: true + } } ] }, @@ -298,6 +402,7 @@ export const asyncRouterMap = [ path: '/stat', component: Layout, redirect: 'noredirect', + alwaysShow: true, name: 'statManage', meta: { title: '统计', @@ -308,19 +413,31 @@ export const asyncRouterMap = [ path: 'user', component: () => import('@/views/stat/user'), name: 'statUser', - meta: { title: '用户统计', noCache: true } + meta: { + perms: ['GET /admin/stat/user'], + title: '用户统计', + noCache: true + } }, { path: 'order', component: () => import('@/views/stat/order'), name: 'statOrder', - meta: { title: '订单统计', noCache: true } + meta: { + perms: ['GET /admin/stat/order'], + title: '订单统计', + noCache: true + } }, { path: 'goods', component: () => import('@/views/stat/goods'), name: 'statGoods', - meta: { title: '商品统计', noCache: true } + meta: { + perms: ['GET /admin/stat/goods'], + title: '商品统计', + noCache: true + } } ] }, @@ -328,6 +445,7 @@ export const asyncRouterMap = [ path: 'external-link', component: Layout, redirect: 'noredirect', + alwaysShow: true, name: 'externalLink', meta: { title: '外链', @@ -368,6 +486,7 @@ export const asyncRouterMap = [ path: '/profile', component: Layout, redirect: 'noredirect', + alwaysShow: true, children: [ { path: 'password', diff --git a/litemall-admin/src/store/modules/permission.js b/litemall-admin/src/store/modules/permission.js index 23bf2008..bcdeea76 100644 --- a/litemall-admin/src/store/modules/permission.js +++ b/litemall-admin/src/store/modules/permission.js @@ -23,11 +23,15 @@ function filterAsyncRouter(routes, perms) { routes.forEach(route => { const tmp = { ...route } - if (hasPermission(perms, tmp)) { - if (tmp.children) { - tmp.children = filterAsyncRouter(tmp.children, perms) + if (tmp.children) { + tmp.children = filterAsyncRouter(tmp.children, perms) + if (tmp.children && tmp.children.length > 0) { + res.push(tmp) + } + } else { + if (hasPermission(perms, tmp)) { + res.push(tmp) } - res.push(tmp) } })