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