v2.7.0 一键导出全部历史(GET /api/tests/export JSON, Key打码);左侧三块配置卡片可折叠展开(状态localStorage持久化);置顶/置底按钮高亮蓝渐变高对比配色
This commit is contained in:
@@ -1098,8 +1098,23 @@ function bind() {
|
||||
$("#btn-export-log").addEventListener("click", exportCurrentLog);
|
||||
$("#btn-refresh-history").addEventListener("click", () => { histState.page = 1; loadHistory(); });
|
||||
$("#btn-compare").addEventListener("click", openCompare);
|
||||
$("#btn-export-history").addEventListener("click", exportAllHistory);
|
||||
$("#btn-clear-history").addEventListener("click", clearAllHistory);
|
||||
|
||||
// 左侧三块:点击标题折叠/展开(状态存 localStorage)
|
||||
const COLLAPSE_KEY = "llmst.collapsed";
|
||||
let collapsedSections = new Set();
|
||||
try { collapsedSections = new Set(JSON.parse(localStorage.getItem(COLLAPSE_KEY) || "[]")); } catch (e) {}
|
||||
document.querySelectorAll(".card.collapsible").forEach((sec) => {
|
||||
if (collapsedSections.has(sec.id)) sec.classList.add("collapsed");
|
||||
const head = sec.querySelector(".collapse-head");
|
||||
if (head) head.addEventListener("click", () => {
|
||||
const on = sec.classList.toggle("collapsed");
|
||||
if (on) collapsedSections.add(sec.id); else collapsedSections.delete(sec.id);
|
||||
try { localStorage.setItem(COLLAPSE_KEY, JSON.stringify([...collapsedSections])); } catch (e) {}
|
||||
});
|
||||
});
|
||||
|
||||
// 历史:筛选 / 搜索 / 每页条数 / 分页 / 重置
|
||||
let histQTimer = null;
|
||||
$("#hist-q").addEventListener("input", () => {
|
||||
@@ -1223,6 +1238,25 @@ async function clearAllHistory() {
|
||||
}
|
||||
}
|
||||
|
||||
async function exportAllHistory() {
|
||||
try {
|
||||
const resp = await fetch("/api/tests/export");
|
||||
if (!resp.ok) throw new Error("HTTP " + resp.status);
|
||||
const blob = await resp.blob();
|
||||
const cd = resp.headers.get("Content-Disposition") || "";
|
||||
const m = cd.match(/filename\"?=?\"?([^";]+)\"?/);
|
||||
const name = m ? m[1] : "llm_speed_tests.json";
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.href = url; a.download = name;
|
||||
document.body.appendChild(a); a.click(); a.remove();
|
||||
URL.revokeObjectURL(url);
|
||||
toast("✅ 已导出全部历史(共 " + (blob.size / 1024).toFixed(1) + " KB)");
|
||||
} catch (e) {
|
||||
toast("❌ 导出失败:" + e.message);
|
||||
}
|
||||
}
|
||||
|
||||
/* ───────────────────────── 初始化 ───────────────────────── */
|
||||
|
||||
(async function init() {
|
||||
|
||||
Reference in New Issue
Block a user