feat(core): micropython 板卡文件管理 右键菜单添加 上传下载 选项

This commit is contained in:
王立帮
2025-08-21 21:40:18 +08:00
parent 4a45323c82
commit 30f3da24b1
11 changed files with 171 additions and 14 deletions

View File

@@ -54,12 +54,16 @@ class AmpyFS extends FS {
return [error, stdout];
}
async readFile(filePath) {
async readFile(filePath, encoding = 'utf8') {
let stdout = '', error = null;
try {
const output = await this.#ampy_.get(this.#port_, this.#baud_, filePath);
stdout = output.stdout;
stdout = this.#decoder_.decode(this.#ampy_.unhexlify(stdout));
if (encoding = 'utf8') {
stdout = this.#decoder_.decode(this.#ampy_.unhexlify(stdout));
} else {
stdout = this.#ampy_.unhexlify(stdout);
}
} catch (e) {
error = e;
Debug.error(error);
@@ -71,6 +75,9 @@ class AmpyFS extends FS {
let stdout = '', error = null;
try {
const startFilePath = path.join(Env.clientPath, 'temp/temp');
if (data.constructor.name === 'ArrayBuffer') {
data = Buffer.from(data);
}
await fs_extra.outputFile(startFilePath, data);
const output = await this.#ampy_.put(this.#port_, this.#baud_, startFilePath, filePath);
stdout = output.stdout;