u1s1-cli 0.19.2 → 0.19.3
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/dist/usage.js +18 -1
- package/package.json +1 -1
package/dist/usage.js
CHANGED
|
@@ -46,11 +46,28 @@ export async function usage() {
|
|
|
46
46
|
};
|
|
47
47
|
if (me.packages.length === 0)
|
|
48
48
|
console.log(" 用量包 (无生效中的用量包)");
|
|
49
|
+
// 同种类、同范围、同有效期的包合并成一条展示(比如邀请多个好友拿到的多份邀请赠送)
|
|
50
|
+
const groups = new Map();
|
|
49
51
|
for (const p of me.packages) {
|
|
52
|
+
const key = `${p.kind}|${p.scope}|${p.daily_tokens != null}|${p.expires_at || ""}`;
|
|
53
|
+
const g = groups.get(key);
|
|
54
|
+
// 可空字段求和:两边都是 null 就保持 null,别把「一次性包没有日额度」污染成 0
|
|
55
|
+
const sumOpt = (a, b) => (a == null && b == null ? null : (a ?? 0) + (b ?? 0));
|
|
56
|
+
if (g) {
|
|
57
|
+
g.count += 1;
|
|
58
|
+
g.daily_tokens = sumOpt(g.daily_tokens, p.daily_tokens);
|
|
59
|
+
g.total_tokens = sumOpt(g.total_tokens, p.total_tokens);
|
|
60
|
+
g.remaining += p.remaining;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
groups.set(key, { ...p, count: 1 });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
for (const p of groups.values()) {
|
|
50
67
|
const daily = p.daily_tokens != null;
|
|
51
68
|
const total = daily ? (p.daily_tokens ?? 0) : (p.total_tokens ?? 0);
|
|
52
69
|
const ratio = total > 0 ? p.remaining / total : 0;
|
|
53
|
-
const label = (PKG_LABEL[p.kind] ?? p.kind).padEnd(5, " ");
|
|
70
|
+
const label = ((PKG_LABEL[p.kind] ?? p.kind) + (p.count > 1 ? ` ×${p.count}` : "")).padEnd(5, " ");
|
|
54
71
|
const per = daily ? "/天" : "";
|
|
55
72
|
console.log(` ${label} 还剩 ${fmtTokensCn(p.remaining)} / ${fmtTokensCn(total)}${per} ${bar(ratio)}`);
|
|
56
73
|
const scopeNote = p.scope === "free" ? "仅默认模型和搜索 · 0 点恢复" : "全模型可用";
|