# web-hardware-plugin **Repository Path**: freereinnew/web-hardware-plugin ## Basic Information - **Project Name**: web-hardware-plugin - **Description**: 网页端通过websoket调用本地电脑的硬件设备,电子秤,打印机 - **Primary Language**: C# - **License**: AFL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 4 - **Created**: 2021-11-27 - **Last Updated**: 2025-01-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # web-hardware-plugin #### 介绍 网页端通过websoket调用本地电脑的硬件设备,电子秤,打印机 #### 软件架构 软件架构说明 网页硬件插件主要使用c#的websocket双向通信,试试获取串口数据。前端调用相应的消息,获取相应硬件的数据 #### 使用说明 本地前端通过:ws://127.0.0.1:5000 开启websocket并获取后端的硬件数据 示例: // messageType: { // type: String, // default: 'Print' // Print:打印,ElectronicScale:电子秤,PrintDevice:获取本机的打印机设备,SerialPort:获取本机驱动的端口 // }, // dataType: { // type: String, // default: 'File' // File:文件,Url:网址,Html:html // }, // fileType: { // type: String, // default: 'PDF' // NONE:空,PDF:pdf文件,IMG:图片文件,dataType为File/Url时,必须指定文件类型是pdf还是img // }, // body: { // type: String, // default: '' // 打印内容 // }, // device: { // type: String, // default: '' // 打印设备,不填写,使用后台设置打印机 // }, // printQty: { // type: Number, // default: 1 // 打印1份 // }, // width: { // type: Number, // default: 0 // 宽度cm:不填写默认使用当前文档的宽度 // }, // height: { // type: Number, // default: 0 // 高度cm:不填写默认使用当前文档的高度 // }, 1.js请求body const data = { messageType: this.messageType, content: { dataType: this.dataType, fileType: this.fileType, body: body, device: this.device, printQty: this.printQty, width: this.width, height: this.height } }; const json = JSON.stringify(data); this.webSocket.send(json);