fix: 四所统计日历 embed 切换后初始化与加载失败仍渲染网格
统一 initInstanceStatsCalendar,统计 tab 动态注入时重新挂载日历,API 异常时保留月历骨架。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -851,7 +851,7 @@
|
||||
<script src="/static/form_submit_guard.js?v=2"></script>
|
||||
<script src="/static/manual_order_rr_preview.js?v=5"></script>
|
||||
<script src="/static/strategy_roll.js?v=5"></script>
|
||||
<script src="/static/trade_stats_calendar.js?v=1"></script>
|
||||
<script src="/static/trade_stats_calendar.js?v=2"></script>
|
||||
<script>
|
||||
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
|
||||
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
|
||||
@@ -1510,36 +1510,7 @@ function switchStatsSegment(){
|
||||
q.set("stats_segment", key);
|
||||
const qs = q.toString();
|
||||
history.replaceState(null, "", qs ? (window.location.pathname + "?" + qs) : window.location.pathname);
|
||||
if(statsCalendarWidget) statsCalendarWidget.load();
|
||||
}
|
||||
|
||||
let statsCalendarWidget = null;
|
||||
|
||||
function initStatsCalendarWidget(){
|
||||
const grid = document.getElementById("stats-calendar");
|
||||
if(!grid || !window.TradeStatsCalendar) return;
|
||||
statsCalendarWidget = new TradeStatsCalendar({
|
||||
gridEl: grid,
|
||||
titleEl: document.getElementById("stats-cal-title"),
|
||||
prevBtn: document.getElementById("stats-cal-prev"),
|
||||
nextBtn: document.getElementById("stats-cal-next"),
|
||||
apiUrl: "/api/stats/calendar",
|
||||
showSick: false,
|
||||
buildQuery: function(year, month){
|
||||
const q = new URLSearchParams();
|
||||
q.set("year", String(year));
|
||||
q.set("month", String(month));
|
||||
const sel = document.getElementById("stats-segment-select");
|
||||
if(sel) q.set("segment", sel.value || "all");
|
||||
return q;
|
||||
},
|
||||
parseResponse: function(data){
|
||||
if(data && data.ok === false) return {};
|
||||
return (data && data.days) || {};
|
||||
}
|
||||
});
|
||||
statsCalendarWidget.ensureMonth(new Date());
|
||||
statsCalendarWidget.load();
|
||||
if(window.statsCalendarWidget) window.statsCalendarWidget.load();
|
||||
}
|
||||
|
||||
function initStatsSegmentFromUrl(){
|
||||
@@ -1563,7 +1534,7 @@ function toggleStatsCard(){
|
||||
attachListWindowToExports();
|
||||
toggleListWindowCustom();
|
||||
initStatsSegmentFromUrl();
|
||||
initStatsCalendarWidget();
|
||||
if(typeof initInstanceStatsCalendar === "function") initInstanceStatsCalendar();
|
||||
if(document.getElementById("journal-list")) loadJournals();
|
||||
if(document.getElementById("review-list")) loadReviews();
|
||||
const reviewToggle = document.getElementById("review-mode-toggle");
|
||||
|
||||
Reference in New Issue
Block a user