修改交管和信号交互插件加载时机

This commit is contained in:
ykkokluo
2026-08-25 08:59:00 +08:00
parent 134c7480b3
commit c5c1578696
25 changed files with 589 additions and 73 deletions
@@ -29,6 +29,7 @@ const routes: RouteRecordRaw[] = [
redirect: '/admin/dashboard',
children: [
{ path: 'dashboard', name: 'admin-dashboard', component: () => import('@/views/admin/DashboardView.vue'), meta: { title: '总览' } },
{ path: 'setup', name: 'admin-setup', component: () => import('@/views/admin/SetupChecklistView.vue'), meta: { title: '初始配置' } },
{ path: 'map-monitor', name: 'admin-map-monitor', component: () => import('@/views/admin/MapMonitorView.vue'), meta: { title: '地图监控' } },
{ path: 'tasks', name: 'admin-tasks', component: () => import('@/views/admin/TaskManagementView.vue'), meta: { title: '任务管理' } },
{ path: 'alarms', name: 'admin-alarms', component: () => import('@/views/admin/AlarmManagementView.vue'), meta: { title: '报警管理' } },
@@ -114,9 +115,33 @@ const router = createRouter({
routes
})
function safeRedirect(raw: unknown, fallback: string): string {
const redirect = Array.isArray(raw) ? raw[0] : raw
if (
typeof redirect === 'string' &&
redirect.startsWith('/') &&
!redirect.startsWith('//') &&
!redirect.startsWith('/login')
) {
return redirect
}
return fallback
}
router.beforeEach(async (to) => {
const auth = useAuthStore()
if (to.meta.public) return true
if (to.meta.public) {
// 已登录再进登录页:直接送去向导 / 业务页,避免「登录成功仍停在 /login」。
if (to.name === 'login' && auth.isAuthed) {
if (!auth.validated) {
try { await auth.validate() } catch { return true }
}
if (auth.needsWizard) return { name: 'wizard' }
const fallback = auth.scope === 'RCSMonitor' ? '/monitor/map' : '/admin/dashboard'
return { path: safeRedirect(to.query.redirect, fallback) }
}
return true
}
if (!auth.isAuthed) {
return { path: '/login', query: { redirect: to.fullPath } }
}