diff --git a/mixly/common/modules/mixly-modules/web-socket/burn-upload.js b/mixly/common/modules/mixly-modules/web-socket/burn-upload.js index d6937575..4c94cb52 100644 --- a/mixly/common/modules/mixly-modules/web-socket/burn-upload.js +++ b/mixly/common/modules/mixly-modules/web-socket/burn-upload.js @@ -31,8 +31,8 @@ goog.loadJs('web', () => { const { SELECTED_BOARD, BOARD } = Config; - // 引入本地 Web.BU 模块,用于 MicroPython 本地上传 - const WebBU = Mixly.Web?.BU; + // WebBU 需要在使用时动态获取,避免模块加载顺序问题 + const getWebBU = () => Mixly.Web?.BU; const { Serial } = WebSocket; @@ -74,6 +74,7 @@ goog.loadJs('web', () => { this.initBurn = function () { // MicroPython 板卡使用本地 Web Serial API 烧录,而非通过服务器 + const WebBU = getWebBU(); if (SELECTED_BOARD?.language === 'MicroPython' && WebBU) { return WebBU.initBurn(); } @@ -111,6 +112,7 @@ goog.loadJs('web', () => { this.initUpload = function () { // MicroPython 板卡使用本地 Web Serial API 上传,而非通过服务器 + const WebBU = getWebBU(); if (SELECTED_BOARD?.language === 'MicroPython' && WebBU) { return WebBU.initUpload(); }