refactor: extend device-type.ts
This commit is contained in:
@@ -1,17 +1,28 @@
|
||||
export const DeviceType = {
|
||||
Camera: '132',
|
||||
Nvr: '118',
|
||||
Switch: '220',
|
||||
Decoder: '114',
|
||||
SecurityBox: '222',
|
||||
MediaServer: '403',
|
||||
VideoServer: '401',
|
||||
Keyboard: '141',
|
||||
Camera: 'ndmCamera',
|
||||
Nvr: 'ndmNvr',
|
||||
Switch: 'ndmSwitch',
|
||||
Decoder: 'ndmDecoder',
|
||||
SecurityBox: 'ndmSecurityBox',
|
||||
MediaServer: 'ndmMediaServer',
|
||||
VideoServer: 'ndmVideoServer',
|
||||
Keyboard: 'ndmKeyboard',
|
||||
} as const;
|
||||
|
||||
export type DeviceTypeKey = keyof typeof DeviceType;
|
||||
export type DeviceTypeVal = (typeof DeviceType)[DeviceTypeKey];
|
||||
|
||||
export const DeviceTypeCode: Record<DeviceTypeVal, string[]> = {
|
||||
[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'],
|
||||
};
|
||||
|
||||
export const DeviceTypeName: Record<DeviceTypeVal, string> = {
|
||||
[DeviceType.Camera]: '摄像机',
|
||||
[DeviceType.Nvr]: '网络录像机',
|
||||
@@ -22,3 +33,16 @@ export const DeviceTypeName: Record<DeviceTypeVal, string> = {
|
||||
[DeviceType.VideoServer]: '视频服务器',
|
||||
[DeviceType.Keyboard]: '网络键盘',
|
||||
};
|
||||
|
||||
export const getDeviceTypeVal = (devcieTypeCode?: string): DeviceTypeVal => {
|
||||
let result: DeviceTypeVal = DeviceType.Camera;
|
||||
if (devcieTypeCode) {
|
||||
for (const key in DeviceTypeCode) {
|
||||
if (DeviceTypeCode[key as DeviceTypeVal].includes(devcieTypeCode)) {
|
||||
result = key as DeviceTypeVal;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user