snack-mall/admin-snack/src/router/index.ts

149 lines
4.1 KiB
TypeScript

import { createRouter, createWebHistory } from 'vue-router'
const router = createRouter({
history: createWebHistory(),
scrollBehavior: () => ({ left: 0, top: 0 }),
routes: [
// ==================== 公开路由 ====================
{
path: '/login',
name: 'Login',
component: () => import('@/views/login/index.vue'),
meta: { title: '登录', hidden: true }
},
{
path: '/404',
name: 'NotFound',
component: () => import('@/views/error/404.vue'),
meta: { title: '404', hidden: true }
},
// ==================== 仪表盘 ====================
{
path: '/',
component: () => import('@/layouts/BasicLayout.vue'),
redirect: '/dashboard',
children: [
{
path: '/dashboard',
name: 'Dashboard',
component: () => import('@/views/dashboard/index.vue'),
meta: { title: '仪表盘', icon: 'Odometer', keepAlive: true }
}
]
},
// ==================== 商品管理 ====================
{
path: '/product',
component: () => import('@/layouts/BasicLayout.vue'),
redirect: '/product/list',
meta: { title: '商品管理', icon: 'Goods' },
children: [
{
path: '/product/list',
name: 'ProductList',
component: () => import('@/views/product/list.vue'),
meta: { title: '商品列表', icon: 'List' }
},
{
path: '/product/category',
name: 'ProductCategory',
component: () => import('@/views/product/category.vue'),
meta: { title: '商品分类', icon: 'Menu' }
}
]
},
// ==================== 订单管理 ====================
{
path: '/order',
component: () => import('@/layouts/BasicLayout.vue'),
redirect: '/order/list',
children: [
{
path: '/order/list',
name: 'OrderList',
component: () => import('@/views/order/list.vue'),
meta: { title: '订单管理', icon: 'Document' }
}
]
},
// ==================== 用户管理 ====================
{
path: '/user',
component: () => import('@/layouts/BasicLayout.vue'),
redirect: '/user/list',
children: [
{
path: '/user/list',
name: 'UserList',
component: () => import('@/views/user/list.vue'),
meta: { title: '用户管理', icon: 'User' }
}
]
},
// ==================== 营销管理 ====================
{
path: '/marketing',
component: () => import('@/layouts/BasicLayout.vue'),
redirect: '/marketing/coupon',
meta: { title: '营销管理', icon: 'Present' },
children: [
{
path: '/marketing/coupon',
name: 'CouponList',
component: () => import('@/views/coupon/list.vue'),
meta: { title: '优惠券', icon: 'Ticket' }
},
{
path: '/marketing/seckill',
name: 'SeckillList',
component: () => import('@/views/seckill/list.vue'),
meta: { title: '限时抢购', icon: 'AlarmClock' }
}
]
},
// ==================== 系统公告 ====================
{
path: '/notice',
component: () => import('@/layouts/BasicLayout.vue'),
redirect: '/notice/list',
children: [
{
path: '/notice/list',
name: 'NoticeList',
component: () => import('@/views/notice/list.vue'),
meta: { title: '系统公告', icon: 'Bell' }
}
]
},
// ==================== 客服消息 ====================
{
path: '/chat',
component: () => import('@/layouts/BasicLayout.vue'),
redirect: '/chat/list',
children: [
{
path: '/chat/list',
name: 'ChatList',
component: () => import('@/views/chat/list.vue'),
meta: { title: '客服消息', icon: 'ChatDotRound' }
}
]
},
// ==================== 404 兜底(放最后) ====================
{
path: '/:pathMatch(.*)*',
redirect: '/404'
}
]
})
export default router