feat: 完成 issue #158 交接班摘要页补充历史摘要查看(最近 10 次本地保存)
This commit is contained in:
@@ -40,6 +40,10 @@
|
|||||||
</select>
|
</select>
|
||||||
<button id="btn-gen" class="primary">生成摘要</button>
|
<button id="btn-gen" class="primary">生成摘要</button>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- issue #158:历史摘要查看(最近 10 次生成,本地保存) -->
|
||||||
|
<div class="row" id="brief-history-row" hidden>
|
||||||
|
<select id="brief-history"></select>
|
||||||
|
</div>
|
||||||
<div id="gen-status" class="hint"></div>
|
<div id="gen-status" class="hint"></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="brief"></div>
|
<div id="brief"></div>
|
||||||
|
|||||||
@@ -208,12 +208,51 @@ function generateBrief() {
|
|||||||
showEnergy: true, showTodos: true
|
showEnergy: true, showTodos: true
|
||||||
};
|
};
|
||||||
renderBrief(brief);
|
renderBrief(brief);
|
||||||
|
saveBriefToHistory(brief);
|
||||||
})
|
})
|
||||||
.catch(function (e) { status.textContent = "生成失败:" + e.message; })
|
.catch(function (e) { status.textContent = "生成失败:" + e.message; })
|
||||||
.finally(function () { btn.disabled = false; });
|
.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() {
|
(function init() {
|
||||||
document.querySelectorAll("#tabbar .tab").forEach(function (tab) {
|
document.querySelectorAll("#tabbar .tab").forEach(function (tab) {
|
||||||
tab.onclick = function () {
|
tab.onclick = function () {
|
||||||
@@ -244,4 +283,5 @@ function generateBrief() {
|
|||||||
}
|
}
|
||||||
document.getElementById("btn-refresh").onclick = loadPlan;
|
document.getElementById("btn-refresh").onclick = loadPlan;
|
||||||
loadPlan();
|
loadPlan();
|
||||||
|
renderBriefHistory(); // issue #158:启动时恢复历史摘要入口
|
||||||
})();
|
})();
|
||||||
|
|||||||
Reference in New Issue
Block a user