编辑器体验改进
- 导入文件后直接关闭弹窗 + toast 提示导入数量 - 自动布局改为按出口顺序的子树居中:选项1/2/3 分支顺序正确且对齐
This commit is contained in:
@ -210,14 +210,16 @@
|
||||
}
|
||||
|
||||
$("import-do").onclick = async () => {
|
||||
$("import-result").classList.add("err"); $("import-result").style.color = "";
|
||||
$("import-result").textContent = "";
|
||||
let events;
|
||||
try { events = await collectImportEvents(); } catch (e) { $("import-result").textContent = e.message; return; }
|
||||
if (!events.length) { $("import-result").textContent = "请先选择文件或粘贴 JSON"; return; }
|
||||
const r = await api("/api/import", { method: "POST", body: JSON.stringify({ events, by: App.by }) });
|
||||
const d = await r.json();
|
||||
$("import-result").textContent = "已导入 " + (d.saved || []).length + " 个" + ((d.errors || []).length ? "," + d.errors.join(";") : "");
|
||||
importFiles = []; renderImportFiles(); $("import-text").value = "";
|
||||
$("import-modal").classList.add("hidden"); // 导入完直接关闭
|
||||
const ne = (d.errors || []).length;
|
||||
toast("已导入 " + (d.saved || []).length + " 个事件" + (ne ? "," + ne + " 个跳过/出错" : ""));
|
||||
await loadList();
|
||||
};
|
||||
|
||||
@ -241,6 +243,14 @@
|
||||
|
||||
// ---------- 工具 ----------
|
||||
function esc(s) { return String(s == null ? "" : s).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"); }
|
||||
let toastTimer = null;
|
||||
function toast(msg) {
|
||||
let el = $("toast");
|
||||
if (!el) { el = document.createElement("div"); el.id = "toast"; document.body.appendChild(el); }
|
||||
el.textContent = msg; el.classList.add("show");
|
||||
clearTimeout(toastTimer);
|
||||
toastTimer = setTimeout(() => el.classList.remove("show"), 2600);
|
||||
}
|
||||
|
||||
// ---------- 画布工具栏 ----------
|
||||
$("btn-autolayout").onclick = () => {
|
||||
|
||||
Reference in New Issue
Block a user