dsh-deepseek-balance-widget 1.2.3 → 1.2.4
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/lib/client.js +10 -2
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -14,6 +14,8 @@ window.__ModuleLoader__.load({
|
|
|
14
14
|
const UPDATE_ENDPOINT = "/deepseek-balance-update";
|
|
15
15
|
/** Auto-refresh cadence, milliseconds. */
|
|
16
16
|
const REFRESH_MS = 30000;
|
|
17
|
+
/** How long the "update succeeded, restart dsh" message stays visible, milliseconds. */
|
|
18
|
+
const UPDATE_SUCCESS_MS = 5000;
|
|
17
19
|
|
|
18
20
|
/** Inline icon (matches the shell's 16px nav-icon look). */
|
|
19
21
|
const ICON = '<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4.5 4L8 8.5 11.5 4M8 8.5v4M5.5 9.5h5M5.5 11.5h5"/></svg>';
|
|
@@ -210,8 +212,9 @@ window.__ModuleLoader__.load({
|
|
|
210
212
|
if (result.ok) {
|
|
211
213
|
btn.textContent = "成功,请重启 dsh";
|
|
212
214
|
btn.disabled = true;
|
|
213
|
-
//
|
|
214
|
-
|
|
215
|
+
// Keep the success message visible for a while before reverting to version info.
|
|
216
|
+
updateSuccessUntil = Date.now() + UPDATE_SUCCESS_MS;
|
|
217
|
+
setTimeout(() => checkVersion(), UPDATE_SUCCESS_MS);
|
|
215
218
|
} else {
|
|
216
219
|
btn.textContent = "更新失败";
|
|
217
220
|
btn.title = String(result.error || "更新失败") + (result.output ? "\n" + result.output.slice(-200) : "");
|
|
@@ -398,6 +401,9 @@ window.__ModuleLoader__.load({
|
|
|
398
401
|
|
|
399
402
|
/** Build the npm version snippet shown in the footer (always a clickable button). */
|
|
400
403
|
function versionHtmlOf(versionEnvelope) {
|
|
404
|
+
if (Date.now() < updateSuccessUntil) {
|
|
405
|
+
return '<span class="dshBalanceVersion" data-state="ok">成功,请重启 dsh</span>';
|
|
406
|
+
}
|
|
401
407
|
if (!versionEnvelope) {
|
|
402
408
|
return '<span class="dshBalanceVersion" data-state="ok"><button class="dshBalanceVersionBtn" type="button" data-update-cmd>检查更新</button></span>';
|
|
403
409
|
}
|
|
@@ -469,6 +475,7 @@ window.__ModuleLoader__.load({
|
|
|
469
475
|
let lastUpdated = null;
|
|
470
476
|
let timer = null;
|
|
471
477
|
let versionTimer = null;
|
|
478
|
+
let updateSuccessUntil = 0;
|
|
472
479
|
|
|
473
480
|
/** One refresh cycle: fetch balance + usage, update entry stats and popover. */
|
|
474
481
|
async function refresh(manual) {
|
|
@@ -562,6 +569,7 @@ window.__ModuleLoader__.load({
|
|
|
562
569
|
document.removeEventListener("mousedown", outsideHandler);
|
|
563
570
|
outsideHandler = null;
|
|
564
571
|
}
|
|
572
|
+
updateSuccessUntil = 0;
|
|
565
573
|
if (popRef !== null) popRef.remove();
|
|
566
574
|
entry.remove();
|
|
567
575
|
entryRef = null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-deepseek-balance-widget",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "DeepSeek API balance widget for the dsh web sidebar: a live, auto-refreshing balance pill (balance / today spend / today tokens) with a detail popover (cumulative spend, monthly usage, request count). Every user sees only their own balance — keys are resolved per-machine from the local credential seam, never hardcoded.",
|
|
6
6
|
"keywords": [
|