refactor: 重构项目结构
- 优化 `车站-设备-告警` 轮询机制 - 改进设备卡片的布局 - 支持修改设备 - 告警轮询中获取完整告警数据 - 车站告警详情支持导出完整的 `今日告警列表` - 支持将状态持久化到 `IndexedDB` - 新增轮询控制 (调试模式) - 新增离线开发模式 (调试模式) - 新增 `IndexedDB` 数据控制 (调试模式)
This commit is contained in:
75
src/router/index.ts
Normal file
75
src/router/index.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import { useUserStore } from '@/stores';
|
||||
import { createRouter, createWebHistory } from 'vue-router';
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(import.meta.env.BASE_URL),
|
||||
routes: [
|
||||
{
|
||||
path: '/login',
|
||||
component: () => import('@/pages/login-page.vue'),
|
||||
},
|
||||
{
|
||||
path: '/',
|
||||
component: () => import('@/layouts/app-layout.vue'),
|
||||
redirect: '/station',
|
||||
children: [
|
||||
{
|
||||
path: 'station',
|
||||
component: () => import('@/pages/station-page.vue'),
|
||||
},
|
||||
{
|
||||
path: 'device',
|
||||
component: () => import('@/pages/device-page.vue'),
|
||||
},
|
||||
{
|
||||
path: 'alarm',
|
||||
component: () => import('@/pages/alarm-page.vue'),
|
||||
},
|
||||
{
|
||||
path: 'log',
|
||||
children: [
|
||||
{
|
||||
path: 'vimp-log',
|
||||
component: () => import('@/pages/vimp-log-page.vue'),
|
||||
},
|
||||
{
|
||||
path: 'call-log',
|
||||
component: () => import('@/pages/call-log-page.vue'),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/:pathMatch(.*)*',
|
||||
component: () => import('@/pages/not-found-page.vue'),
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
router.beforeEach((to) => {
|
||||
const whiteList: string[] = [];
|
||||
const inWhiteList = whiteList.some((path) => to.path.startsWith(path));
|
||||
if (inWhiteList) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const userStore = useUserStore();
|
||||
const isAuthed = !!userStore.userLoginResult?.token;
|
||||
|
||||
if (to.path === '/login') {
|
||||
if (isAuthed) {
|
||||
return { path: '/' };
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (!isAuthed) {
|
||||
return { path: '/login' };
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export default router;
|
||||
Reference in New Issue
Block a user