diff --git a/web/mobile/index.html b/web/mobile/index.html index d5fde78..4411ae4 100644 --- a/web/mobile/index.html +++ b/web/mobile/index.html @@ -40,6 +40,10 @@ + +
diff --git a/web/mobile/mobile.js b/web/mobile/mobile.js index dee01ac..46c7792 100644 --- a/web/mobile/mobile.js +++ b/web/mobile/mobile.js @@ -208,12 +208,51 @@ function generateBrief() { showEnergy: true, showTodos: true }; renderBrief(brief); + saveBriefToHistory(brief); }) .catch(function (e) { status.textContent = "生成失败:" + e.message; }) .finally(function () { btn.disabled = false; }); } /* ---------------- 启动 ---------------- */ +/* issue #158:历史摘要本地保存与查看(最近 10 次生成) */ +var BRIEFS_KEY = "iaop.mobile.briefs.v1"; +function getBriefHistory() { + try { return JSON.parse(localStorage.getItem(BRIEFS_KEY)) || []; } + catch (e) { return []; } +} +function saveBriefToHistory(p) { + var list = getBriefHistory(); + list.unshift(p); + localStorage.setItem(BRIEFS_KEY, JSON.stringify(list.slice(0, 10))); + renderBriefHistory(); +} +function renderBriefHistory() { + var list = getBriefHistory(); + var row = document.getElementById("brief-history-row"); + var sel = document.getElementById("brief-history"); + if (!list.length) { row.hidden = true; return; } + row.hidden = false; + sel.innerHTML = ""; + var ph = document.createElement("option"); + ph.value = "-1"; ph.textContent = "查看历史摘要(" + list.length + " 条)…"; + sel.appendChild(ph); + list.forEach(function (p, i) { + var opt = document.createElement("option"); + opt.value = String(i); + opt.textContent = p.shift + " · " + (p.generatedAt || "").slice(0, 16).replace("T", " "); + sel.appendChild(opt); + }); + sel.onchange = function () { + var idx = parseInt(sel.value, 10); + if (idx >= 0 && list[idx]) { + brief = list[idx]; + renderBrief(brief); + document.getElementById("gen-status").textContent = "(查看历史摘要)"; + document.getElementById("push-status").textContent = ""; + } + }; +} (function init() { document.querySelectorAll("#tabbar .tab").forEach(function (tab) { tab.onclick = function () { @@ -244,4 +283,5 @@ function generateBrief() { } document.getElementById("btn-refresh").onclick = loadPlan; loadPlan(); + renderBriefHistory(); // issue #158:启动时恢复历史摘要入口 })();