mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-16 17:12:25 +08:00
feat: add dropdown selector for Recent Decisions count (5/10/20/50/100)
This commit is contained in:
@@ -98,6 +98,7 @@ function App() {
|
|||||||
const [currentPage, setCurrentPage] = useState<Page>(getInitialPage())
|
const [currentPage, setCurrentPage] = useState<Page>(getInitialPage())
|
||||||
const [selectedTraderId, setSelectedTraderId] = useState<string | undefined>()
|
const [selectedTraderId, setSelectedTraderId] = useState<string | undefined>()
|
||||||
const [lastUpdate, setLastUpdate] = useState<string>('--:--:--')
|
const [lastUpdate, setLastUpdate] = useState<string>('--:--:--')
|
||||||
|
const [decisionsLimit, setDecisionsLimit] = useState<number>(5)
|
||||||
|
|
||||||
// 监听URL变化,同步页面状态
|
// 监听URL变化,同步页面状态
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -209,9 +210,9 @@ function App() {
|
|||||||
|
|
||||||
const { data: decisions } = useSWR<DecisionRecord[]>(
|
const { data: decisions } = useSWR<DecisionRecord[]>(
|
||||||
currentPage === 'trader' && selectedTraderId
|
currentPage === 'trader' && selectedTraderId
|
||||||
? `decisions/latest-${selectedTraderId}`
|
? `decisions/latest-${selectedTraderId}-${decisionsLimit}`
|
||||||
: null,
|
: null,
|
||||||
() => api.getLatestDecisions(selectedTraderId),
|
() => api.getLatestDecisions(selectedTraderId, decisionsLimit),
|
||||||
{
|
{
|
||||||
refreshInterval: 30000, // 30秒刷新(决策更新频率较低)
|
refreshInterval: 30000, // 30秒刷新(决策更新频率较低)
|
||||||
revalidateOnFocus: false,
|
revalidateOnFocus: false,
|
||||||
@@ -477,6 +478,8 @@ function App() {
|
|||||||
account={account}
|
account={account}
|
||||||
positions={positions}
|
positions={positions}
|
||||||
decisions={decisions}
|
decisions={decisions}
|
||||||
|
decisionsLimit={decisionsLimit}
|
||||||
|
onDecisionsLimitChange={setDecisionsLimit}
|
||||||
stats={stats}
|
stats={stats}
|
||||||
lastUpdate={lastUpdate}
|
lastUpdate={lastUpdate}
|
||||||
language={language}
|
language={language}
|
||||||
@@ -601,6 +604,8 @@ function TraderDetailsPage({
|
|||||||
account,
|
account,
|
||||||
positions,
|
positions,
|
||||||
decisions,
|
decisions,
|
||||||
|
decisionsLimit,
|
||||||
|
onDecisionsLimitChange,
|
||||||
lastUpdate,
|
lastUpdate,
|
||||||
language,
|
language,
|
||||||
traders,
|
traders,
|
||||||
@@ -620,6 +625,8 @@ function TraderDetailsPage({
|
|||||||
account?: AccountInfo
|
account?: AccountInfo
|
||||||
positions?: Position[]
|
positions?: Position[]
|
||||||
decisions?: DecisionRecord[]
|
decisions?: DecisionRecord[]
|
||||||
|
decisionsLimit: number
|
||||||
|
onDecisionsLimitChange: (limit: number) => void
|
||||||
stats?: Statistics
|
stats?: Statistics
|
||||||
lastUpdate: string
|
lastUpdate: string
|
||||||
language: Language
|
language: Language
|
||||||
@@ -1164,7 +1171,7 @@ function TraderDetailsPage({
|
|||||||
>
|
>
|
||||||
🧠
|
🧠
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div className="flex-1">
|
||||||
<h2 className="text-xl font-bold" style={{ color: '#EAECEF' }}>
|
<h2 className="text-xl font-bold" style={{ color: '#EAECEF' }}>
|
||||||
{t('recentDecisions', language)}
|
{t('recentDecisions', language)}
|
||||||
</h2>
|
</h2>
|
||||||
@@ -1174,6 +1181,23 @@ function TraderDetailsPage({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</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>
|
</div>
|
||||||
|
|
||||||
{/* 决策列表 - 可滚动 */}
|
{/* 决策列表 - 可滚动 */}
|
||||||
|
|||||||
Reference in New Issue
Block a user