From cb10d07f2260588bab5e6ba5fa2f39f4e42d1a48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=AB=8B=E5=B8=AE?= <3294713004@qq.com> Date: Sat, 26 Jul 2025 15:31:17 +0800 Subject: [PATCH] =?UTF-8?q?fix(core):=20=E4=BF=AE=E5=A4=8Dgoog.platform?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E7=A7=BB=E5=8A=A8=E7=AB=AF=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E5=88=A4=E5=AE=9A=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../micropython_esp32c2/origin/config.json | 27 ++++++++++++++++--- common/main.js | 4 +-- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/boards/default_src/micropython_esp32c2/origin/config.json b/boards/default_src/micropython_esp32c2/origin/config.json index 0600af7d..4c4b8d58 100644 --- a/boards/default_src/micropython_esp32c2/origin/config.json +++ b/boards/default_src/micropython_esp32c2/origin/config.json @@ -70,9 +70,30 @@ "pythonToBlockly": false, "web": { "devices": { - "serial": true, - "hid": true, - "usb": true + "serial": { + "filters": [ + { + "usbVendorId": 6790, + "usbProductId": 65036 + } + ] + }, + "hid": { + "filters": [ + { + "vendorId": 6790, + "productId": 65036 + } + ] + }, + "usb": { + "filters": [ + { + "vendorId": 6790, + "productId": 65036 + } + ] + } }, "burn": { "erase": true, diff --git a/common/main.js b/common/main.js index 575fb230..38db5671 100644 --- a/common/main.js +++ b/common/main.js @@ -77,7 +77,7 @@ LazyLoad.js([ goog.platform = () => { const userAgent = navigator.userAgent; - if (!navigator.serial) return 'mobile'; + if (!navigator.hid) return 'mobile'; if (userAgent.indexOf('Windows NT') !== -1) return 'win32'; if (userAgent.indexOf('Mac') !== -1) return 'darwin'; if (userAgent.indexOf('X11') !== -1) return 'linux'; @@ -96,7 +96,7 @@ LazyLoad.js([ else if (userAgent.indexOf('Windows NT 6.1') != -1) os = 'win7'; else if (userAgent.indexOf('Windows NT 6.0') != -1) os = 'winvista'; else if (userAgent.indexOf('Windows NT 5.1') != -1) os = 'winxp'; - } else if (!navigator.serial) { + } else if (!navigator.hid) { os = 'android'; } else if (platform.includes('iphone') || platform.includes('ipad') || platform.includes('ipod')) { os = 'ios';