@hystudio/dsh-quota-pill 0.2.5 → 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/client.js +29 -5
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -513,6 +513,30 @@ window.__ModuleLoader__.load({
|
|
|
513
513
|
credits: null,
|
|
514
514
|
}];
|
|
515
515
|
}
|
|
516
|
+
// Prepaid wallets (official DeepSeek): a balance, plus optional bonus
|
|
517
|
+
// credit. Both are money, not percentages, so each needs its own row —
|
|
518
|
+
// collapsing them into one label silently loses the bonus.
|
|
519
|
+
if (v.kind === 'payg' && v.credits && typeof v.credits.remain === 'number') {
|
|
520
|
+
const rows = [{
|
|
521
|
+
key: 'balance',
|
|
522
|
+
label: pick(lang, 'balanceLeft'),
|
|
523
|
+
pct: null,
|
|
524
|
+
reset: '',
|
|
525
|
+
credits: { remain: v.credits.remain, unit: v.credits.unit },
|
|
526
|
+
money: true,
|
|
527
|
+
}];
|
|
528
|
+
if (v.bonus && typeof v.bonus.amount === 'number') {
|
|
529
|
+
rows.push({
|
|
530
|
+
key: 'bonus',
|
|
531
|
+
label: pick(lang, 'bonusBalance'),
|
|
532
|
+
pct: null,
|
|
533
|
+
reset: '',
|
|
534
|
+
credits: { remain: v.bonus.amount, unit: v.bonus.unit },
|
|
535
|
+
money: true,
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
return rows;
|
|
539
|
+
}
|
|
516
540
|
if (v.kind !== 'subscription-quota' || v.remainingPct === null || v.remainingPct === undefined) {
|
|
517
541
|
return [{ key: 'kind', label: describeQuota(v, lang).text, pct: null, reset: '', credits: null }];
|
|
518
542
|
}
|
|
@@ -1250,7 +1274,7 @@ window.__ModuleLoader__.load({
|
|
|
1250
1274
|
}
|
|
1251
1275
|
|
|
1252
1276
|
function WindowRow(props) {
|
|
1253
|
-
const { label, pct, reset, credits, lang, stale } = props;
|
|
1277
|
+
const { label, pct, reset, credits, lang, stale, money: isMoney } = props;
|
|
1254
1278
|
const isNum = typeof pct === 'number' && Number.isFinite(pct);
|
|
1255
1279
|
const tweened = useTween(isNum ? pct : null, 450);
|
|
1256
1280
|
// 首帧 tween 还没拿到起点时 shown 是 null;这时按目标值渲染静态读数,
|
|
@@ -1281,7 +1305,7 @@ window.__ModuleLoader__.load({
|
|
|
1281
1305
|
? `${fmtAmount(credits.remain)} / ${fmtAmount(credits.total)}`
|
|
1282
1306
|
+ (credits.unit ? ' ' + String(credits.unit) : '')
|
|
1283
1307
|
: undefined,
|
|
1284
|
-
}, fmtCompact(credits.remain))
|
|
1308
|
+
}, isMoney ? money(credits.remain, credits.unit) : fmtCompact(credits.remain))
|
|
1285
1309
|
: isNum
|
|
1286
1310
|
? h('span', {
|
|
1287
1311
|
className: 'quota-pill-win-pct',
|
|
@@ -1293,7 +1317,7 @@ window.__ModuleLoader__.load({
|
|
|
1293
1317
|
style: { color: remainingColor(shown) },
|
|
1294
1318
|
}, typeof shown === 'number' ? `${shown.toFixed(shown < 10 ? 1 : 0)}%` : '')
|
|
1295
1319
|
: null,
|
|
1296
|
-
showCredits && unitLabel(credits.unit, lang)
|
|
1320
|
+
showCredits && !isMoney && unitLabel(credits.unit, lang)
|
|
1297
1321
|
? h('span', { className: 'quota-pill-win-unit' }, unitLabel(credits.unit, lang))
|
|
1298
1322
|
: null,
|
|
1299
1323
|
|
|
@@ -1313,7 +1337,7 @@ window.__ModuleLoader__.load({
|
|
|
1313
1337
|
h('div', { className: 'quota-pill-group-head' }, name),
|
|
1314
1338
|
// 组内行 key 带组名,避免不同 provider 的同名窗口(都是 5h/weekly)
|
|
1315
1339
|
// 被 React 当成同一个组件实例,导致 tween 跨 provider 插值。
|
|
1316
|
-
entries.map((e) => h(WindowRow, { key: `${name}|${e.key}`, label: e.label, pct: e.pct, reset: e.reset, credits: e.credits, lang, stale })),
|
|
1340
|
+
entries.map((e) => h(WindowRow, { key: `${name}|${e.key}`, label: e.label, pct: e.pct, reset: e.reset, credits: e.credits, lang, stale, money: e.money })),
|
|
1317
1341
|
);
|
|
1318
1342
|
}
|
|
1319
1343
|
|
|
@@ -1388,7 +1412,7 @@ window.__ModuleLoader__.load({
|
|
|
1388
1412
|
// key 带 provider:换 provider 时强制重挂载,让 tween 从「空」开始,
|
|
1389
1413
|
// 而不是把 A 的 5h 平滑滑到 B 的 5h——那是两个不同账户的额度,
|
|
1390
1414
|
// 中间的数字不代表任何真实状态。
|
|
1391
|
-
entries.map((e) => h(WindowRow, { key: `${providerName}|${e.key}`, label: e.label, pct: e.pct, reset: e.reset, credits: e.credits, lang, stale })),
|
|
1415
|
+
entries.map((e) => h(WindowRow, { key: `${providerName}|${e.key}`, label: e.label, pct: e.pct, reset: e.reset, credits: e.credits, lang, stale, money: e.money })),
|
|
1392
1416
|
),
|
|
1393
1417
|
h('dl', { className: 'quota-pill-stats' },
|
|
1394
1418
|
data.account ? statRow(pick(lang, 'account'), String(data.account)) : null,
|
package/package.json
CHANGED