mirror of
https://github.com/laoxong/nofx.git
synced 2026-06-04 09:58:22 +08:00
feat: add dropdown selector for Recent Decisions count (5/10/20/50/100)
This commit is contained in:
+27
-3
@@ -98,6 +98,7 @@ function App() {
|
||||
const [currentPage, setCurrentPage] = useState<Page>(getInitialPage())
|
||||
const [selectedTraderId, setSelectedTraderId] = useState<string | undefined>()
|
||||
const [lastUpdate, setLastUpdate] = useState<string>('--:--:--')
|
||||
const [decisionsLimit, setDecisionsLimit] = useState<number>(5)
|
||||
|
||||
// 监听URL变化,同步页面状态
|
||||
useEffect(() => {
|
||||
@@ -209,9 +210,9 @@ function App() {
|
||||
|
||||
const { data: decisions } = useSWR<DecisionRecord[]>(
|
||||
currentPage === 'trader' && selectedTraderId
|
||||
? `decisions/latest-${selectedTraderId}`
|
||||
? `decisions/latest-${selectedTraderId}-${decisionsLimit}`
|
||||
: null,
|
||||
() => api.getLatestDecisions(selectedTraderId),
|
||||
() => api.getLatestDecisions(selectedTraderId, decisionsLimit),
|
||||
{
|
||||
refreshInterval: 30000, // 30秒刷新(决策更新频率较低)
|
||||
revalidateOnFocus: false,
|
||||
@@ -477,6 +478,8 @@ function App() {
|
||||
account={account}
|
||||
positions={positions}
|
||||
decisions={decisions}
|
||||
decisionsLimit={decisionsLimit}
|
||||
onDecisionsLimitChange={setDecisionsLimit}
|
||||
stats={stats}
|
||||
lastUpdate={lastUpdate}
|
||||
language={language}
|
||||
@@ -601,6 +604,8 @@ function TraderDetailsPage({
|
||||
account,
|
||||
positions,
|
||||
decisions,
|
||||
decisionsLimit,
|
||||
onDecisionsLimitChange,
|
||||
lastUpdate,
|
||||
language,
|
||||
traders,
|
||||
@@ -620,6 +625,8 @@ function TraderDetailsPage({
|
||||
account?: AccountInfo
|
||||
positions?: Position[]
|
||||
decisions?: DecisionRecord[]
|
||||
decisionsLimit: number
|
||||
onDecisionsLimitChange: (limit: number) => void
|
||||
stats?: Statistics
|
||||
lastUpdate: string
|
||||
language: Language
|
||||
@@ -1164,7 +1171,7 @@ function TraderDetailsPage({
|
||||
>
|
||||
🧠
|
||||
</div>
|
||||
<div>
|
||||
<div className="flex-1">
|
||||
<h2 className="text-xl font-bold" style={{ color: '#EAECEF' }}>
|
||||
{t('recentDecisions', language)}
|
||||
</h2>
|
||||
@@ -1174,6 +1181,23 @@ function TraderDetailsPage({
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{/* 数量选择器 */}
|
||||
<select
|
||||
value={decisionsLimit}
|
||||
onChange={(e) => onDecisionsLimitChange(Number(e.target.value))}
|
||||
className="px-3 py-1.5 rounded-lg text-sm font-medium cursor-pointer transition-all"
|
||||
style={{
|
||||
background: '#2B3139',
|
||||
color: '#EAECEF',
|
||||
border: '1px solid #3C4043',
|
||||
}}
|
||||
>
|
||||
<option value={5}>5</option>
|
||||
<option value={10}>10</option>
|
||||
<option value={20}>20</option>
|
||||
<option value={50}>50</option>
|
||||
<option value={100}>100</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{/* 决策列表 - 可滚动 */}
|
||||
|
||||
Reference in New Issue
Block a user