@pinkbanana/dsh-balance 0.5.0 → 0.6.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 +36 -6
- package/README_EN.md +36 -6
- package/lib/client.js +340 -172
- package/lib/client.js.map +1 -1
- package/lib/index.js +201 -82
- package/lib/index.js.map +1 -1
- package/lib/types/balance.d.ts +8 -8
- package/lib/types/client/BalanceTab.d.ts +6 -3
- package/lib/types/client/DeepSeekPanel.d.ts +1 -1
- package/lib/types/client/ModelsTab.d.ts +7 -4
- package/lib/types/client/locales.d.ts +34 -15
- package/lib/types/client/styles.d.ts +1 -1
- package/lib/types/index.d.ts +11 -3
- package/lib/types/models.d.ts +11 -6
- package/lib/types/providers.d.ts +24 -0
- package/lib/types/types.d.ts +23 -12
- package/package.json +7 -3
package/lib/client.js
CHANGED
|
@@ -9,7 +9,7 @@ window.__ModuleLoader__.load({
|
|
|
9
9
|
//#region src/types.ts
|
|
10
10
|
/** The same-origin endpoint exposed by the plugin's Host half. */
|
|
11
11
|
const BALANCE_ROUTE = "/dsh-balance/api/balance";
|
|
12
|
-
/** The same-origin endpoint that proxies
|
|
12
|
+
/** The same-origin endpoint that proxies the selected provider’s `/models` API. */
|
|
13
13
|
const MODELS_ROUTE = "/dsh-balance/api/models";
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/pricing.ts
|
|
@@ -183,33 +183,69 @@ window.__ModuleLoader__.load({
|
|
|
183
183
|
});
|
|
184
184
|
}
|
|
185
185
|
//#endregion
|
|
186
|
+
//#region src/providers.ts
|
|
187
|
+
/** Browser-safe provider metadata. Credentials and wire parsers stay on the Host. */
|
|
188
|
+
const BALANCE_PROVIDERS = [{
|
|
189
|
+
id: "deepseek",
|
|
190
|
+
name: "DeepSeek",
|
|
191
|
+
apiKeyRef: "DEEPSEEK_API_KEY",
|
|
192
|
+
baseUrl: "https://api.deepseek.com"
|
|
193
|
+
}, {
|
|
194
|
+
id: "stepfun",
|
|
195
|
+
name: "StepFun",
|
|
196
|
+
apiKeyRef: "STEPFUN_API_KEY",
|
|
197
|
+
baseUrl: "https://api.stepfun.com/v1"
|
|
198
|
+
}];
|
|
199
|
+
function findBalanceProvider(id) {
|
|
200
|
+
return BALANCE_PROVIDERS.find((provider) => provider.id === id.trim().toLowerCase());
|
|
201
|
+
}
|
|
202
|
+
//#endregion
|
|
186
203
|
//#region src/client/locales.ts
|
|
187
204
|
const LOCALE_NS = "dsh-balance";
|
|
188
205
|
/** Simplified Chinese dictionary and source of truth for the namespace key set. */
|
|
189
206
|
const zh = {
|
|
190
207
|
"locale.tag": "zh-CN",
|
|
191
|
-
"
|
|
208
|
+
"panel.ledger": "账户总览",
|
|
209
|
+
"panel.private": "密钥仅存本机",
|
|
210
|
+
"panel.title": "账户余额",
|
|
211
|
+
"panel.copy": "查看各提供方的账户余额与 API 消费。",
|
|
212
|
+
"panel.providers": "选择提供方",
|
|
213
|
+
"panel.models": "可用模型",
|
|
214
|
+
"panel.activity": "消费记录",
|
|
215
|
+
"panel.allProviders": "全部提供方",
|
|
216
|
+
"panel.account": "账户余额",
|
|
217
|
+
"balance.availableAmount": "当前可用余额",
|
|
218
|
+
"balance.totalCash": "总充值金额",
|
|
219
|
+
"balance.totalVoucher": "总赠送金额",
|
|
220
|
+
"balance.prepaid": "预付费账户",
|
|
221
|
+
"balance.postpaid": "后付费账户",
|
|
222
|
+
"balance.totalsNote": "总充值与总赠送金额为账户累计金额,不代表当前剩余余额;账户类型不表示服务可用状态。",
|
|
223
|
+
"balance.setupDeepSeek": "在“设置 → 模型”保存 DeepSeek API 密钥,或配置 {ref} 环境变量。",
|
|
224
|
+
"balance.setup": "在“设置 → 模型”添加自定义提供方,Provider ID 填写 {provider}(大小写不限),并保存 API 密钥。默认凭据为 {ref};自定义凭据请检查插件配置。",
|
|
225
|
+
"error.UNSUPPORTED_PROVIDER": "暂不支持此提供方的余额查询",
|
|
226
|
+
"nav.balance": "模型余额",
|
|
192
227
|
"action.loading": "查询中…",
|
|
193
|
-
"balance.title": "
|
|
228
|
+
"balance.title": "{provider} 账户",
|
|
194
229
|
"balance.copy": "余额由本机 Host 使用已保存的 API 密钥查询,密钥不会发送到浏览器。",
|
|
195
230
|
"balance.refresh": "刷新余额",
|
|
196
|
-
"balance.loading": "
|
|
231
|
+
"balance.loading": "正在查询账户余额…",
|
|
197
232
|
"balance.available": "当前账户有可用余额",
|
|
198
233
|
"balance.unavailable": "当前账户没有可用余额",
|
|
199
|
-
"balance.empty": "
|
|
234
|
+
"balance.empty": "提供方未返回任何币种余额。",
|
|
200
235
|
"balance.toppedUp": "充值余额",
|
|
201
236
|
"balance.granted": "赠送余额",
|
|
202
237
|
"dock.label": "DeepSeek 余额",
|
|
203
238
|
"dock.loading": "查询中…",
|
|
204
239
|
"dock.unavailable": "暂时无法获取",
|
|
205
240
|
"dock.empty": "暂无余额信息",
|
|
206
|
-
"models.title": "
|
|
207
|
-
"models.copy": "
|
|
241
|
+
"models.title": "{provider} 可用模型",
|
|
242
|
+
"models.copy": "查看 {provider} 返回的可用模型。",
|
|
208
243
|
"models.refresh": "刷新模型",
|
|
209
|
-
"models.loading": "
|
|
244
|
+
"models.loading": "正在查询模型列表…",
|
|
210
245
|
"models.count": "当前可用 {count} 个模型",
|
|
211
|
-
"models.empty": "
|
|
246
|
+
"models.empty": "提供方未返回任何可用模型。",
|
|
212
247
|
"models.owner": "由 {owner} 提供",
|
|
248
|
+
"models.created": "创建于 {date}",
|
|
213
249
|
"billing.tab": "消费",
|
|
214
250
|
"billing.title": "API 消费统计",
|
|
215
251
|
"billing.copy": "按会话、模型和日期统计实际 provider usage;日期按 {timeZone} 分组。",
|
|
@@ -257,40 +293,59 @@ window.__ModuleLoader__.load({
|
|
|
257
293
|
"meta.updated": "更新于 {time}",
|
|
258
294
|
"meta.cached": " · 缓存",
|
|
259
295
|
"error.FORBIDDEN": "此查询仅允许从本机访问",
|
|
260
|
-
"error.INVALID_API_KEY": "
|
|
261
|
-
"error.INVALID_RESPONSE": "
|
|
296
|
+
"error.INVALID_API_KEY": "API 密钥无效或没有查询权限",
|
|
297
|
+
"error.INVALID_RESPONSE": "返回了无法识别的响应",
|
|
262
298
|
"error.METHOD_NOT_ALLOWED": "请求方法不受支持",
|
|
263
|
-
"error.MISSING_API_KEY": "未配置
|
|
264
|
-
"error.RATE_LIMITED": "
|
|
265
|
-
"error.UPSTREAM_ERROR": "
|
|
266
|
-
"error.UPSTREAM_TIMEOUT": "查询
|
|
267
|
-
"error.UPSTREAM_UNAVAILABLE": "无法连接到
|
|
299
|
+
"error.MISSING_API_KEY": "未配置 API 密钥,请先在“模型”设置中保存",
|
|
300
|
+
"error.RATE_LIMITED": "API 请求过于频繁,请稍后重试",
|
|
301
|
+
"error.UPSTREAM_ERROR": "API 返回了错误",
|
|
302
|
+
"error.UPSTREAM_TIMEOUT": "查询 API 超时",
|
|
303
|
+
"error.UPSTREAM_UNAVAILABLE": "无法连接到 API"
|
|
268
304
|
};
|
|
269
305
|
/** English dictionary, checked complete against the Chinese key set. */
|
|
270
306
|
const en = {
|
|
271
307
|
"locale.tag": "en-US",
|
|
272
|
-
"
|
|
308
|
+
"panel.ledger": "ACCOUNT LEDGER",
|
|
309
|
+
"panel.private": "Keys stay local",
|
|
310
|
+
"panel.title": "Account balances",
|
|
311
|
+
"panel.copy": "View account balances and API usage by provider.",
|
|
312
|
+
"panel.providers": "Select provider",
|
|
313
|
+
"panel.models": "AVAILABLE MODELS",
|
|
314
|
+
"panel.activity": "USAGE ACTIVITY",
|
|
315
|
+
"panel.allProviders": "All providers",
|
|
316
|
+
"panel.account": "ACCOUNT BALANCE",
|
|
317
|
+
"balance.availableAmount": "Available balance",
|
|
318
|
+
"balance.totalCash": "Total cash credited",
|
|
319
|
+
"balance.totalVoucher": "Total vouchers granted",
|
|
320
|
+
"balance.prepaid": "Prepaid account",
|
|
321
|
+
"balance.postpaid": "Postpaid account",
|
|
322
|
+
"balance.totalsNote": "Cash and voucher totals are cumulative amounts, not remaining balances. Account type does not indicate service availability.",
|
|
323
|
+
"balance.setupDeepSeek": "Save your DeepSeek API key in Settings → Models, or set the {ref} environment variable.",
|
|
324
|
+
"balance.setup": "Add a custom provider in Settings → Models with Provider ID {provider} (case-insensitive), then save your API key. The default credential is {ref}; check plugin configuration for custom references.",
|
|
325
|
+
"error.UNSUPPORTED_PROVIDER": "Balance queries are not supported for this provider",
|
|
326
|
+
"nav.balance": "Model Balances",
|
|
273
327
|
"action.loading": "Loading…",
|
|
274
|
-
"balance.title": "
|
|
328
|
+
"balance.title": "{provider} account",
|
|
275
329
|
"balance.copy": "The local Host queries your balance with the saved API key. The key is never sent to the browser.",
|
|
276
330
|
"balance.refresh": "Refresh balance",
|
|
277
|
-
"balance.loading": "Loading your
|
|
331
|
+
"balance.loading": "Loading your account balance…",
|
|
278
332
|
"balance.available": "This account has available balance",
|
|
279
333
|
"balance.unavailable": "This account has no available balance",
|
|
280
|
-
"balance.empty": "
|
|
334
|
+
"balance.empty": "The provider returned no currency balances.",
|
|
281
335
|
"balance.toppedUp": "Topped-up balance",
|
|
282
336
|
"balance.granted": "Granted balance",
|
|
283
337
|
"dock.label": "DeepSeek Balance",
|
|
284
338
|
"dock.loading": "Loading…",
|
|
285
339
|
"dock.unavailable": "Temporarily unavailable",
|
|
286
340
|
"dock.empty": "No balance information",
|
|
287
|
-
"models.title": "Available
|
|
288
|
-
"models.copy": "
|
|
341
|
+
"models.title": "Available {provider} models",
|
|
342
|
+
"models.copy": "Models available from {provider}.",
|
|
289
343
|
"models.refresh": "Refresh models",
|
|
290
|
-
"models.loading": "Loading the
|
|
344
|
+
"models.loading": "Loading the model list…",
|
|
291
345
|
"models.count": "{count} models available",
|
|
292
|
-
"models.empty": "
|
|
346
|
+
"models.empty": "The provider returned no available models.",
|
|
293
347
|
"models.owner": "Provided by {owner}",
|
|
348
|
+
"models.created": "Created {date}",
|
|
294
349
|
"billing.tab": "Usage",
|
|
295
350
|
"billing.title": "API Usage",
|
|
296
351
|
"billing.copy": "Actual provider usage grouped by session, model, and date; dates use {timeZone}.",
|
|
@@ -338,14 +393,14 @@ window.__ModuleLoader__.load({
|
|
|
338
393
|
"meta.updated": "Updated {time}",
|
|
339
394
|
"meta.cached": " · Cached",
|
|
340
395
|
"error.FORBIDDEN": "This query is available only from the local machine",
|
|
341
|
-
"error.INVALID_API_KEY": "The
|
|
342
|
-
"error.INVALID_RESPONSE": "
|
|
396
|
+
"error.INVALID_API_KEY": "The API key is invalid or lacks permission",
|
|
397
|
+
"error.INVALID_RESPONSE": "The provider returned an unrecognized response",
|
|
343
398
|
"error.METHOD_NOT_ALLOWED": "This request method is not supported",
|
|
344
|
-
"error.MISSING_API_KEY": "No
|
|
345
|
-
"error.RATE_LIMITED": "Too many
|
|
346
|
-
"error.UPSTREAM_ERROR": "The
|
|
347
|
-
"error.UPSTREAM_TIMEOUT": "The
|
|
348
|
-
"error.UPSTREAM_UNAVAILABLE": "Could not connect to the
|
|
399
|
+
"error.MISSING_API_KEY": "No API key is configured. Save one in Models settings first.",
|
|
400
|
+
"error.RATE_LIMITED": "Too many API requests. Try again later.",
|
|
401
|
+
"error.UPSTREAM_ERROR": "The API returned an error",
|
|
402
|
+
"error.UPSTREAM_TIMEOUT": "The API request timed out",
|
|
403
|
+
"error.UPSTREAM_UNAVAILABLE": "Could not connect to the API"
|
|
349
404
|
};
|
|
350
405
|
function errorLocaleKey(code) {
|
|
351
406
|
return `error.${code}`;
|
|
@@ -353,91 +408,116 @@ window.__ModuleLoader__.load({
|
|
|
353
408
|
//#endregion
|
|
354
409
|
//#region src/client/BalanceTab.tsx
|
|
355
410
|
function BalanceCard({ info, t }) {
|
|
411
|
+
const details = [
|
|
412
|
+
["balance.toppedUp", info.toppedUpBalance],
|
|
413
|
+
["balance.granted", info.grantedBalance],
|
|
414
|
+
["balance.totalCash", info.totalCashBalance],
|
|
415
|
+
["balance.totalVoucher", info.totalVoucherBalance]
|
|
416
|
+
];
|
|
356
417
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("article", {
|
|
357
418
|
className: "dsh-balance-card",
|
|
358
419
|
children: [
|
|
359
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
420
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
360
421
|
className: "dsh-balance-card-head",
|
|
361
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
422
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("balance.availableAmount") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
362
423
|
className: "dsh-balance-currency",
|
|
363
424
|
children: info.currency
|
|
364
|
-
})
|
|
425
|
+
})]
|
|
365
426
|
}),
|
|
366
427
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
367
428
|
className: "dsh-balance-total",
|
|
368
429
|
children: displayAmount(info.totalBalance, info.currency, t("locale.tag"))
|
|
369
430
|
}),
|
|
370
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
431
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dl", {
|
|
371
432
|
className: "dsh-balance-breakdown",
|
|
372
|
-
children: [
|
|
373
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", { children: t("balance.toppedUp") }),
|
|
374
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dd", { children: displayAmount(info.toppedUpBalance, info.currency, t("locale.tag")) }),
|
|
375
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", { children: t("balance.granted") }),
|
|
376
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dd", { children: displayAmount(info.grantedBalance, info.currency, t("locale.tag")) })
|
|
377
|
-
]
|
|
433
|
+
children: details.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))
|
|
378
434
|
})
|
|
379
435
|
]
|
|
380
436
|
});
|
|
381
437
|
}
|
|
382
|
-
function BalanceSection({ loadBalance, t }) {
|
|
438
|
+
function BalanceSection({ loadBalance, t, provider = "deepseek" }) {
|
|
383
439
|
const [result, setResult] = (0, react.useState)();
|
|
384
440
|
const [loading, setLoading] = (0, react.useState)(true);
|
|
385
|
-
const
|
|
441
|
+
const active = (0, react.useRef)();
|
|
442
|
+
const providerName = findBalanceProvider(provider).name;
|
|
443
|
+
const load = (0, react.useCallback)(async (forceRefresh) => {
|
|
444
|
+
active.current?.abort();
|
|
445
|
+
const controller = new AbortController();
|
|
446
|
+
active.current = controller;
|
|
447
|
+
const { signal } = controller;
|
|
386
448
|
setLoading(true);
|
|
387
449
|
try {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
setResult({
|
|
450
|
+
const value = await loadBalance(forceRefresh, signal, provider);
|
|
451
|
+
if (!signal.aborted) setResult(value);
|
|
452
|
+
} catch {
|
|
453
|
+
if (!signal.aborted) setResult({
|
|
392
454
|
ok: false,
|
|
393
455
|
code: "UPSTREAM_UNAVAILABLE",
|
|
394
|
-
message:
|
|
456
|
+
message: ""
|
|
395
457
|
});
|
|
396
458
|
} finally {
|
|
397
459
|
if (!signal.aborted) setLoading(false);
|
|
398
460
|
}
|
|
399
|
-
}, [loadBalance]);
|
|
461
|
+
}, [loadBalance, provider]);
|
|
400
462
|
(0, react.useEffect)(() => {
|
|
401
|
-
|
|
402
|
-
load(false
|
|
463
|
+
setResult(void 0);
|
|
464
|
+
load(false);
|
|
403
465
|
return () => {
|
|
404
|
-
|
|
466
|
+
active.current?.abort();
|
|
405
467
|
};
|
|
406
468
|
}, [load]);
|
|
407
|
-
const refresh = () => {
|
|
408
|
-
const controller = new AbortController();
|
|
409
|
-
load(true, controller.signal);
|
|
410
|
-
};
|
|
411
469
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
412
470
|
className: "dsh-balance-section",
|
|
413
471
|
"aria-labelledby": "dsh-balance-title",
|
|
472
|
+
"aria-busy": loading,
|
|
473
|
+
"data-provider": provider,
|
|
414
474
|
children: [
|
|
415
475
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
416
476
|
className: "dsh-balance-summary",
|
|
417
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.
|
|
477
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
478
|
+
className: "dsh-ledger-kicker",
|
|
479
|
+
children: ["01 / ", t("panel.account")]
|
|
480
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
|
|
418
481
|
id: "dsh-balance-title",
|
|
419
482
|
className: "dsh-balance-heading",
|
|
420
|
-
children: t("balance.title")
|
|
421
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.
|
|
422
|
-
className: "dsh-balance-copy",
|
|
423
|
-
children: t("balance.copy")
|
|
424
|
-
})] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
483
|
+
children: t("balance.title", { provider: providerName })
|
|
484
|
+
})] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
425
485
|
className: "dsh-balance-refresh",
|
|
426
486
|
type: "button",
|
|
427
487
|
disabled: loading,
|
|
428
|
-
onClick:
|
|
429
|
-
|
|
488
|
+
onClick: () => {
|
|
489
|
+
load(true);
|
|
490
|
+
},
|
|
491
|
+
children: [
|
|
492
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
493
|
+
"aria-hidden": "true",
|
|
494
|
+
children: "↻"
|
|
495
|
+
}),
|
|
496
|
+
" ",
|
|
497
|
+
loading ? t("action.loading") : t("balance.refresh")
|
|
498
|
+
]
|
|
430
499
|
})]
|
|
431
500
|
}),
|
|
432
|
-
loading && result === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.
|
|
433
|
-
className: "dsh-balance-
|
|
501
|
+
loading && result === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
502
|
+
className: "dsh-balance-skeleton",
|
|
434
503
|
role: "status",
|
|
435
|
-
children:
|
|
504
|
+
children: [
|
|
505
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("balance.loading") }),
|
|
506
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {}),
|
|
507
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {})
|
|
508
|
+
]
|
|
436
509
|
}) : null,
|
|
437
|
-
result?.ok === false ? /* @__PURE__ */ (0, react_jsx_runtime.
|
|
510
|
+
result?.ok === false ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
438
511
|
className: "dsh-balance-error",
|
|
439
512
|
role: "alert",
|
|
440
|
-
children:
|
|
513
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("strong", { children: [
|
|
514
|
+
providerName,
|
|
515
|
+
" / ",
|
|
516
|
+
t(errorLocaleKey(result.code))
|
|
517
|
+
] }), result.code === "MISSING_API_KEY" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t(provider === "deepseek" ? "balance.setupDeepSeek" : "balance.setup", {
|
|
518
|
+
provider: providerName,
|
|
519
|
+
ref: findBalanceProvider(provider).apiKeyRef
|
|
520
|
+
}) }) : null]
|
|
441
521
|
}) : null,
|
|
442
522
|
result?.ok === true ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
443
523
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -446,7 +526,7 @@ window.__ModuleLoader__.load({
|
|
|
446
526
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
447
527
|
className: "dsh-balance-dot",
|
|
448
528
|
"aria-hidden": "true"
|
|
449
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t(result.isAvailable ? "balance.available" : "balance.unavailable") })]
|
|
529
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: result.accountType !== void 0 ? t(`balance.${result.accountType}`) : t(result.isAvailable ? "balance.available" : "balance.unavailable") })]
|
|
450
530
|
}),
|
|
451
531
|
result.balanceInfos.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
452
532
|
className: "dsh-balance-grid",
|
|
@@ -458,9 +538,16 @@ window.__ModuleLoader__.load({
|
|
|
458
538
|
className: "dsh-balance-status",
|
|
459
539
|
children: t("balance.empty")
|
|
460
540
|
}),
|
|
461
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
462
|
-
className: "dsh-balance-
|
|
463
|
-
children:
|
|
541
|
+
result.accountType !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
542
|
+
className: "dsh-balance-copy",
|
|
543
|
+
children: t("balance.totalsNote")
|
|
544
|
+
}) : null,
|
|
545
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
546
|
+
className: "dsh-balance-footer",
|
|
547
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
548
|
+
className: "dsh-balance-meta",
|
|
549
|
+
children: [t("meta.updated", { time: new Date(result.fetchedAt).toLocaleString(t("locale.tag")) }), result.source === "cache" ? t("meta.cached") : ""]
|
|
550
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("panel.private") })]
|
|
464
551
|
})
|
|
465
552
|
] }) : null
|
|
466
553
|
]
|
|
@@ -471,62 +558,74 @@ window.__ModuleLoader__.load({
|
|
|
471
558
|
function ModelCard({ model, t }) {
|
|
472
559
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("article", {
|
|
473
560
|
className: "dsh-model-card",
|
|
474
|
-
children: [
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
561
|
+
children: [
|
|
562
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
|
|
563
|
+
className: "dsh-model-id",
|
|
564
|
+
children: model.id
|
|
565
|
+
}),
|
|
566
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
567
|
+
className: "dsh-model-owner",
|
|
568
|
+
children: t("models.owner", { owner: model.ownedBy })
|
|
569
|
+
}),
|
|
570
|
+
model.created === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
571
|
+
className: "dsh-model-owner",
|
|
572
|
+
children: t("models.created", { date: (/* @__PURE__ */ new Date(model.created * 1e3)).toLocaleDateString(t("locale.tag")) })
|
|
573
|
+
})
|
|
574
|
+
]
|
|
481
575
|
});
|
|
482
576
|
}
|
|
483
|
-
function ModelsSection({ loadModels, t }) {
|
|
577
|
+
function ModelsSection({ loadModels, t, provider = "deepseek" }) {
|
|
484
578
|
const [result, setResult] = (0, react.useState)();
|
|
485
579
|
const [loading, setLoading] = (0, react.useState)(true);
|
|
486
|
-
const
|
|
580
|
+
const active = (0, react.useRef)();
|
|
581
|
+
const providerName = findBalanceProvider(provider).name;
|
|
582
|
+
const load = (0, react.useCallback)(async (forceRefresh) => {
|
|
583
|
+
active.current?.abort();
|
|
584
|
+
const controller = new AbortController();
|
|
585
|
+
active.current = controller;
|
|
586
|
+
const { signal } = controller;
|
|
487
587
|
setLoading(true);
|
|
488
588
|
try {
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
setResult({
|
|
589
|
+
const value = await loadModels(forceRefresh, signal, provider);
|
|
590
|
+
if (!signal.aborted) setResult(value);
|
|
591
|
+
} catch {
|
|
592
|
+
if (!signal.aborted) setResult({
|
|
493
593
|
ok: false,
|
|
494
594
|
code: "UPSTREAM_UNAVAILABLE",
|
|
495
|
-
message:
|
|
595
|
+
message: ""
|
|
496
596
|
});
|
|
497
597
|
} finally {
|
|
498
598
|
if (!signal.aborted) setLoading(false);
|
|
499
599
|
}
|
|
500
|
-
}, [loadModels]);
|
|
600
|
+
}, [loadModels, provider]);
|
|
501
601
|
(0, react.useEffect)(() => {
|
|
502
|
-
|
|
503
|
-
load(false
|
|
602
|
+
setResult(void 0);
|
|
603
|
+
load(false);
|
|
504
604
|
return () => {
|
|
505
|
-
|
|
605
|
+
active.current?.abort();
|
|
506
606
|
};
|
|
507
607
|
}, [load]);
|
|
508
|
-
const refresh = () => {
|
|
509
|
-
const controller = new AbortController();
|
|
510
|
-
load(true, controller.signal);
|
|
511
|
-
};
|
|
512
608
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
513
609
|
className: "dsh-models-section",
|
|
514
610
|
"aria-labelledby": "dsh-models-title",
|
|
611
|
+
"aria-busy": loading,
|
|
515
612
|
children: [
|
|
516
613
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
517
614
|
className: "dsh-balance-summary",
|
|
518
615
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
|
|
519
616
|
id: "dsh-models-title",
|
|
520
617
|
className: "dsh-balance-heading",
|
|
521
|
-
children: t("models.title")
|
|
618
|
+
children: t("models.title", { provider: providerName })
|
|
522
619
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
523
620
|
className: "dsh-balance-copy",
|
|
524
|
-
children: t("models.copy")
|
|
621
|
+
children: t("models.copy", { provider: providerName })
|
|
525
622
|
})] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
526
623
|
className: "dsh-balance-refresh",
|
|
527
624
|
type: "button",
|
|
528
625
|
disabled: loading,
|
|
529
|
-
onClick:
|
|
626
|
+
onClick: () => {
|
|
627
|
+
load(true);
|
|
628
|
+
},
|
|
530
629
|
children: loading ? t("action.loading") : t("models.refresh")
|
|
531
630
|
})]
|
|
532
631
|
}),
|
|
@@ -1003,26 +1102,70 @@ window.__ModuleLoader__.load({
|
|
|
1003
1102
|
}
|
|
1004
1103
|
//#endregion
|
|
1005
1104
|
//#region src/client/DeepSeekPanel.tsx
|
|
1006
|
-
/**
|
|
1105
|
+
/** Provider-neutral settings workspace. The exported name preserves existing integrations. */
|
|
1007
1106
|
function DeepSeekPanel({ loadBalance, loadModels, loadUsage, t }) {
|
|
1107
|
+
const [provider, setProvider] = (0, react.useState)("deepseek");
|
|
1008
1108
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1009
1109
|
className: "dsh-deepseek-panel",
|
|
1010
1110
|
children: [
|
|
1111
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", {
|
|
1112
|
+
className: "dsh-ledger-header",
|
|
1113
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1114
|
+
className: "dsh-ledger-eyebrow",
|
|
1115
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: ["DSH / ", t("panel.ledger")] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("panel.private") })]
|
|
1116
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1117
|
+
className: "dsh-ledger-intro",
|
|
1118
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", { children: t("panel.title") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("panel.copy") })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1119
|
+
className: "dsh-ledger-orbit",
|
|
1120
|
+
"aria-hidden": "true",
|
|
1121
|
+
children: [
|
|
1122
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {}),
|
|
1123
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {}),
|
|
1124
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {}),
|
|
1125
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "↗" })
|
|
1126
|
+
]
|
|
1127
|
+
})]
|
|
1128
|
+
})]
|
|
1129
|
+
}),
|
|
1130
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1131
|
+
className: "dsh-provider-switch",
|
|
1132
|
+
role: "group",
|
|
1133
|
+
"aria-label": t("panel.providers"),
|
|
1134
|
+
children: BALANCE_PROVIDERS.map((item, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1135
|
+
type: "button",
|
|
1136
|
+
"aria-pressed": provider === item.id,
|
|
1137
|
+
onClick: () => setProvider(item.id),
|
|
1138
|
+
children: [
|
|
1139
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1140
|
+
className: "dsh-provider-index",
|
|
1141
|
+
children: ["0", index + 1]
|
|
1142
|
+
}),
|
|
1143
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: item.name }),
|
|
1144
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1145
|
+
className: "dsh-provider-arrow",
|
|
1146
|
+
"aria-hidden": "true",
|
|
1147
|
+
children: "↗"
|
|
1148
|
+
})
|
|
1149
|
+
]
|
|
1150
|
+
}, item.id))
|
|
1151
|
+
}),
|
|
1011
1152
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(BalanceSection, {
|
|
1153
|
+
provider,
|
|
1012
1154
|
loadBalance,
|
|
1013
1155
|
t
|
|
1014
|
-
}),
|
|
1015
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
1016
|
-
className: "dsh-
|
|
1017
|
-
"
|
|
1156
|
+
}, `balance-${provider}`),
|
|
1157
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1158
|
+
className: "dsh-ledger-section-label",
|
|
1159
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: ["02 / ", t("panel.models")] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: findBalanceProvider(provider).name })]
|
|
1018
1160
|
}),
|
|
1019
1161
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelsSection, {
|
|
1162
|
+
provider,
|
|
1020
1163
|
loadModels,
|
|
1021
1164
|
t
|
|
1022
|
-
}),
|
|
1023
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
1024
|
-
className: "dsh-
|
|
1025
|
-
"
|
|
1165
|
+
}, `models-${provider}`),
|
|
1166
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1167
|
+
className: "dsh-ledger-section-label",
|
|
1168
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: ["03 / ", t("panel.activity")] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("panel.allProviders") })]
|
|
1026
1169
|
}),
|
|
1027
1170
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(BillingOverview, {
|
|
1028
1171
|
loadUsage,
|
|
@@ -1035,77 +1178,96 @@ window.__ModuleLoader__.load({
|
|
|
1035
1178
|
//#region src/client/styles.ts
|
|
1036
1179
|
const balanceStyles = `
|
|
1037
1180
|
.dsh-deepseek-panel {
|
|
1181
|
+
--ledger-ink: var(--dsw-alias-label-primary, #202421);
|
|
1182
|
+
--ledger-muted: var(--dsw-alias-label-secondary, #60665f);
|
|
1183
|
+
--ledger-line: var(--dsw-alias-border-l2, #d7dbd3);
|
|
1184
|
+
--ledger-paper: var(--dsw-alias-bg-layer-3, #f5f6f0);
|
|
1038
1185
|
display: flex;
|
|
1039
1186
|
flex-direction: column;
|
|
1040
|
-
gap:
|
|
1187
|
+
gap: 24px;
|
|
1041
1188
|
max-width: 1040px;
|
|
1042
|
-
|
|
1189
|
+
min-width: 0;
|
|
1190
|
+
color: var(--ledger-ink);
|
|
1191
|
+
container-type: inline-size;
|
|
1192
|
+
}
|
|
1193
|
+
.dsh-deepseek-panel *, .dsh-deepseek-panel *::before, .dsh-deepseek-panel *::after { box-sizing: border-box; }
|
|
1194
|
+
.dsh-ledger-header { border-top: 2px solid var(--ledger-ink); padding-top: 14px; }
|
|
1195
|
+
.dsh-ledger-eyebrow, .dsh-ledger-section-label, .dsh-ledger-kicker {
|
|
1196
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
1197
|
+
font-size: 11px;
|
|
1198
|
+
letter-spacing: .08em;
|
|
1199
|
+
line-height: 1.6;
|
|
1200
|
+
color: var(--ledger-muted);
|
|
1043
1201
|
}
|
|
1202
|
+
.dsh-ledger-eyebrow, .dsh-ledger-section-label { display: flex; justify-content: space-between; gap: 16px; }
|
|
1203
|
+
.dsh-ledger-intro { display: grid; grid-template-columns: 1fr 150px; align-items: center; gap: 24px; padding: 32px 0 20px; }
|
|
1204
|
+
.dsh-ledger-intro h1 { max-width: 650px; margin: 0; font-size: 24px; font-weight: 500; line-height: 1.4; }
|
|
1205
|
+
.dsh-ledger-intro p { margin: 18px 0 0; color: var(--ledger-muted); font-size: 13px; line-height: 1.7; }
|
|
1206
|
+
.dsh-ledger-orbit { position: relative; display: grid; place-items: center; width: 148px; height: 148px; }
|
|
1207
|
+
.dsh-ledger-orbit i { position: absolute; width: 112px; height: 112px; border: 1px solid var(--ledger-muted); border-radius: 50%; transform: rotate(-35deg) scaleX(.5); }
|
|
1208
|
+
.dsh-ledger-orbit i:nth-child(2) { transform: rotate(25deg) scaleX(.5); }
|
|
1209
|
+
.dsh-ledger-orbit i:nth-child(3) { transform: rotate(85deg) scaleX(.5); }
|
|
1210
|
+
.dsh-ledger-orbit span { display: grid; place-items: center; width: 40px; height: 40px; background: #d7ed9d; color: #233316; border-radius: 50%; font-size: 24px; transition: transform .4s ease; }
|
|
1211
|
+
.dsh-ledger-header:hover .dsh-ledger-orbit span { transform: rotate(45deg); }
|
|
1212
|
+
.dsh-provider-switch { display: flex; gap: 8px; padding-bottom: 24px; border-bottom: 1px solid var(--ledger-line); }
|
|
1213
|
+
.dsh-provider-switch button { display: flex; align-items: center; gap: 14px; flex: 1; max-width: 270px; min-height: 58px; padding: 12px 18px; border: 1px solid var(--ledger-line); border-radius: 4px; color: var(--ledger-ink); background: transparent; font: inherit; font-size: 16px; cursor: pointer; transition: background .2s, transform .2s; }
|
|
1214
|
+
.dsh-provider-switch button:hover { background: var(--ledger-paper); transform: translateY(-2px); }
|
|
1215
|
+
.dsh-provider-switch button[aria-pressed='true'] { color: #e5f6bd; background: #25352e; border-color: #25352e; }
|
|
1216
|
+
.dsh-provider-index { font-family: ui-monospace, monospace; font-size: 10px; opacity: .7; }
|
|
1217
|
+
.dsh-provider-arrow { margin-left: auto; transition: transform .2s; }
|
|
1218
|
+
.dsh-provider-switch button[aria-pressed='true'] .dsh-provider-arrow { transform: rotate(45deg); }
|
|
1219
|
+
.dsh-ledger-kicker { margin: 0 0 8px; }
|
|
1220
|
+
.dsh-ledger-section-label { border-top: 1px solid var(--ledger-line); padding-top: 18px; margin-top: 12px; }
|
|
1044
1221
|
.dsh-balance-section,
|
|
1045
1222
|
.dsh-models-section,
|
|
1046
1223
|
.dsh-billing-section,
|
|
1047
|
-
.dsh-billing-view {
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
}
|
|
1052
|
-
.dsh-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
}
|
|
1056
|
-
.dsh-balance-summary {
|
|
1057
|
-
display: flex;
|
|
1058
|
-
align-items: center;
|
|
1059
|
-
justify-content: space-between;
|
|
1060
|
-
gap: 16px;
|
|
1061
|
-
}
|
|
1062
|
-
.dsh-balance-heading { margin: 0; font-size: 18px; font-weight: 600; line-height: 24px; }
|
|
1063
|
-
.dsh-balance-copy { margin: 4px 0 0; color: var(--dsw-alias-label-tertiary); font-size: 13px; line-height: 1.5; }
|
|
1064
|
-
.dsh-balance-refresh {
|
|
1065
|
-
flex: none;
|
|
1066
|
-
appearance: none;
|
|
1067
|
-
border: 1px solid var(--dsw-alias-border-l2);
|
|
1068
|
-
border-radius: 16px;
|
|
1069
|
-
min-height: 32px;
|
|
1070
|
-
padding: 0 14px;
|
|
1071
|
-
background: transparent;
|
|
1072
|
-
color: var(--dsw-alias-label-primary);
|
|
1073
|
-
font: inherit;
|
|
1074
|
-
font-size: 13px;
|
|
1075
|
-
cursor: pointer;
|
|
1076
|
-
}
|
|
1077
|
-
.dsh-balance-refresh:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }
|
|
1078
|
-
.dsh-balance-refresh:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 2px; }
|
|
1224
|
+
.dsh-billing-view { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
|
|
1225
|
+
.dsh-balance-section { animation: dsh-ledger-reveal .3s ease-out; }
|
|
1226
|
+
.dsh-balance-summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
|
|
1227
|
+
.dsh-balance-heading { margin: 0; font-size: 20px; font-weight: 550; line-height: 1.4; letter-spacing: -.025em; }
|
|
1228
|
+
.dsh-balance-copy { margin: 4px 0 0; color: var(--dsw-alias-label-secondary, #60665f); font-size: 12px; line-height: 1.7; }
|
|
1229
|
+
.dsh-balance-refresh { flex: none; appearance: none; border: 1px solid var(--dsw-alias-border-l2, #d7dbd3); border-radius: 4px; min-height: 36px; padding: 0 14px; background: transparent; color: var(--dsw-alias-label-primary, #202421); font: inherit; font-size: 12px; cursor: pointer; transition: background .2s; }
|
|
1230
|
+
.dsh-balance-refresh:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover, #e9edde); }
|
|
1231
|
+
.dsh-balance-refresh:focus-visible, .dsh-provider-switch button:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary, #628537); outline-offset: 3px; }
|
|
1079
1232
|
.dsh-balance-refresh:disabled { cursor: default; opacity: .55; }
|
|
1080
|
-
.dsh-balance-status,
|
|
1081
|
-
.dsh-balance-error {
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1233
|
+
.dsh-balance-status, .dsh-balance-error { margin: 0; border: 1px solid var(--dsw-alias-border-l2, #d7dbd3); border-radius: 4px; padding: 24px; background: var(--dsw-alias-bg-layer-3, #f5f6f0); color: var(--dsw-alias-label-secondary, #60665f); font-size: 13px; line-height: 1.7; }
|
|
1234
|
+
.dsh-balance-error { border-left: 3px solid var(--dsw-alias-state-error-primary, #b04734); }
|
|
1235
|
+
.dsh-balance-error strong { color: var(--dsw-alias-state-error-primary, #b04734); }
|
|
1236
|
+
.dsh-balance-error p { margin: 10px 0 0; }
|
|
1237
|
+
.dsh-balance-availability { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ledger-muted); }
|
|
1238
|
+
.dsh-balance-dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--dsw-alias-state-error-primary, #b04734); }
|
|
1239
|
+
.dsh-balance-availability[data-available='true'] .dsh-balance-dot { background: var(--dsw-alias-state-success-primary, #568434); }
|
|
1240
|
+
.dsh-balance-availability[data-available='null'] .dsh-balance-dot { background: var(--ledger-muted); }
|
|
1241
|
+
.dsh-balance-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 12px; }
|
|
1242
|
+
.dsh-balance-card { position: relative; min-width: 0; overflow: hidden; border: 1px solid var(--ledger-line); border-radius: 4px; padding: 26px; background: var(--ledger-paper); }
|
|
1243
|
+
.dsh-balance-card:first-child { background: #25352e; border-color: #25352e; color: #f2f5eb; }
|
|
1244
|
+
.dsh-balance-card::before { content: ''; position: absolute; top: 0; right: 22px; height: 9px; width: 30px; border-left: 1px solid currentColor; border-right: 1px solid currentColor; opacity: .4; }
|
|
1245
|
+
.dsh-balance-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12px; }
|
|
1246
|
+
.dsh-balance-currency { font-family: ui-monospace, monospace; font-size: 11px; letter-spacing: .1em; padding: 4px 7px; border: 1px solid currentColor; border-radius: 3px; }
|
|
1247
|
+
.dsh-balance-total { margin: 24px 0 32px; font-size: clamp(32px, 6cqi, 64px); font-weight: 450; letter-spacing: -.045em; line-height: 1.1; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
|
|
1248
|
+
.dsh-balance-card:first-child .dsh-balance-total { color: #d7ed9d; }
|
|
1249
|
+
.dsh-balance-breakdown { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 0; padding-top: 18px; border-top: 1px solid color-mix(in srgb, currentColor 20%, transparent); }
|
|
1250
|
+
.dsh-balance-breakdown dt { font-size: 11px; opacity: .75; line-height: 1.5; }
|
|
1251
|
+
.dsh-balance-breakdown dd { margin: 8px 0 0; font-size: 17px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
|
|
1252
|
+
.dsh-balance-meta { margin: 0; color: var(--dsw-alias-label-secondary, #60665f); font-size: 11px; line-height: 1.6; }
|
|
1253
|
+
.dsh-balance-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; color: var(--ledger-muted); font-size: 11px; }
|
|
1254
|
+
.dsh-balance-skeleton { min-height: 245px; display: flex; flex-direction: column; align-items: flex-start; gap: 28px; padding: 26px; border: 1px solid var(--ledger-line); background: var(--ledger-paper); font-size: 12px; color: var(--ledger-muted); }
|
|
1255
|
+
.dsh-balance-skeleton i { width: 60%; height: 42px; background: var(--ledger-line); animation: dsh-ledger-pulse 1.4s ease-in-out infinite alternate; }
|
|
1256
|
+
.dsh-balance-skeleton i:last-child { width: 35%; height: 16px; }
|
|
1257
|
+
@keyframes dsh-ledger-reveal { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
|
|
1258
|
+
@keyframes dsh-ledger-pulse { to { opacity: .4; } }
|
|
1259
|
+
@container (max-width: 540px) {
|
|
1260
|
+
.dsh-ledger-intro { grid-template-columns: 1fr; padding-top: 24px; }
|
|
1261
|
+
.dsh-ledger-orbit { display: none; }
|
|
1262
|
+
.dsh-provider-switch button { padding: 12px; gap: 10px; }
|
|
1263
|
+
.dsh-balance-grid, .dsh-deepseek-panel .dsh-model-grid, .dsh-deepseek-panel .dsh-billing-card-grid, .dsh-deepseek-panel .dsh-billing-table-grid { grid-template-columns: 1fr; }
|
|
1264
|
+
.dsh-balance-card { padding: 20px; }
|
|
1265
|
+
.dsh-deepseek-panel .dsh-balance-summary { flex-wrap: wrap; }
|
|
1090
1266
|
}
|
|
1091
|
-
|
|
1092
|
-
.dsh-
|
|
1093
|
-
.dsh-balance-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--dsw-alias-state-error-primary); }
|
|
1094
|
-
.dsh-balance-availability[data-available='true'] .dsh-balance-dot { background: var(--dsw-alias-state-success-primary); }
|
|
1095
|
-
.dsh-balance-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
|
|
1096
|
-
.dsh-balance-card {
|
|
1097
|
-
border: 1px solid var(--dsw-alias-border-l2);
|
|
1098
|
-
border-radius: 12px;
|
|
1099
|
-
padding: 16px;
|
|
1100
|
-
background: var(--dsw-alias-bg-layer-3);
|
|
1267
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1268
|
+
.dsh-deepseek-panel *, .dsh-deepseek-panel *::before, .dsh-deepseek-panel *::after { animation: none !important; transition: none !important; }
|
|
1101
1269
|
}
|
|
1102
|
-
.dsh-
|
|
1103
|
-
.dsh-balance-currency { color: var(--dsw-alias-label-tertiary); font-size: 12px; font-weight: 600; letter-spacing: .04em; }
|
|
1104
|
-
.dsh-balance-total { margin: 12px 0 16px; font-size: 28px; font-weight: 650; line-height: 1.15; }
|
|
1105
|
-
.dsh-balance-breakdown { display: grid; grid-template-columns: 1fr auto; gap: 7px 12px; margin: 0; font-size: 12px; }
|
|
1106
|
-
.dsh-balance-breakdown dt { color: var(--dsw-alias-label-tertiary); }
|
|
1107
|
-
.dsh-balance-breakdown dd { margin: 0; color: var(--dsw-alias-label-secondary); font-variant-numeric: tabular-nums; }
|
|
1108
|
-
.dsh-balance-meta { margin: 0; color: var(--dsw-alias-label-tertiary); font-size: 12px; }
|
|
1270
|
+
.dsh-deepseek-panel .dsh-model-card, .dsh-deepseek-panel .dsh-billing-card, .dsh-deepseek-panel .dsh-billing-list-section { border-radius: 4px; }
|
|
1109
1271
|
.dsh-billing-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
|
|
1110
1272
|
.dsh-billing-actions select {
|
|
1111
1273
|
min-height: 32px;
|
|
@@ -1253,8 +1415,11 @@ window.__ModuleLoader__.load({
|
|
|
1253
1415
|
//#endregion
|
|
1254
1416
|
//#region src/client/index.tsx
|
|
1255
1417
|
const inject = ["slots", "locale"];
|
|
1256
|
-
async function loadBalance(forceRefresh, signal) {
|
|
1257
|
-
const
|
|
1418
|
+
async function loadBalance(forceRefresh, signal, provider = "deepseek") {
|
|
1419
|
+
const params = new URLSearchParams({ provider });
|
|
1420
|
+
if (forceRefresh) params.set("refresh", "1");
|
|
1421
|
+
const url = `${BALANCE_ROUTE}?${params}`;
|
|
1422
|
+
const value = await (await fetch(url, {
|
|
1258
1423
|
method: "GET",
|
|
1259
1424
|
headers: { accept: "application/json" },
|
|
1260
1425
|
cache: "no-store",
|
|
@@ -1263,8 +1428,11 @@ window.__ModuleLoader__.load({
|
|
|
1263
1428
|
if (typeof value !== "object" || value === null || !("ok" in value) || typeof value.ok !== "boolean") throw new Error("余额插件收到了无法识别的 Host 响应");
|
|
1264
1429
|
return value;
|
|
1265
1430
|
}
|
|
1266
|
-
async function loadModels(forceRefresh, signal) {
|
|
1267
|
-
const
|
|
1431
|
+
async function loadModels(forceRefresh, signal, provider = "deepseek") {
|
|
1432
|
+
const params = new URLSearchParams({ provider });
|
|
1433
|
+
if (forceRefresh) params.set("refresh", "1");
|
|
1434
|
+
const url = `${MODELS_ROUTE}?${params}`;
|
|
1435
|
+
const value = await (await fetch(url, {
|
|
1268
1436
|
method: "GET",
|
|
1269
1437
|
headers: { accept: "application/json" },
|
|
1270
1438
|
cache: "no-store",
|