skillfree 0.1.19 → 0.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skillfree",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "description": "🦞 一个 API,满足所有龙虾技能需求",
5
5
  "main": "bin/skillfree.js",
6
6
  "bin": {
@@ -36,26 +36,25 @@ const LOW_CREDITS_THRESHOLD = 100
36
36
 
37
37
  function formatLowCreditsWarning(credits) {
38
38
  return `
39
- ⚠️ 积分不足,无法继续调用(当前积分:${credits},最低需要 ${LOW_CREDITS_THRESHOLD} 积分)
39
+ ⚠️ 积分余额偏低(当前积分:${credits}),建议尽快充值,避免中断使用。
40
40
 
41
41
  💳 充值流程:
42
42
  1. 打开浏览器,访问 https://skillfree.tech/app/billing
43
43
  2. 选择充值套餐(推荐 ¥30 = 350积分,性价比最高)
44
44
  3. 微信扫码支付,积分自动到账(约 3 秒)
45
- 4. 充值后继续使用 skillfree 命令即可
46
45
 
47
46
  📦 套餐参考:
48
47
  ¥10 → 100 积分
49
48
  ¥30 → 350 积分(多送 50)
50
49
  ¥100 → 1300 积分(多送 300)
51
50
  ¥300 → 4500 积分(多送 1500)
52
-
53
- 积分永不过期,无月费无订阅。`
51
+ `
54
52
  }
55
53
 
56
54
  /**
57
- * 主动检查积分余额,不足 LOW_CREDITS_THRESHOLD 时抛出错误
58
- * pilot.js 等在实际调用前主动触发
55
+ * 主动检查积分余额:
56
+ * < LOW_CREDITS_THRESHOLD 打印警告,但继续执行(不抛错)
57
+ * 真正积分不够扣时由服务器返回 402,在 request() 里处理
59
58
  */
60
59
  async function checkCredits() {
61
60
  const apiKey = getApiKey()
@@ -68,11 +67,11 @@ async function checkCredits() {
68
67
  const data = await res.json()
69
68
  const credits = data.credits ?? data.balance ?? 0
70
69
  if (credits < LOW_CREDITS_THRESHOLD) {
71
- throw new Error(formatLowCreditsWarning(credits))
70
+ // 只打印警告,不抛错,继续执行
71
+ console.warn(formatLowCreditsWarning(credits))
72
72
  }
73
73
  }
74
74
  } catch (e) {
75
- if (e.message.includes('积分不足')) throw e
76
75
  // 网络失败等忽略,不阻塞用户
77
76
  }
78
77
  }
@@ -94,7 +93,7 @@ async function request(endpoint, options = {}) {
94
93
  },
95
94
  })
96
95
 
97
- if (res.status === 402) throw new Error('积分不足,请前往 https://skillfree.tech/app/billing 充值')
96
+ if (res.status === 402) throw new Error(`❌ 积分不足,本次调用无法完成。\n\n💳 充值流程:\n 1. 访问 https://skillfree.tech/app/billing\n 2. 选择套餐(推荐 ¥30 = 350积分),微信扫码支付,约 3 秒到账`)
98
97
  if (res.status === 401) throw new Error('API Key 无效或已过期,请重新登录: skillfree auth login')
99
98
 
100
99
  return res