diff --git a/ui/index.html b/ui/index.html index 1031952..9445750 100644 --- a/ui/index.html +++ b/ui/index.html @@ -845,6 +845,6 @@

使用模型

- + diff --git a/ui/js/app.js b/ui/js/app.js index de3ea03..e1af207 100644 --- a/ui/js/app.js +++ b/ui/js/app.js @@ -2030,7 +2030,10 @@ // P2-B:登录 → 后端 /api/api-keys(key 已脱敏;完整 key 仅生成时可得) let list; if (Live.apiKeys) { - list = Live.apiKeys.map((k) => ({ + // idx = 定位符:行内按钮带的索引是**缓存数组里的下标**,不是搜索过滤后的行号 + //(过滤会改变行号;copyKey/renameKey/deleteKey 都按 Live.apiKeys[idx] 取记录) + list = Live.apiKeys.map((k, idx) => ({ + idx, id: k.id, fullKey: k.full_key || null, name: k.name || T("common.unnamed"), @@ -2043,15 +2046,15 @@ list = []; } list = list.filter((k) => !q || k.name.toLowerCase().includes(q)); - $("#api-keys").innerHTML = list.length ? list.map((k, i) => - "" + hl(k.name, rawQ) + "" + + $("#api-keys").innerHTML = list.length ? list.map((k) => + "" + hl(k.name, rawQ) + "" + "" + esc(Live.apiKeys ? k.key : "") + "" + "" + esc(k.created) + "" + "" + (k.last ? timeCell(k.last) : esc(T("settings.ak.last.never"))) + "" + "" + (k.status === "active" ? '' + T("settings.ak.status.active") + "" : '' + esc(k.status || "—") + "") + "" + - " " + - " " + - "" + " " + + " " + + "" ).join("") : emptyRow(6, T("settings.ak.empty"), T("settings.ak.empty.sub"), '"); pulseTbody($("#api-keys")); @@ -2217,7 +2220,8 @@ function renameKey(i) { const k = Live.apiKeys ? Live.apiKeys[i] : null; if (!k) return; - const row = document.querySelector('#api-keys tr:nth-child(' + (i + 1) + ')'); + // 行号会随搜索过滤变化 ⇒ 按定位符(缓存下标)找行,而不是 nth-child + const row = document.querySelector('#api-keys [data-key-row="' + i + '"]'); const cell = row ? row.children[0] : null; if (!cell) return; inlineForm(cell, { @@ -2349,8 +2353,11 @@ const q = rawQ.toLowerCase(); const list = Live.adminModels.filter((m) => !q || (m.provider || "").toLowerCase().includes(q) || (m.model || "").toLowerCase().includes(q)); - $("#model-body").innerHTML = list.length ? list.map((m, i) => - "" + esc(m.provider) + "" + + // 定位符 = 缓存数组下标(editModelRow/deleteModel 按 Live.adminModels[i] 取记录); + // 搜索过滤会改变行号,所以不能把行号当定位符填进按钮 + $("#model-body").innerHTML = list.length ? list.map((m) => { + const i = Live.adminModels.indexOf(m); + return "" + esc(m.provider) + "" + "" + esc(m.model) + "" + '' + D.fmt(m.input_per_m || 0) + "" + '' + D.fmt(m.output_per_m || 0) + "" + @@ -2358,8 +2365,8 @@ '' + fmtCtx(m.max_output || 0) + "" + "" + (m.vision ? '' + T("admin.models.vision.yes") + "" : '' + T("admin.models.vision.no") + "") + "" + " " + - "" - ).join("") : emptyRow(8, T("admin.models.empty"), T("admin.models.empty.sub")); + ""; + }).join("") : emptyRow(8, T("admin.models.empty"), T("admin.models.empty.sub")); pulseTbody($("#model-body")); } @@ -2543,7 +2550,10 @@ stat(T("admin.org.stats.remain"), D.fmt(totalQuota - totalUsed) + " " + T("common.points"), T("admin.org.stats.remain.sub")), ].join(""); - $("#dept-body").innerHTML = list.length ? list.map((d, i) => { + // 定位符 = 缓存数组下标(openDeptForm/deleteDept 按 Live.departments[i] 取记录); + // 搜索过滤会改变行号,所以不能把行号当定位符填进按钮 + $("#dept-body").innerHTML = list.length ? list.map((d) => { + const i = src.indexOf(d); const used = d.month_cost || 0; const members = d.member_count || 0; const pct = d.quota > 0 ? used / d.quota : 0;