test
Some checks failed
test / Run tests (push) Failing after 13s
build / Build (push) Failing after 21s

This commit is contained in:
王一之 2025-03-17 18:02:23 +08:00
parent 0a025f1b50
commit c8a8d136c8

View File

@ -175,6 +175,7 @@ function ScriptEditor() {
visible[key] = show;
setVisible({ ...visible });
};
const save = (script: Script, e: editor.IStandaloneCodeEditor): Promise<Script> => {
// 解析code生成新的script并更新
return new Promise((resolve) => {
@ -369,27 +370,42 @@ function ScriptEditor() {
if (uuid) {
for (let i = 0; i < scripts.length; i += 1) {
if (scripts[i].uuid === uuid) {
const code = await scriptCodeDAO.findByUUID(uuid);
editors.push({
// 如果已经打开则激活
scriptCodeDAO.findByUUID(uuid).then((code) => {
setEditors((prev) => {
const flag = prev.some((item) => item.script.uuid === scripts[i].uuid);
if (flag) {
return prev.map((item) => {
if (item.script.uuid === scripts[i].uuid) {
item.active = true;
item.code = code!.code;
} else {
item.active = false;
}
return item;
});
}
prev.push({
script: scripts[i],
code: code!.code,
active: true,
hotKeys,
isChanged: false,
});
return prev;
});
setSelectSciptButtonAndTab(scripts[i].uuid);
setEditors([...editors]);
});
break;
}
}
}
});
if (!uuid) {
} else {
emptyScript(template || "", hotKeys, target).then((e) => {
editors.push(e);
setEditors([...editors]);
});
}
});
}, []);
// 控制onbeforeunload