export const DeviceType = { Camera: 'ndmCamera', Nvr: 'ndmNvr', Switch: 'ndmSwitch', Decoder: 'ndmDecoder', SecurityBox: 'ndmSecurityBox', MediaServer: 'ndmMediaServer', VideoServer: 'ndmVideoServer', Keyboard: 'ndmKeyboard', AlarmHost: 'ndmAlarmHost', } as const; export type DeviceTypeKey = keyof typeof DeviceType; export type DeviceTypeVal = (typeof DeviceType)[DeviceTypeKey]; export const DeviceTypeCode: Record = { [DeviceType.Camera]: ['131', '132'], [DeviceType.Nvr]: ['111', '118'], [DeviceType.Switch]: ['220'], [DeviceType.Decoder]: ['114'], [DeviceType.SecurityBox]: ['222'], [DeviceType.MediaServer]: ['403'], [DeviceType.VideoServer]: ['401'], [DeviceType.Keyboard]: ['141'], [DeviceType.AlarmHost]: ['117'], }; export const DeviceTypeName: Record = { [DeviceType.Camera]: '摄像机', [DeviceType.Nvr]: '网络录像机', [DeviceType.Switch]: '交换机', [DeviceType.Decoder]: '解码器', [DeviceType.SecurityBox]: '智能安防箱', [DeviceType.MediaServer]: '媒体服务器', [DeviceType.VideoServer]: '视频服务器', [DeviceType.Keyboard]: '网络键盘', [DeviceType.AlarmHost]: '报警主机', }; /** * @deprecated */ export const getDeviceTypeVal = (deviceTypeCode?: string): DeviceTypeVal => { let result: DeviceTypeVal = DeviceType.Camera; if (deviceTypeCode) { for (const key in DeviceTypeCode) { if (DeviceTypeCode[key as DeviceTypeVal].includes(deviceTypeCode)) { result = key as DeviceTypeVal; break; } } } return result; }; export const tryGetDeviceTypeVal = (deviceTypeCode?: string) => { if (!deviceTypeCode) return undefined; const entry = Object.entries(DeviceTypeCode).find(([, codes]) => codes.includes(deviceTypeCode)); return entry?.[0] as DeviceTypeVal | undefined; };