fix: toNum 对 null/空串返回 null,修正测试脚本 glob
This commit is contained in:
+11
-9
@@ -65,10 +65,21 @@ function round2(n) {
|
||||
}
|
||||
|
||||
function toNum(v) {
|
||||
if (v === null || v === undefined || v === "") return null;
|
||||
const n = Number(v);
|
||||
return n === n ? n : null;
|
||||
}
|
||||
|
||||
// Codex rate_limit 窗口秒数 → 展示名(18000s=5小时、604800s=7天、2592000s=30天)
|
||||
function codexWindowName(secs) {
|
||||
if (secs === 18000) return { label: "5小时", key: "5h" };
|
||||
if (secs === 604800) return { label: "7天", key: "7d" };
|
||||
if (secs === 2592000) return { label: "30天", key: "30d" };
|
||||
const hours = Math.floor(secs / 3600);
|
||||
if (hours >= 24) return { label: Math.floor(hours / 24) + "天", key: Math.floor(hours / 24) + "d" };
|
||||
return { label: hours + "小时", key: hours + "h" };
|
||||
}
|
||||
|
||||
function writeJson(res, status, body) {
|
||||
const payload = JSON.stringify(body);
|
||||
res.writeHead(status, {
|
||||
@@ -932,15 +943,6 @@ function apply(ctx) {
|
||||
// rate_limit.primary/secondary_window:used_percent=已用%、limit_window_seconds=窗口秒数、
|
||||
// reset_at=重置时间戳(秒)。
|
||||
|
||||
function codexWindowName(secs) {
|
||||
if (secs === 18000) return { label: "5小时", key: "5h" };
|
||||
if (secs === 604800) return { label: "7天", key: "7d" };
|
||||
if (secs === 2592000) return { label: "30天", key: "30d" };
|
||||
const hours = Math.floor(secs / 3600);
|
||||
if (hours >= 24) return { label: Math.floor(hours / 24) + "天", key: Math.floor(hours / 24) + "d" };
|
||||
return { label: hours + "小时", key: hours + "h" };
|
||||
}
|
||||
|
||||
async function queryCodexUsage() {
|
||||
let key;
|
||||
try {
|
||||
|
||||
+1
-1
@@ -47,6 +47,6 @@
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node --test test/"
|
||||
"test": "node --test test/*.test.mjs"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user