feat(core): micropython 板卡文件管理 右键菜单添加 上传 和 下载 选项
This commit is contained in:
@@ -72,12 +72,12 @@ class AmpyFS extends FS {
|
||||
return [error, stdout];
|
||||
}
|
||||
|
||||
async readFile(filePath) {
|
||||
async readFile(filePath, encoding = 'utf8') {
|
||||
let stdout = '', error = null, ampy = null;
|
||||
try {
|
||||
ampy = await this.getAmpy();
|
||||
await ampy.enter();
|
||||
stdout = await ampy.get(filePath);
|
||||
stdout = await ampy.get(filePath, encoding);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
Debug.error(error);
|
||||
|
||||
@@ -211,7 +211,7 @@ class AmpyExt extends Ampy {
|
||||
this.#active_ = false;
|
||||
}
|
||||
|
||||
async get(filename, timeout = 5000) {
|
||||
async get(filename, encoding = 'utf8', timeout = 5000) {
|
||||
if (!this.isActive()) {
|
||||
throw new Error(Msg.Lang['ampy.portIsNotOpen']);
|
||||
}
|
||||
@@ -222,7 +222,11 @@ class AmpyExt extends Ampy {
|
||||
if (dataError) {
|
||||
return '';
|
||||
}
|
||||
return this.#device_.decode(this.unhexlify(data));
|
||||
if (encoding === 'utf8') {
|
||||
return this.#device_.decode(this.unhexlify(data));
|
||||
} else {
|
||||
return this.unhexlify(data);
|
||||
}
|
||||
}
|
||||
|
||||
async put(filename, data, timeout = 5000) {
|
||||
|
||||
@@ -57,8 +57,7 @@ File.open = async () => {
|
||||
const fileConfig = {
|
||||
multiple: false,
|
||||
types: File.getFileTypes(filters),
|
||||
excludeAcceptAllOption: true,
|
||||
multiple: false,
|
||||
excludeAcceptAllOption: true
|
||||
};
|
||||
try {
|
||||
const [ obj ] = await window.showOpenFilePicker(fileConfig);
|
||||
|
||||
Reference in New Issue
Block a user