2026-08-28 15:06:01 +08:00
|
|
|
import { createRouter, createWebHistory } from 'vue-router'
|
|
|
|
|
import MainLayout from '../layouts/MainLayout.vue'
|
|
|
|
|
|
|
|
|
|
const routes = [
|
|
|
|
|
{ path: '/login', name: 'Login', component: () => import('../pages/Login.vue'), meta: { title: '登录' } },
|
|
|
|
|
// 免登录大屏:全屏无侧栏
|
|
|
|
|
{ path: '/display', name: 'Display', component: () => import('../pages/Display.vue'), meta: { title: '库存大屏' } },
|
|
|
|
|
{
|
|
|
|
|
path: '/',
|
|
|
|
|
component: MainLayout,
|
|
|
|
|
children: [
|
|
|
|
|
{ path: '', name: 'Dashboard', component: () => import('../pages/Dashboard.vue'), meta: { title: '工作台' } },
|
|
|
|
|
{ path: 'inbound', name: 'Inbound', component: () => import('../pages/Inbound.vue'), meta: { title: '入库管理' } },
|
|
|
|
|
{ path: 'outbound', name: 'Outbound', component: () => import('../pages/Outbound.vue'), meta: { title: '备料出库' } },
|
|
|
|
|
{ path: 'inventory', name: 'Inventory', component: () => import('../pages/Inventory.vue'), meta: { title: '库存查询' } },
|
|
|
|
|
{ path: 'inspection', name: 'Inspection', component: () => import('../pages/Inspection.vue'), meta: { title: '质量检验' } },
|
|
|
|
|
{ path: 'stocktake', name: 'Stocktake', component: () => import('../pages/Stocktake.vue'), meta: { title: '库存盘点' } },
|
|
|
|
|
{ path: 'semi', name: 'Semi', component: () => import('../pages/Semi.vue'), meta: { title: '半成品/成品' } },
|
2026-09-01 13:49:44 +08:00
|
|
|
{ path: 'package', name: 'Package', component: () => import('../pages/Package.vue'), meta: { title: '装箱管理' } },
|
2026-08-29 15:30:25 +08:00
|
|
|
{ path: 'ledger', name: 'Ledger', component: () => import('../pages/Ledger.vue'), meta: { title: '备料台账' } },
|
2026-08-31 12:58:28 +08:00
|
|
|
{ path: 'base-data', name: 'BaseData', component: () => import('../pages/BaseData.vue'), meta: { title: '基础数据' } },
|
|
|
|
|
{ path: 'change-password', name: 'ChangePassword', component: () => import('../pages/ChangePassword.vue'), meta: { title: '修改密码' } }
|
2026-08-28 15:06:01 +08:00
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{ path: '/:pathMatch(.*)*', redirect: '/' }
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
const router = createRouter({
|
|
|
|
|
history: createWebHistory(),
|
|
|
|
|
routes
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// 路由守卫:除 /login 和 /display 外校验 token
|
|
|
|
|
router.beforeEach((to) => {
|
|
|
|
|
if (to.path !== '/login' && to.path !== '/display' && !to.path.startsWith('/display')) {
|
|
|
|
|
if (!localStorage.getItem('token')) {
|
|
|
|
|
return { path: '/login', query: to.fullPath ? { redirect: to.fullPath } : {} }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
router.afterEach((to) => {
|
2026-08-29 15:30:25 +08:00
|
|
|
document.title = to.meta?.title ? `${to.meta.title} - 库房客户端` : '库房客户端'
|
2026-08-28 15:06:01 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export default router
|