fix: 修复 InputNumber formatter 正则表达式错误,导致输入 10 变成 1 的问题

- 修复 copyRatio InputNumber 的 parser 函数,正确处理 % 符号和最小值检查
- 修复所有 formatter 函数中的正则表达式:将 /\.?0+$/ 改为 /\.0+$/
- 添加调试日志用于问题排查(可后续移除)

修复的文件:
- CopyTradingAdd.tsx
- CopyTradingEdit.tsx
- CopyTradingOrders/EditModal.tsx
- CopyTradingList.tsx
- TemplateList.tsx
- TemplateEdit.tsx
- TemplateAdd.tsx

问题原因:
错误的正则表达式 /\.?0+$/ 会匹配整数末尾的 0(如 "10" 的末尾 "0"),
导致 "10" 被错误替换为 "1"。
正确的正则表达式 /\.0+$/ 只匹配小数点后的尾随零。
This commit is contained in:
WrBug
2026-01-04 12:13:40 +08:00
parent a097376db7
commit d9443e0d56
7 changed files with 479 additions and 38 deletions
+2 -2
View File
@@ -196,7 +196,7 @@ const CopyTradingList: React.FC = () => {
render: (_: any, record: CopyTrading) => (
<Tag color={record.copyMode === 'RATIO' ? 'blue' : 'green'}>
{record.copyMode === 'RATIO'
? `${t('copyTradingList.ratioMode') || '比例'} ${record.copyRatio}x`
? `${t('copyTradingList.ratioMode') || '比例'} ${(parseFloat(record.copyRatio || '0') * 100).toFixed(2).replace(/\.0+$/, '')}%`
: `${t('copyTradingList.fixedAmountMode') || '固定'} ${formatUSDC(record.fixedAmount || '0')}`
}
</Tag>
@@ -466,7 +466,7 @@ const CopyTradingList: React.FC = () => {
color: '#666'
}}>
{record.copyMode === 'RATIO'
? `${t('copyTradingList.ratioMode') || '比例'} ${record.copyRatio}x`
? `${t('copyTradingList.ratioMode') || '比例'} ${(parseFloat(record.copyRatio || '0') * 100).toFixed(2).replace(/\.0+$/, '')}%`
: `${t('copyTradingList.fixedAmountMode') || '固定'} ${formatUSDC(record.fixedAmount || '0')}`
}
</div>