dsh-account-pool 0.2.4 → 0.2.6
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/lib/client.js +42 -9
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -334,12 +334,23 @@ window.__ModuleLoader__.load({ id: "dsh-account-pool", factory: (require) => {
|
|
|
334
334
|
* 大数字紧凑显示:1234567 → 1.23M。
|
|
335
335
|
* 指标卡上空间有限,完整千分位会撑破布局;完整值放到 title 里。
|
|
336
336
|
*/
|
|
337
|
+
/**
|
|
338
|
+
* 大数缩写:1000 → K,1e6 → M,1e9 → B。
|
|
339
|
+
*
|
|
340
|
+
* 精度随量级放宽(1.55B 比 2B 有用),但**整数结果不带多余的 .0**:
|
|
341
|
+
* 800.0M 读起来像精度声明,其实 800M 就够——去掉尾零更干净。
|
|
342
|
+
*
|
|
343
|
+
* 缩写会丢精度,所以表格里用它时必须把精确值放到悬停。
|
|
344
|
+
*/
|
|
337
345
|
function formatCompact(n) {
|
|
338
346
|
const v = Number(n) || 0;
|
|
339
347
|
if (v < 1000) return String(v);
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
348
|
+
const scaled = v < 1e6 ? v / 1e3 : v < 1e9 ? v / 1e6 : v / 1e9;
|
|
349
|
+
const unit = v < 1e6 ? "K" : v < 1e9 ? "M" : "B";
|
|
350
|
+
const digits = v < 1e4 ? 1 : v < 1e7 ? 2 : 2;
|
|
351
|
+
// 去掉尾部多余的零:800.00M → 800M,1.50B → 1.5B,1.00K → 1K
|
|
352
|
+
// (先删结尾的 0,再删可能留下的小数点)
|
|
353
|
+
return scaled.toFixed(digits).replace(/0+$/, "").replace(/\.$/, "") + unit;
|
|
343
354
|
}
|
|
344
355
|
|
|
345
356
|
/** 等宽数字:表格里数字列对齐才读得下去。 */
|
|
@@ -628,14 +639,23 @@ window.__ModuleLoader__.load({ id: "dsh-account-pool", factory: (require) => {
|
|
|
628
639
|
* 三态刻意区分开:
|
|
629
640
|
* 有数字 → +N(有收益为绿);0 也显示 +0,因为「确实没加」与
|
|
630
641
|
* 「不知道」不同
|
|
631
|
-
* 没数字 →
|
|
642
|
+
* 没数字 → —,并说明原因(见下)
|
|
632
643
|
*/
|
|
633
644
|
function earnedCell(account, lastRun) {
|
|
634
645
|
const run = lastRun?.[account.accountId];
|
|
635
646
|
const earned = typeof account.earnedCredits === "number"
|
|
636
647
|
? account.earnedCredits
|
|
637
648
|
: run?.earnedCredits;
|
|
638
|
-
if (typeof earned !== "number")
|
|
649
|
+
if (typeof earned !== "number") {
|
|
650
|
+
// 说明为什么没有数字,避免误以为功能坏了:
|
|
651
|
+
// 台账只记录「本功能上线之后」发生的收益,历史签到的奖励
|
|
652
|
+
// 无法回溯(上游只给累计总量,分不出是哪天签的)。
|
|
653
|
+
return h("span", {
|
|
654
|
+
title: "今天还没有记录到收益。台账从本功能启用后开始累计;"
|
|
655
|
+
+ "今天之前已经领取的奖励无法回溯。点「全部执行」后即可记录。",
|
|
656
|
+
style: { opacity: 0.5, cursor: "help" },
|
|
657
|
+
}, "—");
|
|
658
|
+
}
|
|
639
659
|
return h("span", {
|
|
640
660
|
style: { color: earned > 0 ? "var(--dsw-alias-state-success-primary)" : "inherit" },
|
|
641
661
|
}, "+" + formatNumber(earned));
|
|
@@ -1008,11 +1028,21 @@ window.__ModuleLoader__.load({ id: "dsh-account-pool", factory: (require) => {
|
|
|
1008
1028
|
}));
|
|
1009
1029
|
|
|
1010
1030
|
// 表格列宽:数字列右对齐、等宽,读起来才顺
|
|
1011
|
-
|
|
1031
|
+
/**
|
|
1032
|
+
* 数字单元格。
|
|
1033
|
+
*
|
|
1034
|
+
* @param {string} value 显示文本(可能是缩写的 1.69B)
|
|
1035
|
+
* @param {string} [color] 文字色
|
|
1036
|
+
* @param {string} [exact] 精确值,有则在悬停时显示——
|
|
1037
|
+
* 缩写会丢精度(1.69B 到底是 1,690,000,000 还是 1,689,999,999
|
|
1038
|
+
* 看不出来),能对账的数字要能查到原值。
|
|
1039
|
+
*/
|
|
1040
|
+
const numCell = (value, color, exact) => h("td", {
|
|
1012
1041
|
style: Object.assign({}, TD_STYLE, NUM_STYLE, {
|
|
1013
1042
|
textAlign: "right",
|
|
1014
1043
|
color: color ?? "var(--dsw-alias-label-primary)",
|
|
1015
1044
|
}),
|
|
1045
|
+
...(exact === undefined ? {} : { title: exact }),
|
|
1016
1046
|
}, value);
|
|
1017
1047
|
|
|
1018
1048
|
return h("div", { style: CARD_STYLE },
|
|
@@ -1147,9 +1177,12 @@ window.__ModuleLoader__.load({ id: "dsh-account-pool", factory: (require) => {
|
|
|
1147
1177
|
h("td", { style: Object.assign({}, TD_STYLE, { whiteSpace: "nowrap" }) }, m.key),
|
|
1148
1178
|
numCell(formatNumber(m.requests)),
|
|
1149
1179
|
numCell(formatNumber(m.errors), m.errors > 0 ? "var(--dsw-alias-state-error-primary)" : "var(--dsw-alias-label-secondary)"),
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
numCell(formatNumber(m.
|
|
1180
|
+
// token 用 K/M/B 缩写:纯数字能到十位(如 1,690,000,000),
|
|
1181
|
+
// 把表格撑得很宽。精确值放悬停里,需要对账时够用。
|
|
1182
|
+
numCell(formatCompact(m.promptTokens), undefined, formatNumber(m.promptTokens) + " tokens"),
|
|
1183
|
+
numCell(formatCompact(m.completionTokens), undefined, formatNumber(m.completionTokens) + " tokens"),
|
|
1184
|
+
numCell(formatCompact(m.totalTokens), undefined, formatNumber(m.totalTokens) + " tokens"),
|
|
1185
|
+
// 积分保持整数:它是要对账的数字,缩写反而看不清
|
|
1153
1186
|
numCell(formatNumber(m.credits)),
|
|
1154
1187
|
)
|
|
1155
1188
|
)),
|