@pinkbanana/dsh-balance 0.10.2 → 0.11.0
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/README.md +3 -3
- package/README_EN.md +1 -1
- package/lib/client.js +139 -69
- package/lib/client.js.map +1 -1
- package/lib/index.js +18 -5
- package/lib/index.js.map +1 -1
- package/lib/types/billing.d.ts +8 -0
- package/lib/types/client/DeepSeekPanel.d.ts +4 -3
- package/lib/types/client/format.d.ts +2 -0
- package/lib/types/client/locales.d.ts +2 -0
- package/lib/types/client/styles.d.ts +1 -1
- package/package.json +50 -48
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ DeepSeek Harness 插件,用于查询 DeepSeek / StepFun API 余额、各提供
|
|
|
16
16
|
- 在聊天框下方显示当前 provider、模型和余额,兼容模型选择器与 `/model` 切换
|
|
17
17
|
- 从当前提供方的 `/models` 接口读取可用模型、所属组织与创建时间
|
|
18
18
|
- 在设置页按所选 provider、模型、会话和日期查看实际 usage 消费,并在当前会话的“消费”Tab 查看请求明细
|
|
19
|
-
-
|
|
19
|
+
- 明确区分已计费、免费(已知价格且费用为 0)与未计费请求;缺少 provider usage、未知 provider 或未知模型时不进行费用估算
|
|
20
20
|
- 日期按浏览器 IANA 时区分组;DeepSeek 峰谷价格始终按北京时间计算
|
|
21
21
|
- DeepSeek 费用显示 USD、StepFun 显示原生 CNY;配置 `usdToCny` 后显示人民币合计
|
|
22
22
|
- 缓存查询结果并支持手动刷新
|
|
@@ -28,7 +28,7 @@ DeepSeek Harness 插件,用于查询 DeepSeek / StepFun API 余额、各提供
|
|
|
28
28
|
|
|
29
29
|
## 兼容性
|
|
30
30
|
|
|
31
|
-
0.
|
|
31
|
+
0.11.0 适配 DeepSeek Harness **0.2.1-rc.2**([上游版本](https://github.com/deepseek-ai/deepseek-harness/releases/tag/dsh-v0.2.1-rc.2)),需要 Node.js **22.19+(22.x)或 24+**。所有 DSH peer 依赖和开发依赖均锁定为 `0.2.1-rc.2`。Harness `0.2.0-rc.2` 用户请继续使用插件 `0.10.2`;本次源码不再兼容 Harness 0.1 的接口。
|
|
32
32
|
|
|
33
33
|
也可在本地构建并打包源码,再用 `dsh plugin --profile web add /absolute/path/to/package.tgz` 安装生成的 `.tgz` 文件,随后重启 Harness:
|
|
34
34
|
|
|
@@ -87,7 +87,7 @@ providers:
|
|
|
87
87
|
|
|
88
88
|
内置 DeepSeek 美元定价,以及 2026-09-30 核验的 [StepFun 官方人民币标准价](https://platform.stepfun.com/docs/zh/guides/pricing/details):`step-5-preview`、`step-3.7-flash`、`step-3.5-flash` 和 `step-3.5-flash-2603`。StepFun 未缓存输入(含缓存写入)、缓存读取、输出分别计价,不套用 DeepSeek 峰谷倍率。费用是公开标准价估算,不代表账户实际账单;套餐、折扣和未保存的历史调价不包含在内。
|
|
89
89
|
|
|
90
|
-
美元和原生人民币费用分别展示;设置 `usdToCny`
|
|
90
|
+
美元和原生人民币费用分别展示;设置 `usdToCny` 后,人民币合计才会包含美元折算金额,并明确标为固定汇率换算。未设置汇率时,原生人民币金额不会被表述为包含美元费用的完整人民币合计。已知价格且费用为 0 的请求单列为“免费”;未知 provider / model 和缺失 usage 的请求保留请求数与 token,显示“未计费”。账户余额是实时查询值,与本地用量估算独立;赠送余额与充值余额分别展示,StepFun 的总充值/总赠送为累计值而非剩余余额。会话消费页采用居中内容宽度、响应式外边距,并为底部输入框保留空间。
|
|
91
91
|
|
|
92
92
|
## 扩展与设计
|
|
93
93
|
|
package/README_EN.md
CHANGED
|
@@ -26,7 +26,7 @@ The composer readout follows the current session’s provider and model. The Set
|
|
|
26
26
|
|
|
27
27
|
## Compatibility
|
|
28
28
|
|
|
29
|
-
Version 0.
|
|
29
|
+
Version 0.11.0 targets DeepSeek Harness **0.2.1-rc.2** ([upstream release](https://github.com/deepseek-ai/deepseek-harness/releases/tag/dsh-v0.2.1-rc.2)). Use Node.js **22.19+ (22.x) or 24+**. All DSH peer and development dependencies are pinned to `0.2.1-rc.2`. Harness `0.2.0-rc.2` users should keep plugin `0.10.2`; Harness 0.1 APIs are no longer supported by this checkout.
|
|
30
30
|
|
|
31
31
|
To install from source, build and pack it locally, then pass the generated `.tgz` path to `dsh plugin --profile web add /absolute/path/to/package.tgz` and restart Harness:
|
|
32
32
|
|
package/lib/client.js
CHANGED
|
@@ -61,7 +61,10 @@ window.__ModuleLoader__.load({
|
|
|
61
61
|
const row = Math.floor(index / 24);
|
|
62
62
|
const col = index % 24;
|
|
63
63
|
const next = key === "ArrowRight" ? row * 24 + (col + 1) % 24 : key === "ArrowLeft" ? row * 24 + (col + 23) % 24 : key === "ArrowDown" ? (row + 1) % 7 * 24 + col : key === "ArrowUp" ? (row + 6) % 7 * 24 + col : key === "Home" ? row * 24 : key === "End" ? row * 24 + 23 : void 0;
|
|
64
|
-
if (next !== void 0)
|
|
64
|
+
if (next !== void 0) {
|
|
65
|
+
setFocus(next);
|
|
66
|
+
svg.current?.querySelector(`[data-cell="${next}"]`)?.focus();
|
|
67
|
+
}
|
|
65
68
|
return next !== void 0;
|
|
66
69
|
};
|
|
67
70
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
@@ -87,9 +90,13 @@ window.__ModuleLoader__.load({
|
|
|
87
90
|
}),
|
|
88
91
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
89
92
|
className: "dsh-punchcard-scroll",
|
|
93
|
+
tabIndex: 0,
|
|
94
|
+
role: "region",
|
|
95
|
+
"aria-label": t("punchcard.keyboard"),
|
|
90
96
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
91
97
|
ref: svg,
|
|
92
98
|
viewBox: "0 0 860 300",
|
|
99
|
+
preserveAspectRatio: "xMinYMid meet",
|
|
93
100
|
className: "dsh-punchcard-chart",
|
|
94
101
|
role: "group",
|
|
95
102
|
"aria-label": t("punchcard.keyboard"),
|
|
@@ -331,7 +338,7 @@ window.__ModuleLoader__.load({
|
|
|
331
338
|
type: "button",
|
|
332
339
|
role: "tab",
|
|
333
340
|
id: `${id}-${tab.value}`,
|
|
334
|
-
"aria-controls": `${id}-panel`,
|
|
341
|
+
"aria-controls": `${id}-${tab.value}-panel`,
|
|
335
342
|
"aria-selected": value === tab.value,
|
|
336
343
|
tabIndex: value === tab.value ? 0 : -1,
|
|
337
344
|
onClick: () => onChange(tab.value),
|
|
@@ -368,7 +375,7 @@ window.__ModuleLoader__.load({
|
|
|
368
375
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
369
376
|
className: "dsh-billing-detail-body",
|
|
370
377
|
role: "tabpanel",
|
|
371
|
-
id: `${id}-panel`,
|
|
378
|
+
id: `${id}-${value}-panel`,
|
|
372
379
|
"aria-labelledby": `${id}-${value}`,
|
|
373
380
|
tabIndex: 0,
|
|
374
381
|
children
|
|
@@ -468,10 +475,13 @@ window.__ModuleLoader__.load({
|
|
|
468
475
|
return `${value} ${currency}`;
|
|
469
476
|
}
|
|
470
477
|
}
|
|
478
|
+
function displayTokens(value, locale) {
|
|
479
|
+
return new Intl.NumberFormat(locale, { maximumFractionDigits: 0 }).format(value);
|
|
480
|
+
}
|
|
471
481
|
//#endregion
|
|
472
482
|
//#region src/client/BillingTab.tsx
|
|
473
|
-
function formatTokens(value) {
|
|
474
|
-
return
|
|
483
|
+
function formatTokens(value, locale = "en-US") {
|
|
484
|
+
return displayTokens(value, locale);
|
|
475
485
|
}
|
|
476
486
|
function amount(value, currency, locale) {
|
|
477
487
|
return value === null ? "—" : displayAmount(String(value), currency, locale);
|
|
@@ -495,6 +505,7 @@ window.__ModuleLoader__.load({
|
|
|
495
505
|
return summary.byDay.find((item) => item.date === date) ?? {
|
|
496
506
|
requests: 0,
|
|
497
507
|
pricedRequests: 0,
|
|
508
|
+
freeRequests: 0,
|
|
498
509
|
unpricedRequests: 0,
|
|
499
510
|
inputTokens: 0,
|
|
500
511
|
outputTokens: 0,
|
|
@@ -503,22 +514,25 @@ window.__ModuleLoader__.load({
|
|
|
503
514
|
costUsd: 0,
|
|
504
515
|
costCny: summary.usdToCny === null ? null : 0,
|
|
505
516
|
nativeCostCny: 0,
|
|
506
|
-
cnyPricedRequests: 0
|
|
517
|
+
cnyPricedRequests: 0,
|
|
518
|
+
hasCompleteCnyTotal: summary.usdToCny !== null
|
|
507
519
|
};
|
|
508
520
|
}
|
|
509
521
|
function ErrorMessage({ result, t }) {
|
|
510
522
|
if (result.ok === true) return null;
|
|
511
523
|
const key = `billing.error.${result.code}`;
|
|
524
|
+
const detail = result.code === "SESSION_NOT_FOUND" && result.message ? ` (${result.message})` : "";
|
|
512
525
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
513
526
|
className: "dsh-balance-error",
|
|
514
527
|
role: "alert",
|
|
515
|
-
children: [t(key),
|
|
528
|
+
children: [t(key), detail]
|
|
516
529
|
});
|
|
517
530
|
}
|
|
518
|
-
function CostLabel({ totals, t,
|
|
531
|
+
function CostLabel({ totals, t, cnyTotalMode = "unavailable" }) {
|
|
519
532
|
const locale = t("locale.tag");
|
|
520
|
-
const
|
|
521
|
-
const
|
|
533
|
+
const freeRequests = totals.freeRequests ?? 0;
|
|
534
|
+
const unpriced = totals.pricedRequests === 0 && freeRequests === 0 && totals.unpricedRequests > 0;
|
|
535
|
+
const cnyOnly = totals.cnyPricedRequests > 0 && totals.pricedRequests === totals.cnyPricedRequests;
|
|
522
536
|
const mixed = totals.cnyPricedRequests > 0 && !cnyOnly;
|
|
523
537
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
524
538
|
className: "dsh-billing-cost-value",
|
|
@@ -530,7 +544,7 @@ window.__ModuleLoader__.load({
|
|
|
530
544
|
t("billing.nativeCny")
|
|
531
545
|
] }) : null,
|
|
532
546
|
totals.unpricedRequests > 0 && !unpriced ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", { children: t("billing.partial") }) : null,
|
|
533
|
-
totals.costCny !== null && !unpriced && !cnyOnly &&
|
|
547
|
+
totals.costCny !== null && totals.hasCompleteCnyTotal && !unpriced && !cnyOnly && cnyTotalMode === "converted" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
534
548
|
amount(totals.costCny, "CNY", locale),
|
|
535
549
|
" ",
|
|
536
550
|
t("billing.fixedRate")
|
|
@@ -549,9 +563,14 @@ window.__ModuleLoader__.load({
|
|
|
549
563
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("billing.totalCost") }),
|
|
550
564
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CostLabel, {
|
|
551
565
|
totals: summary.totals,
|
|
552
|
-
t
|
|
566
|
+
t,
|
|
567
|
+
cnyTotalMode: summary.cnyTotalMode
|
|
553
568
|
}),
|
|
554
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
569
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("small", { children: [
|
|
570
|
+
t("billing.pricedRequests", { count: summary.totals.pricedRequests }),
|
|
571
|
+
" · ",
|
|
572
|
+
t("billing.freeRequests", { count: summary.totals.freeRequests ?? 0 })
|
|
573
|
+
] })
|
|
555
574
|
]
|
|
556
575
|
}),
|
|
557
576
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("article", {
|
|
@@ -561,7 +580,7 @@ window.__ModuleLoader__.load({
|
|
|
561
580
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CostLabel, {
|
|
562
581
|
totals: today,
|
|
563
582
|
t,
|
|
564
|
-
|
|
583
|
+
cnyTotalMode: summary.cnyTotalMode
|
|
565
584
|
}),
|
|
566
585
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", { children: t("billing.today", { date: localDateKey(summary.timeZone) }) })
|
|
567
586
|
]
|
|
@@ -570,7 +589,7 @@ window.__ModuleLoader__.load({
|
|
|
570
589
|
className: "dsh-billing-card",
|
|
571
590
|
children: [
|
|
572
591
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("billing.tokens") }),
|
|
573
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: formatTokens(summary.totals.inputTokens + summary.totals.outputTokens + summary.totals.cacheReadTokens + summary.totals.cacheWriteTokens) }),
|
|
592
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: formatTokens(summary.totals.inputTokens + summary.totals.outputTokens + summary.totals.cacheReadTokens + summary.totals.cacheWriteTokens, t("locale.tag")) }),
|
|
574
593
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TotalsCaption, {
|
|
575
594
|
totals: summary.totals,
|
|
576
595
|
t
|
|
@@ -583,7 +602,7 @@ window.__ModuleLoader__.load({
|
|
|
583
602
|
"data-warning": summary.totals.unpricedRequests > 0 ? "true" : "false",
|
|
584
603
|
children: [
|
|
585
604
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("billing.unpriced") }),
|
|
586
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: formatTokens(summary.totals.unpricedRequests) }),
|
|
605
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: formatTokens(summary.totals.unpricedRequests, t("locale.tag")) }),
|
|
587
606
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", { children: t("billing.unpricedHint") })
|
|
588
607
|
]
|
|
589
608
|
})
|
|
@@ -597,22 +616,22 @@ window.__ModuleLoader__.load({
|
|
|
597
616
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
598
617
|
t("billing.inputShort"),
|
|
599
618
|
" ",
|
|
600
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: formatTokens(totals.inputTokens) })
|
|
619
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: formatTokens(totals.inputTokens, t("locale.tag")) })
|
|
601
620
|
] }),
|
|
602
621
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
603
622
|
t("billing.outputShort"),
|
|
604
623
|
" ",
|
|
605
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: formatTokens(totals.outputTokens) })
|
|
624
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: formatTokens(totals.outputTokens, t("locale.tag")) })
|
|
606
625
|
] }),
|
|
607
626
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
608
627
|
t("billing.cacheReadShort"),
|
|
609
628
|
" ",
|
|
610
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: formatTokens(totals.cacheReadTokens) })
|
|
629
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: formatTokens(totals.cacheReadTokens, t("locale.tag")) })
|
|
611
630
|
] }),
|
|
612
631
|
totals.cacheWriteTokens > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
|
|
613
632
|
t("billing.cacheWriteShort"),
|
|
614
633
|
" ",
|
|
615
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: formatTokens(totals.cacheWriteTokens) })
|
|
634
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: formatTokens(totals.cacheWriteTokens, t("locale.tag")) })
|
|
616
635
|
] }) : null
|
|
617
636
|
]
|
|
618
637
|
});
|
|
@@ -795,6 +814,7 @@ window.__ModuleLoader__.load({
|
|
|
795
814
|
className: "dsh-billing-request-list",
|
|
796
815
|
children: requests.map((request) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("article", {
|
|
797
816
|
className: "dsh-billing-request-row",
|
|
817
|
+
"data-billing-status": request.billingStatus,
|
|
798
818
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
|
|
799
819
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
800
820
|
className: "dsh-billing-request-meta",
|
|
@@ -815,7 +835,7 @@ window.__ModuleLoader__.load({
|
|
|
815
835
|
] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TotalsCaption, {
|
|
816
836
|
totals: request,
|
|
817
837
|
t
|
|
818
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: request.
|
|
838
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: request.billingStatus === "free" ? t("billing.free") : request.billingStatus === "unpriced" ? t("billing.notPriced") : request.costCny !== void 0 ? amount(request.costCny, "CNY", locale) : amount(request.costUsd, "USD", locale) })] })]
|
|
819
839
|
}, request.seq))
|
|
820
840
|
});
|
|
821
841
|
}
|
|
@@ -1080,8 +1100,9 @@ window.__ModuleLoader__.load({
|
|
|
1080
1100
|
//#endregion
|
|
1081
1101
|
//#region src/client/UsagePage.tsx
|
|
1082
1102
|
function UsagePage({ loadUsage, t }) {
|
|
1083
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
1103
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("main", {
|
|
1084
1104
|
className: "dsh-usage-page",
|
|
1105
|
+
"aria-label": t("nav.usage"),
|
|
1085
1106
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1086
1107
|
className: "dsh-usage-content",
|
|
1087
1108
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BillingOverview, {
|
|
@@ -1246,9 +1267,26 @@ window.__ModuleLoader__.load({
|
|
|
1246
1267
|
const [result, setResult] = (0, react.useState)();
|
|
1247
1268
|
const [now, setNow] = (0, react.useState)(() => /* @__PURE__ */ new Date());
|
|
1248
1269
|
(0, react.useEffect)(() => {
|
|
1249
|
-
|
|
1270
|
+
if (typeof document === "undefined") {
|
|
1271
|
+
const timer = setInterval(() => setNow(/* @__PURE__ */ new Date()), PEAK_TICK_MS);
|
|
1272
|
+
return () => clearInterval(timer);
|
|
1273
|
+
}
|
|
1274
|
+
let timer;
|
|
1275
|
+
const sync = () => {
|
|
1276
|
+
setNow(/* @__PURE__ */ new Date());
|
|
1277
|
+
if (document.visibilityState === "visible" && timer === void 0) timer = window.setInterval(() => setNow(/* @__PURE__ */ new Date()), PEAK_TICK_MS);
|
|
1278
|
+
else if (document.visibilityState !== "visible" && timer !== void 0) {
|
|
1279
|
+
window.clearInterval(timer);
|
|
1280
|
+
timer = void 0;
|
|
1281
|
+
}
|
|
1282
|
+
};
|
|
1283
|
+
sync();
|
|
1284
|
+
document.addEventListener("visibilitychange", sync);
|
|
1285
|
+
window.addEventListener("focus", sync);
|
|
1250
1286
|
return () => {
|
|
1251
|
-
window.clearInterval(timer);
|
|
1287
|
+
if (timer !== void 0) window.clearInterval(timer);
|
|
1288
|
+
document.removeEventListener("visibilitychange", sync);
|
|
1289
|
+
window.removeEventListener("focus", sync);
|
|
1252
1290
|
};
|
|
1253
1291
|
}, []);
|
|
1254
1292
|
(0, react.useEffect)(() => {
|
|
@@ -1268,10 +1306,32 @@ window.__ModuleLoader__.load({
|
|
|
1268
1306
|
});
|
|
1269
1307
|
});
|
|
1270
1308
|
};
|
|
1271
|
-
|
|
1272
|
-
|
|
1309
|
+
if (typeof document === "undefined") {
|
|
1310
|
+
load();
|
|
1311
|
+
const timer = setInterval(load, REFRESH_INTERVAL_MS);
|
|
1312
|
+
return () => {
|
|
1313
|
+
clearInterval(timer);
|
|
1314
|
+
controller?.abort();
|
|
1315
|
+
};
|
|
1316
|
+
}
|
|
1317
|
+
let timer;
|
|
1318
|
+
const sync = () => {
|
|
1319
|
+
if (document.visibilityState === "visible") {
|
|
1320
|
+
load();
|
|
1321
|
+
if (timer === void 0) timer = window.setInterval(load, REFRESH_INTERVAL_MS);
|
|
1322
|
+
} else if (timer !== void 0) {
|
|
1323
|
+
window.clearInterval(timer);
|
|
1324
|
+
timer = void 0;
|
|
1325
|
+
controller?.abort();
|
|
1326
|
+
}
|
|
1327
|
+
};
|
|
1328
|
+
sync();
|
|
1329
|
+
document.addEventListener("visibilitychange", sync);
|
|
1330
|
+
window.addEventListener("focus", sync);
|
|
1273
1331
|
return () => {
|
|
1274
|
-
window.clearInterval(timer);
|
|
1332
|
+
if (timer !== void 0) window.clearInterval(timer);
|
|
1333
|
+
document.removeEventListener("visibilitychange", sync);
|
|
1334
|
+
window.removeEventListener("focus", sync);
|
|
1275
1335
|
controller?.abort();
|
|
1276
1336
|
};
|
|
1277
1337
|
}, [loadBalance, provider]);
|
|
@@ -1400,6 +1460,8 @@ window.__ModuleLoader__.load({
|
|
|
1400
1460
|
"billing.todayCost": "今日消费",
|
|
1401
1461
|
"billing.today": "日期 {date}",
|
|
1402
1462
|
"billing.pricedRequests": "已计费请求 {count} 次",
|
|
1463
|
+
"billing.freeRequests": "免费请求 {count} 次",
|
|
1464
|
+
"billing.free": "免费",
|
|
1403
1465
|
"billing.tokens": "Token 总量",
|
|
1404
1466
|
"billing.requestCount": "{count} 次请求",
|
|
1405
1467
|
"billing.share": "占已知消费 {percent}",
|
|
@@ -1534,6 +1596,8 @@ window.__ModuleLoader__.load({
|
|
|
1534
1596
|
"billing.todayCost": "Today’s cost",
|
|
1535
1597
|
"billing.today": "Date {date}",
|
|
1536
1598
|
"billing.pricedRequests": "{count} priced requests",
|
|
1599
|
+
"billing.freeRequests": "{count} free requests",
|
|
1600
|
+
"billing.free": "Free",
|
|
1537
1601
|
"billing.tokens": "Total tokens",
|
|
1538
1602
|
"billing.requestCount": "{count} requests",
|
|
1539
1603
|
"billing.share": "{percent} of priced cost",
|
|
@@ -1603,12 +1667,9 @@ window.__ModuleLoader__.load({
|
|
|
1603
1667
|
//#endregion
|
|
1604
1668
|
//#region src/client/BalanceTab.tsx
|
|
1605
1669
|
function BalanceCard({ info, t }) {
|
|
1606
|
-
const
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
["balance.totalCash", info.totalCashBalance],
|
|
1610
|
-
["balance.totalVoucher", info.totalVoucherBalance]
|
|
1611
|
-
];
|
|
1670
|
+
const available = [["balance.toppedUp", info.toppedUpBalance], ["balance.granted", info.grantedBalance]];
|
|
1671
|
+
const cumulative = [["balance.totalCash", info.totalCashBalance], ["balance.totalVoucher", info.totalVoucherBalance]];
|
|
1672
|
+
const renderRows = (rows) => rows.filter(([, value]) => value !== void 0).map(([label, value]) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", { children: t(label) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dd", { children: displayAmount(value, info.currency, t("locale.tag")) })] }, label));
|
|
1612
1673
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("article", {
|
|
1613
1674
|
className: "dsh-balance-card",
|
|
1614
1675
|
children: [
|
|
@@ -1623,10 +1684,17 @@ window.__ModuleLoader__.load({
|
|
|
1623
1684
|
className: "dsh-balance-total",
|
|
1624
1685
|
children: displayAmount(info.totalBalance, info.currency, t("locale.tag"))
|
|
1625
1686
|
}),
|
|
1626
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dl", {
|
|
1687
|
+
available.some(([, value]) => value !== void 0) ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dl", {
|
|
1627
1688
|
className: "dsh-balance-breakdown",
|
|
1628
|
-
children:
|
|
1629
|
-
})
|
|
1689
|
+
children: renderRows(available)
|
|
1690
|
+
}) : null,
|
|
1691
|
+
cumulative.some(([, value]) => value !== void 0) ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1692
|
+
className: "dsh-balance-copy",
|
|
1693
|
+
children: t("balance.totalsNote")
|
|
1694
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dl", {
|
|
1695
|
+
className: "dsh-balance-breakdown",
|
|
1696
|
+
children: renderRows(cumulative)
|
|
1697
|
+
})] }) : null
|
|
1630
1698
|
]
|
|
1631
1699
|
});
|
|
1632
1700
|
}
|
|
@@ -1733,10 +1801,6 @@ window.__ModuleLoader__.load({
|
|
|
1733
1801
|
className: "dsh-balance-status",
|
|
1734
1802
|
children: t("balance.empty")
|
|
1735
1803
|
}),
|
|
1736
|
-
result.accountType !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1737
|
-
className: "dsh-balance-copy",
|
|
1738
|
-
children: t("balance.totalsNote")
|
|
1739
|
-
}) : null,
|
|
1740
1804
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1741
1805
|
className: "dsh-balance-footer",
|
|
1742
1806
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
@@ -1824,15 +1888,26 @@ window.__ModuleLoader__.load({
|
|
|
1824
1888
|
children: loading ? t("action.loading") : t("models.refresh")
|
|
1825
1889
|
})]
|
|
1826
1890
|
}),
|
|
1827
|
-
loading && result === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.
|
|
1828
|
-
className: "dsh-balance-
|
|
1891
|
+
loading && result === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1892
|
+
className: "dsh-balance-skeleton",
|
|
1829
1893
|
role: "status",
|
|
1830
|
-
children:
|
|
1894
|
+
children: [
|
|
1895
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("models.loading") }),
|
|
1896
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {}),
|
|
1897
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {})
|
|
1898
|
+
]
|
|
1831
1899
|
}) : null,
|
|
1832
|
-
result?.ok === false ? /* @__PURE__ */ (0, react_jsx_runtime.
|
|
1900
|
+
result?.ok === false ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1833
1901
|
className: "dsh-balance-error",
|
|
1834
1902
|
role: "alert",
|
|
1835
|
-
children:
|
|
1903
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("strong", { children: [
|
|
1904
|
+
providerName,
|
|
1905
|
+
" / ",
|
|
1906
|
+
t(errorLocaleKey(result.code))
|
|
1907
|
+
] }), result.code === "MISSING_API_KEY" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t(provider === "deepseek" ? "balance.setupDeepSeek" : "balance.setup", {
|
|
1908
|
+
provider: providerName,
|
|
1909
|
+
ref: findBalanceProvider(provider).apiKeyRef
|
|
1910
|
+
}) }) : null]
|
|
1836
1911
|
}) : null,
|
|
1837
1912
|
result?.ok === true ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
1838
1913
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -1863,7 +1938,7 @@ window.__ModuleLoader__.load({
|
|
|
1863
1938
|
//#endregion
|
|
1864
1939
|
//#region src/client/DeepSeekPanel.tsx
|
|
1865
1940
|
/** Provider-neutral settings workspace. The exported name preserves existing integrations. */
|
|
1866
|
-
function DeepSeekPanel({ loadBalance, loadModels,
|
|
1941
|
+
function DeepSeekPanel({ loadBalance, loadModels, t }) {
|
|
1867
1942
|
const [provider, setProvider] = (0, react.useState)("deepseek");
|
|
1868
1943
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1869
1944
|
className: "dsh-deepseek-panel",
|
|
@@ -1899,16 +1974,7 @@ window.__ModuleLoader__.load({
|
|
|
1899
1974
|
provider,
|
|
1900
1975
|
loadModels,
|
|
1901
1976
|
t
|
|
1902
|
-
}, `models-${provider}`)
|
|
1903
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1904
|
-
className: "dsh-ledger-section-label",
|
|
1905
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("panel.activity") })
|
|
1906
|
-
}),
|
|
1907
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(BillingOverview, {
|
|
1908
|
-
provider,
|
|
1909
|
-
loadUsage,
|
|
1910
|
-
t
|
|
1911
|
-
})
|
|
1977
|
+
}, `models-${provider}`)
|
|
1912
1978
|
]
|
|
1913
1979
|
});
|
|
1914
1980
|
}
|
|
@@ -1918,7 +1984,7 @@ window.__ModuleLoader__.load({
|
|
|
1918
1984
|
.dsh-deepseek-panel, .dsh-usage-content, .dsh-billing-view {
|
|
1919
1985
|
--ledger-ink: var(--dsw-alias-label-primary, #202124);
|
|
1920
1986
|
--ledger-muted: var(--dsw-alias-label-secondary, #686b70);
|
|
1921
|
-
--ledger-line: var(--dsw-alias-border-l2, #e3e4e7);
|
|
1987
|
+
--ledger-line: var(--dsw-alias-border-l3, var(--dsw-alias-border-l2, #e3e4e7));
|
|
1922
1988
|
--ledger-paper: var(--dsw-alias-bg-layer-3, #fafafa);
|
|
1923
1989
|
color: var(--ledger-ink);
|
|
1924
1990
|
min-width: 0;
|
|
@@ -1940,11 +2006,11 @@ window.__ModuleLoader__.load({
|
|
|
1940
2006
|
.dsh-balance-summary { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; }
|
|
1941
2007
|
.dsh-balance-heading { margin: 0; font-size: 18px; font-weight: 600; line-height: 1.4; }
|
|
1942
2008
|
.dsh-balance-copy { margin: 6px 0 0; color: var(--ledger-muted); font-size: 13px; line-height: 1.6; }
|
|
1943
|
-
.dsh-balance-refresh { flex: none; border:
|
|
2009
|
+
.dsh-balance-refresh { flex: none; border: .5px solid var(--ledger-line); border-radius: var(--dsw-radius-md, 8px); min-height: 32px; padding: 0 12px; background: transparent; color: var(--ledger-ink); font: inherit; font-size: 13px; cursor: pointer; }
|
|
1944
2010
|
.dsh-balance-refresh:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover, color-mix(in srgb, currentColor 6%, transparent)); }
|
|
1945
2011
|
.dsh-balance-refresh:disabled { cursor: default; opacity: .55; }
|
|
1946
2012
|
.dsh-balance-refresh:focus-visible, .dsh-provider-switch button:focus-visible, .dsh-usage-select:focus-visible { outline: 2px solid var(--dsw-alias-state-business-primary, #4d6bfe); outline-offset: 2px; }
|
|
1947
|
-
.dsh-balance-status, .dsh-balance-error { margin: 0; border:
|
|
2013
|
+
.dsh-balance-status, .dsh-balance-error { margin: 0; border: .5px solid var(--ledger-line); border-radius: var(--dsw-radius-lg, 12px); padding: 20px; background: var(--ledger-paper); color: var(--ledger-muted); font-size: 13px; line-height: 1.6; }
|
|
1948
2014
|
.dsh-balance-error { border-left: 3px solid var(--dsw-alias-state-error-primary, #c33); }
|
|
1949
2015
|
.dsh-billing-coverage { border-left: 3px solid var(--dsw-alias-state-warn-primary, #d99525); }
|
|
1950
2016
|
.dsh-balance-error strong { color: var(--dsw-alias-state-error-primary, #c33); }
|
|
@@ -1954,16 +2020,16 @@ window.__ModuleLoader__.load({
|
|
|
1954
2020
|
.dsh-balance-availability[data-available='true'] .dsh-balance-dot { background: var(--dsw-alias-state-success-primary, #35a16b); }
|
|
1955
2021
|
.dsh-balance-availability[data-available='null'] .dsh-balance-dot { background: var(--ledger-muted); }
|
|
1956
2022
|
.dsh-balance-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 12px; }
|
|
1957
|
-
.dsh-balance-card { min-width: 0; border:
|
|
2023
|
+
.dsh-balance-card { min-width: 0; border: .5px solid var(--ledger-line); border-radius: var(--dsw-radius-lg, 12px); padding: 20px; background: var(--ledger-paper); }
|
|
1958
2024
|
.dsh-balance-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--ledger-muted); }
|
|
1959
|
-
.dsh-balance-currency { font-size: 12px; padding: 3px 6px; border:
|
|
2025
|
+
.dsh-balance-currency { font-size: 12px; padding: 3px 6px; border: .5px solid var(--ledger-line); border-radius: 4px; }
|
|
1960
2026
|
.dsh-balance-total { margin: 20px 0; font-size: 36px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
|
|
1961
2027
|
.dsh-balance-breakdown { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 0; padding-top: 16px; border-top: 1px solid var(--ledger-line); }
|
|
1962
2028
|
.dsh-balance-breakdown dt { font-size: 12px; color: var(--ledger-muted); line-height: 1.5; }
|
|
1963
2029
|
.dsh-balance-breakdown dd { margin: 6px 0 0; font-size: 16px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
|
|
1964
2030
|
.dsh-balance-meta, .dsh-balance-footer { margin: 0; color: var(--ledger-muted); font-size: 11px; line-height: 1.6; }
|
|
1965
2031
|
.dsh-balance-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
|
|
1966
|
-
.dsh-balance-skeleton { min-height: 180px; display: flex; flex-direction: column; gap: 24px; padding: 20px; border:
|
|
2032
|
+
.dsh-balance-skeleton { min-height: 180px; display: flex; flex-direction: column; gap: 24px; padding: 20px; border: .5px solid var(--ledger-line); border-radius: 12px; background: var(--ledger-paper); font-size: 12px; color: var(--ledger-muted); }
|
|
1967
2033
|
.dsh-balance-skeleton i { width: 60%; height: 32px; border-radius: 4px; background: var(--ledger-line); }
|
|
1968
2034
|
.dsh-balance-skeleton i:last-child { width: 35%; height: 16px; }
|
|
1969
2035
|
@container (max-width: 700px) { .dsh-billing-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; } }
|
|
@@ -1989,7 +2055,7 @@ window.__ModuleLoader__.load({
|
|
|
1989
2055
|
.dsh-usage-select-option[data-active='true'] { background: var(--dsw-alias-interactive-bg-hover, color-mix(in srgb, currentColor 6%, transparent)); }
|
|
1990
2056
|
.dsh-usage-select-option[aria-selected='true'] { font-weight: 500; }
|
|
1991
2057
|
@media (prefers-reduced-motion: reduce) { .dsh-usage-select svg { transition: none; } }
|
|
1992
|
-
.dsh-punchcard { min-width: 0; padding: 20px; border:
|
|
2058
|
+
.dsh-punchcard { min-width: 0; padding: 20px; border: .5px solid var(--ledger-line); border-radius: var(--dsw-radius-lg, 12px); background: var(--ledger-paper); }
|
|
1993
2059
|
.dsh-punchcard-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
|
|
1994
2060
|
.dsh-punchcard-header h3 { margin: 0; font-size: 14px; font-weight: 600; }
|
|
1995
2061
|
.dsh-punchcard-header p { margin: 6px 0 0; color: var(--ledger-muted); font-size: 12px; line-height: 1.5; }
|
|
@@ -1998,7 +2064,8 @@ window.__ModuleLoader__.load({
|
|
|
1998
2064
|
.dsh-punchcard-legend i:nth-of-type(2) { width: 10px; height: 10px; }
|
|
1999
2065
|
.dsh-punchcard-legend i:nth-of-type(3) { width: 16px; height: 16px; }
|
|
2000
2066
|
.dsh-punchcard-scroll { overflow-x: auto; margin-top: 8px; }
|
|
2001
|
-
.dsh-punchcard-
|
|
2067
|
+
.dsh-punchcard-scroll:focus-visible { outline: 2px solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary)); outline-offset: 2px; }
|
|
2068
|
+
.dsh-punchcard-chart { display: block; width: 100%; min-width: min(700px, 100%); overflow: visible; }
|
|
2002
2069
|
.dsh-punchcard-label { fill: var(--ledger-muted); font-size: 11px; font-family: inherit; }
|
|
2003
2070
|
.dsh-punchcard-line { stroke: var(--ledger-line); stroke-dasharray: 2 6; opacity: .5; }
|
|
2004
2071
|
.dsh-punchcard-dot { fill: var(--dsw-alias-state-success-primary, #35a16b); outline: none; }
|
|
@@ -2012,7 +2079,7 @@ window.__ModuleLoader__.load({
|
|
|
2012
2079
|
flex-direction: column;
|
|
2013
2080
|
gap: 8px;
|
|
2014
2081
|
min-height: 104px;
|
|
2015
|
-
border:
|
|
2082
|
+
border: .5px solid var(--dsw-alias-border-l2);
|
|
2016
2083
|
border-radius: 12px;
|
|
2017
2084
|
padding: 16px;
|
|
2018
2085
|
background: var(--dsw-alias-bg-layer-3);
|
|
@@ -2060,7 +2127,9 @@ window.__ModuleLoader__.load({
|
|
|
2060
2127
|
.dsh-billing-request-row span { color: var(--dsw-alias-label-tertiary); }
|
|
2061
2128
|
.dsh-billing-request-row code { color: var(--dsw-alias-label-secondary); overflow-wrap: anywhere; }
|
|
2062
2129
|
.dsh-billing-request-row strong { font-variant-numeric: tabular-nums; }
|
|
2063
|
-
.dsh-billing-
|
|
2130
|
+
.dsh-billing-request-row[data-billing-status='free'] strong { color: var(--dsw-alias-state-success-primary); }
|
|
2131
|
+
.dsh-billing-request-row[data-billing-status='unpriced'] strong { color: var(--dsw-alias-state-warn-primary); }
|
|
2132
|
+
.dsh-billing-detail-panel { min-width: 0; border: .5px solid var(--ledger-line); border-radius: var(--dsw-radius-lg, 12px); background: var(--ledger-paper); }
|
|
2064
2133
|
.dsh-billing-detail-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--ledger-line); }
|
|
2065
2134
|
.dsh-billing-detail-tabs { display: flex; gap: 20px; min-width: 0; }
|
|
2066
2135
|
.dsh-billing-detail-tabs > button { display: inline-flex; align-items: center; gap: 7px; min-height: 54px; margin-bottom: -1px; padding: 10px 2px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--ledger-muted); font: inherit; font-size: 13px; white-space: nowrap; cursor: pointer; }
|
|
@@ -2086,7 +2155,7 @@ window.__ModuleLoader__.load({
|
|
|
2086
2155
|
.dsh-billing-pagination { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 8px; padding: 12px 0; border-top: 1px solid var(--ledger-line); color: var(--ledger-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
|
|
2087
2156
|
.dsh-billing-pagination-actions { display: flex; align-items: center; gap: 6px; }
|
|
2088
2157
|
.dsh-billing-pagination-actions .dsh-usage-select { min-height: 30px; font-size: 11px; }
|
|
2089
|
-
.dsh-billing-page-button { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 30px; height: 30px; padding: 0; border:
|
|
2158
|
+
.dsh-billing-page-button { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 30px; height: 30px; padding: 0; border: .5px solid var(--ledger-line); border-radius: var(--dsw-radius-md, 8px); background: transparent; color: var(--ledger-ink); cursor: pointer; }
|
|
2090
2159
|
.dsh-billing-page-button:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover, #00000006); }
|
|
2091
2160
|
.dsh-billing-page-button:disabled { opacity: .35; cursor: default; }
|
|
2092
2161
|
@container (max-width: 560px) {
|
|
@@ -2112,14 +2181,14 @@ window.__ModuleLoader__.load({
|
|
|
2112
2181
|
display: flex;
|
|
2113
2182
|
flex-direction: column;
|
|
2114
2183
|
gap: 10px;
|
|
2115
|
-
border:
|
|
2184
|
+
border: .5px solid var(--dsw-alias-border-l2);
|
|
2116
2185
|
border-radius: 12px;
|
|
2117
2186
|
padding: 16px;
|
|
2118
2187
|
background: var(--dsw-alias-bg-layer-3);
|
|
2119
2188
|
}
|
|
2120
2189
|
.dsh-model-id {
|
|
2121
2190
|
color: var(--dsw-alias-label-primary);
|
|
2122
|
-
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
2191
|
+
font-family: var(--ds-font-family-code, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
|
|
2123
2192
|
font-size: 15px;
|
|
2124
2193
|
font-weight: 600;
|
|
2125
2194
|
overflow-wrap: anywhere;
|
|
@@ -2166,6 +2235,7 @@ window.__ModuleLoader__.load({
|
|
|
2166
2235
|
@media (max-width: 640px) {
|
|
2167
2236
|
.dsh-billing-view { padding: 20px 16px calc(var(--dsh-composer-height, 152px) + 20px); }
|
|
2168
2237
|
.dsh-balance-dock { white-space: normal; }
|
|
2238
|
+
.dsh-balance-dock-model, .dsh-balance-dock-value { max-width: 100%; }
|
|
2169
2239
|
.dsh-balance-summary { align-items: flex-start; }
|
|
2170
2240
|
.dsh-balance-grid,
|
|
2171
2241
|
.dsh-model-grid,
|