feat: supported models and exchange fix

This commit is contained in:
icy
2025-11-06 20:39:20 +08:00
parent 6fa30b6d40
commit 75db4c01e3

View File

@@ -136,33 +136,17 @@ export function AITradersPage({ onTraderSelect }: AITradersPageProps) {
const configuredExchanges = allExchanges || [] const configuredExchanges = allExchanges || []
const selectableModels = useMemo(() => { const selectableModels = useMemo(() => {
const map = new Map<string, AIModel>() return (supportedModels || []).map((model) => {
;(supportedModels || []).forEach((model) => { const configured = allModels?.find((m) => m.id === model.id)
if (model?.id) { return configured ? { ...model, ...configured } : model
map.set(model.id, model)
}
}) })
;(allModels || []).forEach((model) => {
if (model?.id) {
map.set(model.id, { ...map.get(model.id), ...model })
}
})
return Array.from(map.values())
}, [supportedModels, allModels]) }, [supportedModels, allModels])
const selectableExchanges = useMemo(() => { const selectableExchanges = useMemo(() => {
const map = new Map<string, Exchange>() return (supportedExchanges || []).map((exchange) => {
;(supportedExchanges || []).forEach((exchange) => { const configured = allExchanges?.find((e) => e.id === exchange.id)
if (exchange?.id) { return configured ? { ...exchange, ...configured } : exchange
map.set(exchange.id, exchange)
}
}) })
;(allExchanges || []).forEach((exchange) => {
if (exchange?.id) {
map.set(exchange.id, { ...map.get(exchange.id), ...exchange })
}
})
return Array.from(map.values())
}, [supportedExchanges, allExchanges]) }, [supportedExchanges, allExchanges])
// 只在创建交易员时使用已启用且配置完整的 // 只在创建交易员时使用已启用且配置完整的
@@ -449,7 +433,17 @@ export function AITradersPage({ onTraderSelect }: AITradersPageProps) {
const updatedExchanges = const updatedExchanges =
allExchanges?.map((e) => allExchanges?.map((e) =>
e.id === exchangeId e.id === exchangeId
? { ...e, apiKey: '', secretKey: '', enabled: false } ? {
...e,
apiKey: '',
secretKey: '',
hyperliquidWalletAddr: '',
asterUser: '',
asterSigner: '',
asterPrivateKey: '',
testnet: false,
enabled: false,
}
: e : e
) || [] ) || []
@@ -462,6 +456,11 @@ export function AITradersPage({ onTraderSelect }: AITradersPageProps) {
api_key: exchange.apiKey || '', api_key: exchange.apiKey || '',
secret_key: exchange.secretKey || '', secret_key: exchange.secretKey || '',
testnet: exchange.testnet || false, testnet: exchange.testnet || false,
hyperliquid_wallet_addr:
exchange.hyperliquidWalletAddr || '',
aster_user: exchange.asterUser || '',
aster_signer: exchange.asterSigner || '',
aster_private_key: exchange.asterPrivateKey || '',
}, },
]) ])
), ),