57 lines
3.8 KiB
TypeScript
57 lines
3.8 KiB
TypeScript
/** 路由:登录守卫 + 主布局 */
|
|
import { createRouter, createWebHistory } from 'vue-router'
|
|
import { useAuthStore } from '../stores/auth'
|
|
|
|
const router = createRouter({
|
|
history: createWebHistory(),
|
|
routes: [
|
|
{ path: '/login', component: () => import('../views/LoginView.vue') },
|
|
{
|
|
path: '/',
|
|
component: () => import('../views/LayoutView.vue'),
|
|
children: [
|
|
{ path: '', redirect: '/dashboard' },
|
|
{ path: 'dashboard', component: () => import('../views/DashboardView.vue'), meta: { title: '工作台' } },
|
|
{ path: 'chart', component: () => import('../views/ReportView.vue'), meta: { title: '报表统计' } },
|
|
{ path: 'orders', component: () => import('../views/OrdersView.vue'), meta: { title: '订单管理' } },
|
|
{ path: 'sunny', component: () => import('../views/SunnyHouseView.vue'), meta: { title: '阳光房' } },
|
|
{ path: 'quotations', component: () => import('../views/QuotationsView.vue'), meta: { title: '报价单' } },
|
|
{ path: 'contracts', component: () => import('../views/ContractsView.vue'), meta: { title: '合同管理' } },
|
|
{ path: 'financial', component: () => import('../views/FinancialView.vue'), meta: { title: '财务管理' } },
|
|
{ path: 'customers', component: () => import('../views/CustomersView.vue'), meta: { title: '客户管理' } },
|
|
{ path: 'measure', component: () => import('../views/MeasureView.vue'), meta: { title: '量尺管理' } },
|
|
{ path: 'aftersale', component: () => import('../views/AfterSaleView.vue'), meta: { title: '售后管理' } },
|
|
{ path: 'templates', component: () => import('../views/TemplatesView.vue'), meta: { title: '样板库' } },
|
|
{ path: 'combine', component: () => import('../views/CombineView.vue'), meta: { title: '样板组合' } },
|
|
{ path: 'products', component: () => import('../views/ProductsView.vue'), meta: { title: '产品管理' } },
|
|
{ path: 'warehouse', component: () => import('../views/WarehouseView.vue'), meta: { title: '仓库库存' } },
|
|
{ path: 'optimize', component: () => import('../views/OptimizeView.vue'), meta: { title: '优化下料' } },
|
|
{ path: 'rendering', component: () => import('../views/RenderView.vue'), meta: { title: '效果图渲染' } },
|
|
{ path: 'ai_render', component: () => import('../views/AIRenderView.vue'), meta: { title: 'AI 炫图' } },
|
|
{ path: 'threed', component: () => import('../views/RenderView.vue'), meta: { title: '3D 展示' } },
|
|
{ path: 'printer', component: () => import('../views/PrinterView.vue'), meta: { title: '打印中心' } },
|
|
{ path: 'cut_solution', component: () => import('../views/CutSolutionView.vue'), meta: { title: '下料方案' } },
|
|
{ path: 'devices', component: () => import('../views/DevicesView.vue'), meta: { title: '设备管理' } },
|
|
{ path: 'market', component: () => import('../views/MarketView.vue'), meta: { title: '商城' } },
|
|
{ path: 'guide', component: () => import('../views/GuideView.vue'), meta: { title: '使用指南' } },
|
|
{ path: 'personal', component: () => import('../views/PersonalView.vue'), meta: { title: '个人中心' } },
|
|
],
|
|
},
|
|
{ path: '/share/order/:token', component: () => import('../views/ShareOrderView.vue') },
|
|
{ path: '/share/s/:token', component: () => import('../views/ShareView.vue') },
|
|
],
|
|
})
|
|
|
|
router.beforeEach(to => {
|
|
const auth = useAuthStore()
|
|
// 公开页:分享订单
|
|
if (to.path.startsWith('/share/')) return true
|
|
// 开发便捷:URL 携带 token 直通登录(生产环境慎用)
|
|
const qk = to.query.token as string | undefined
|
|
if (qk && !auth.isLogin) auth.setSession(qk, '游客')
|
|
if (to.path !== '/login' && !auth.isLogin) return '/login'
|
|
return true
|
|
})
|
|
|
|
export default router
|