@simonyea/holysheep-cli 1.7.57 → 1.7.58
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 +1 -1
- package/src/webui/server.js +6 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simonyea/holysheep-cli",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.58",
|
|
4
4
|
"description": "Claude Code/Cursor/Cline API relay for China — ¥1=$1, WeChat/Alipay payment, no credit card, no VPN. One command setup for all AI coding tools.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"openai-china",
|
package/src/webui/server.js
CHANGED
|
@@ -158,10 +158,13 @@ async function handleBalance(_req, res) {
|
|
|
158
158
|
if (!apiKey) return json(res, { error: '未登录' }, 401)
|
|
159
159
|
try {
|
|
160
160
|
const fetch = require('node-fetch')
|
|
161
|
+
const controller = new AbortController()
|
|
162
|
+
const timer = setTimeout(() => controller.abort(), 15000)
|
|
161
163
|
const r = await fetch(`${SHOP_URL}/api/stats/overview`, {
|
|
162
164
|
headers: { Authorization: `Bearer ${apiKey}` },
|
|
163
|
-
|
|
165
|
+
signal: controller.signal,
|
|
164
166
|
})
|
|
167
|
+
clearTimeout(timer)
|
|
165
168
|
if (r.status === 401) return json(res, { error: 'API Key 无效或已过期' }, 401)
|
|
166
169
|
if (!r.ok) return json(res, { error: `HTTP ${r.status}` }, r.status)
|
|
167
170
|
const data = await r.json()
|
|
@@ -172,7 +175,8 @@ async function handleBalance(_req, res) {
|
|
|
172
175
|
totalCalls: Number(data.totalCalls || 0),
|
|
173
176
|
})
|
|
174
177
|
} catch (e) {
|
|
175
|
-
|
|
178
|
+
const msg = e.name === 'AbortError' ? '请求超时,请稍后重试' : e.message
|
|
179
|
+
json(res, { error: msg }, 500)
|
|
176
180
|
}
|
|
177
181
|
}
|
|
178
182
|
|