Browse Source

更新hub插件库,提示没有链接方向盘

caner 2 years ago
parent
commit
457b8deade
3 changed files with 4 additions and 2 deletions
  1. 1 0
      electron/logiControl.js
  2. 2 1
      electron/main.js
  3. 1 1
      package.json

+ 1 - 0
electron/logiControl.js

@@ -3,6 +3,7 @@ let data = null
 try {
     const devices = HID.devices();
     const logitech = devices.filter(el => el.manufacturer === 'Logitech' && el.product.includes('G923'));
+    if(!logitech.length) throw '请链接罗技G923方向盘'
     data = new HID.HID(logitech[0].vendorId, logitech[0].productId);
     data.on('data', (db) => {
         if (process.connected) { process.send(db) } else {

+ 2 - 1
electron/main.js

@@ -134,7 +134,7 @@ class MainSerivce {
       if (evt === 'close-loading') {
         if (this.loadingWin) this.loadingWin.close()
         this.mainWin.show()
-        // if (this.mainWin.isVisible()) this.connectLogi()
+        if (this.mainWin.isVisible()) this.connectLogi()
       } else if (evt === 'minWin') {
         this.mainWin.minimize()
       } else if (evt === 'closeWin') {
@@ -199,6 +199,7 @@ class MainSerivce {
         this.contrlEvent = null
         dialog.showMessageBox(this.mainWin, { message: msg.text, type: 'error', title: '连接错误' }).then(async ({ response }) => {
           if (!response) {
+            if(msg.includes('请链接')) return
             await sleep(2000)
             this.connectLogi()
           }

+ 1 - 1
package.json

@@ -14,7 +14,7 @@
   },
   "dependencies": {
     "mqtt": "^5.0.4",
-    "node-hid": "^2.1.2"
+    "node-hid": "^3.0.0"
   },
   "devDependencies": {
     "@types/node": "^18.15.3",