feat: 实现 Builder API Key 系统级配置和 Gasless 交易支持
- 新增系统配置表(SystemConfig)用于存储 Builder API Key - 实现 Builder API Key 的前端配置页面 - 集成 Builder Relayer API 支持 Gasless 交易 - 在 API 健康检查中添加 Builder Relayer API 检测 - 移除前端 API 测试功能,简化配置页面 - 修复赎回仓位时的 Builder API Key 检查逻辑 - 更新错误处理,引导用户配置 Builder API Key
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { useEffect, useState, useMemo } from 'react'
|
||||
import { Card, Table, Tag, message, Space, Input, Radio, Select, Button, Row, Col, Empty, Modal, Form, Descriptions } from 'antd'
|
||||
import { SearchOutlined, AppstoreOutlined, UnorderedListOutlined, UpOutlined, DownOutlined } from '@ant-design/icons'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { apiService } from '../services/api'
|
||||
import type { AccountPosition, Account, PositionPushMessage, PositionSellRequest, MarketPriceResponse, RedeemablePositionsSummary, PositionRedeemRequest } from '../types'
|
||||
import { getPositionKey } from '../types'
|
||||
@@ -13,6 +14,7 @@ type PositionFilter = 'current' | 'historical'
|
||||
type ViewMode = 'card' | 'list'
|
||||
|
||||
const PositionList: React.FC = () => {
|
||||
const navigate = useNavigate()
|
||||
const isMobile = useMediaQuery({ maxWidth: 768 })
|
||||
const [currentPositions, setCurrentPositions] = useState<AccountPosition[]>([])
|
||||
const [historyPositions, setHistoryPositions] = useState<AccountPosition[]>([])
|
||||
@@ -113,10 +115,34 @@ const PositionList: React.FC = () => {
|
||||
// 刷新可赎回统计
|
||||
await fetchRedeemableSummary()
|
||||
} else {
|
||||
message.error(response.data.msg || '赎回失败')
|
||||
// 检查是否是 Builder API Key 未配置的错误
|
||||
if (response.data.code === 2014 || response.data.msg?.includes('Builder API Key 未配置')) {
|
||||
message.error({
|
||||
content: response.data.msg || 'Builder API Key 未配置',
|
||||
duration: 5,
|
||||
})
|
||||
// 延迟跳转,让用户看到错误消息
|
||||
setTimeout(() => {
|
||||
navigate('/system-settings/builder-api-key')
|
||||
}, 1500)
|
||||
} else {
|
||||
message.error(response.data.msg || '赎回失败')
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
message.error('赎回失败: ' + (error.message || '未知错误'))
|
||||
// 检查是否是 Builder API Key 未配置的错误
|
||||
if (error.response?.data?.code === 2014 || error.message?.includes('Builder API Key 未配置')) {
|
||||
message.error({
|
||||
content: error.response?.data?.msg || error.message || 'Builder API Key 未配置,请前往系统设置页面配置',
|
||||
duration: 5,
|
||||
})
|
||||
// 延迟跳转,让用户看到错误消息
|
||||
setTimeout(() => {
|
||||
navigate('/system-settings/builder-api-key')
|
||||
}, 1500)
|
||||
} else {
|
||||
message.error('赎回失败: ' + (error.message || '未知错误'))
|
||||
}
|
||||
} finally {
|
||||
setRedeeming(false)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user