dsh-offpeak-guard 0.3.1 → 0.3.2
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/CHANGELOG.md +6 -0
- package/client.js +14 -2
- package/index.js +4 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.2 — 2026-11-06
|
|
4
|
+
|
|
5
|
+
- 修复设置面板切换峰时策略时报 `Unexpected end of JSON input`:Host 启动顺序可能让 `webServer` 在插件 apply 时尚未就绪,导致设置路由根本没注册;改用 `ctx.inject(['webServer'], ...)` 后再挂载路由。
|
|
6
|
+
- 客户端对非 JSON/空响应改为显示 `HTTP <status>`,不再把浏览器 JSON 解析异常直接抛到面板底部。
|
|
7
|
+
- 已验证设置面板「立即暂停 / 完成当前轮后暂停」切换成功,路由返回 200。
|
|
8
|
+
|
|
3
9
|
## 0.3.1 — 2026-11-06
|
|
4
10
|
|
|
5
11
|
- 左侧会话行悬停操作新增盾牌按钮:直接在对话索引里豁免/取消豁免,豁免中的会话行保留盾牌标记。
|
package/client.js
CHANGED
|
@@ -231,7 +231,13 @@ window.__ModuleLoader__.load({
|
|
|
231
231
|
headers: { 'content-type': 'application/json' },
|
|
232
232
|
body: JSON.stringify(body),
|
|
233
233
|
});
|
|
234
|
-
const
|
|
234
|
+
const text = await response.text();
|
|
235
|
+
let json = {};
|
|
236
|
+
try {
|
|
237
|
+
json = text === '' ? {} : JSON.parse(text);
|
|
238
|
+
} catch {
|
|
239
|
+
json = {};
|
|
240
|
+
}
|
|
235
241
|
if (!response.ok || json.ok === false) throw new Error(json.error ?? `HTTP ${response.status}`);
|
|
236
242
|
if (sharedStatus.ctx !== null) await loadSharedStatus(sharedStatus.ctx);
|
|
237
243
|
return json;
|
|
@@ -480,7 +486,13 @@ window.__ModuleLoader__.load({
|
|
|
480
486
|
headers: { 'content-type': 'application/json' },
|
|
481
487
|
body: JSON.stringify(body),
|
|
482
488
|
});
|
|
483
|
-
const
|
|
489
|
+
const text = await response.text();
|
|
490
|
+
let json = {};
|
|
491
|
+
try {
|
|
492
|
+
json = text === '' ? {} : JSON.parse(text);
|
|
493
|
+
} catch {
|
|
494
|
+
json = {};
|
|
495
|
+
}
|
|
484
496
|
if (!response.ok || json.ok === false) throw new Error(json.error ?? `HTTP ${response.status}`);
|
|
485
497
|
await refresh();
|
|
486
498
|
} catch (caught) {
|
package/index.js
CHANGED
|
@@ -197,11 +197,10 @@ export function apply(ctx, rawConfig = {}) {
|
|
|
197
197
|
};
|
|
198
198
|
}, 'offpeak-guard: tools');
|
|
199
199
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
ctx.effect(
|
|
200
|
+
ctx.inject(['webServer'], (webCtx) => {
|
|
201
|
+
webCtx.effect(
|
|
203
202
|
() =>
|
|
204
|
-
webServer.register({
|
|
203
|
+
webCtx.webServer.register({
|
|
205
204
|
kind: 'prefix',
|
|
206
205
|
path: '/plugins/dsh-offpeak-guard',
|
|
207
206
|
async handler(req, res) {
|
|
@@ -241,5 +240,5 @@ export function apply(ctx, rawConfig = {}) {
|
|
|
241
240
|
}),
|
|
242
241
|
'offpeak-guard: settings route',
|
|
243
242
|
);
|
|
244
|
-
}
|
|
243
|
+
});
|
|
245
244
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-offpeak-guard",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "DeepSeek peak/off-peak pricing guard for DSH: detects the price window and current model, pauses running tasks at peak, resumes them automatically when off-peak begins, and schedules work for the next off-peak window.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|