
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@vanwei-wcs/device-utils
Advanced tools
🚀 wcs device的一些方法 🌈.
npm i @vanwei-wcs/device-utils
import { CountDeviceNumber } from ' @vanwei-wcs/device-utils'
const count = CountDeviceNumber(data.statistics)
console.log(count)
是wcs虚拟出来的类型,下面代码中的label表示名称、type表示基础类型、abilities表示该类型具有的能力集合
export const VirtualGroups = [
{ label: '下级域', type: 'port', abilities: []},
{ label: '区域', type: 'district', abilities: []},
{ label: '链接', type: 'link', abilities: []}
]
能够接入真实的设备类型,下面代码中的label表示名称,type表示基础类型,abilities表示该类型具有的能力集合
export const RealDevices: device[] = [
{ label: '网关', type: 'vbox', abilities: ['transcode']},
{ label: '网络录像机', type: 'NVR', abilities: ['record']},
{ label: '摄像头', type: 'IPC', abilities: ['video', 'transcode']},
{ label: '硬盘录像机', type: 'DVR', abilities: ['record']},
{ label: '门禁', type: 'AccessController', abilities: ['door']},
{ label: '人证机', type: 'IDCardReader', abilities: ['face']},
{ label: '一键报警设备', type: 'EmergencyAlarmer', abilities: ['alarm']},
{ label: '消防网关', type: 'FireGateway', abilities: []},
{ label: '物联网网关', type: 'IOTBox', abilities: []},
{ label: '混合硬盘录像机', type: 'HVR', abilities: []},
{ label: '视频服务器', type: 'DVS', abilities: []},
{ label: 'NVS设备', type: 'NVS', abilities: []},
{ label: '智能dvr', type: 'IVR', abilities: []},
{ label: '车载dvr', type: 'MVR', abilities: []},
{ label: '云台摄像头', type: 'IPC/IPDome', abilities: ['video', 'ptz']},
{ label: '红外摄像头', type: 'IPC/TII', abilities: ['video', 'thermal']},
{ label: '云台红外摄像头', type: 'IPC/TII/IPDome', abilities: ['video', 'ptz', 'thermal']},
{ label: '智能交通摄像机', type: 'IPC/ITC', abilities: ['video', 'door', 'car']},
{ label: '智能人脸相机', type: 'IPC/Face', abilities: ['video', 'face']},
// 兼容性要求,后续版本可能会删除
{ label: '道闸(弃用)', type: 'ITC', abilities: ['door']},
{ label: '红外摄像头(弃用)', type: 'TII/IPC', abilities: ['thermal']}
]
指设备树中设备的device_type的值,是由下面的DeviceTypePrefix的字段(除了masterText)和设备的基础类型组合而成(用/连接),另外有以下几点需要了解
group的都称为目录,类似于文件夹device/master的都称为主设备,是表示接入的设备本身,例如group/vbox表示网关目录,它的子级有device/master/vbox和一些其他的目录,这个device/master/vbox就表示网关本身,可以用来执行重启网关等操作device的都成为设备,目前一般情况下只有device/IPC开头的设备(表示摄像头的通道,一般用来播放视频)// 举例
// group
// group/port
// group/IPC/ITC
// group/AccessController
// device/IPC
// device/IPC/IPDome
// device/master/vbox
// device/master/IPC/Face
| 字段 | 说明 | 类型 | 值 |
|---|---|---|---|
| DeviceTypePrefix | wcs设备类型前缀 | Object | {group: 'group',device: 'device',masterText: 'master',master: 'device/master'} |
| AllBaseTypes | 全部类型数组 | Array | 打印以查看具体值 |
| VirtualGroups | 虚拟目录 | Array | |
| RealDevices | 真实设备 | Array | |
| GroupTypes | 虚拟目录和group组合之后的设备类型集合 | Array | |
| DeviceTypes | 真实设备和device组合之后的设备类型集合 | Array | |
| GroupDeviceTypes | GroupTypes和DeviceTypes的合集 | Array | |
| MasterDeviceTypes | 真实设备和device/master组合之后的设备类型集合 | Array | |
| RealDeviceTypes | 等于DeviceTypes | Array | |
| RealMasterDeviceTypes | 等于MasterDeviceTypes | Array | |
| RealGroupDeviceTypes | 真实设备和group组合之后的设备类型集合 | Array | |
| VirtualGroupTypes | 等于GroupTypes | Array |
| 方法 | 说明 | 参数 | 返回值 |
|---|---|---|---|
| GetBaseTypeByDeviceType | 获取设备类型的基础类型,例如 device/IPC -> IPC | deviceType:string | string |
| GetLabelByType | 根据设备基础类型获取设备label,例如 IPC -> 摄像头 | type:string | string |
| GetLabelByDeviceType | 获取设备类型的label, 例如 device/master/IPC -> 摄像头 | deviceType:string | string |
| GetLabelByMasterDeviceType | 获取设备类型的label,含有主设备标识 "(主)", 例如 device/master/IPC -> 摄像头(主) | deviceType:string | string |
| IsGroupType | 判断是否是目录 | deviceType:string | boolean |
| IsDeviceType | 判断是真实设备类型,含有device前缀 | deviceType:string | boolean |
| IsMasterDeviceType | 判断是主设备类型,含有device/master前缀 | deviceType:string | boolean |
| IsIPCDevice | 判断是摄像头类型,含有device/IPC | deviceType:string | boolean |
| GetDeviceTypesByAbility | 获取含有指定能力的真实设备类型集合(含设备类型前缀),参数ability表示能力,prefix表示返回时组合此前缀,默认为device | ability:string,prefix:string | Array |
| GetDeviceTypesByAbilities | 获取一种或多种能力的真实设备类型集合(含设备类型前缀),参数abilities表示能力字符数组,prefix表示返回时组合此前缀,默认为device | abilities:Array,prefix:string | Array |
| GetBaseTypesByAbility | 获取含有指定能力的真实设备基础类型集合,参数ability表示能力 | ability:string | Array |
| GetBaseTypesByAbilities | 获取一种或多种能力的真实设备基础类型集合,参数abilities表示能力字符数组 | abilities:Array | Array |
| CountDeviceNumber | 统计设备的子设备在线和总数,参数statistics为设备详情中的statistics字段 | statistics | {online,total} |
| GetDeviceIcon | 获取设备类型的icon字符,参数deviceType为设备类型,status为设备详情中的status字段,具体请参考文末的icon解释 | deviceType:string,status:string | string |
| HasChildGroup | 判断此设备类型的设备是否含有目录类型的子级 | deviceType:string | boolean |
| GetPathChain | 获取一个设备路径path的父级链路数组 | path:string | string[] |
| GetPathsChain | 获取多个设备路径path的父级链路数组 | path:string[] | string[] |
| IsValidPath | 获取多个设备路径path的父级链路数组 | path:string[] | string[] |
| GetParentPath | 判断设备路径是否符合规则 | path:string | boolean |
export default {
DeviceTypePrefix,
AllBaseTypes,
GroupTypes,
DeviceTypes,
MasterDeviceTypes,
GroupDeviceTypes,
RealDevices,
RealDeviceTypes,
RealMasterDeviceTypes,
RealGroupDeviceTypes,
VirtualGroups,
VirtualGroupTypes,
GetBaseTypeByDeviceType,
GetLabelByType,
GetLabelByDeviceType,
GetLabelByMasterDeviceType,
IsGroupType,
IsDeviceType,
IsMasterDeviceType,
IsIPCDevice,
GetDeviceTypesByAbility,
GetDeviceTypesByAbilities,
GetBaseTypesByAbility,
GetBaseTypesByAbilities,
CountDeviceNumber,
GetDeviceIcon,
HasChildGroup,
IsValidPath,
GetPathChain,
GetPathsChain,
GetParentPath
}
通过设备类型和状态来获取一个值,此值可以用来设置这个设备的图片或者图标
/**
* icon字符列表
*
* group 目录
* device_online 在线设备
* device_offline 离线设备
* box_online 在线网关
* box_offline 离线网关
* ipc_online 在线摄像头
* ipc_offline 离线摄像头
* ball_ipc_online 在线球机
* ball_ipc_offline 离线球机
* nvr_online 在线nvr
* nvr_offline 离线nvr
* device_master_online 在线主设备
* device_master_offline 离线主设备
* link 连接
* delete 已删除
*
*/
const icon = GetDeviceIcon('device/IPC')
const img_url = '/static/device_images/'+ icon + '.png'
// 对应参考图片在device_images文件夹里面,也可以自定义图片
FAQs
wcs device utils
We found that @vanwei-wcs/device-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.