mirror of
https://gitcode.com/JianFeeeee/ModelRouter.git
synced 2026-10-03 23:54:06 +00:00
fix(ui): 优先级页的保存/重置/添加按钮每次打开都被画布渲染冲掉
renderSortEditor 会整体替换 mount 的 innerHTML。per-key AUTO 弹窗的 mount 只有画布,覆写无害;但全局优先级页把 .card(连同里面装着工具栏的 h2)当 mount 传了进去,于是每次打开页面,画布一渲染就把工具栏删了。 症状很隐蔽:泳道和积木照常渲染、拖拽也正常,只是「保存排序」「重置」 「+ 添加档位」和聊天/生图切换全部消失 —— 优先级变得无从调整,也无从保存。 DOM 里数画布元素一切正常,只有量按钮的几何尺寸才看得见它没了。 修法:工具栏留在 .card 里,另给一个 #sort-mount 专供画布。per-key 弹窗 本来就是这个结构,无需改动。 判据 1 条,断言工具栏必须落在 #sort-mount 之外,且 renderSortEditor 必须 接收 #sort-mount 而不是 .card。变异(mount 改回 .card)判红。 生产 CDP 实测(真实点击,非仅 DOM 断言): 5 个按钮全部可见,坐标尺寸正常(保存排序 72x29) 画布 4 泳道 / 10 块 点击「保存排序」→ toast「排序已保存并热重载 · 链上冷却已复位」 切走再回来,按钮仍在位 Co-Authored-By: ModelRouter <noreply@modelrouter.dev>
This commit is contained in:
@ -3648,13 +3648,20 @@ recsState.keyNames = keyNames || {};
|
||||
sortState.origin = JSON.stringify(sortState.lanes);
|
||||
const kindToggle =
|
||||
`<div class="kind-toggle"><button class="${sortState.kind === "chat" ? "" : "ghost"} small" onclick="switchSortKind('chat')">${t("kChat") || "聊天"}</button><button class="${sortState.kind === "image" ? "" : "ghost"} small" onclick="switchSortKind('image')">${t("kImage") || "生图"}</button></div>`;
|
||||
// renderSortEditor replaces its mount wholesale, so the mount must be
|
||||
// the canvas slot ALONE. Passing the .card (which holds the h2 with the
|
||||
// save/reset/add buttons) used to wipe the toolbar on every open — the
|
||||
// lane canvas survived, the buttons did not. The per-key modal never hit
|
||||
// this because its mount only ever contained the canvas.
|
||||
$("#tab-sort").innerHTML = `
|
||||
<div class="card"><h2><span>${t("sortTitle")}</span><span class="grow"></span>${kindToggle}
|
||||
<div class="card">
|
||||
<h2><span>${t("sortTitle")}</span><span class="grow"></span>${kindToggle}
|
||||
<button class="ghost small" onclick="scrAddModal()">+ ${t("sortAdd")}</button>
|
||||
<button class="ghost small" onclick="sortReset()">${t("sortReset")}</button>
|
||||
<button class="small" onclick="saveSort()">${t("sortSave")}</button></h2>
|
||||
<button class="small" onclick="saveSort()">${t("sortSave")}</button></h2>
|
||||
<div id="sort-mount"></div>
|
||||
</div>`;
|
||||
renderSortEditor($("#tab-sort").querySelector(".card"), {
|
||||
renderSortEditor($("#sort-mount"), {
|
||||
canvasId: "scr-canvas",
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user