feat: 优化跟单买入逻辑和错误处理
- 更新 Twitter 链接为 @polyhermes - 简化订单创建失败日志,只保留 code 和 errorBody - 修复 @Transactional 注解问题(类改为 open class) - 改进唯一键冲突异常处理,支持并发场景 - 整理跟单买入和重试逻辑,使用常量配置 - 重试延迟从 1 秒调整为 3 秒 - 添加订单簿匹配检查,避免 FAK 订单失败 - 前端移除 Leader 管理的分类相关设置和显示 - 补充多语言翻译(AccountImport 和 CopyTradingList)
This commit is contained in:
@@ -238,7 +238,7 @@ const Layout: React.FC<LayoutProps> = ({ children }) => {
|
||||
<GithubOutlined />
|
||||
</a>
|
||||
<a
|
||||
href="https://x.com/quant_tr"
|
||||
href="https://x.com/polyhermes"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
style={{ color: '#fff', fontSize: '16px', display: 'flex', alignItems: 'center' }}
|
||||
@@ -362,7 +362,7 @@ const Layout: React.FC<LayoutProps> = ({ children }) => {
|
||||
<GithubOutlined />
|
||||
</a>
|
||||
<a
|
||||
href="https://x.com/quant_tr"
|
||||
href="https://x.com/polyhermes"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
style={{ color: '#fff', fontSize: '18px', display: 'flex', alignItems: 'center' }}
|
||||
|
||||
@@ -856,6 +856,8 @@
|
||||
"copyTradingList": {
|
||||
"title": "Copy Trading Config Management",
|
||||
"addCopyTrading": "Add Copy Trading",
|
||||
"configName": "Config Name",
|
||||
"configNameNotProvided": "Not Provided",
|
||||
"wallet": "Wallet",
|
||||
"account": "Account",
|
||||
"template": "Template",
|
||||
|
||||
@@ -117,19 +117,40 @@
|
||||
},
|
||||
"accountImport": {
|
||||
"title": "导入账户",
|
||||
"back": "返回",
|
||||
"securityTip": "安全提示",
|
||||
"securityTipDesc": "私钥将存储在后端数据库中,请确保数据库访问安全。建议使用 HTTPS 连接。",
|
||||
"importMethod": "导入方式",
|
||||
"privateKey": "私钥",
|
||||
"mnemonic": "助记词",
|
||||
"privateKeyLabel": "私钥",
|
||||
"privateKeyPlaceholder": "请输入私钥(64位十六进制字符串,可选0x前缀)",
|
||||
"privateKeyRequired": "请输入私钥",
|
||||
"privateKeyPlaceholder": "请输入或粘贴私钥",
|
||||
"privateKeyHelp": "私钥将加密存储,仅用于签名交易",
|
||||
"privateKeyInvalid": "私钥格式不正确(应为64位十六进制字符串)",
|
||||
"walletAddress": "钱包地址",
|
||||
"walletAddressPlaceholder": "钱包地址(将从私钥自动推导)",
|
||||
"walletAddressRequired": "请输入钱包地址",
|
||||
"walletAddressInvalid": "钱包地址格式不正确",
|
||||
"walletAddressMismatch": "钱包地址与私钥不匹配",
|
||||
"mnemonicLabel": "助记词",
|
||||
"mnemonicPlaceholder": "请输入12或24个单词的助记词(用空格分隔)",
|
||||
"mnemonicRequired": "请输入助记词",
|
||||
"mnemonicInvalid": "助记词格式不正确(应为12或24个单词,用空格分隔)",
|
||||
"walletAddressMismatchMnemonic": "钱包地址与助记词不匹配",
|
||||
"accountName": "账户名称",
|
||||
"accountNameRequired": "请输入账户名称",
|
||||
"accountNamePlaceholder": "请输入账户名称",
|
||||
"accountNamePlaceholder": "可选,用于标识账户",
|
||||
"accountNameHelp": "用于标识账户,便于管理",
|
||||
"privateKeyHelp": "私钥将加密存储,仅用于签名交易",
|
||||
"submit": "导入",
|
||||
"invalidPrivateKey": "无效的私钥",
|
||||
"duplicateAccount": "账户已存在",
|
||||
"importAccount": "导入账户",
|
||||
"importSuccess": "导入账户成功",
|
||||
"importFailed": "导入账户失败",
|
||||
"invalidPrivateKey": "无效的私钥",
|
||||
"duplicateAccount": "账户已存在"
|
||||
"derivedAddress": "推导地址",
|
||||
"addressError": "无法从私钥推导地址",
|
||||
"addressErrorMnemonic": "无法从助记词推导地址"
|
||||
},
|
||||
"leader": {
|
||||
"title": "Leader 管理",
|
||||
|
||||
@@ -856,6 +856,8 @@
|
||||
"copyTradingList": {
|
||||
"title": "跟單配置管理",
|
||||
"addCopyTrading": "新增跟單",
|
||||
"configName": "配置名",
|
||||
"configNameNotProvided": "未提供",
|
||||
"wallet": "錢包",
|
||||
"account": "賬戶",
|
||||
"template": "模板",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { Card, Form, Input, Button, Select, message, Typography, Space } from 'antd'
|
||||
import { Card, Form, Input, Button, message, Typography, Space } from 'antd'
|
||||
import { ArrowLeftOutlined } from '@ant-design/icons'
|
||||
import { apiService } from '../services/api'
|
||||
import { useMediaQuery } from 'react-responsive'
|
||||
@@ -8,7 +8,6 @@ import { useTranslation } from 'react-i18next'
|
||||
import { isValidWalletAddress } from '../utils'
|
||||
|
||||
const { Title } = Typography
|
||||
const { Option } = Select
|
||||
|
||||
const LeaderAdd: React.FC = () => {
|
||||
const { t } = useTranslation()
|
||||
@@ -24,8 +23,7 @@ const LeaderAdd: React.FC = () => {
|
||||
leaderAddress: values.leaderAddress.trim(),
|
||||
leaderName: values.leaderName?.trim() || undefined,
|
||||
remark: values.remark?.trim() || undefined,
|
||||
website: values.website?.trim() || undefined,
|
||||
category: values.category || undefined
|
||||
website: values.website?.trim() || undefined
|
||||
})
|
||||
|
||||
if (response.data.code === 0) {
|
||||
@@ -121,17 +119,6 @@ const LeaderAdd: React.FC = () => {
|
||||
<Input placeholder={t('leaderAdd.websitePlaceholder') || '可选,例如:https://example.com'} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label={t('leaderAdd.category') || '分类筛选'}
|
||||
name="category"
|
||||
tooltip={t('leaderAdd.categoryTooltip') || '仅跟单该分类的交易,不选择则跟单所有分类(sports 或 crypto)'}
|
||||
>
|
||||
<Select placeholder={t('leaderAdd.categoryPlaceholder') || '选择分类(可选)'} allowClear>
|
||||
<Option value="sports">Sports</Option>
|
||||
<Option value="crypto">Crypto</Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item>
|
||||
<Space>
|
||||
<Button
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import { useNavigate, useSearchParams } from 'react-router-dom'
|
||||
import { Card, Form, Input, Button, Select, message, Typography, Space, Spin } from 'antd'
|
||||
import { Card, Form, Input, Button, message, Typography, Space, Spin } from 'antd'
|
||||
import { ArrowLeftOutlined } from '@ant-design/icons'
|
||||
import { apiService } from '../services/api'
|
||||
import { useMediaQuery } from 'react-responsive'
|
||||
@@ -8,7 +8,6 @@ import { useTranslation } from 'react-i18next'
|
||||
import type { Leader } from '../types'
|
||||
|
||||
const { Title } = Typography
|
||||
const { Option } = Select
|
||||
|
||||
const LeaderEdit: React.FC = () => {
|
||||
const { t } = useTranslation()
|
||||
@@ -38,8 +37,7 @@ const LeaderEdit: React.FC = () => {
|
||||
form.setFieldsValue({
|
||||
leaderName: leader.leaderName || '',
|
||||
remark: leader.remark || '',
|
||||
website: leader.website || '',
|
||||
category: leader.category || undefined
|
||||
website: leader.website || ''
|
||||
})
|
||||
} else {
|
||||
message.error(response.data.msg || t('leaderEdit.fetchFailed') || '获取 Leader 详情失败')
|
||||
@@ -65,8 +63,7 @@ const LeaderEdit: React.FC = () => {
|
||||
leaderId: parseInt(leaderId),
|
||||
leaderName: values.leaderName?.trim() || undefined,
|
||||
remark: values.remark?.trim() || undefined,
|
||||
website: values.website?.trim() || undefined,
|
||||
category: values.category || undefined
|
||||
website: values.website?.trim() || undefined
|
||||
})
|
||||
|
||||
if (response.data.code === 0) {
|
||||
@@ -145,17 +142,6 @@ const LeaderEdit: React.FC = () => {
|
||||
<Input placeholder={t('leaderEdit.websitePlaceholder') || '可选,例如:https://example.com'} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label={t('leaderEdit.category') || '分类筛选'}
|
||||
name="category"
|
||||
tooltip={t('leaderEdit.categoryTooltip') || '仅跟单该分类的交易,不选择则跟单所有分类(sports 或 crypto)'}
|
||||
>
|
||||
<Select placeholder={t('leaderEdit.categoryPlaceholder') || '选择分类(可选)'} allowClear>
|
||||
<Option value="sports">Sports</Option>
|
||||
<Option value="crypto">Crypto</Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item>
|
||||
<Space>
|
||||
<Button
|
||||
|
||||
@@ -67,14 +67,6 @@ const LeaderList: React.FC = () => {
|
||||
</span>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: t('leaderList.category') || '分类',
|
||||
dataIndex: 'category',
|
||||
key: 'category',
|
||||
render: (category: string | undefined) => category ? (
|
||||
<Tag color={category === 'sports' ? 'blue' : 'green'}>{category}</Tag>
|
||||
) : <Tag>{t('leaderList.all') || '全部'}</Tag>
|
||||
},
|
||||
{
|
||||
title: t('leaderList.remark') || '备注',
|
||||
dataIndex: 'remark',
|
||||
@@ -252,18 +244,9 @@ const LeaderList: React.FC = () => {
|
||||
|
||||
<Divider style={{ margin: '12px 0' }} />
|
||||
|
||||
{/* 分类和跟单关系数 */}
|
||||
{/* 跟单关系数 */}
|
||||
<div style={{ marginBottom: '12px' }}>
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '6px', alignItems: 'center' }}>
|
||||
{leader.category ? (
|
||||
<Tag color={leader.category === 'sports' ? 'blue' : 'green'}>
|
||||
{leader.category}
|
||||
</Tag>
|
||||
) : (
|
||||
<Tag>{t('leaderList.all') || '全部'}</Tag>
|
||||
)}
|
||||
<Tag>{t('leaderList.copyTradingRelations', { count: leader.copyTradingCount }) || `${leader.copyTradingCount} 个跟单关系`}</Tag>
|
||||
</div>
|
||||
<Tag>{t('leaderList.copyTradingRelations', { count: leader.copyTradingCount }) || `${leader.copyTradingCount} 个跟单关系`}</Tag>
|
||||
</div>
|
||||
|
||||
{/* 创建时间 */}
|
||||
|
||||
Reference in New Issue
Block a user