diff --git a/app/__pycache__/__init__.cpython-311.pyc b/app/__pycache__/__init__.cpython-311.pyc index 92086fc..5da7f5f 100644 Binary files a/app/__pycache__/__init__.cpython-311.pyc and b/app/__pycache__/__init__.cpython-311.pyc differ diff --git a/app/__pycache__/config.cpython-311.pyc b/app/__pycache__/config.cpython-311.pyc index 104f2d4..e0c1fe6 100644 Binary files a/app/__pycache__/config.cpython-311.pyc and b/app/__pycache__/config.cpython-311.pyc differ diff --git a/app/__pycache__/database.cpython-311.pyc b/app/__pycache__/database.cpython-311.pyc index 2e3b6db..507bc0c 100644 Binary files a/app/__pycache__/database.cpython-311.pyc and b/app/__pycache__/database.cpython-311.pyc differ diff --git a/app/__pycache__/main.cpython-311.pyc b/app/__pycache__/main.cpython-311.pyc index 13e81c5..eef9d37 100644 Binary files a/app/__pycache__/main.cpython-311.pyc and b/app/__pycache__/main.cpython-311.pyc differ diff --git a/app/__pycache__/models.cpython-311.pyc b/app/__pycache__/models.cpython-311.pyc index fc97c34..9f5a968 100644 Binary files a/app/__pycache__/models.cpython-311.pyc and b/app/__pycache__/models.cpython-311.pyc differ diff --git a/app/__pycache__/schemas.cpython-311.pyc b/app/__pycache__/schemas.cpython-311.pyc index 7cafdde..0e2ed94 100644 Binary files a/app/__pycache__/schemas.cpython-311.pyc and b/app/__pycache__/schemas.cpython-311.pyc differ diff --git a/app/api/__pycache__/__init__.cpython-311.pyc b/app/api/__pycache__/__init__.cpython-311.pyc index 948dd22..2b2a5c5 100644 Binary files a/app/api/__pycache__/__init__.cpython-311.pyc and b/app/api/__pycache__/__init__.cpython-311.pyc differ diff --git a/app/api/__pycache__/config.cpython-311.pyc b/app/api/__pycache__/config.cpython-311.pyc index 07635b5..a307fe9 100644 Binary files a/app/api/__pycache__/config.cpython-311.pyc and b/app/api/__pycache__/config.cpython-311.pyc differ diff --git a/app/api/__pycache__/data.cpython-311.pyc b/app/api/__pycache__/data.cpython-311.pyc index c75b420..0ca2fc9 100644 Binary files a/app/api/__pycache__/data.cpython-311.pyc and b/app/api/__pycache__/data.cpython-311.pyc differ diff --git a/app/api/__pycache__/tasks.cpython-311.pyc b/app/api/__pycache__/tasks.cpython-311.pyc index c97bc57..e23d5dd 100644 Binary files a/app/api/__pycache__/tasks.cpython-311.pyc and b/app/api/__pycache__/tasks.cpython-311.pyc differ diff --git a/app/services/__pycache__/__init__.cpython-311.pyc b/app/services/__pycache__/__init__.cpython-311.pyc index 0fe3f4c..ebac38b 100644 Binary files a/app/services/__pycache__/__init__.cpython-311.pyc and b/app/services/__pycache__/__init__.cpython-311.pyc differ diff --git a/app/services/__pycache__/cache.cpython-311.pyc b/app/services/__pycache__/cache.cpython-311.pyc index 8c19002..7732f0c 100644 Binary files a/app/services/__pycache__/cache.cpython-311.pyc and b/app/services/__pycache__/cache.cpython-311.pyc differ diff --git a/app/services/__pycache__/collector.cpython-311.pyc b/app/services/__pycache__/collector.cpython-311.pyc index a386f8e..7224897 100644 Binary files a/app/services/__pycache__/collector.cpython-311.pyc and b/app/services/__pycache__/collector.cpython-311.pyc differ diff --git a/app/services/__pycache__/scheduler.cpython-311.pyc b/app/services/__pycache__/scheduler.cpython-311.pyc index 5e1f5a2..05eb282 100644 Binary files a/app/services/__pycache__/scheduler.cpython-311.pyc and b/app/services/__pycache__/scheduler.cpython-311.pyc differ diff --git a/app/static/index.html b/app/static/index.html index 862c8f5..4c139e2 100644 --- a/app/static/index.html +++ b/app/static/index.html @@ -914,6 +914,12 @@ 查询缓存 +
+ +
@@ -1805,12 +1811,14 @@ if (!res.ok) { showToast(data.detail || '未找到缓存数据', 'error'); + document.getElementById('btnExportData').disabled = true; return; } addLog(`查询成功: ${symbol}, 缓存 ${data.timeframes ? data.timeframes.length : 0} 个周期`, 'success'); currentQueryData = data; + document.getElementById('btnExportData').disabled = false; if (!data.timeframes || data.timeframes.length === 0) { document.getElementById('queryResult').innerHTML = '

暂无K线数据

'; @@ -1822,7 +1830,49 @@ } catch (e) { showToast(`查询失败: ${e.message}`, 'error'); + document.getElementById('btnExportData').disabled = true; + } + } + + function exportData() { + if (!currentQueryData || !currentQueryData.timeframes || currentQueryData.timeframes.length === 0) { + showToast('暂无可导出的数据', 'error'); + return; } + + const symbol = document.getElementById('querySymbol').value.trim() || 'unknown'; + const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19); + const filename = `${symbol}_多周期数据_${timestamp}.json`; + + const exportObj = { + symbol: currentQueryData.symbol || symbol, + type: currentQueryData.type || 'futures', + current_price: currentQueryData.current_price, + timestamp: currentQueryData.timestamp || new Date().toISOString(), + timeframes: {} + }; + + currentQueryData.timeframes.forEach(tf => { + exportObj.timeframes[tf.period] = tf.candles || []; + }); + + const jsonStr = JSON.stringify(exportObj, null, 2); + const blob = new Blob([jsonStr], { type: 'application/json' }); + const url = URL.createObjectURL(blob); + + const a = document.createElement('a'); + a.href = url; + a.download = filename; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + URL.revokeObjectURL(url); + + const periodCount = currentQueryData.timeframes.length; + const totalCandles = currentQueryData.timeframes.reduce((sum, tf) => sum + (tf.candles ? tf.candles.length : 0), 0); + + addLog(`数据导出成功: ${filename}, ${periodCount} 个周期, ${totalCandles} 条K线`, 'success'); + showToast(`已导出 ${periodCount} 个周期数据`, 'success'); } function renderKlineChart(timeframe, symbol) {