Merge branch 'main' of http://it.fairylandtech.com:8666/Third_Dev_Dept/Migu2.0
This commit is contained in:
@@ -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: '报警管理' } },
|
||||
@@ -42,6 +43,13 @@ const routes: RouteRecordRaw[] = [
|
||||
{ path: 'wcs-template-proto', name: 'admin-wcs-template-proto', component: () => import('@/views/admin/WcsTemplateProtoView.vue'), meta: { title: 'WCS模板引擎原型' } },
|
||||
{ path: 'simple-fields', name: 'admin-simple-fields', component: () => import('@/views/admin/SimpleFieldManagementView.vue'), meta: { title: '字段管理' } },
|
||||
{ path: 'project-properties', name: 'admin-project-properties', component: () => import('@/views/admin/ProjectPropertiesView.vue'), meta: { title: '项目属性' } },
|
||||
{ path: 'data-center', redirect: '/admin/data-center/stations' },
|
||||
{
|
||||
path: 'data-center/:tableId',
|
||||
name: 'admin-data-center',
|
||||
component: () => import('@/views/admin/DataCenterView.vue'),
|
||||
meta: { title: '数据中心' }
|
||||
},
|
||||
// ── 平台配置中心:聚合页 + 独立业务页(page key = route.name,对齐后端 PageCatalog)。 ──
|
||||
{ path: 'config/strategy', name: 'admin-config-strategy', component: () => import('@/views/admin/config/StrategyConfigView.vue'), meta: { title: '调度策略' } },
|
||||
{ path: 'config/vehicle-hub', name: 'admin-vehicle-hub', component: () => import('@/views/shared/VehicleHubView.vue'), meta: { title: '车辆运维' } },
|
||||
@@ -108,9 +116,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 } }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user