fix(shell-micropython): 修复 reset 数组参数序列化导致的引号错误

This commit is contained in:
yczpf2019
2026-01-24 19:57:25 +08:00
parent ed9264bd70
commit cc550ec5cc

View File

@@ -25,11 +25,19 @@ export default class ShellMicroPython extends Shell {
}
async upload(config) {
// 正确处理 reset 参数:如果是数组则序列化为 JSON 字符串
let resetValue = config.reset;
if (Array.isArray(resetValue)) {
resetValue = JSON.stringify(resetValue);
} else if (resetValue === undefined || resetValue === null) {
resetValue = '[]';
}
const info = {
indexPath: path.resolve(CLIENT_PATH, config.boardDirPath),
ampy: `"${PYTHON.path.cli}" "${MICROPYTHON.path.ampy}"`,
com: config.port,
reset: config.reset || "[]"
reset: resetValue
};
// 兼容性处理:移除模板中可能存在的冗余引号
let cmdTemplate = config.command || "";