fix: 修复币安白名单IP复制功能失效问题 (#680)

## 🐛 问题描述
币安交易所配置页面中的服务器IP复制功能无法正常工作
## 🔍 根因分析
原始实现仅使用 navigator.clipboard.writeText() API:
- 在某些浏览器环境下不可用或被阻止
- 需要 HTTPS 或 localhost 环境
- 缺少错误处理和用户反馈
##  修复方案
1. **双重降级机制**:
   - 优先使用现代 Clipboard API
   - 降级到传统 execCommand 方法
2. **错误处理**:
   - 添加 try-catch 错误捕获
   - 失败时显示友好的错误提示
   - 提供IP地址供用户手动复制
3. **多语言支持**:
   - 添加 copyIPFailed 翻译键(中英文)
## 📝 修改文件
- web/src/components/AITradersPage.tsx
  - handleCopyIP 函数重构为异步函数
  - 添加双重复制机制和错误处理
- web/src/i18n/translations.ts
  - 添加 copyIPFailed 错误提示翻译
## 🧪 测试验证
 TypeScript 编译通过
 Vite 构建成功
 支持现代和传统浏览器环境
Co-authored-by: tinkle-community <tinklefund@gmail.com>
This commit is contained in:
Sue
2025-11-11 09:34:22 +08:00
committed by GitHub
parent e6689eeb5b
commit e49aa09de1
2 changed files with 37 additions and 5 deletions

View File

@@ -373,6 +373,7 @@ export const translations = {
serverIPAddresses: 'Server IP Addresses',
copyIP: 'Copy',
ipCopied: 'IP Copied',
copyIPFailed: 'Failed to copy IP address. Please copy manually',
loadingServerIP: 'Loading server IP...',
// Error Messages
@@ -1143,6 +1144,7 @@ export const translations = {
serverIPAddresses: '服务器IP地址',
copyIP: '复制',
ipCopied: 'IP已复制',
copyIPFailed: 'IP地址复制失败请手动复制',
loadingServerIP: '正在加载服务器IP...',
// Error Messages