@iasiv5/dsh-quota-watch 0.0.14 → 0.0.16
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 +41 -13
- package/package.json +1 -1
- package/src/client.mjs +42 -13
package/lib/client.js
CHANGED
|
@@ -88,7 +88,7 @@ var CARD_SELECTOR = "[data-dsh-quota-watch-card]";
|
|
|
88
88
|
var FETCH_TIMEOUT_MS = 15e3;
|
|
89
89
|
var COPY = {
|
|
90
90
|
zh: {
|
|
91
|
-
title: "\
|
|
91
|
+
title: "Token\u989D\u5EA6",
|
|
92
92
|
openDetails: "\u67E5\u770B\u8BE6\u60C5",
|
|
93
93
|
backToOverview: "\u8FD4\u56DE\u989D\u5EA6\u6982\u89C8",
|
|
94
94
|
providerNames: { glm: "GLM", copilot: "Copilot" },
|
|
@@ -166,7 +166,7 @@ var STYLE_TEXT = `
|
|
|
166
166
|
.dqw-stale-mark { flex: none; font-size: 9px; line-height: 14px; color: var(--dsw-alias-label-warning, #b46900); cursor: help; }
|
|
167
167
|
.dqw-errtext { font-size: 10px; line-height: 14px; opacity: .7; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
168
168
|
.dqw-rail-trigger { display: none; flex: none; align-items: center; justify-content: center; width: 36px; height: 36px; margin: 0; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--dsw-alias-label-primary, inherit); cursor: pointer; transition: background-color .12s, color .12s; }
|
|
169
|
-
.dqw-rail-trigger svg { display: block; width:
|
|
169
|
+
.dqw-rail-trigger svg { display: block; width: 22px; height: 22px; }
|
|
170
170
|
.dqw-rail-trigger:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover, rgba(128,128,128,.12)); color: var(--dsw-alias-label-primary, inherit); }
|
|
171
171
|
.dqw-rail-trigger:active:not(:disabled), .dqw-rail-trigger[aria-expanded="true"] { background: var(--dsw-alias-interactive-bg-active, rgba(128,128,128,.18)); color: var(--dsw-alias-label-primary, inherit); }
|
|
172
172
|
.dqw-rail-trigger:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary, #5b8def); outline-offset: 2px; }
|
|
@@ -177,8 +177,10 @@ var STYLE_TEXT = `
|
|
|
177
177
|
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .dqw-pop { background: var(--dsw-alias-bg-elevated, var(--dsw-alias-bg-base, #1f1f1f)); } }
|
|
178
178
|
.dqw-pop[hidden] { display: none; }
|
|
179
179
|
.dqw-pop *, .dqw-pop *::before, .dqw-pop *::after { box-sizing: border-box; }
|
|
180
|
+
.dqw-pop-header { display: flex; align-items: center; gap: 6px; min-width: 0; }
|
|
180
181
|
.dqw-pop-title { margin: 0; font-size: 11px; font-weight: 600; line-height: 16px; }
|
|
181
|
-
.dqw-pop-back { align-
|
|
182
|
+
.dqw-pop-back { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 28px; height: 28px; margin: 0; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--dsw-alias-label-secondary, inherit); cursor: pointer; }
|
|
183
|
+
.dqw-pop-back svg { display: block; width: 16px; height: 16px; }
|
|
182
184
|
.dqw-pop-back:hover { background: var(--dsw-alias-interactive-bg-hover, rgba(128,128,128,.12)); color: var(--dsw-alias-label-primary, inherit); }
|
|
183
185
|
.dqw-overview-list { display: flex; flex-direction: column; gap: 2px; }
|
|
184
186
|
.dqw-overview-row { display: flex; align-items: center; width: 100%; gap: 6px; margin: 0; padding: 5px 4px; border: 0; border-radius: 8px; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
|
|
@@ -250,8 +252,8 @@ function quotaIcon(doc) {
|
|
|
250
252
|
const namespace = "http://www.w3.org/2000/svg";
|
|
251
253
|
const svg = doc.createElementNS(namespace, "svg");
|
|
252
254
|
svg.setAttribute("viewBox", "0 0 24 24");
|
|
253
|
-
svg.setAttribute("width", "
|
|
254
|
-
svg.setAttribute("height", "
|
|
255
|
+
svg.setAttribute("width", "22");
|
|
256
|
+
svg.setAttribute("height", "22");
|
|
255
257
|
svg.setAttribute("fill", "none");
|
|
256
258
|
svg.setAttribute("stroke", "currentColor");
|
|
257
259
|
svg.setAttribute("stroke-width", "1.7");
|
|
@@ -259,17 +261,39 @@ function quotaIcon(doc) {
|
|
|
259
261
|
svg.setAttribute("stroke-linejoin", "round");
|
|
260
262
|
svg.setAttribute("aria-hidden", "true");
|
|
261
263
|
svg.setAttribute("focusable", "false");
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
+
const dial = doc.createElementNS(namespace, "circle");
|
|
265
|
+
dial.setAttribute("cx", "12");
|
|
266
|
+
dial.setAttribute("cy", "12");
|
|
267
|
+
dial.setAttribute("r", "9");
|
|
268
|
+
const ticks = doc.createElementNS(namespace, "path");
|
|
269
|
+
ticks.setAttribute("d", "M12 2.7v2.1M12 19.2v2.1M2.7 12h2.1M19.2 12h2.1M5.43 5.43l1.49 1.49M17.08 17.08l1.49 1.49M18.57 5.43l-1.49 1.49M6.92 17.08l-1.49 1.49");
|
|
264
270
|
const needle = doc.createElementNS(namespace, "path");
|
|
265
|
-
needle.setAttribute("d", "
|
|
271
|
+
needle.setAttribute("d", "M12 12l4.5-4");
|
|
266
272
|
const hub = doc.createElementNS(namespace, "circle");
|
|
267
273
|
hub.setAttribute("cx", "12");
|
|
268
|
-
hub.setAttribute("cy", "
|
|
269
|
-
hub.setAttribute("r", "1");
|
|
274
|
+
hub.setAttribute("cy", "12");
|
|
275
|
+
hub.setAttribute("r", "1.2");
|
|
270
276
|
hub.setAttribute("fill", "currentColor");
|
|
271
277
|
hub.setAttribute("stroke", "none");
|
|
272
|
-
svg.append(
|
|
278
|
+
svg.append(dial, ticks, needle, hub);
|
|
279
|
+
return svg;
|
|
280
|
+
}
|
|
281
|
+
function backIcon(doc) {
|
|
282
|
+
const namespace = "http://www.w3.org/2000/svg";
|
|
283
|
+
const svg = doc.createElementNS(namespace, "svg");
|
|
284
|
+
svg.setAttribute("viewBox", "0 0 16 16");
|
|
285
|
+
svg.setAttribute("width", "16");
|
|
286
|
+
svg.setAttribute("height", "16");
|
|
287
|
+
svg.setAttribute("fill", "none");
|
|
288
|
+
svg.setAttribute("stroke", "currentColor");
|
|
289
|
+
svg.setAttribute("stroke-width", "1.7");
|
|
290
|
+
svg.setAttribute("stroke-linecap", "round");
|
|
291
|
+
svg.setAttribute("stroke-linejoin", "round");
|
|
292
|
+
svg.setAttribute("aria-hidden", "true");
|
|
293
|
+
svg.setAttribute("focusable", "false");
|
|
294
|
+
const chevrons = doc.createElementNS(namespace, "path");
|
|
295
|
+
chevrons.setAttribute("d", "M11 4 7 8l4 4M7 4 3 8l4 4");
|
|
296
|
+
svg.append(chevrons);
|
|
273
297
|
return svg;
|
|
274
298
|
}
|
|
275
299
|
function kvRow(doc, label, value) {
|
|
@@ -478,13 +502,17 @@ function mountQuotaCard({
|
|
|
478
502
|
function renderDetail(detail, key, provider, fromRail = false) {
|
|
479
503
|
detail.replaceChildren();
|
|
480
504
|
if (fromRail) {
|
|
505
|
+
const header = doc.createElement("div");
|
|
506
|
+
header.className = "dqw-pop-header";
|
|
481
507
|
const back = doc.createElement("button");
|
|
482
508
|
back.type = "button";
|
|
483
509
|
back.className = "dqw-pop-back";
|
|
484
510
|
back.dataset.action = "back-to-overview";
|
|
485
511
|
back.setAttribute("aria-label", copy.backToOverview);
|
|
486
|
-
back.
|
|
487
|
-
|
|
512
|
+
back.title = copy.backToOverview;
|
|
513
|
+
back.append(backIcon(doc));
|
|
514
|
+
header.append(back, text(doc, "p", "dqw-pop-title", copy.providerNames[key]));
|
|
515
|
+
detail.append(header);
|
|
488
516
|
}
|
|
489
517
|
if (provider?.status === "stale") {
|
|
490
518
|
detail.append(text(doc, "p", "dqw-error", `${copy.stale}${provider.error ? `: ${provider.error}` : ""}`));
|
package/package.json
CHANGED
package/src/client.mjs
CHANGED
|
@@ -9,7 +9,7 @@ const FETCH_TIMEOUT_MS = 15_000
|
|
|
9
9
|
|
|
10
10
|
const COPY = {
|
|
11
11
|
zh: {
|
|
12
|
-
title: '
|
|
12
|
+
title: 'Token额度',
|
|
13
13
|
openDetails: '查看详情',
|
|
14
14
|
backToOverview: '返回额度概览',
|
|
15
15
|
providerNames: { glm: 'GLM', copilot: 'Copilot' },
|
|
@@ -88,7 +88,7 @@ const STYLE_TEXT = `
|
|
|
88
88
|
.dqw-stale-mark { flex: none; font-size: 9px; line-height: 14px; color: var(--dsw-alias-label-warning, #b46900); cursor: help; }
|
|
89
89
|
.dqw-errtext { font-size: 10px; line-height: 14px; opacity: .7; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
90
90
|
.dqw-rail-trigger { display: none; flex: none; align-items: center; justify-content: center; width: 36px; height: 36px; margin: 0; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--dsw-alias-label-primary, inherit); cursor: pointer; transition: background-color .12s, color .12s; }
|
|
91
|
-
.dqw-rail-trigger svg { display: block; width:
|
|
91
|
+
.dqw-rail-trigger svg { display: block; width: 22px; height: 22px; }
|
|
92
92
|
.dqw-rail-trigger:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover, rgba(128,128,128,.12)); color: var(--dsw-alias-label-primary, inherit); }
|
|
93
93
|
.dqw-rail-trigger:active:not(:disabled), .dqw-rail-trigger[aria-expanded="true"] { background: var(--dsw-alias-interactive-bg-active, rgba(128,128,128,.18)); color: var(--dsw-alias-label-primary, inherit); }
|
|
94
94
|
.dqw-rail-trigger:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary, #5b8def); outline-offset: 2px; }
|
|
@@ -99,8 +99,10 @@ const STYLE_TEXT = `
|
|
|
99
99
|
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .dqw-pop { background: var(--dsw-alias-bg-elevated, var(--dsw-alias-bg-base, #1f1f1f)); } }
|
|
100
100
|
.dqw-pop[hidden] { display: none; }
|
|
101
101
|
.dqw-pop *, .dqw-pop *::before, .dqw-pop *::after { box-sizing: border-box; }
|
|
102
|
+
.dqw-pop-header { display: flex; align-items: center; gap: 6px; min-width: 0; }
|
|
102
103
|
.dqw-pop-title { margin: 0; font-size: 11px; font-weight: 600; line-height: 16px; }
|
|
103
|
-
.dqw-pop-back { align-
|
|
104
|
+
.dqw-pop-back { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 28px; height: 28px; margin: 0; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--dsw-alias-label-secondary, inherit); cursor: pointer; }
|
|
105
|
+
.dqw-pop-back svg { display: block; width: 16px; height: 16px; }
|
|
104
106
|
.dqw-pop-back:hover { background: var(--dsw-alias-interactive-bg-hover, rgba(128,128,128,.12)); color: var(--dsw-alias-label-primary, inherit); }
|
|
105
107
|
.dqw-overview-list { display: flex; flex-direction: column; gap: 2px; }
|
|
106
108
|
.dqw-overview-row { display: flex; align-items: center; width: 100%; gap: 6px; margin: 0; padding: 5px 4px; border: 0; border-radius: 8px; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
|
|
@@ -179,8 +181,8 @@ function quotaIcon(doc) {
|
|
|
179
181
|
const namespace = 'http://www.w3.org/2000/svg'
|
|
180
182
|
const svg = doc.createElementNS(namespace, 'svg')
|
|
181
183
|
svg.setAttribute('viewBox', '0 0 24 24')
|
|
182
|
-
svg.setAttribute('width', '
|
|
183
|
-
svg.setAttribute('height', '
|
|
184
|
+
svg.setAttribute('width', '22')
|
|
185
|
+
svg.setAttribute('height', '22')
|
|
184
186
|
svg.setAttribute('fill', 'none')
|
|
185
187
|
svg.setAttribute('stroke', 'currentColor')
|
|
186
188
|
svg.setAttribute('stroke-width', '1.7')
|
|
@@ -188,17 +190,40 @@ function quotaIcon(doc) {
|
|
|
188
190
|
svg.setAttribute('stroke-linejoin', 'round')
|
|
189
191
|
svg.setAttribute('aria-hidden', 'true')
|
|
190
192
|
svg.setAttribute('focusable', 'false')
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
+
const dial = doc.createElementNS(namespace, 'circle')
|
|
194
|
+
dial.setAttribute('cx', '12')
|
|
195
|
+
dial.setAttribute('cy', '12')
|
|
196
|
+
dial.setAttribute('r', '9')
|
|
197
|
+
const ticks = doc.createElementNS(namespace, 'path')
|
|
198
|
+
ticks.setAttribute('d', 'M12 2.7v2.1M12 19.2v2.1M2.7 12h2.1M19.2 12h2.1M5.43 5.43l1.49 1.49M17.08 17.08l1.49 1.49M18.57 5.43l-1.49 1.49M6.92 17.08l-1.49 1.49')
|
|
193
199
|
const needle = doc.createElementNS(namespace, 'path')
|
|
194
|
-
needle.setAttribute('d', '
|
|
200
|
+
needle.setAttribute('d', 'M12 12l4.5-4')
|
|
195
201
|
const hub = doc.createElementNS(namespace, 'circle')
|
|
196
202
|
hub.setAttribute('cx', '12')
|
|
197
|
-
hub.setAttribute('cy', '
|
|
198
|
-
hub.setAttribute('r', '1')
|
|
203
|
+
hub.setAttribute('cy', '12')
|
|
204
|
+
hub.setAttribute('r', '1.2')
|
|
199
205
|
hub.setAttribute('fill', 'currentColor')
|
|
200
206
|
hub.setAttribute('stroke', 'none')
|
|
201
|
-
svg.append(
|
|
207
|
+
svg.append(dial, ticks, needle, hub)
|
|
208
|
+
return svg
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function backIcon(doc) {
|
|
212
|
+
const namespace = 'http://www.w3.org/2000/svg'
|
|
213
|
+
const svg = doc.createElementNS(namespace, 'svg')
|
|
214
|
+
svg.setAttribute('viewBox', '0 0 16 16')
|
|
215
|
+
svg.setAttribute('width', '16')
|
|
216
|
+
svg.setAttribute('height', '16')
|
|
217
|
+
svg.setAttribute('fill', 'none')
|
|
218
|
+
svg.setAttribute('stroke', 'currentColor')
|
|
219
|
+
svg.setAttribute('stroke-width', '1.7')
|
|
220
|
+
svg.setAttribute('stroke-linecap', 'round')
|
|
221
|
+
svg.setAttribute('stroke-linejoin', 'round')
|
|
222
|
+
svg.setAttribute('aria-hidden', 'true')
|
|
223
|
+
svg.setAttribute('focusable', 'false')
|
|
224
|
+
const chevrons = doc.createElementNS(namespace, 'path')
|
|
225
|
+
chevrons.setAttribute('d', 'M11 4 7 8l4 4M7 4 3 8l4 4')
|
|
226
|
+
svg.append(chevrons)
|
|
202
227
|
return svg
|
|
203
228
|
}
|
|
204
229
|
|
|
@@ -427,13 +452,17 @@ export function mountQuotaCard({
|
|
|
427
452
|
function renderDetail(detail, key, provider, fromRail = false) {
|
|
428
453
|
detail.replaceChildren()
|
|
429
454
|
if (fromRail) {
|
|
455
|
+
const header = doc.createElement('div')
|
|
456
|
+
header.className = 'dqw-pop-header'
|
|
430
457
|
const back = doc.createElement('button')
|
|
431
458
|
back.type = 'button'
|
|
432
459
|
back.className = 'dqw-pop-back'
|
|
433
460
|
back.dataset.action = 'back-to-overview'
|
|
434
461
|
back.setAttribute('aria-label', copy.backToOverview)
|
|
435
|
-
back.
|
|
436
|
-
|
|
462
|
+
back.title = copy.backToOverview
|
|
463
|
+
back.append(backIcon(doc))
|
|
464
|
+
header.append(back, text(doc, 'p', 'dqw-pop-title', copy.providerNames[key]))
|
|
465
|
+
detail.append(header)
|
|
437
466
|
}
|
|
438
467
|
if (provider?.status === 'stale') {
|
|
439
468
|
detail.append(text(doc, 'p', 'dqw-error', `${copy.stale}${provider.error ? `: ${provider.error}` : ''}`))
|