feat: 完善 Telegram 推送通知功能

- 推送模板优化:
  - 优先使用账户名称而不是钱包地址
  - 使用市场标题而不是16进制ID
  - 添加可点击的市场链接(支持 slug 和 conditionId)
  - 添加市场方向(outcome)显示
  - 数量和价格从订单详情API获取实际值
  - 失败通知只显示后端返回的msg,不显示完整堆栈

- 多语言支持:
  - 后端推送消息支持多语言(使用前端最后请求的语言)
  - 添加所有 ErrorCode 的多语言资源文件(中文简体、繁体、英文)
  - 通知消息文本全部使用多语言资源

- 功能改进:
  - 从订单详情获取实际的 side、price、size、outcome
  - 支持买入/卖出方向的多语言显示
  - 错误信息优化,只显示后端返回的错误消息
This commit is contained in:
WrBug
2025-12-05 02:20:46 +08:00
parent 41596887c9
commit 777710c2ed
32 changed files with 4059 additions and 21 deletions
+71
View File
@@ -203,6 +203,7 @@
"language": "Language",
"apiHealth": "API Health",
"proxy": "Proxy",
"notifications": "Notifications",
"logout": "Logout",
"logoutConfirm": "Confirm Logout",
"logoutConfirmDesc": "Are you sure you want to logout?",
@@ -428,5 +429,75 @@
"deleteSuccess": "Copy trading deleted successfully",
"deleteFailed": "Failed to delete copy trading",
"deleteConfirm": "Are you sure you want to delete this copy trading relationship?"
},
"notificationSettings": {
"title": "Notification Settings",
"addConfig": "Add Configuration",
"editConfig": "Edit Configuration",
"configName": "Configuration Name",
"configNamePlaceholder": "e.g., My Telegram Bot",
"configNameRequired": "Please enter configuration name",
"type": "Notification Type",
"typeRequired": "Please select notification type",
"enabled": "Enabled Status",
"status": "Status",
"enabledStatus": "Enabled",
"disabledStatus": "Disabled",
"chatIds": "Chat IDs",
"chatIdsPlaceholder": "Chat IDs (click button above to auto-fetch, or enter manually, separate multiple with commas)",
"chatIdsRequired": "Please enter at least one Chat ID",
"chatIdsExtra": "Multiple Chat IDs separated by commas, e.g., 123456789,987654321. Click button above to auto-fetch (need to send message to bot first)",
"chatIdsCount": " recipients",
"chatIdsNotConfigured": "Not Configured",
"edit": "Edit",
"test": "Test",
"delete": "Delete",
"deleteConfirm": "Are you sure you want to delete this configuration?",
"enableSuccess": "Enabled",
"disableSuccess": "Disabled",
"updateStatusFailed": "Failed to update",
"deleteSuccess": "Deleted successfully",
"deleteFailed": "Failed to delete",
"createSuccess": "Created successfully",
"createFailed": "Failed to create",
"updateSuccess": "Updated successfully",
"updateFailed": "Failed to update",
"fetchFailed": "Failed to get configuration list",
"testSuccess": "Test message sent successfully, please check Telegram",
"testFailed": "Failed to send test message",
"getChatIdsSuccess": "Successfully fetched {count} Chat ID(s)",
"getChatIdsFailed": "Failed to get Chat IDs",
"getChatIdsNoToken": "Please enter Bot Token first",
"getChatIdsNoMessage": "Chat ID not found, please send a message to the bot first (e.g., /start), then retry",
"getChatIdsButton": "Get Chat ID"
},
"telegramConfig": {
"title": "Telegram Configuration Guide",
"step1": "Create a Telegram bot via <strong>@BotFather</strong> and get Bot Token",
"step2": "After entering Bot Token, click 'Get Chat ID' button to auto-fetch (need to send message to bot first)",
"step3": "Or manually get Chat ID via <strong>@userinfobot</strong>",
"step4": "Support multiple Chat IDs (separated by commas), all configured users will receive notifications",
"step5": "Telegram messages will be sent automatically when orders succeed or fail",
"botToken": "Bot Token",
"botTokenPlaceholder": "Bot Token (from @BotFather)",
"botTokenRequired": "Please enter Bot Token"
},
"discordConfig": {
"title": "Discord Configuration Guide",
"step1": "Create a Webhook in Discord server",
"step2": "Copy Webhook URL and enter in configuration",
"step3": "Discord messages will be sent automatically when orders succeed or fail",
"webhookUrl": "Webhook URL",
"webhookUrlPlaceholder": "Webhook URL (from Discord server settings)",
"webhookUrlRequired": "Please enter Webhook URL"
},
"slackConfig": {
"title": "Slack Configuration Guide",
"step1": "Create an Incoming Webhook in Slack workspace",
"step2": "Copy Webhook URL and enter in configuration",
"step3": "Slack messages will be sent automatically when orders succeed or fail",
"webhookUrl": "Webhook URL",
"webhookUrlPlaceholder": "Webhook URL (from Slack App settings)",
"webhookUrlRequired": "Please enter Webhook URL"
}
}
+115
View File
@@ -56,14 +56,58 @@
"importAccount": "导入账户",
"accountName": "账户名称",
"walletAddress": "钱包地址",
"proxyAddress": "代理钱包地址",
"apiCredentials": "API 凭证",
"balance": "余额",
"activeOrders": "活跃订单",
"action": "操作",
"actions": "操作",
"detail": "详情",
"edit": "编辑",
"delete": "删除",
"viewDetail": "查看详情",
"deleteConfirm": "确定要删除这个账户吗?",
"deleteConfirmDesc": "删除账户前,请确保已取消所有活跃订单。删除后无法恢复,请谨慎操作!",
"deleteConfirmDescSimple": "删除后无法恢复,请谨慎操作!",
"deleteConfirmOk": "确定删除",
"deleteSuccess": "删除账户成功",
"deleteFailed": "删除账户失败",
"copySuccess": "已复制到剪贴板",
"copyFailed": "复制失败",
"fullConfig": "完整配置",
"partialConfig": "部分配置",
"notConfigured": "未配置",
"totalBalance": "总余额",
"available": "可用",
"position": "仓位",
"refreshBalance": "刷新余额",
"refreshBalanceSuccess": "余额刷新成功",
"refreshBalanceFailed": "刷新余额失败",
"getDetailFailed": "获取账户详情失败",
"openDetailFailed": "打开详情失败",
"accountDetail": "账户详情",
"accountId": "账户ID",
"apiKey": "API Key",
"apiSecret": "API Secret",
"apiPassphrase": "API Passphrase",
"configured": "已配置",
"notConfiguredStatus": "未配置",
"configStatus": "配置状态",
"statistics": "交易统计",
"totalOrders": "总订单数",
"activeOrdersCount": "活跃订单数",
"completedOrders": "已完成订单数",
"positionCount": "持仓数量",
"totalPnl": "总盈亏",
"editAccount": "编辑账户",
"editTip": "编辑提示",
"editTipDesc": "API 凭证字段留空表示不修改。如需更新 API 凭证,请输入新值;如需保持原值不变,请留空。",
"accountNamePlaceholder": "账户名称(可选)",
"leaveEmptyToNotModify": "留空表示不修改",
"updateSuccess": "更新账户成功",
"updateFailed": "更新账户失败",
"getDetailFailedForEdit": "获取账户详情失败",
"loading": "加载中...",
"fetchFailed": "获取账户列表失败"
},
"accountImport": {
@@ -104,6 +148,7 @@
"language": "语言",
"apiHealth": "API健康",
"proxy": "代理",
"notifications": "消息推送",
"logout": "退出登录",
"logoutConfirm": "确认退出",
"logoutConfirmDesc": "确定要退出登录吗?",
@@ -330,5 +375,75 @@
"deleteSuccess": "删除跟单成功",
"deleteFailed": "删除跟单失败",
"deleteConfirm": "确定要删除这个跟单关系吗?"
},
"notificationSettings": {
"title": "消息推送设置",
"addConfig": "添加配置",
"editConfig": "编辑配置",
"configName": "配置名称",
"configNamePlaceholder": "例如:我的 Telegram 机器人",
"configNameRequired": "请输入配置名称",
"type": "推送类型",
"typeRequired": "请选择推送类型",
"enabled": "启用状态",
"status": "状态",
"enabledStatus": "已启用",
"disabledStatus": "已禁用",
"chatIds": "Chat IDs",
"chatIdsPlaceholder": "Chat IDs(点击上方按钮自动获取,或手动输入,多个用逗号分隔)",
"chatIdsRequired": "请输入至少一个 Chat ID",
"chatIdsExtra": "多个 Chat ID 用逗号分隔,例如:123456789,987654321。点击上方按钮可自动获取(需要先向机器人发送消息)",
"chatIdsCount": "个接收者",
"chatIdsNotConfigured": "未配置",
"edit": "编辑",
"test": "测试",
"delete": "删除",
"deleteConfirm": "确定要删除这个配置吗?",
"enableSuccess": "已启用",
"disableSuccess": "已禁用",
"updateStatusFailed": "更新失败",
"deleteSuccess": "删除成功",
"deleteFailed": "删除失败",
"createSuccess": "创建成功",
"createFailed": "创建失败",
"updateSuccess": "更新成功",
"updateFailed": "更新失败",
"fetchFailed": "获取配置列表失败",
"testSuccess": "测试消息发送成功,请检查 Telegram",
"testFailed": "测试消息发送失败",
"getChatIdsSuccess": "成功获取 {count} 个 Chat ID",
"getChatIdsFailed": "获取 Chat IDs 失败",
"getChatIdsNoToken": "请先填写 Bot Token",
"getChatIdsNoMessage": "未找到 Chat ID,请先向机器人发送一条消息(如 /start),然后重试",
"getChatIdsButton": "获取 Chat ID"
},
"telegramConfig": {
"title": "Telegram 配置说明",
"step1": "通过 <strong>@BotFather</strong> 创建 Telegram 机器人,获取 Bot Token",
"step2": "填写 Bot Token 后,点击\"获取 Chat ID\"按钮自动获取(需要先向机器人发送消息)",
"step3": "或通过 <strong>@userinfobot</strong> 手动获取 Chat ID",
"step4": "支持配置多个 Chat ID(用逗号分隔),所有配置的用户都会收到通知",
"step5": "订单成功或失败时会自动发送 Telegram 消息",
"botToken": "Bot Token",
"botTokenPlaceholder": "Bot Token(从 @BotFather 获取)",
"botTokenRequired": "请输入 Bot Token"
},
"discordConfig": {
"title": "Discord 配置说明",
"step1": "在 Discord 服务器中创建 Webhook",
"step2": "复制 Webhook URL 并填入配置",
"step3": "订单成功或失败时会自动发送 Discord 消息",
"webhookUrl": "Webhook URL",
"webhookUrlPlaceholder": "Webhook URL(从 Discord 服务器设置中获取)",
"webhookUrlRequired": "请输入 Webhook URL"
},
"slackConfig": {
"title": "Slack 配置说明",
"step1": "在 Slack 工作区中创建 Incoming Webhook",
"step2": "复制 Webhook URL 并填入配置",
"step3": "订单成功或失败时会自动发送 Slack 消息",
"webhookUrl": "Webhook URL",
"webhookUrlPlaceholder": "Webhook URL(从 Slack App 设置中获取)",
"webhookUrlRequired": "请输入 Webhook URL"
}
}
+71
View File
@@ -203,6 +203,7 @@
"language": "語言",
"apiHealth": "API健康",
"proxy": "代理",
"notifications": "消息推送",
"logout": "退出登錄",
"logoutConfirm": "確認退出",
"logoutConfirmDesc": "確定要退出登錄嗎?",
@@ -428,5 +429,75 @@
"deleteSuccess": "刪除跟單成功",
"deleteFailed": "刪除跟單失敗",
"deleteConfirm": "確定要刪除這個跟單關係嗎?"
},
"notificationSettings": {
"title": "消息推送設置",
"addConfig": "添加配置",
"editConfig": "編輯配置",
"configName": "配置名稱",
"configNamePlaceholder": "例如:我的 Telegram 機器人",
"configNameRequired": "請輸入配置名稱",
"type": "推送類型",
"typeRequired": "請選擇推送類型",
"enabled": "啟用狀態",
"status": "狀態",
"enabledStatus": "已啟用",
"disabledStatus": "已禁用",
"chatIds": "Chat IDs",
"chatIdsPlaceholder": "Chat IDs(點擊上方按鈕自動獲取,或手動輸入,多個用逗號分隔)",
"chatIdsRequired": "請輸入至少一個 Chat ID",
"chatIdsExtra": "多個 Chat ID 用逗號分隔,例如:123456789,987654321。點擊上方按鈕可自動獲取(需要先向機器人發送消息)",
"chatIdsCount": "個接收者",
"chatIdsNotConfigured": "未配置",
"edit": "編輯",
"test": "測試",
"delete": "刪除",
"deleteConfirm": "確定要刪除這個配置嗎?",
"enableSuccess": "已啟用",
"disableSuccess": "已禁用",
"updateStatusFailed": "更新失敗",
"deleteSuccess": "刪除成功",
"deleteFailed": "刪除失敗",
"createSuccess": "創建成功",
"createFailed": "創建失敗",
"updateSuccess": "更新成功",
"updateFailed": "更新失敗",
"fetchFailed": "獲取配置列表失敗",
"testSuccess": "測試消息發送成功,請檢查 Telegram",
"testFailed": "測試消息發送失敗",
"getChatIdsSuccess": "成功獲取 {count} 個 Chat ID",
"getChatIdsFailed": "獲取 Chat IDs 失敗",
"getChatIdsNoToken": "請先填寫 Bot Token",
"getChatIdsNoMessage": "未找到 Chat ID,請先向機器人發送一條消息(如 /start),然後重試",
"getChatIdsButton": "獲取 Chat ID"
},
"telegramConfig": {
"title": "Telegram 配置說明",
"step1": "通過 <strong>@BotFather</strong> 創建 Telegram 機器人,獲取 Bot Token",
"step2": "填寫 Bot Token 後,點擊\"獲取 Chat ID\"按鈕自動獲取(需要先向機器人發送消息)",
"step3": "或通過 <strong>@userinfobot</strong> 手動獲取 Chat ID",
"step4": "支持配置多個 Chat ID(用逗號分隔),所有配置的用戶都會收到通知",
"step5": "訂單成功或失敗時會自動發送 Telegram 消息",
"botToken": "Bot Token",
"botTokenPlaceholder": "Bot Token(從 @BotFather 獲取)",
"botTokenRequired": "請輸入 Bot Token"
},
"discordConfig": {
"title": "Discord 配置說明",
"step1": "在 Discord 服務器中創建 Webhook",
"step2": "複製 Webhook URL 並填入配置",
"step3": "訂單成功或失敗時會自動發送 Discord 消息",
"webhookUrl": "Webhook URL",
"webhookUrlPlaceholder": "Webhook URL(從 Discord 服務器設置中獲取)",
"webhookUrlRequired": "請輸入 Webhook URL"
},
"slackConfig": {
"title": "Slack 配置說明",
"step1": "在 Slack 工作區中創建 Incoming Webhook",
"step2": "複製 Webhook URL 並填入配置",
"step3": "訂單成功或失敗時會自動發送 Slack 消息",
"webhookUrl": "Webhook URL",
"webhookUrlPlaceholder": "Webhook URL(從 Slack App 設置中獲取)",
"webhookUrlRequired": "請輸入 Webhook URL"
}
}