From 51c5c19793682efac448b7a840c520ecb077eb7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=AB=8B=E5=B8=AE?= <3294713004@qq.com> Date: Thu, 6 Mar 2025 21:13:49 +0800 Subject: [PATCH] =?UTF-8?q?Fix:=20=E4=BF=AE=E5=A4=8D=E5=B9=B3=E6=9D=BF?= =?UTF-8?q?=E4=B8=8B=E6=8A=A5=E9=94=99instanceof=E6=9C=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/modules/mixly-modules/web/burn-upload.js | 4 ++-- common/modules/mixly-modules/web/serial.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/modules/mixly-modules/web/burn-upload.js b/common/modules/mixly-modules/web/burn-upload.js index 8c8c06db..74dc0d36 100644 --- a/common/modules/mixly-modules/web/burn-upload.js +++ b/common/modules/mixly-modules/web/burn-upload.js @@ -670,9 +670,9 @@ BU.uploadWithAmpy = (portName) => { const editor = mainWorkspace.getEditorsManager().getActive(); const port = Serial.getPort(portName); let useBuffer = true, dataLength = 256; - if (port instanceof window.USBDevice) { + if (port.constructor.name === 'USBDevice') { dataLength = 64; - } else if (port instanceof window.HIDDevice) { + } else if (port.constructor.name === 'HIDDevice') { dataLength = 31; } const layerNum = layer.open({ diff --git a/common/modules/mixly-modules/web/serial.js b/common/modules/mixly-modules/web/serial.js index b17035ee..4e3f0ac6 100644 --- a/common/modules/mixly-modules/web/serial.js +++ b/common/modules/mixly-modules/web/serial.js @@ -113,11 +113,11 @@ class WebSerial extends Serial { } this.getHandler = function (device) { - if (device instanceof window.SerialPort) { + if (device.constructor.name === 'SerialPort') { return SerialPort; - } else if (device instanceof window.HIDDevice) { + } else if (device.constructor.name === 'HIDDevice') { return HID; - } else if (device instanceof window.USBDevice) { + } else if (device.constructor.name === 'USBDevice') { if (this.devicesRegistry.hasKey('usbmini')) { return USBMini; } else {