fix: core template engine and upload params to resolve Syntax error

This commit is contained in:
yczpf2019
2026-01-24 19:37:52 +08:00
parent ec4814c208
commit ef98c5e89f
4 changed files with 313 additions and 331 deletions

View File

@@ -1,21 +0,0 @@
import os
import json
boards_dir = r"D:\DE-MIXLY\mixly3-server\mixly\boards"
for root, dirs, files in os.walk(boards_dir):
for file in files:
if file == "config.json":
file_path = os.path.join(root, file)
try:
with open(file_path, "r", encoding="utf-8") as f:
content = f.read()
new_content = content.replace('\\"{esptool}\\"', '{esptool}').replace('\\"{ampy}\\"', '{ampy}')
if content != new_content:
print(f"Fixing: {file_path}")
with open(file_path, "w", encoding="utf-8") as f:
f.write(new_content)
except Exception as e:
print(f"Error processing {file_path}: {e}")

View File

@@ -154,8 +154,7 @@ class WebSocketBU {
statusBarTerminal.addValue(`\n==${message}==\n`);
} else {
message = (this.shell.isBurning() ? Msg.Lang['shell.burnSucc'] : Msg.Lang['shell.uploadSucc']);
statusBarTerminal.addValue(`\n==${message}(${Msg.Lang['shell.timeCost']} ${
dayjs.duration(time).format('HH:mm:ss.SSS')
statusBarTerminal.addValue(`\n==${message}(${Msg.Lang['shell.timeCost']} ${dayjs.duration(time).format('HH:mm:ss.SSS')
})==\n`);
}
layer.msg(message, { time: 1000 });
@@ -194,7 +193,9 @@ class WebSocketBU {
const config = {
boardDirPath: `.${Env.boardDirPath}`,
port,
command: SELECTED_BOARD.burn.command
command: SELECTED_BOARD.burn.command,
baudrate: Boards.getSelectedBoardConfigParam('BurnSpeed'),
reset: SELECTED_BOARD.burn.reset || []
};
const mixlySocket = WebSocketBU.getMixlySocket();
mixlySocket.emit('micropython.burn', config, (response) => {
@@ -230,6 +231,8 @@ class WebSocketBU {
boardDirPath: `.${Env.boardDirPath}`,
command: SELECTED_BOARD.upload.command,
filePath: SELECTED_BOARD.upload.filePath,
baudrate: Boards.getSelectedBoardConfigParam('BurnSpeed'),
reset: SELECTED_BOARD.upload.reset || [],
port, code, libraries
};

View File

@@ -17,7 +17,7 @@ MString.tpl = (str, obj) => {
return str;
}
for (let key in obj) {
let re = new RegExp(`{*${key}*}`, 'gim');
let re = new RegExp(`{${key}}`, 'gm');
str = str.replace(re, obj[key]);
}
return str;

View File

@@ -14,7 +14,7 @@ export default class ShellMicroPython extends Shell {
indexPath: path.resolve(CLIENT_PATH, config.boardDirPath),
esptool: `"${PYTHON.path.cli}" "${MICROPYTHON.path.esptool}"`,
com: config.port,
baudrate: config.baudRates
baudrate: config.baudrate || "460800"
};
// 兼容性处理:移除模板中可能存在的冗余引号
let cmdTemplate = config.command || "";
@@ -29,7 +29,7 @@ export default class ShellMicroPython extends Shell {
indexPath: path.resolve(CLIENT_PATH, config.boardDirPath),
ampy: `"${PYTHON.path.cli}" "${MICROPYTHON.path.ampy}"`,
com: config.port,
reset: config.reset || ""
reset: config.reset || "[]"
};
// 兼容性处理:移除模板中可能存在的冗余引号
let cmdTemplate = config.command || "";