refactor: 重构项目结构

- 优化 `车站-设备-告警`  轮询机制
- 改进设备卡片的布局
- 支持修改设备
- 告警轮询中获取完整告警数据
- 车站告警详情支持导出完整的 `今日告警列表`
- 支持将状态持久化到 `IndexedDB`
- 新增轮询控制 (调试模式)
- 新增离线开发模式 (调试模式)
- 新增 `IndexedDB` 数据控制 (调试模式)
This commit is contained in:
yangsy
2025-12-11 13:42:22 +08:00
commit 37781216b2
278 changed files with 17988 additions and 0 deletions

6
src/enums/alarm-type.ts Normal file
View File

@@ -0,0 +1,6 @@
export const ALARM_TYPES: Record<string, string> = {
'1': '设备告警',
'2': '环境告警',
'3': '性能告警',
'': '-',
};

47
src/enums/device-type.ts Normal file
View File

@@ -0,0 +1,47 @@
import type { Optional } from '@/types/util-type';
// 这个还决定了设备树组件的Tab顺序
export const DEVICE_TYPE_LITERALS = {
ndmCamera: 'ndmCamera',
ndmNvr: 'ndmNvr',
ndmSwitch: 'ndmSwitch',
ndmDecoder: 'ndmDecoder',
ndmSecurityBox: 'ndmSecurityBox',
ndmMediaServer: 'ndmMediaServer',
ndmVideoServer: 'ndmVideoServer',
ndmKeyboard: 'ndmKeyboard',
ndmAlarmHost: 'ndmAlarmHost',
} as const;
export type DeviceType = keyof typeof DEVICE_TYPE_LITERALS;
export const DEVICE_TYPE_CODES: Record<DeviceType, string[]> = {
[DEVICE_TYPE_LITERALS.ndmAlarmHost]: ['117'],
[DEVICE_TYPE_LITERALS.ndmCamera]: ['131', '132'],
[DEVICE_TYPE_LITERALS.ndmDecoder]: ['114'],
[DEVICE_TYPE_LITERALS.ndmKeyboard]: ['141'],
[DEVICE_TYPE_LITERALS.ndmMediaServer]: ['403'],
[DEVICE_TYPE_LITERALS.ndmNvr]: ['111', '118'],
[DEVICE_TYPE_LITERALS.ndmSecurityBox]: ['222'],
[DEVICE_TYPE_LITERALS.ndmSwitch]: ['220'],
[DEVICE_TYPE_LITERALS.ndmVideoServer]: ['401'],
} as const;
export const DEVICE_TYPE_NAMES: Record<DeviceType, string> = {
[DEVICE_TYPE_LITERALS.ndmAlarmHost]: '报警主机',
[DEVICE_TYPE_LITERALS.ndmCamera]: '网络摄像机',
[DEVICE_TYPE_LITERALS.ndmDecoder]: '解码器',
[DEVICE_TYPE_LITERALS.ndmKeyboard]: '网络键盘',
[DEVICE_TYPE_LITERALS.ndmMediaServer]: '媒体服务器',
[DEVICE_TYPE_LITERALS.ndmNvr]: '网络录像机',
[DEVICE_TYPE_LITERALS.ndmSecurityBox]: '智能安防箱',
[DEVICE_TYPE_LITERALS.ndmSwitch]: '交换机',
[DEVICE_TYPE_LITERALS.ndmVideoServer]: '视频服务器',
} as const;
export const tryGetDeviceType = (deviceTypeCode: Optional<string>) => {
if (!deviceTypeCode) return null;
const entry = Object.entries(DEVICE_TYPE_CODES).find(([, codes]) => codes.includes(deviceTypeCode));
if (!entry) return null;
return entry[0] as DeviceType;
};

7
src/enums/fault-level.ts Normal file
View File

@@ -0,0 +1,7 @@
export const FAULT_LEVELS: Record<string, string> = {
1: '严重',
2: '重要',
3: '一般',
4: '提示',
'': '-',
};

3
src/enums/index.ts Normal file
View File

@@ -0,0 +1,3 @@
export * from './alarm-type';
export * from './device-type';
export * from './fault-level';