feat: 添加市场信息管理和订单ID复制功能
- 新增市场信息表和服务,支持市场名称缓存和自动更新 - 创建 Market 实体和 MarketRepository - 实现 MarketService 提供市场信息查询和缓存 - 实现 MarketPollingService 每30秒自动检查并更新缺失的市场信息 - 添加数据库迁移 V19 创建 markets 表 - 订单列表显示市场名称 - 在 BuyOrderInfo、SellOrderInfo、MatchedOrderInfo 中添加 marketTitle 字段 - 订单查询时自动查询并填充市场名称 - 前端订单列表显示市场名称(优先显示名称,ID作为辅助信息) - 前端订单ID复制功能 - 添加 isAutoGeneratedOrderId 和 copyToClipboard 工具函数 - 非自动生成的订单ID支持一键复制 - 买入、卖出、匹配订单列表均支持复制功能 - 仓位检查延迟检测机制优化 - 首次检测到仓位不存在时先记录,3分钟后再次检查 - 避免因API延迟导致的误判
This commit is contained in:
@@ -83,3 +83,44 @@ export {
|
||||
getGitHubTagUrl
|
||||
} from './version'
|
||||
|
||||
/**
|
||||
* 检查订单ID是否为自动生成的
|
||||
* 自动生成的订单ID通常以 "AUTO_" 或 "AUTO_FIFO_" 开头
|
||||
* @param orderId - 订单ID
|
||||
* @returns 如果是自动生成的订单ID,返回 true,否则返回 false
|
||||
*/
|
||||
export const isAutoGeneratedOrderId = (orderId: string | undefined | null): boolean => {
|
||||
if (!orderId) return false
|
||||
return orderId.startsWith('AUTO_') || orderId.startsWith('AUTO_FIFO_')
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制文本到剪贴板
|
||||
* @param text - 要复制的文本
|
||||
* @returns Promise<boolean> - 复制成功返回 true,失败返回 false
|
||||
*/
|
||||
export const copyToClipboard = async (text: string): Promise<boolean> => {
|
||||
try {
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
await navigator.clipboard.writeText(text)
|
||||
return true
|
||||
} else {
|
||||
// 降级方案:使用传统的 document.execCommand
|
||||
const textArea = document.createElement('textarea')
|
||||
textArea.value = text
|
||||
textArea.style.position = 'fixed'
|
||||
textArea.style.left = '-999999px'
|
||||
textArea.style.top = '-999999px'
|
||||
document.body.appendChild(textArea)
|
||||
textArea.focus()
|
||||
textArea.select()
|
||||
const successful = document.execCommand('copy')
|
||||
document.body.removeChild(textArea)
|
||||
return successful
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('复制到剪贴板失败:', error)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user