dsh-account-pool 0.2.4 → 0.2.5
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 +31 -7
- 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
|
/** 等宽数字:表格里数字列对齐才读得下去。 */
|
|
@@ -1008,11 +1019,21 @@ window.__ModuleLoader__.load({ id: "dsh-account-pool", factory: (require) => {
|
|
|
1008
1019
|
}));
|
|
1009
1020
|
|
|
1010
1021
|
// 表格列宽:数字列右对齐、等宽,读起来才顺
|
|
1011
|
-
|
|
1022
|
+
/**
|
|
1023
|
+
* 数字单元格。
|
|
1024
|
+
*
|
|
1025
|
+
* @param {string} value 显示文本(可能是缩写的 1.69B)
|
|
1026
|
+
* @param {string} [color] 文字色
|
|
1027
|
+
* @param {string} [exact] 精确值,有则在悬停时显示——
|
|
1028
|
+
* 缩写会丢精度(1.69B 到底是 1,690,000,000 还是 1,689,999,999
|
|
1029
|
+
* 看不出来),能对账的数字要能查到原值。
|
|
1030
|
+
*/
|
|
1031
|
+
const numCell = (value, color, exact) => h("td", {
|
|
1012
1032
|
style: Object.assign({}, TD_STYLE, NUM_STYLE, {
|
|
1013
1033
|
textAlign: "right",
|
|
1014
1034
|
color: color ?? "var(--dsw-alias-label-primary)",
|
|
1015
1035
|
}),
|
|
1036
|
+
...(exact === undefined ? {} : { title: exact }),
|
|
1016
1037
|
}, value);
|
|
1017
1038
|
|
|
1018
1039
|
return h("div", { style: CARD_STYLE },
|
|
@@ -1147,9 +1168,12 @@ window.__ModuleLoader__.load({ id: "dsh-account-pool", factory: (require) => {
|
|
|
1147
1168
|
h("td", { style: Object.assign({}, TD_STYLE, { whiteSpace: "nowrap" }) }, m.key),
|
|
1148
1169
|
numCell(formatNumber(m.requests)),
|
|
1149
1170
|
numCell(formatNumber(m.errors), m.errors > 0 ? "var(--dsw-alias-state-error-primary)" : "var(--dsw-alias-label-secondary)"),
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
numCell(formatNumber(m.
|
|
1171
|
+
// token 用 K/M/B 缩写:纯数字能到十位(如 1,690,000,000),
|
|
1172
|
+
// 把表格撑得很宽。精确值放悬停里,需要对账时够用。
|
|
1173
|
+
numCell(formatCompact(m.promptTokens), undefined, formatNumber(m.promptTokens) + " tokens"),
|
|
1174
|
+
numCell(formatCompact(m.completionTokens), undefined, formatNumber(m.completionTokens) + " tokens"),
|
|
1175
|
+
numCell(formatCompact(m.totalTokens), undefined, formatNumber(m.totalTokens) + " tokens"),
|
|
1176
|
+
// 积分保持整数:它是要对账的数字,缩写反而看不清
|
|
1153
1177
|
numCell(formatNumber(m.credits)),
|
|
1154
1178
|
)
|
|
1155
1179
|
)),
|