index.ts
2.53 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import { createRouter, createWebHistory } from 'vue-router'
import { useAuthStore } from '@/stores/auth'
const router = createRouter({
history: createWebHistory(),
routes: [
{
path: '/login',
name: 'Login',
component: () => import('@/views/Login.vue'),
meta: { public: true },
},
{
path: '/',
component: () => import('@/layouts/MainLayout.vue'),
redirect: '/city',
children: [
{
path: 'city',
name: 'City',
component: () => import('@/views/city/CityList.vue'),
meta: { title: '城市管理' },
},
{
path: 'substation',
name: 'Substation',
component: () => import('@/views/substation/SubstationList.vue'),
meta: { title: '分站管理' },
},
{
path: 'merchant/enter',
name: 'MerchantEnter',
component: () => import('@/views/merchant/EnterList.vue'),
meta: { title: '入驻申请' },
},
{
path: 'merchant/store',
name: 'MerchantStore',
component: () => import('@/views/merchant/StoreList.vue'),
meta: { title: '店铺管理' },
},
{
path: 'rider',
name: 'Rider',
component: () => import('@/views/rider/RiderList.vue'),
meta: { title: '骑手管理' },
},
{
path: 'order',
name: 'Order',
component: () => import('@/views/order/OrderList.vue'),
meta: { title: '订单管理' },
},
{
path: 'refund',
name: 'Refund',
component: () => import('@/views/order/RefundList.vue'),
meta: { title: '退款管理' },
},
{
path: 'delivery/order',
name: 'DeliveryOrder',
component: () => import('@/views/delivery/DeliveryOrderList.vue'),
meta: { title: '配送订单' },
},
{
path: 'rider/evaluate',
name: 'RiderEvaluate',
component: () => import('@/views/rider/RiderEvaluateList.vue'),
meta: { title: '骑手评价' },
},
{
path: 'open',
name: 'OpenApp',
component: () => import('@/views/open/OpenAppList.vue'),
meta: { title: '开放平台' },
},
],
},
{ path: '/:pathMatch(.*)*', redirect: '/' },
],
})
router.beforeEach((to) => {
const auth = useAuthStore()
if (!to.meta.public && !auth.token) {
return { path: '/login' }
}
})
export default router