@virzz/dsh-plugin-deepseek-balance 1.0.1 → 1.1.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 CHANGED
@@ -5,7 +5,7 @@ official account balance as a row in the sidebar footer, above **Settings**.
5
5
 
6
6
  ```
7
7
  ◆ Cordis Plugin 0 running
8
- ▤ DeepSeek 余额 $1058.69 · ¥-0.01
8
+ ▤ DeepSeek 余额 $1058.69
9
9
  ⚙ 设置
10
10
  ```
11
11
 
@@ -34,6 +34,10 @@ Design notes:
34
34
  the browser. The read route returns only balance figures.
35
35
  - **Two cadences.** The child collects every 60s; the row re-reads the host's cached
36
36
  snapshot every 15s, so no polling happens from the browser.
37
+ - **Positive balances only.** A currency whose total is zero or negative says nothing useful
38
+ in a balance read-out, so it is left out of both the row and its tooltip. The tooltip
39
+ reports how many entries were hidden, and the row reads `0` when nothing is positive. The
40
+ host still returns every currency it receives — the rule is presentation, not data.
37
41
 
38
42
  ## Install into DSH
39
43
 
@@ -107,7 +111,7 @@ The row appears in the sidebar footer, directly above **Settings**:
107
111
 
108
112
  ```
109
113
  ◆ Cordis Plugin 0 running
110
- ▤ DeepSeek 余额 $1058.69 · ¥-0.01
114
+ ▤ DeepSeek 余额 $1058.69
111
115
  ⚙ 设置
112
116
  ```
113
117
 
package/lib/client.js CHANGED
@@ -45,13 +45,18 @@ window.__ModuleLoader__.load({
45
45
  return symbolOf(entry.currency) + entry.total;
46
46
  }
47
47
 
48
- /** The entry whose figure stands for the account: the first non-zero one, else the first. */
49
- function primaryOf(balances) {
48
+ /**
49
+ * The balances worth showing. A currency whose total is zero or negative carries no
50
+ * information for a balance read-out, so it is left out of both the row and its
51
+ * tooltip — and only counted, so the tooltip can say that something was hidden.
52
+ */
53
+ function positiveOf(balances) {
54
+ const shown = [];
50
55
  for (let index = 0; index < balances.length; index += 1) {
51
56
  const value = Number(balances[index].total);
52
- if (Number.isFinite(value) && value !== 0) return balances[index];
57
+ if (Number.isFinite(value) && value > 0) shown.push(balances[index]);
53
58
  }
54
- return balances.length > 0 ? balances[0] : undefined;
59
+ return shown;
55
60
  }
56
61
 
57
62
  function timeText(ms) {
@@ -131,6 +136,8 @@ window.__ModuleLoader__.load({
131
136
  }, []);
132
137
 
133
138
  const balances = state.balances;
139
+ const shown = positiveOf(balances);
140
+ const hidden = balances.length - shown.length;
134
141
  let tone = "loading";
135
142
  let label = "DeepSeek 余额";
136
143
  let value = "…";
@@ -138,12 +145,14 @@ window.__ModuleLoader__.load({
138
145
 
139
146
  if (state.phase === "ok") {
140
147
  tone = state.available ? "ok" : "error";
141
- value = balances.slice(0, 2).map(amountOf).join(" · ");
148
+ value = shown.length > 0 ? shown.slice(0, 2).map(amountOf).join(" · ") : "0";
142
149
  const lines = ["DeepSeek 余额(常驻 node 采集)"];
143
- for (let index = 0; index < balances.length; index += 1) {
144
- const entry = balances[index];
150
+ for (let index = 0; index < shown.length; index += 1) {
151
+ const entry = shown[index];
145
152
  lines.push(entry.currency + " " + entry.total + "(赠金 " + entry.granted + " · 充值 " + entry.toppedUp + ")");
146
153
  }
154
+ if (shown.length === 0) lines.push("所有币种余额均不大于 0")
155
+ else if (hidden > 0) lines.push("已隐藏 " + hidden + " 项非正余额")
147
156
  if (state.available !== true) lines.push("该账户当前不可调用");
148
157
  const updated = timeText(state.fetchedAt);
149
158
  if (updated !== "") lines.push("采集于 " + updated);
@@ -156,8 +165,10 @@ window.__ModuleLoader__.load({
156
165
  }
157
166
 
158
167
  if (wide !== true) {
159
- const primary = primaryOf(balances);
160
- const glyph = state.phase === "ok" ? symbolOf(primary === undefined ? "" : primary.currency) : state.phase === "error" ? "!" : "…";
168
+ const primary = shown.length > 0 ? shown[0] : undefined;
169
+ const glyph = state.phase === "ok"
170
+ ? (primary === undefined ? "0" : symbolOf(primary.currency))
171
+ : state.phase === "error" ? "!" : "…";
161
172
  return React.createElement("button", {
162
173
  type: "button",
163
174
  className: "dsb-row dsb-rail",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@virzz/dsh-plugin-deepseek-balance",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "DeepSeek official account balance as a DSH sidebar status row, collected by one resident node process",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",