dsh-billing-badge 0.1.2 → 0.1.3

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/CHANGELOG.md CHANGED
@@ -5,6 +5,15 @@ All notable changes to this project are documented in this file.
5
5
  The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this
6
6
  project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.1.3] - 2026-09-18
9
+
10
+ ### Changed
11
+
12
+ - The panel names the granted and topped-up parts only when the account is actually
13
+ split. With no grant the topped-up amount is the whole balance, so both rows repeated
14
+ the account balance line above them. Such an account now shows one row, and **Granted**
15
+ appears as soon as the endpoint reports one.
16
+
8
17
  ## [0.1.2] - 2026-09-18
9
18
 
10
19
  ### Fixed
package/README.md CHANGED
@@ -20,7 +20,7 @@ opens a small panel with the full picture.
20
20
  | Where | What |
21
21
  |---|---|
22
22
  | The pill | a coloured dot (amber for peak, green for off-peak), the season, and the time until it flips |
23
- | The panel (click) | billing season, next switch with the Beijing wall clock, current Beijing time, account balance with its currency, granted and topped-up split, and a refresh button |
23
+ | The panel (click) | billing season, next switch with the Beijing wall clock, current Beijing time, account balance with its currency, the granted and topped-up split when the account has one, and a refresh button |
24
24
 
25
25
  The season rule is the published one: peak is Beijing time, Monday to Friday,
26
26
  09:00-12:00 and 14:00-18:00. Everything else, including all of Saturday and Sunday,
@@ -41,10 +41,14 @@ total_balance = granted_balance + topped_up_balance
41
41
  row on its own.
42
42
  - `topped_up_balance`, shown as **Topped up**, is money you paid in.
43
43
 
44
- When the two upper rows are equal there is no grant on the account. `is_available`
45
- is a top-level field of the response and answers one question: is the balance enough
46
- for API calls. The panel adds a warning row when the answer is no, and stays quiet
47
- otherwise, because the flag is true for every funded account.
44
+ The panel names the two parts only when the account is actually split. With no grant the
45
+ topped-up amount is the whole balance, so the split would repeat the account balance row
46
+ above it, and that account shows one row instead. **Granted** appears as soon as the
47
+ endpoint reports one.
48
+
49
+ `is_available` is a top-level field of the response and answers one question: is the
50
+ balance enough for API calls. The panel adds a warning row when the answer is no, and
51
+ stays quiet otherwise, because the flag is true for every funded account.
48
52
 
49
53
  The currency is taken from the response, never assumed: an account reporting USD is
50
54
  not labelled with a CNY sign.
package/README.zh.md CHANGED
@@ -18,7 +18,7 @@ DeepSeek Harness 网页界面的计费时段与账户余额插件。它在输入
18
18
  | 位置 | 内容 |
19
19
  |---|---|
20
20
  | 胶囊 | 一个圆点(高峰为琥珀色,非高峰为绿色)、当前时段,以及距离切换的倒计时 |
21
- | 面板(点击展开) | 计费时段、下次切换时间与北京时间、当前北京时间、账户余额及其货币、赠送与充值的拆分,以及刷新按钮 |
21
+ | 面板(点击展开) | 计费时段、下次切换时间与北京时间、当前北京时间、账户余额及其货币、账户确实拆分为两部分时的赠送与充值明细,以及刷新按钮 |
22
22
 
23
23
  计费时段采用官方公布的规则:高峰为北京时间周一至周五 09:00-12:00 与 14:00-18:00,其余时间(含整个周六与周日)均为非高峰,价格为半价。
24
24
 
@@ -34,7 +34,9 @@ total_balance = granted_balance + topped_up_balance
34
34
  - `granted_balance`,界面显示为 **Granted**,是官方赠送的额度。接口只返回尚未过期的部分,过期的赠送额度会自动从这一行消失。
35
35
  - `topped_up_balance`,界面显示为 **Topped up**,是你自己充值的金额。
36
36
 
37
- 前两行数值相等时,说明账户没有赠送额度。`is_available` 是响应顶层的字段,只回答一个问题:余额是否足够调用接口。只有接口报告余额不足时,面板才会加一行警告,其余时候保持安静,因为任何有余额的账户这个字段都是 true。
37
+ 只有在账户确实拆分为两部分时,面板才会列出赠送与充值。没有赠送额度时,充值额就等于全部余额,拆分只会重复上面那行账户余额,因此这种账户只显示一行;接口一旦报告赠送额度,**Granted** 就会出现。
38
+
39
+ `is_available` 是响应顶层的字段,只回答一个问题:余额是否足够调用接口。只有接口报告余额不足时,面板才会加一行警告,其余时候保持安静,因为任何有余额的账户这个字段都是 true。
38
40
 
39
41
  货币一律取自接口返回值,不做假设:返回 USD 的账户不会被标上人民币符号。
40
42
 
package/lib/client.js CHANGED
@@ -265,8 +265,17 @@ window.__ModuleLoader__.load({
265
265
  ];
266
266
  if (balance && balance.ok) {
267
267
  rows.push(["Account balance", formatMoney(balance.total, balance.currency) + (balance.currency ? ` ${balance.currency}` : "")]);
268
- rows.push(["Granted", formatMoney(balance.granted, balance.currency)]);
269
- rows.push(["Topped up", formatMoney(balance.toppedUp, balance.currency)]);
268
+ // The split earns rows only when the account actually has one. With no
269
+ // grant the topped-up amount IS the total, so both rows would repeat the
270
+ // line above; with no top-up the grant alone is still worth naming.
271
+ const granted = typeof balance.granted === "number" ? balance.granted : 0;
272
+ const toppedUp = typeof balance.toppedUp === "number" ? balance.toppedUp : 0;
273
+ if (granted > 0) {
274
+ rows.push(["Granted", formatMoney(balance.granted, balance.currency)]);
275
+ if (toppedUp > 0) {
276
+ rows.push(["Topped up", formatMoney(balance.toppedUp, balance.currency)]);
277
+ }
278
+ }
270
279
  // `is_available` is true for every funded account, so it earns a row
271
280
  // only when the API says the balance is not enough for calls. A
272
281
  // permanent "allowed" row would be furniture.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-billing-badge",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Billing season and account balance chip for the DeepSeek Harness web GUI composer: a native-looking pill after the cache-hit stat, with a panel on click. DeepSeek Harness 计费时段与余额插件",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",