fix: 版本更新 — 自动检查 + 手动备份 + 创建备份按钮

1. 设置页加载时自动触发版本检查
2. POST /api/updates/backup — 手动创建备份
3. 备份管理区新增「+ 创建备份」按钮
4. 顶栏版本按钮: checkTopUpdate 每10min轮询

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
qinglong
2026-06-13 21:08:54 +08:00
parent 95a2f375e8
commit 67d0f00525
2 changed files with 40 additions and 2 deletions
+12 -2
View File
@@ -19,6 +19,7 @@
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:8px">
<h4 style="margin:0"><svg width="18" height="18" viewBox="0 0 24 24" style="vertical-align:-3px;margin-right:4px"><path fill="currentColor" d="M20 6h-8l-2-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V6h5.17l2 2H20v10z"/></svg>备份管理</h4>
<button class="btn btn-sm btn-outlined" onclick="loadBackups()">刷新列表</button>
<button class="btn btn-sm btn-filled" onclick="createBackup()" style="margin-left:8px">+ 创建备份</button>
</div>
<div id="backup-list"><span style="color:var(--text-dim);font-size:.85rem">加载中...</span></div>
</div>
@@ -112,6 +113,15 @@
} catch(e) {}
}
async function createBackup() {
try {
var r = await fetch("./api/updates/backup", {method:"POST"}), d = await r.json();
if (d.ok) alert("✓ 备份已创建: " + d.name);
else alert("✗ " + (d.error||"失败"));
loadBackups();
} catch(e) { alert("✗ " + e); }
}
async function checkUpdate() {
document.getElementById("ver-badge").textContent = "⏳ 检查中...";
await fetch("./api/updates/check", {method:"POST"});
@@ -127,7 +137,7 @@
if (d.ok) alert("✓ " + d.msg);
else alert("✗ " + (d.error||"失败"));
} catch(e) { alert("✗ " + e); }
loadVersion();
loadVersion().then(function(){ checkUpdate(); });
}
// ── 备份管理 ──
@@ -237,7 +247,7 @@
// ── 初始加载 ──
loadKeys();
loadVersion();
loadVersion().then(function(){ checkUpdate(); });
loadBackups();
</script>
</div>