@wannanbigpig/dsh-usage-stats 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/README.md +1 -1
- package/lib/client.js +10 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -133,7 +133,7 @@ DEEPSEEK_API_KEY: sk-your-key-here
|
|
|
133
133
|
|
|
134
134
|
### 用量提醒与限额(设置 → 用量与计费)
|
|
135
135
|
|
|
136
|
-
「设置 → 用量与计费」页面承载限额配置(已从查询弹窗迁出,弹窗保持只读)。可**按 Key
|
|
136
|
+
「设置 → 用量与计费」页面承载限额配置(已从查询弹窗迁出,弹窗保持只读)。可**按 Key(或全局)**配置;**仅配置一个 API Key 时,「目标 API Key」选择器自动隐藏**,直接配置全局规则即可(单 Key 下全局规则就是生效规则):
|
|
137
137
|
|
|
138
138
|
- **启用限额**:开关。
|
|
139
139
|
- **每日消费限额**(CNY):今日估算消费达到限额 × `alertPercent`(默认 80%)→ 黄色预警;达到限额 × `criticalPercent`(默认 90%)→ 红色已超限(仅提醒与告警,不拦截);两个比例都可在设置页调整。
|
package/lib/client.js
CHANGED
|
@@ -1095,7 +1095,9 @@ window.__ModuleLoader__.load({
|
|
|
1095
1095
|
const [limits, setLimits] = react.useState(null);
|
|
1096
1096
|
const limitsRef = react.useRef(null);
|
|
1097
1097
|
const [statusMap, setStatusMap] = react.useState({});
|
|
1098
|
+
const isSingleKey = (keys || []).length <= 1;
|
|
1098
1099
|
const [activeKey, setActiveKey] = react.useState(() => {
|
|
1100
|
+
if (isSingleKey) return "__global__";
|
|
1099
1101
|
const stored = safeGetStorage("dsh_usage_limits_active_key");
|
|
1100
1102
|
if (stored !== null && stored !== "") return stored;
|
|
1101
1103
|
return selectedKey ?? "__global__";
|
|
@@ -1134,6 +1136,10 @@ window.__ModuleLoader__.load({
|
|
|
1134
1136
|
|
|
1135
1137
|
// Sync activeKey when selectedKey becomes available (if not explicitly chosen in storage)
|
|
1136
1138
|
react.useEffect(() => {
|
|
1139
|
+
if (isSingleKey) {
|
|
1140
|
+
setActiveKey("__global__");
|
|
1141
|
+
return;
|
|
1142
|
+
}
|
|
1137
1143
|
if (selectedKey !== null && selectedKey !== undefined && selectedKey !== "") {
|
|
1138
1144
|
const stored = safeGetStorage("dsh_usage_limits_active_key");
|
|
1139
1145
|
if (stored) {
|
|
@@ -1142,7 +1148,7 @@ window.__ModuleLoader__.load({
|
|
|
1142
1148
|
}
|
|
1143
1149
|
setActiveKey(selectedKey);
|
|
1144
1150
|
}
|
|
1145
|
-
}, [selectedKey]);
|
|
1151
|
+
}, [selectedKey, isSingleKey]);
|
|
1146
1152
|
|
|
1147
1153
|
// Update form fields when activeKey or limits payload change
|
|
1148
1154
|
react.useEffect(() => {
|
|
@@ -1160,6 +1166,7 @@ window.__ModuleLoader__.load({
|
|
|
1160
1166
|
}, [activeKey, limits]);
|
|
1161
1167
|
|
|
1162
1168
|
const handleKeySelect = (newKey) => {
|
|
1169
|
+
if (isSingleKey) return;
|
|
1163
1170
|
// Do not strand an unsaved batch on the previous key's form.
|
|
1164
1171
|
if (pendingRef.current !== null && !savingRef.current) flushSave();
|
|
1165
1172
|
setActiveKey(newKey);
|
|
@@ -1306,8 +1313,8 @@ window.__ModuleLoader__.load({
|
|
|
1306
1313
|
}),
|
|
1307
1314
|
react_jsx_runtime.jsx("p", { className: S.note, children: translate("limits.desc") }),
|
|
1308
1315
|
error && react_jsx_runtime.jsx("div", { className: S.error, children: error }),
|
|
1309
|
-
// Key selection
|
|
1310
|
-
react_jsx_runtime.jsxs("label", {
|
|
1316
|
+
// Key selection — hidden when only one key is configured (the global rule IS the key rule).
|
|
1317
|
+
keys.length > 1 && react_jsx_runtime.jsxs("label", {
|
|
1311
1318
|
className: S.pickerRow,
|
|
1312
1319
|
children: [
|
|
1313
1320
|
react_jsx_runtime.jsxs("span", {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wannanbigpig/dsh-usage-stats",
|
|
3
3
|
"description": "DeepSeek 官方余额、Token 用量、月历热图与离线 tokenizer,内置在 Harness 侧栏",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.3",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/wannanbigpig/dsh-usage-stats.git"
|