|
|
@@ -33,11 +33,18 @@ const router = createRouter({
|
|
|
path: '/storeDetail/:storeId',
|
|
|
name: 'storeDetail',
|
|
|
component: () => import('../views/portal/StoreDetail.vue'),
|
|
|
+ meta: {
|
|
|
+ title: '店铺详情'
|
|
|
+ }
|
|
|
},
|
|
|
{
|
|
|
path: '/staff/createProduct/:storeId',
|
|
|
name: 'createProduct',
|
|
|
component: () => import('../views/staff/CreateProduct.vue'),
|
|
|
+ meta: {
|
|
|
+ title: '创建商品',
|
|
|
+ permission: ['STAFF', 'MANAGER']
|
|
|
+ }
|
|
|
},
|
|
|
{
|
|
|
path: '/customer/coupon/',
|
|
|
@@ -53,30 +60,56 @@ const router = createRouter({
|
|
|
path: '/productDetail/:productId',
|
|
|
name: 'productDetail',
|
|
|
component: () => import('../views/portal/ProductDetail.vue'),
|
|
|
+ meta: {
|
|
|
+ title: '商品详情'
|
|
|
+ }
|
|
|
},
|
|
|
{
|
|
|
path: '/customer/buyProduct/:productId',
|
|
|
name: 'buyProduct',
|
|
|
component: () => import('../views/customer/BuyProduct.vue'),
|
|
|
+ meta: {
|
|
|
+ title: '购买商品',
|
|
|
+ permission: ['CUSTOMER']
|
|
|
+ }
|
|
|
},
|
|
|
{
|
|
|
path: '/customer/allOrder',
|
|
|
- name: 'bugProduct',
|
|
|
+ name: 'allOrder',
|
|
|
component: () => import('../views/customer/AllOrder.vue'),
|
|
|
+ meta: {
|
|
|
+ title: '全部订单',
|
|
|
+ permission: ['CUSTOMER']
|
|
|
+ }
|
|
|
},
|
|
|
{
|
|
|
path: '/manager/createStore',
|
|
|
+ name: 'createStore',
|
|
|
component: () => import('../views/manager/CreateStore.vue'),
|
|
|
+ meta: {
|
|
|
+ title: '创建店铺',
|
|
|
+ permission: ['MANAGER']
|
|
|
+ }
|
|
|
},
|
|
|
]
|
|
|
}]
|
|
|
})
|
|
|
|
|
|
router.beforeEach((to, from, next) => {
|
|
|
- const role = sessionStorage.getItem('token');
|
|
|
+ const token:string|null = sessionStorage.getItem('token');
|
|
|
+ const role:string|null = sessionStorage.getItem('role')
|
|
|
|
|
|
- if (role) {
|
|
|
- next();
|
|
|
+ if (token) {
|
|
|
+ if(to.meta.permission) {
|
|
|
+ if(to.meta.permission.includes(role!)) {
|
|
|
+ next();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ next('/allStore');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ next()
|
|
|
+ }
|
|
|
} else {
|
|
|
if(to.path === '/login') {
|
|
|
next();
|