前端重构 Vite

This commit is contained in:
2026-05-29 17:30:26 +08:00
parent cbd5d98993
commit 5bb9bc84ea
44 changed files with 7289 additions and 8769 deletions
+34
View File
@@ -0,0 +1,34 @@
import { createRouter, createWebHistory } from 'vue-router'
import { useAppStore } from '@/stores/app'
const router = createRouter({
history: createWebHistory(),
routes: [
{ path: '/', component: () => import('@/modules/home/HomeView.vue') },
{ path: '/login', component: () => import('@/modules/login/LoginView.vue') },
{ path: '/users', component: () => import('@/modules/users/UsersView.vue') },
{ path: '/moldinsight', component: () => import('@/modules/moldinsight/MoldInsightView.vue') },
{ path: '/moldinsight/result/:taskId', component: () => import('@/modules/moldinsight/ResultView.vue') },
{ path: '/inventory', component: () => import('@/modules/inventory/InventoryView.vue') },
{ path: '/_design-system', component: () => import('@/design-system/DesignSystemView.vue') },
{ path: '/_release', component: () => import('@/design-system/ReleaseView.vue') },
],
})
router.beforeEach((to, _from, next) => {
const publicPages = ['/login', '/_design-system', '/_release']
const authRequired = !publicPages.includes(to.path)
const store = useAppStore()
if (authRequired && !store.user) {
return next('/login')
}
if (to.path === '/login' && store.user) {
return next('/')
}
next()
})
export default router