From 091fc0d553737d13be51364da1e9c92108db2fab Mon Sep 17 00:00:00 2001 From: "zhangkun9038@dingtalk.com" Date: Thu, 26 Feb 2026 10:58:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=BC=BAlive.sh=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E7=9A=84=E8=BF=9C=E7=A8=8B=E5=B8=81=E5=AF=B9=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=A8=B3=E5=AE=9A=E6=80=A7=EF=BC=8C=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=A4=B1=E8=B4=A5=E5=A4=87=E7=94=A8=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/live.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/live.sh b/tools/live.sh index b35c495a..842a72a2 100755 --- a/tools/live.sh +++ b/tools/live.sh @@ -95,7 +95,19 @@ get_remote_pairs() { # 重试循环 while [ $attempt -le $max_retries ]; do echo "正在从远程URL获取币对列表 (尝试 $attempt/$max_retries): $remote_url" >&2 - local pairs_json=$(curl -s "$remote_url") + + # 方式1: 使用curl + local pairs_json=$(curl -s --connect-timeout 3 --max-time 5 "$remote_url" 2>/dev/null) + + # 如果curl失败,使用备用方案 + if [ $? -ne 0 ] || [ -z "$pairs_json" ]; then + echo "⚠️ 远程API获取失败,使用默认币对列表" >&2 + # 使用硬编码的默认币对列表 + pairs_json='[{"instId":"BTC/USDT","instIdRaw":"BTC-USDT","rank":1},{"instId":"ETH/USDT","instIdRaw":"ETH-USDT","rank":2},{"instId":"SOL/USDT","instIdRaw":"SOL-USDT","rank":3},{"instId":"XRP/USDT","instIdRaw":"XRP-USDT","rank":4},{"instId":"SUI/USDT","instIdRaw":"SUI-USDT","rank":5}]' + fi + + echo "curl返回结果: $?" >&2 + echo "curl返回内容长度: ${#pairs_json}" >&2 if [ $? -eq 0 ] && [ -n "$pairs_json" ]; then # curl 成功且有返回内容,尝试解析