Files
PolyHermes/frontend/src/components/LeaderSelect.tsx
T
WrBug 5487c7c862 feat(leader): Leader 管理展示跟单/回测数量并支持跳转筛选
- 后端:LeaderDto 增加 backtestCount,LeaderService 统计回测数并返回
- Leader 列表:展示跟单数、回测数,点击跳转跟单配置/回测页并带 leaderId 筛选
- 跟单配置页:从 URL 读取 leaderId 并应用筛选,Leader 下拉改用 LeaderSelect
- 回测页:支持 Leader 筛选,页面加载时请求 Leader 列表,筛选与详情统一显示规则
- LeaderSelect:支持 style,回测/跟单筛选统一使用
- 多语言:补充 leaderList 相关 key
- 移动端:Leader 管理卡片内按钮增加内边距 padding 8px 16px

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 02:03:17 +08:00

71 lines
1.6 KiB
TypeScript

import React from 'react'
import { Select } from 'antd'
import type { Leader } from '../types'
const { Option } = Select
interface LeaderSelectProps {
value?: number
onChange?: (value: number | undefined) => void
onSelectChange?: (value: number | undefined) => void // 选择变化时的回调
leaders: Leader[]
placeholder?: string
disabled?: boolean
showSearch?: boolean
allowClear?: boolean
notFoundContent?: React.ReactNode
style?: React.CSSProperties
}
const LeaderSelect: React.FC<LeaderSelectProps> = ({
value,
onChange,
onSelectChange,
leaders,
placeholder,
disabled,
showSearch = true,
allowClear = false,
notFoundContent,
style
}) => {
// 处理选择变化
const handleChange = (val: number | undefined) => {
if (onChange) {
onChange(val)
}
if (onSelectChange) {
onSelectChange(val)
}
}
return (
<Select
value={value}
onChange={handleChange}
placeholder={placeholder}
disabled={disabled}
showSearch={showSearch}
allowClear={allowClear}
notFoundContent={notFoundContent}
style={style}
optionFilterProp="label"
optionLabelProp="label"
>
{leaders.map(leader => {
const label = leader.leaderName || `Leader ${leader.id}`
return (
<Option key={leader.id} value={leader.id} label={label}>
<div style={{ display: 'flex', flexDirection: 'column' }}>
<span>{label}</span>
<span style={{ fontSize: '12px', color: '#999' }}>{leader.leaderAddress}</span>
</div>
</Option>
)
})}
</Select>
)
}
export default LeaderSelect