diff --git a/app/static/futures_analysis.html b/app/static/futures_analysis.html index 4102440..62a2c9e 100644 --- a/app/static/futures_analysis.html +++ b/app/static/futures_analysis.html @@ -594,6 +594,12 @@ .tr-tab-panel { display: none; } .tr-tab-panel.active { display: block; } + /* 快捷日期按钮 */ + .tr-quick-dates { display: flex; gap: 8px; margin-bottom: 16px; } + .tr-quick-date { padding: 6px 16px; border-radius: 20px; border: 1px solid #e0e0e0; background: #fff; color: var(--text-secondary); font-size: 13px; cursor: pointer; transition: all 0.2s; } + .tr-quick-date:hover { border-color: var(--color-brand); color: var(--color-brand); } + .tr-quick-date.active { background: var(--color-brand); color: #fff; border-color: var(--color-brand); } + /* 数据管理 Tab 样式 */ .tr-data-management { background: var(--bg-card); border-radius: var(--radius-card); padding: 32px; box-shadow: var(--shadow-sm); } .tr-section-title { font-size: 16px; font-weight: 600; color: var(--text-primary); margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid rgba(0,0,0,0.05); } @@ -1124,9 +1130,9 @@
- +
@@ -1185,8 +1191,17 @@
+ +
+ + + + + + +
-
+
~ diff --git a/app/static/futures_analysis.js b/app/static/futures_analysis.js index 5d0257a..addb558 100644 --- a/app/static/futures_analysis.js +++ b/app/static/futures_analysis.js @@ -1643,6 +1643,58 @@ async function trInitDefaultDate() { } catch (e) { console.error('获取最后交易日失败', e); } + // 初始化快捷日期按钮 + trInitQuickDates(); + trLoadAllData(); +} + +function trInitQuickDates() { + document.querySelectorAll('#tr-quick-dates .tr-quick-date').forEach(btn => { + btn.addEventListener('click', () => trSetDateRange(btn.dataset.range)); + }); +} + +function trSetDateRange(range) { + // 更新按钮状态 + document.querySelectorAll('#tr-quick-dates .tr-quick-date').forEach(btn => { + btn.classList.toggle('active', btn.dataset.range === range); + }); + + const today = new Date(); + const end = today.toISOString().split('T')[0]; + let start = end; + + switch (range) { + case 'today': + start = end; + break; + case 'week': + const weekAgo = new Date(today); + weekAgo.setDate(weekAgo.getDate() - 7); + start = weekAgo.toISOString().split('T')[0]; + break; + case 'half-month': + const halfMonthAgo = new Date(today); + halfMonthAgo.setDate(halfMonthAgo.getDate() - 15); + start = halfMonthAgo.toISOString().split('T')[0]; + break; + case 'month': + const monthAgo = new Date(today); + monthAgo.setMonth(monthAgo.getMonth() - 1); + start = monthAgo.toISOString().split('T')[0]; + break; + case 'quarter': + const quarterAgo = new Date(today); + quarterAgo.setMonth(quarterAgo.getMonth() - 3); + start = quarterAgo.toISOString().split('T')[0]; + break; + case 'custom': + // 自定义模式,不自动设置日期,让用户手动选择 + return; + } + + document.getElementById('tr-start-date').value = start; + document.getElementById('tr-end-date').value = end; trLoadAllData(); } diff --git a/data/futures_analysis.db b/data/futures_analysis.db index e04fd31..669a23d 100644 Binary files a/data/futures_analysis.db and b/data/futures_analysis.db differ