From 27dd669932fce3e2ab04f66794db6baf93fb5e68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=AB=8B=E5=B8=AE?= <3294713004@qq.com> Date: Fri, 3 Oct 2025 13:13:13 +0800 Subject: [PATCH] =?UTF-8?q?fix(core):=20=E4=BF=AE=E5=A4=8D=E5=9C=A8?= =?UTF-8?q?=E7=BA=BF=E7=89=88ampy=E5=86=99=E6=96=87=E4=BB=B6=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/modules/mixly-modules/web/ampy.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/modules/mixly-modules/web/ampy.js b/common/modules/mixly-modules/web/ampy.js index db348eac..42de7be1 100644 --- a/common/modules/mixly-modules/web/ampy.js +++ b/common/modules/mixly-modules/web/ampy.js @@ -237,8 +237,10 @@ class AmpyExt extends Ampy { } await this.exec(`file = open('${filename}', 'wb')`, timeout); let buffer = null; - if (typeof data === 'string') { + if (data.constructor === String) { buffer = this.#device_.encode(data); + } else if (data.constructor === ArrayBuffer) { + buffer = new Uint8Array(data); } else { buffer = data; } @@ -255,7 +257,7 @@ class AmpyExt extends Ampy { } await this.exec(`file.write(b'${writeStr}')`, timeout); } - await this.exec(`file.close()`, timeout); + await this.exec('file.close()', timeout); } async ls(directory = '/', longFormat = true, recursive = false, timeout = 5000) {