Files
nofx/web/src/components/charts/ChartWithOrdersSimple.tsx
shinchan-zhai 84758e2942 chore: remove ~100 debug console.log statements from frontend
Cleaned up verbose debug logging left from development:
- AdvancedChart.tsx: removed ~50 debug logs (time parsing, order fetching, marker creation)
- ChartWithOrders.tsx: removed debug logs and unused klineMinTime/klineMaxTime variables
- ChartWithOrdersSimple.tsx: removed data loading debug logs
- ChartTabs.tsx: removed render/selection debug logs
- ComparisonChart.tsx: removed equity history debug logs
- AITradersPage.tsx: removed 🔥 DEBUG logs from handleSaveEditTrader
- App.tsx: removed mount debug log

Kept legitimate console.error/console.warn for actual error handling.
2026-03-25 01:05:54 +08:00

117 lines
3.9 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { useEffect, useState } from 'react'
import { httpClient } from '../../lib/httpClient'
interface ChartWithOrdersSimpleProps {
symbol: string
interval?: string
traderID?: string
height?: number
}
export function ChartWithOrdersSimple({
symbol = 'BTCUSDT',
interval = '5m',
traderID,
height = 500,
}: ChartWithOrdersSimpleProps) {
const [loading, setLoading] = useState(true)
const [error, setError] = useState<string | null>(null)
const [klineCount, setKlineCount] = useState(0)
const [orderCount, setOrderCount] = useState(0)
useEffect(() => {
const loadData = async () => {
setLoading(true)
setError(null)
try {
// 从我们自己的服务获取K线数据
const limit = 100
const klineUrl = `/api/klines?symbol=${symbol}&interval=${interval}&limit=${limit}`
const klineResult = await httpClient.get(klineUrl)
if (!klineResult.success || !klineResult.data) {
throw new Error('Failed to fetch klines from our service')
}
setKlineCount(klineResult.data.length)
// 测试获取订单数据
if (traderID) {
const tradesUrl = `/api/trades?trader_id=${traderID}&symbol=${symbol}&limit=100`
const tradesResult = await httpClient.get(tradesUrl)
if (tradesResult.success && tradesResult.data) {
setOrderCount(tradesResult.data.length)
} else {
console.warn('[ChartSimple] Failed to fetch trades:', tradesResult.message || 'Unknown error', tradesResult)
}
}
setLoading(false)
} catch (err: any) {
console.error('[ChartSimple] Error:', err)
setError(err.message || 'Failed to load data')
setLoading(false)
}
}
loadData()
}, [symbol, interval, traderID])
return (
<div className="relative" style={{ background: '#0B0E11', borderRadius: '8px', overflow: 'hidden', minHeight: height }}>
{/* 标题栏 */}
<div className="flex items-center justify-between p-4" style={{ borderBottom: '1px solid #2B3139' }}>
<div className="flex items-center gap-3">
<span className="text-xl">📈</span>
<h3 className="text-lg font-bold" style={{ color: '#EAECEF' }}>
{symbol} {interval} ()
</h3>
</div>
{loading && (
<div className="text-sm" style={{ color: '#848E9C' }}>
...
</div>
)}
</div>
{/* 测试信息 */}
<div className="p-8 space-y-4">
{error ? (
<div className="text-center">
<div className="text-2xl mb-2"></div>
<div style={{ color: '#F6465D' }}>{error}</div>
</div>
) : (
<>
<div className="p-4 rounded" style={{ background: '#1E2329', border: '1px solid #2B3139' }}>
<div className="text-sm mb-2" style={{ color: '#848E9C' }}>K线数据</div>
<div className="text-2xl font-bold" style={{ color: '#0ECB81' }}>
{klineCount} K线
</div>
</div>
{traderID && (
<div className="p-4 rounded" style={{ background: '#1E2329', border: '1px solid #2B3139' }}>
<div className="text-sm mb-2" style={{ color: '#848E9C' }}></div>
<div className="text-2xl font-bold" style={{ color: '#F0B90B' }}>
{orderCount}
</div>
</div>
)}
<div className="p-4 rounded" style={{ background: '#1E2329', border: '1px solid #2B3139' }}>
<div className="text-sm mb-2" style={{ color: '#848E9C' }}></div>
<div className="text-lg" style={{ color: '#EAECEF' }}>
</div>
</div>
</>
)}
</div>
</div>
)
}