fix: AI review loading UX and Gate preview snapshot time filter SQL

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-05 13:51:16 +08:00
parent 86a6081090
commit 4ac4c062e0
8 changed files with 264 additions and 36 deletions
+48 -8
View File
@@ -232,7 +232,7 @@
.stats-period-block h3{font-size:1rem;color:#dbe4ff;margin-bottom:4px}
.stats-period-block .sub{font-size:.78rem;color:#8892b0;margin-bottom:10px;line-height:1.4}
</style>
<link rel="stylesheet" href="/static/instance_theme.css?v=6">
<link rel="stylesheet" href="/static/instance_theme.css?v=7">
</head>
<body data-page="{{ page }}">
@@ -822,11 +822,11 @@
</div>
<div class="form-row">
<input type="date" id="day_date">
<button type="button" onclick="genDaily()">生成日复盘</button>
<button type="button" id="gen-daily-btn" onclick="genDaily()">生成日复盘</button>
<button type="button" onclick="exportDailyBundleMd()" style="background:#1f3a5a">导出当日日复盘MD</button>
<input type="date" id="week_start">
<input type="date" id="week_end">
<button type="button" onclick="genWeekly()">生成周复盘</button>
<button type="button" id="gen-weekly-btn" onclick="genWeekly()">生成周复盘</button>
<button type="button" onclick="exportWeeklyBundleMd()" style="background:#1f3a5a">导出当周复盘MD</button>
</div>
<div class="ai-result-wrap" id="daily_result_wrap" style="display:none">
@@ -911,7 +911,7 @@
</div>
<script src="/static/instance_ui.js?v=1"></script>
<script src="/static/ai_review_render.js?v=1"></script>
<script src="/static/ai_review_render.js?v=2"></script>
<script src="/static/form_submit_guard.js?v=2"></script>
<script>
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
@@ -1242,36 +1242,76 @@ function loadReviews(){
}
function genDaily(){
if(window.AiReviewRender && AiReviewRender.isGenerating && AiReviewRender.isGenerating()) return;
const d = document.getElementById("day_date").value;
if(!d){alert("请选择日期");return;}
if(window.AiReviewRender && AiReviewRender.setGenerating){
AiReviewRender.setGenerating({
wrapId:"daily_result_wrap",
elId:"daily_result",
btnId:"gen-daily-btn",
message:"生成日复盘中,请稍候…(AI 分析可能需要 1~3 分钟)",
btnLabel:"日复盘生成中…"
});
}
fetch("/ai_daily_review",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:`date=${encodeURIComponent(d)}`})
.then(r=>{ if(!r.ok) throw new Error("HTTP "+r.status); return r.json(); })
.then(data=>{
if(!data || data.result == null) throw new Error("返回数据为空");
const el=document.getElementById("daily_result");
const wrap=document.getElementById("daily_result_wrap");
setAiReviewMarkdown(el, data.result);
if(wrap){ wrap.style.display="block"; }
else { el.style.display="block"; }
else if(el){ el.style.display="block"; }
if(window.AiReviewRender && AiReviewRender.clearGenerating) AiReviewRender.clearGenerating("gen-daily-btn");
loadReviews();
})
.catch(e=>alert("生成日复盘失败:"+(e.message||e)));
.catch(e=>{
if(window.AiReviewRender && AiReviewRender.clearGenerating) AiReviewRender.clearGenerating("gen-daily-btn");
const el=document.getElementById("daily_result");
if(el){
el.classList.remove("is-loading","ai-result-md");
el.innerText="生成失败,请重试。";
}
alert("生成日复盘失败:"+(e.message||e));
});
}
function genWeekly(){
if(window.AiReviewRender && AiReviewRender.isGenerating && AiReviewRender.isGenerating()) return;
const s=document.getElementById("week_start").value;
const e=document.getElementById("week_end").value;
if(!s || !e){alert("请选择起止日期");return;}
if(window.AiReviewRender && AiReviewRender.setGenerating){
AiReviewRender.setGenerating({
wrapId:"weekly_result_wrap",
elId:"weekly_result",
btnId:"gen-weekly-btn",
message:"生成周复盘中,请稍候…(AI 分析可能需要 1~3 分钟)",
btnLabel:"周复盘生成中…"
});
}
fetch("/ai_weekly_review",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:`start_date=${encodeURIComponent(s)}&end_date=${encodeURIComponent(e)}`})
.then(r=>{ if(!r.ok) throw new Error("HTTP "+r.status); return r.json(); })
.then(data=>{
if(!data || data.result == null) throw new Error("返回数据为空");
const el=document.getElementById("weekly_result");
const wrap=document.getElementById("weekly_result_wrap");
setAiReviewMarkdown(el, data.result);
if(wrap){ wrap.style.display="block"; }
else { el.style.display="block"; }
else if(el){ el.style.display="block"; }
if(window.AiReviewRender && AiReviewRender.clearGenerating) AiReviewRender.clearGenerating("gen-weekly-btn");
loadReviews();
})
.catch(e=>alert("生成周复盘失败:"+(e.message||e)));
.catch(e=>{
if(window.AiReviewRender && AiReviewRender.clearGenerating) AiReviewRender.clearGenerating("gen-weekly-btn");
const el=document.getElementById("weekly_result");
if(el){
el.classList.remove("is-loading","ai-result-md");
el.innerText="生成失败,请重试。";
}
alert("生成周复盘失败:"+(e.message||e));
});
}
function exportDailyBundleMd(){