feat(hub): add archive quote AI coach review from inner light page

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-11 21:10:39 +08:00
parent bb8bb3ae34
commit 180aff5310
7 changed files with 276 additions and 4 deletions
+71
View File
@@ -3497,9 +3497,70 @@
}
}
const ARCHIVE_QUOTE_AI_KEY = "hub_archive_quote_ai";
async function consumeArchiveQuoteAiPending() {
let raw = "";
try {
raw = sessionStorage.getItem(ARCHIVE_QUOTE_AI_KEY) || "";
} catch (_) {
return;
}
if (!raw) return;
sessionStorage.removeItem(ARCHIVE_QUOTE_AI_KEY);
let payload;
try {
payload = JSON.parse(raw);
} catch (_) {
return;
}
const content = String((payload && payload.content) || "").trim();
const quoteDate = String((payload && payload.quote_date) || "").trim();
if (!content) return;
const input = document.getElementById("ai-chat-input");
if (input) input.value = content;
updateAiBotTabs("trading");
if (isMobileAiLayout()) {
localStorage.setItem(AI_MOBILE_TAB_KEY, "trading");
applyAiMobileTab("trading");
}
setAiChatBusy(true);
renderAiChatMessages(aiChatSessionCache, {
pendingUser: content,
thinking: true,
});
try {
const r = await apiFetch("/api/ai/chat/archive-quote", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ quote_date: quoteDate, content }),
});
const j = await r.json();
if (!r.ok) throw new Error(j.detail || j.msg || "发送失败");
aiChatSessionCache = j.session || null;
aiChatSessionsCache = j.sessions || aiChatSessionsCache;
renderAiChatMessages(aiChatSessionCache);
renderAiChatHistory(aiChatSessionsCache);
if (input) input.value = "";
showToast("复盘语录已发送给交易教练");
} catch (e) {
showToast(String(e), true);
try {
await loadAiChatSession();
} catch (_) {
renderAiChatMessages(aiChatSessionCache);
}
} finally {
setAiChatBusy(false);
}
}
async function loadAiPage() {
applyAiMobileTab();
await loadAiChatSession();
await consumeArchiveQuoteAiPending();
const mobTab = normalizeAiMobileTab(localStorage.getItem(AI_MOBILE_TAB_KEY) || "trading");
if (isMobileAiLayout() && AI_MOBILE_CHAT_TABS.has(mobTab)) {
const input = document.getElementById("ai-chat-input");
@@ -3665,6 +3726,16 @@
window.addEventListener("popstate", setActiveNav);
}
window.hubNavigateTo = function hubNavigateTo(path) {
const href = String(path || "/").split("?")[0] || "/";
if (href === window.location.pathname) {
setActiveNav();
return;
}
history.pushState({}, "", href);
setActiveNav();
};
window.hubOpenMonitorExpand = function hubOpenMonitorExpand(exId) {
const id = String(exId || "").trim();
if (!id) return;