@dougen/dsh-deepseek-usage 0.3.0 → 0.3.1
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 +2 -2
- package/lib/client.js +26 -38
- package/package.json +1 -1
- package/screenshot.png +0 -0
package/README.md
CHANGED
|
@@ -11,9 +11,9 @@ DeepSeek 用量侧边栏插件(DeepSeek Harness Web UI)
|
|
|
11
11
|
## 功能
|
|
12
12
|
|
|
13
13
|
- **余额**:`¥ 110.00` 大字显示(符号随账号币种自动切换:人民币 `¥` / 美元 `$`)
|
|
14
|
-
-
|
|
14
|
+
- **档单价**:`→|1.5 ⚡0.05 |→4.5`(输入 / 输入缓存 / 输出,位于卡片右下角;随当前启用模型与峰谷时段自动切换)
|
|
15
15
|
- **峰谷指示灯**:卡片右上角,高峰(9:00–12:00、14:00–18:00 北京时间)橙色,空闲绿色
|
|
16
|
-
- **自动刷新**:每 5
|
|
16
|
+
- **自动刷新**:每 5 分钟一次;点击卡片任意位置立即刷新
|
|
17
17
|
- 跟随应用明暗主题
|
|
18
18
|
|
|
19
19
|
## 安装
|
package/lib/client.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
//
|
|
3
3
|
// 侧边栏底部用量卡片(注册进 `sidebar.footer.action` 槽位,独占一行,位于
|
|
4
4
|
// Cordis 面板按钮下方)。轮询宿主路由 `/api/deepseek-usage`(见 lib/index.js)
|
|
5
|
-
// 每 5
|
|
6
|
-
//
|
|
5
|
+
// 每 5 分钟一次,点击卡片任意位置可立即刷新。
|
|
6
|
+
// 卡片显示:余额(放大显示,符号随币种 ¥/$)+ 当前模型档单价(输入/输入缓存/
|
|
7
|
+
// 输出,图标 + 数字,位于卡片右下角)+ 峰谷指示灯(右上角)。
|
|
7
8
|
// 样式仅使用 `--dsw-*` 主题变量(含兜底值),跟随明暗主题。
|
|
8
9
|
window.__ModuleLoader__.load({
|
|
9
10
|
id: "@dougen/dsh-deepseek-usage",
|
|
@@ -44,8 +45,8 @@ window.__ModuleLoader__.load({
|
|
|
44
45
|
};
|
|
45
46
|
|
|
46
47
|
const svgBase = {
|
|
47
|
-
width:
|
|
48
|
-
height:
|
|
48
|
+
width: 12,
|
|
49
|
+
height: 12,
|
|
49
50
|
viewBox: "0 0 24 24",
|
|
50
51
|
fill: "none",
|
|
51
52
|
stroke: "currentColor",
|
|
@@ -54,27 +55,28 @@ window.__ModuleLoader__.load({
|
|
|
54
55
|
strokeLinejoin: "round",
|
|
55
56
|
style: { flex: "none", display: "block" },
|
|
56
57
|
};
|
|
58
|
+
// 输入:右箭头指向右边界(→|,数据进入边界)
|
|
57
59
|
const IconIn = () => h("svg", svgBase,
|
|
58
|
-
h("path", { d: "
|
|
59
|
-
h("path", { d: "
|
|
60
|
+
h("path", { d: "M20 4v16" }),
|
|
61
|
+
h("path", { d: "M20 12H6" }),
|
|
62
|
+
h("path", { d: "M10 7l5 5-5 5" }));
|
|
63
|
+
// 输出:左边界发出右箭头(|→,数据从边界流出)
|
|
60
64
|
const IconOut = () => h("svg", svgBase,
|
|
61
|
-
h("path", { d: "
|
|
62
|
-
h("path", { d: "
|
|
65
|
+
h("path", { d: "M4 4v16" }),
|
|
66
|
+
h("path", { d: "M4 12h14" }),
|
|
67
|
+
h("path", { d: "M14 7l5 5-5 5" }));
|
|
68
|
+
// 缓存:闪电(缓存命中,快)
|
|
63
69
|
const IconCache = () => h("svg", svgBase,
|
|
64
|
-
h("
|
|
65
|
-
h("path", { d: "M4 5v14c0 1.7 3.6 3 8 3s8-1.3 8-3V5" }),
|
|
66
|
-
h("path", { d: "M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3" }));
|
|
70
|
+
h("path", { d: "M13 2 3 14h7l-1 8 10-12h-7l1-8z" }));
|
|
67
71
|
|
|
68
72
|
// ---- the widget -------------------------------------------------
|
|
69
73
|
function UsageCell(props) {
|
|
70
74
|
const wide = !!props.wide;
|
|
71
75
|
const [data, setData] = useState(null);
|
|
72
76
|
const [error, setError] = useState("");
|
|
73
|
-
const [spinning, setSpinning] = useState(false);
|
|
74
77
|
const mounted = useRef(true);
|
|
75
78
|
|
|
76
79
|
const load = useCallback(async () => {
|
|
77
|
-
setSpinning(true);
|
|
78
80
|
try {
|
|
79
81
|
const res = await fetch(USAGE_PATH, { cache: "no-store" });
|
|
80
82
|
let body = null;
|
|
@@ -90,8 +92,6 @@ window.__ModuleLoader__.load({
|
|
|
90
92
|
} catch (e) {
|
|
91
93
|
if (!mounted.current) return;
|
|
92
94
|
setError(e instanceof Error ? e.message : String(e));
|
|
93
|
-
} finally {
|
|
94
|
-
if (mounted.current) setSpinning(false);
|
|
95
95
|
}
|
|
96
96
|
}, []);
|
|
97
97
|
|
|
@@ -146,10 +146,9 @@ window.__ModuleLoader__.load({
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
const Price = (icon, label, value) =>
|
|
149
|
-
h("span", { style: { display: "inline-flex", alignItems: "center", gap: 3, minWidth: 0, color: C.sub } },
|
|
149
|
+
h("span", { style: { display: "inline-flex", alignItems: "center", gap: 3, minWidth: 0, color: C.sub, whiteSpace: "nowrap" } },
|
|
150
150
|
h("span", { style: { display: "inline-flex", alignItems: "center" }, title: label }, icon),
|
|
151
|
-
h("span", { style: { fontWeight: 600
|
|
152
|
-
const Sep = () => h("span", { style: { color: C.sub, margin: "0 3px", fontSize: 10 } }, "·");
|
|
151
|
+
h("span", { style: { fontWeight: 600 } }, fmtPrice(value)));
|
|
153
152
|
|
|
154
153
|
return h("div", {
|
|
155
154
|
style: {
|
|
@@ -174,30 +173,21 @@ window.__ModuleLoader__.load({
|
|
|
174
173
|
title,
|
|
175
174
|
onClick: load,
|
|
176
175
|
},
|
|
177
|
-
// 第一行:余额(24px,符号与数字 3px
|
|
176
|
+
// 第一行:余额(24px,符号与数字 3px 间距)
|
|
178
177
|
h("div", { style: { display: "flex", alignItems: "baseline", minWidth: 0, paddingRight: 14, gap: 6 } },
|
|
179
178
|
h("span", { style: { fontWeight: 700, fontSize: 24, color: C.label, lineHeight: "28px", marginRight: 3 } }, symbol),
|
|
180
|
-
h("span", { style: { fontWeight: 700, fontSize: 24, color: C.label, lineHeight: "28px" } }, money(balance && balance.total)),
|
|
181
|
-
h("span", { style: { display: "inline-flex", alignItems: "center", gap: 3, marginLeft: 10 } },
|
|
182
|
-
Price(h(IconIn, null), "输入", tier && tier.input),
|
|
183
|
-
Sep(),
|
|
184
|
-
Price(h(IconCache, null), "输入缓存", tier && tier.cacheRead),
|
|
185
|
-
Sep(),
|
|
186
|
-
Price(h(IconOut, null), "输出", tier && tier.output))),
|
|
179
|
+
h("span", { style: { fontWeight: 700, fontSize: 24, color: C.label, lineHeight: "28px" } }, money(balance && balance.total))),
|
|
187
180
|
h("span", {
|
|
188
181
|
style: { position: "absolute", top: 8, right: 9, ...dot },
|
|
189
182
|
title: data && data.peak ? "高峰时段 " + (data.peakHours || "") : "空闲时段",
|
|
190
183
|
}),
|
|
191
|
-
//
|
|
184
|
+
// 当前档单价:卡片右下角
|
|
192
185
|
h("span", {
|
|
193
|
-
|
|
194
|
-
style: { position: "absolute", bottom: 8, right: 9, display: "inline-flex", alignItems: "center", color: C.sub },
|
|
195
|
-
title: "刷新中",
|
|
186
|
+
style: { position: "absolute", right: 9, bottom: 4, display: "inline-flex", alignItems: "center", gap: 5 },
|
|
196
187
|
},
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
: null),
|
|
188
|
+
Price(h(IconIn, null), "输入", tier && tier.input),
|
|
189
|
+
Price(h(IconCache, null), "输入缓存", tier && tier.cacheRead),
|
|
190
|
+
Price(h(IconOut, null), "输出", tier && tier.output)),
|
|
201
191
|
errs.length
|
|
202
192
|
? h("div", { style: { color: C.err, fontSize: 10, whiteSpace: "pre-wrap" } }, errs.join(" | "))
|
|
203
193
|
: null);
|
|
@@ -207,15 +197,13 @@ window.__ModuleLoader__.load({
|
|
|
207
197
|
const inject = ["slots"];
|
|
208
198
|
|
|
209
199
|
function apply(ctx) {
|
|
210
|
-
// 注入本包样式:footerActions
|
|
200
|
+
// 注入本包样式:footerActions 换行(卡片独占一行)。
|
|
211
201
|
const tagId = "dsh-deepseek-usage";
|
|
212
202
|
if (typeof document !== "undefined" && document.querySelector(`style[data-plugin-css="${tagId}"]`) === null) {
|
|
213
203
|
const style = document.createElement("style");
|
|
214
204
|
style.dataset.plugin = "dsh-deepseek-usage";
|
|
215
205
|
style.dataset.pluginCss = tagId;
|
|
216
|
-
style.textContent =
|
|
217
|
-
'div[class*="footerActions"]{flex-wrap:wrap}' +
|
|
218
|
-
"@keyframes dsh-usage-spin{to{transform:rotate(360deg)}}";
|
|
206
|
+
style.textContent = 'div[class*="footerActions"]{flex-wrap:wrap}';
|
|
219
207
|
document.head.appendChild(style);
|
|
220
208
|
}
|
|
221
209
|
ctx.slots.inject("sidebar.footer.action", () => ctx.slots.register(
|
package/package.json
CHANGED
package/screenshot.png
CHANGED
|
Binary file
|