189 lines
4.8 KiB
JavaScript
189 lines
4.8 KiB
JavaScript
import { createRouter, createWebHistory } from 'vue-router'
|
|
import BasicLayout from '../layouts/BasicLayout.vue'
|
|
|
|
const routes = [
|
|
{
|
|
path: '/',
|
|
component: BasicLayout,
|
|
children: [
|
|
{
|
|
path: '',
|
|
redirect: '/dashboard'
|
|
},
|
|
{
|
|
path: '/dashboard',
|
|
name: 'Dashboard',
|
|
component: () => import('../views/dashboard/Dashboard.vue'),
|
|
meta: { title: '工作台' }
|
|
},
|
|
{
|
|
path: '/user/list',
|
|
name: 'UserList',
|
|
component: () => import('../views/user/UserList.vue'),
|
|
meta: { title: '用户列表' }
|
|
},
|
|
{
|
|
path: '/user/partner',
|
|
name: 'PartnerList',
|
|
component: () => import('../views/user/PartnerList.vue'),
|
|
meta: { title: '运营商管理' }
|
|
},
|
|
{
|
|
path: '/deliveryman/list',
|
|
name: 'DeliverymanList',
|
|
component: () => import('../views/deliveryman/List.vue'),
|
|
meta: { title: '配送员列表' }
|
|
},
|
|
{
|
|
path: '/community/list',
|
|
name: 'CommunityList',
|
|
component: () => import('../views/community/CommunityList.vue'),
|
|
meta: { title: '小区列表' }
|
|
},
|
|
{
|
|
path: '/coupon/template/list',
|
|
name: 'CouponTemplateList',
|
|
component: () => import('../views/coupon/TemplateList.vue'),
|
|
meta: { title: '优惠券模板' }
|
|
},
|
|
{
|
|
path: '/coupon/activity/list',
|
|
name: 'CouponActivityList',
|
|
component: () => import('../views/coupon/ActivityList.vue'),
|
|
meta: { title: '优惠券活动' }
|
|
},
|
|
{
|
|
path: '/community/building',
|
|
name: 'BuildingList',
|
|
component: () => import('../views/community/BuildingList.vue'),
|
|
meta: { title: '楼栋列表' }
|
|
},
|
|
{
|
|
path: 'community/station',
|
|
name: 'StationList',
|
|
component: () => import('../views/station/StationList.vue'),
|
|
meta: { title: '驿站列表' }
|
|
},
|
|
{
|
|
path: 'community/time-periods',
|
|
name: 'CommunityTimePeriods',
|
|
component: () => import('../views/community/TimePeriodList.vue'),
|
|
meta: { title: '小区配送时段' }
|
|
},
|
|
{
|
|
path: 'community/sets',
|
|
name: 'CommunitySets',
|
|
component: () => import('../views/community/CommunitySetList.vue'),
|
|
meta: { title: '小区集合' }
|
|
},
|
|
{
|
|
path: 'community/sets/:id',
|
|
name: 'CommunitySetDetail',
|
|
component: () => import('../views/community/CommunitySetDetail.vue'),
|
|
meta: { title: '小区集合详情' }
|
|
}
|
|
]
|
|
},
|
|
{
|
|
path: '/login',
|
|
name: 'login',
|
|
component: () => import('../views/login/Login.vue')
|
|
},
|
|
{
|
|
path: '/merchant',
|
|
component: BasicLayout,
|
|
children: [
|
|
{
|
|
path: 'list',
|
|
component: () => import('@/views/merchant/List.vue'),
|
|
meta: { title: '商家列表' }
|
|
},
|
|
{
|
|
path: 'categories',
|
|
component: () => import('@/views/merchant/CategoryList.vue'),
|
|
meta: { title: '商家分类' }
|
|
},
|
|
{
|
|
path: 'products',
|
|
component: () => import('@/views/merchant/ProductList.vue'),
|
|
meta: { title: '商品列表' }
|
|
}
|
|
]
|
|
},
|
|
{
|
|
path: '/system',
|
|
component: BasicLayout,
|
|
children: [
|
|
{
|
|
path: 'logs',
|
|
component: () => import('@/views/system/LogList.vue'),
|
|
meta: { title: '日志查询' }
|
|
},
|
|
{
|
|
path: 'config',
|
|
component: () => import('@/views/system/ConfigList.vue'),
|
|
meta: { title: '系统配置' }
|
|
},
|
|
{
|
|
path: 'time-periods',
|
|
component: () => import('@/views/system/TimePeriodList.vue'),
|
|
meta: { title: '时段配置' }
|
|
}
|
|
]
|
|
},
|
|
{
|
|
path: '/order',
|
|
component: BasicLayout,
|
|
children: [
|
|
{
|
|
path: 'delivery',
|
|
component: () => import('@/views/order/DeliveryList.vue'),
|
|
meta: { title: '配送订单' }
|
|
},
|
|
{
|
|
path: 'online',
|
|
component: () => import('@/views/order/OnlineList.vue'),
|
|
meta: { title: '买单订单' }
|
|
}
|
|
]
|
|
},
|
|
{
|
|
path: '/finance',
|
|
component: BasicLayout,
|
|
children: [
|
|
{
|
|
path: 'withdraw',
|
|
component: () => import('@/views/finance/WithdrawList.vue'),
|
|
meta: { title: '提现管理' }
|
|
}
|
|
]
|
|
}
|
|
]
|
|
|
|
const router = createRouter({
|
|
history: createWebHistory(),
|
|
routes
|
|
})
|
|
|
|
router.beforeEach((to, from, next) => {
|
|
const token = localStorage.getItem('token')
|
|
|
|
if (to.path === '/login') {
|
|
if (token) {
|
|
next('/')
|
|
} else {
|
|
next()
|
|
}
|
|
} else {
|
|
if (token) {
|
|
next()
|
|
} else {
|
|
next('/login')
|
|
}
|
|
}
|
|
|
|
document.title = to.meta.title ? `${to.meta.title} - 蜂快 · 运营管理系统` : '蜂快 · 运营管理系统'
|
|
next()
|
|
})
|
|
|
|
export default router
|