feat: WebUI 版本检测 — 顶栏按钮 + 设置页备份/回滚/更新管理

顶栏:
- 版本号按钮, 有更新时变绿色并显示新版本号
- 每10分钟自动检查

设置页新增「版本与更新」区域:
- 当前版本 + 更新状态徽章
- 检查更新 / 立即更新 按钮
- 备份列表 + 手动回滚

API:
- GET /api/updates/backups — 备份列表
- POST /api/updates/rollback — 执行回滚

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
qinglong
2026-06-13 20:39:28 +08:00
parent c20417ff93
commit 9a9a2975de
4 changed files with 173 additions and 1 deletions
+19
View File
@@ -12,6 +12,25 @@ function getCookie(name) {
return match ? match[2] : '';
}
// ── 顶部版本检查 ──
async function checkTopUpdate() {
var btn = document.getElementById("top-ver-btn");
try {
var r = await fetch("./api/updates"), d = await r.json();
btn.textContent = d.current_version || d.latest_version || "v?";
if (d.update_available) {
btn.textContent = "🔄 " + d.latest_version;
btn.style.color = "var(--success)";
btn.title = "新版本可用! " + d.latest_version;
} else {
btn.style.color = "";
btn.title = "已是最新";
}
} catch(e) {}
}
setTimeout(checkTopUpdate, 3000);
setInterval(checkTopUpdate, 600000); // 10min
window.toggleTheme = function(){
var t = document.documentElement.getAttribute("data-theme") === "light" ? "dark" : "light";
document.documentElement.setAttribute("data-theme", t);