Add vue-router, login/setup flow and backend logging

Refactor frontend to route-based navigation with vue-router, add
system setup and login pages with API integration. Add structured
logging, access-log middleware and startup lifecycle to FastAPI
backend.
This commit is contained in:
2026-05-06 22:23:42 +08:00
parent 83d7da3d62
commit ae63766c91
35 changed files with 3762 additions and 404 deletions

110
web/src/router/index.js Normal file
View File

@@ -0,0 +1,110 @@
import { createRouter, createWebHistory } from 'vue-router'
import { appViews } from '../composables/useNavigation.js'
import { useSystemState } from '../composables/useSystemState.js'
import AppShellRouteView from '../views/AppShellRouteView.vue'
import LoginRouteView from '../views/LoginRouteView.vue'
import SetupRouteView from '../views/SetupRouteView.vue'
const appChildRoutes = appViews
.filter((view) => view !== 'requests')
.map((view) => ({
path: view,
name: `app-${view}`,
component: AppShellRouteView,
meta: {
requiresAuth: true,
appView: view
}
}))
const router = createRouter({
history: createWebHistory(),
routes: [
{
path: '/',
name: 'root',
redirect: () => {
const { resolveEntryRoute } = useSystemState()
return resolveEntryRoute()
}
},
{
path: '/setup',
name: 'setup',
component: SetupRouteView
},
{
path: '/login',
name: 'login',
component: LoginRouteView
},
{
path: '/app',
redirect: { name: 'app-overview' }
},
{
path: '/app/requests',
name: 'app-requests',
component: AppShellRouteView,
meta: {
requiresAuth: true,
appView: 'requests'
}
},
{
path: '/app/requests/:requestId',
name: 'app-request-detail',
component: AppShellRouteView,
meta: {
requiresAuth: true,
appView: 'requests'
}
},
...appChildRoutes.map((route) => ({
...route,
path: `/app/${route.path}`
})),
{
path: '/:pathMatch(.*)*',
redirect: '/'
}
]
})
router.beforeEach((to) => {
const { isInitialized, loggedIn, resolveEntryRoute } = useSystemState()
if (!isInitialized.value) {
if (to.name !== 'setup') {
return { name: 'setup' }
}
return true
}
if (to.name === 'setup') {
return resolveEntryRoute()
}
if (!loggedIn.value && to.meta.requiresAuth) {
return {
name: 'login',
query: {
redirect: to.fullPath
}
}
}
if (loggedIn.value && to.name === 'login') {
return resolveEntryRoute()
}
if (to.name === 'root') {
return resolveEntryRoute()
}
return true
})
export default router