dsh-deepseek-balance-widget 2.2.1 → 2.3.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/lib/client.js +20 -3
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -110,7 +110,9 @@ window.__ModuleLoader__.load({
|
|
|
110
110
|
pasteCookieHint: "请粘贴 Cookie 或 cURL,AI 会自动提取",
|
|
111
111
|
copied: "已复制",
|
|
112
112
|
copyFailed: "复制失败",
|
|
113
|
-
refresh: "刷新"
|
|
113
|
+
refresh: "刷新",
|
|
114
|
+
peakPeriod: "繁忙时段",
|
|
115
|
+
offPeakPeriod: "空闲时段"
|
|
114
116
|
},
|
|
115
117
|
en: {
|
|
116
118
|
entryAriaLabel: "AI Balance (Balance / Today Spend / Today Tokens)",
|
|
@@ -193,7 +195,9 @@ window.__ModuleLoader__.load({
|
|
|
193
195
|
pasteCookieHint: "Paste a Cookie or cURL; the AI will extract it",
|
|
194
196
|
copied: "Copied",
|
|
195
197
|
copyFailed: "Copy failed",
|
|
196
|
-
refresh: "Refresh"
|
|
198
|
+
refresh: "Refresh",
|
|
199
|
+
peakPeriod: "Peak",
|
|
200
|
+
offPeakPeriod: "Off-peak"
|
|
197
201
|
}
|
|
198
202
|
};
|
|
199
203
|
/** Authoritative source: host route reads ~/.dsh/settings.yaml locale.preference. */
|
|
@@ -385,6 +389,9 @@ window.__ModuleLoader__.load({
|
|
|
385
389
|
".dshBalanceTabBal{font-size:12px;font-weight:600;color:#3fb950;font-variant-numeric:tabular-nums}",
|
|
386
390
|
".dshBalanceTabBal[data-state=err]{color:#f85149}",
|
|
387
391
|
".dshBalanceTabTitle{font-size:14px;font-weight:600}",
|
|
392
|
+
".dshBalancePeriodBadge{font-size:11px;padding:2px 6px;border-radius:4px;color:#9aa4b2;background:rgba(255,255,255,.08);white-space:nowrap}",
|
|
393
|
+
".dshBalancePeriodBadge[data-period=peak]{color:#f85149;background:rgba(248,81,73,.12)}",
|
|
394
|
+
".dshBalancePeriodBadge[data-period=offPeak]{color:#3fb950;background:rgba(35,197,94,.12)}",
|
|
388
395
|
".dshBalanceTabMenu{appearance:none;cursor:pointer;margin-left:4px;font-size:16px;font-weight:600;line-height:1;color:#7b8494;user-select:none;width:18px;height:18px;display:flex;align-items:center;justify-content:center;border-radius:4px}",
|
|
389
396
|
".dshBalanceTabMenu:hover{color:#f85149;background:rgba(248,81,73,.12)}",
|
|
390
397
|
".dshBalanceCtxMenu{position:absolute;z-index:10000;background:#161b22;border:1px solid rgba(255,255,255,.12);border-radius:6px;box-shadow:0 8px 24px rgba(0,0,0,.35);padding:4px 0;min-width:120px}",
|
|
@@ -1058,6 +1065,12 @@ window.__ModuleLoader__.load({
|
|
|
1058
1065
|
return html;
|
|
1059
1066
|
}
|
|
1060
1067
|
|
|
1068
|
+
/** DeepSeek peak/off-peak period based on Beijing time (UTC+8). Peak: 09-12, 14-18. */
|
|
1069
|
+
function currentDeepseekPeriod() {
|
|
1070
|
+
const hour = (new Date().getUTCHours() + 8) % 24;
|
|
1071
|
+
return ((hour >= 9 && hour < 12) || (hour >= 14 && hour < 18)) ? "peak" : "offPeak";
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1061
1074
|
/** Build one tab button for the provider switcher. */
|
|
1062
1075
|
function providerTabHtml(p, bal, isActive) {
|
|
1063
1076
|
const meta = PROVIDER_META[p.kind] || { label: p.kind };
|
|
@@ -1072,8 +1085,12 @@ window.__ModuleLoader__.load({
|
|
|
1072
1085
|
'<span class="dshBalanceTabMenu" data-tab-remove type="button" role="button" aria-label="' + t("remove") + '" title="' + t("remove") + '">×</span>';
|
|
1073
1086
|
const titleCls = isActive ? ' class="dshBalanceTabTitle"' : '';
|
|
1074
1087
|
const balanceSpan = isActive ? '' : '<span class="dshBalanceTabBal"' + stateAttr + ">" + balanceText + "</span>";
|
|
1088
|
+
const period = currentDeepseekPeriod();
|
|
1089
|
+
const periodBadge = (isActive && p.kind === "deepseek")
|
|
1090
|
+
? '<span class="dshBalancePeriodBadge" data-period="' + period + '">' + t(period + "Period") + "</span>"
|
|
1091
|
+
: "";
|
|
1075
1092
|
return '<button class="dshBalanceTab' + (isActive ? " active" : "") + '" type="button" data-tab="' + escapeHtml(p.id) + '">' +
|
|
1076
|
-
'<span' + titleCls + '>' + escapeHtml(label) + '</span>' + balanceSpan + removeBtn + "</button>";
|
|
1093
|
+
'<span' + titleCls + '>' + escapeHtml(label) + '</span>' + periodBadge + balanceSpan + removeBtn + "</button>";
|
|
1077
1094
|
}
|
|
1078
1095
|
|
|
1079
1096
|
/** Build the detail pane for the currently active provider. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-deepseek-balance-widget",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Multi-provider AI balance widget for the dsh web sidebar: a live, auto-refreshing balance pill plus a detail popover listing DeepSeek and any added providers (MiMo etc.). Keys are stored per-machine in ~/.dsh/ai-balances.json and resolved from the local credential seam, never hardcoded.",
|
|
6
6
|
"keywords": [
|