@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 +6 -2
- package/lib/client.js +20 -9
- package/package.json +1 -1
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 余额
|
|
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 余额
|
|
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
|
-
/**
|
|
49
|
-
|
|
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
|
|
57
|
+
if (Number.isFinite(value) && value > 0) shown.push(balances[index]);
|
|
53
58
|
}
|
|
54
|
-
return
|
|
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 =
|
|
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 <
|
|
144
|
-
const entry =
|
|
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 =
|
|
160
|
-
const glyph = state.phase === "ok"
|
|
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