|
|
|
@@ -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;
|
|
|
|
|
};
|