@iasiv5/dsh-quota-watch 0.1.25 → 0.1.26
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 +43 -22
- package/package.json +1 -1
- package/src/client.mjs +43 -20
package/lib/client.js
CHANGED
|
@@ -249,9 +249,9 @@ var COPY = {
|
|
|
249
249
|
count: "{count} \u5F20",
|
|
250
250
|
none: "\u65E0\u53EF\u7528",
|
|
251
251
|
use: "\u91CD\u7F6E",
|
|
252
|
-
reloadLink: "\uFF08\u5237\u65B0\uFF09",
|
|
252
|
+
reloadLink: "\uFF08 \u5237\u65B0 \uFF09",
|
|
253
253
|
autoToggle: "\u81EA\u52A8\u7528\u5361",
|
|
254
|
-
autoActive: "\u81EA\u52A8\u7528\u5361\xB7\u5DF2\u542F\u7528",
|
|
254
|
+
autoActive: "\u81EA\u52A8\u7528\u5361 \xB7 \u5DF2\u542F\u7528",
|
|
255
255
|
expiry: "{date} \u524D\u6709\u6548",
|
|
256
256
|
confirmTitle: "\u786E\u8BA4\u4F7F\u7528\u91CD\u7F6E\u5361\uFF1F",
|
|
257
257
|
confirmWeek: "\u5C06\u6D88\u8017 1 \u5F20\u6BCF\u5468\u91CD\u7F6E\u5361\uFF0C\u7ACB\u5373\u91CD\u7F6E\u6BCF\u5468\u989D\u5EA6\u4E0E 5 \u5C0F\u65F6\u989D\u5EA6\u3002",
|
|
@@ -263,8 +263,11 @@ var COPY = {
|
|
|
263
263
|
succeeded: "\u5DF2\u91CD\u7F6E",
|
|
264
264
|
failed: "\u91CD\u7F6E\u5931\u8D25",
|
|
265
265
|
loadFailed: "\u8BFB\u53D6\u91CD\u7F6E\u5361\u5931\u8D25",
|
|
266
|
-
|
|
267
|
-
|
|
266
|
+
// Auto rows render as three grid cells — window label, a centered ·
|
|
267
|
+
// separator, and the used note — so the · column lines up across rows.
|
|
268
|
+
autoFiveHour: "\u81EA\u52A8\u7528\u5361\uFF085 \u5C0F\u65F6\uFF09",
|
|
269
|
+
autoWeek: "\u81EA\u52A8\u7528\u5361\uFF08\u6BCF\u5468\uFF09",
|
|
270
|
+
autoUsed: "\u5DF2\u7528 {threshold}% \u89E6\u53D1",
|
|
268
271
|
autoImmediate: "\u5F53\u524D\u5DF2\u7528 {used}\uFF0C\u5DF2\u8D85\u9608\u503C\uFF1A\u5F00\u542F\u540E\u4F1A\u7ACB\u5373\u6D88\u8017\u4E00\u5F20\u5361",
|
|
269
272
|
autoSaveFailed: "\u5F00\u5173\u672A\u80FD\u4FDD\u5B58\uFF0C\u8BF7\u91CD\u8BD5",
|
|
270
273
|
autoPersistFailed: "\u5F00\u5173\u5DF2\u751F\u6548\uFF0C\u4F46\u672A\u80FD\u5199\u5165\u78C1\u76D8\uFF08\u91CD\u542F\u540E\u4F1A\u4E22\u5931\uFF09",
|
|
@@ -318,7 +321,7 @@ var COPY = {
|
|
|
318
321
|
count: "{count}",
|
|
319
322
|
none: "none",
|
|
320
323
|
use: "Reset",
|
|
321
|
-
reloadLink: "(Refresh)",
|
|
324
|
+
reloadLink: "( Refresh )",
|
|
322
325
|
autoToggle: "Auto-use",
|
|
323
326
|
autoActive: "Auto-use \xB7 on",
|
|
324
327
|
expiry: "expires {date}",
|
|
@@ -332,8 +335,10 @@ var COPY = {
|
|
|
332
335
|
succeeded: "Reset done",
|
|
333
336
|
failed: "Reset failed",
|
|
334
337
|
loadFailed: "Could not read reset cards",
|
|
335
|
-
|
|
336
|
-
|
|
338
|
+
// Same three-cell grid as zh: label · used note.
|
|
339
|
+
autoFiveHour: "Auto-use (5h)",
|
|
340
|
+
autoWeek: "Auto-use (weekly)",
|
|
341
|
+
autoUsed: "trigger at {threshold}% used",
|
|
337
342
|
autoImmediate: "Currently {used} used \u2014 already past the threshold: turning this on spends a card immediately",
|
|
338
343
|
autoSaveFailed: "Could not save the switch \u2014 retry",
|
|
339
344
|
autoPersistFailed: "Switch applied, but it could not be written to disk (lost on restart)",
|
|
@@ -449,9 +454,11 @@ var FLOAT_STYLE_TEXT = `
|
|
|
449
454
|
.dqw-reset { border-top: 1px dashed var(--dsw-alias-border-secondary, rgba(128,128,128,.25)); padding-top: 6px; display: flex; flex-direction: column; gap: 4px; }
|
|
450
455
|
.dqw-reset-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 10px; line-height: 14px; }
|
|
451
456
|
.dqw-reset-title { opacity: .65; }
|
|
452
|
-
|
|
457
|
+
/* No underline: the full-width \u300C\uFF08 \u5237\u65B0 \uFF09\u300D brackets carry the affordance, the
|
|
458
|
+
hover opacity bump is the only hover signal. */
|
|
459
|
+
.dqw-reset-reload { border: 0; background: none; padding: 0; font: inherit; font-size: 10px; color: var(--dsw-alias-label-secondary, inherit); opacity: .65; cursor: pointer; }
|
|
453
460
|
.dqw-reset-reload:hover { opacity: 1; }
|
|
454
|
-
.dqw-reset-reload:disabled { cursor: default; opacity: .35;
|
|
461
|
+
.dqw-reset-reload:disabled { cursor: default; opacity: .35; }
|
|
455
462
|
.dqw-reset-head-left { display: flex; align-items: baseline; min-width: 0; }
|
|
456
463
|
.dqw-reset-head-left.is-en { gap: 4px; }
|
|
457
464
|
.dqw-auto-master { display: flex; align-items: center; gap: 4px; cursor: pointer; font-size: 10px; line-height: 14px; }
|
|
@@ -482,13 +489,21 @@ var FLOAT_STYLE_TEXT = `
|
|
|
482
489
|
.dqw-reset-notice.is-error { color: var(--dsw-alias-label-danger, #c93c3c); }
|
|
483
490
|
.dqw-reset-auto { font-size: 10px; line-height: 14px; opacity: .6; }
|
|
484
491
|
/* Auto-use switches: a real checkbox per window, backed by a host-side file so
|
|
485
|
-
automatic spending keeps working while no browser is open.
|
|
486
|
-
|
|
487
|
-
|
|
492
|
+
automatic spending keeps working while no browser is open. Both rows share one
|
|
493
|
+
grid (same recipe as .dqw-reset-lines): the window label stays left-aligned,
|
|
494
|
+
the \xB7 sits in its own narrow centered column so the two rows line up, and the
|
|
495
|
+
used note follows after the column gap. display:contents keeps the <label>
|
|
496
|
+
wrapping its checkbox for click-to-toggle while the cells join the grid. */
|
|
497
|
+
.dqw-auto-grid { display: grid; grid-template-columns: max-content max-content 12px minmax(0, 1fr); column-gap: 6px; row-gap: 2px; align-items: center; font-size: 10.5px; line-height: 16px; }
|
|
498
|
+
.dqw-auto { display: contents; }
|
|
499
|
+
.dqw-auto-row { display: contents; }
|
|
500
|
+
.dqw-auto-grid label > :is(input, span) { cursor: pointer; }
|
|
488
501
|
.dqw-auto-box { width: 12px; height: 12px; margin: 0; flex: none; cursor: pointer; accent-color: var(--dsw-alias-button-primary-fill, #5b8def); }
|
|
489
502
|
.dqw-auto-box:disabled { cursor: default; }
|
|
490
|
-
.dqw-auto-label { opacity: .75; }
|
|
491
|
-
.dqw-auto-
|
|
503
|
+
.dqw-auto-label { opacity: .75; white-space: nowrap; }
|
|
504
|
+
.dqw-auto-dot { justify-self: center; opacity: .75; }
|
|
505
|
+
.dqw-auto-used { opacity: .75; min-width: 0; }
|
|
506
|
+
.dqw-auto-hint { grid-column: 1 / -1; font-size: 10px; line-height: 14px; padding-left: 18px; color: var(--dsw-alias-label-warning, #d29922); }
|
|
492
507
|
.dqw-error { margin: 0; font-size: 10px; line-height: 14px; color: var(--dsw-alias-label-warning, #b46900); }
|
|
493
508
|
`;
|
|
494
509
|
function localeFor(win) {
|
|
@@ -1101,12 +1116,13 @@ function mountQuotaCard({
|
|
|
1101
1116
|
void saveAutoReset(configKey, box.checked);
|
|
1102
1117
|
});
|
|
1103
1118
|
const threshold = typeof entry?.threshold === "number" ? entry.threshold : AUTO_RESET_THRESHOLD_FALLBACK;
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
"dqw-auto-label",
|
|
1108
|
-
(
|
|
1109
|
-
|
|
1119
|
+
const cards = copy.resetCards;
|
|
1120
|
+
row.append(
|
|
1121
|
+
box,
|
|
1122
|
+
text(doc, "span", "dqw-auto-label", windowKey === "5h" ? cards.autoFiveHour : cards.autoWeek),
|
|
1123
|
+
text(doc, "span", "dqw-auto-dot", "\xB7"),
|
|
1124
|
+
text(doc, "span", "dqw-auto-used", cards.autoUsed.replace("{threshold}", formatNumber(threshold, locale)))
|
|
1125
|
+
);
|
|
1110
1126
|
wrap.append(row);
|
|
1111
1127
|
const provider = (snapshot?.providers ?? []).find((item) => item?.key === "glm");
|
|
1112
1128
|
const used = (provider?.plan?.windows ?? []).find((window) => window?.key === windowKey)?.percent;
|
|
@@ -1177,8 +1193,13 @@ function mountQuotaCard({
|
|
|
1177
1193
|
const auto = snapshot?.autoReset;
|
|
1178
1194
|
if (auto !== void 0 && typeof auto === "object") {
|
|
1179
1195
|
if (autoOpen === true) {
|
|
1180
|
-
|
|
1181
|
-
|
|
1196
|
+
const grid = doc.createElement("div");
|
|
1197
|
+
grid.className = "dqw-auto-grid";
|
|
1198
|
+
grid.append(
|
|
1199
|
+
renderAutoResetRow("5h", "fiveHour", auto.fiveHour, auto),
|
|
1200
|
+
renderAutoResetRow("week", "week", auto.week, auto)
|
|
1201
|
+
);
|
|
1202
|
+
section.append(grid);
|
|
1182
1203
|
}
|
|
1183
1204
|
const last = auto.lastEvent;
|
|
1184
1205
|
if (last?.kind === "auto") {
|
package/package.json
CHANGED
package/src/client.mjs
CHANGED
|
@@ -66,9 +66,9 @@ const COPY = {
|
|
|
66
66
|
count: '{count} 张',
|
|
67
67
|
none: '无可用',
|
|
68
68
|
use: '重置',
|
|
69
|
-
reloadLink: '
|
|
69
|
+
reloadLink: '( 刷新 )',
|
|
70
70
|
autoToggle: '自动用卡',
|
|
71
|
-
autoActive: '
|
|
71
|
+
autoActive: '自动用卡 · 已启用',
|
|
72
72
|
expiry: '{date} 前有效',
|
|
73
73
|
confirmTitle: '确认使用重置卡?',
|
|
74
74
|
confirmWeek: '将消耗 1 张每周重置卡,立即重置每周额度与 5 小时额度。',
|
|
@@ -80,8 +80,11 @@ const COPY = {
|
|
|
80
80
|
succeeded: '已重置',
|
|
81
81
|
failed: '重置失败',
|
|
82
82
|
loadFailed: '读取重置卡失败',
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
// Auto rows render as three grid cells — window label, a centered ·
|
|
84
|
+
// separator, and the used note — so the · column lines up across rows.
|
|
85
|
+
autoFiveHour: '自动用卡(5 小时)',
|
|
86
|
+
autoWeek: '自动用卡(每周)',
|
|
87
|
+
autoUsed: '已用 {threshold}% 触发',
|
|
85
88
|
autoImmediate: '当前已用 {used},已超阈值:开启后会立即消耗一张卡',
|
|
86
89
|
autoSaveFailed: '开关未能保存,请重试',
|
|
87
90
|
autoPersistFailed: '开关已生效,但未能写入磁盘(重启后会丢失)',
|
|
@@ -135,7 +138,7 @@ const COPY = {
|
|
|
135
138
|
count: '{count}',
|
|
136
139
|
none: 'none',
|
|
137
140
|
use: 'Reset',
|
|
138
|
-
reloadLink: '(Refresh)',
|
|
141
|
+
reloadLink: '( Refresh )',
|
|
139
142
|
autoToggle: 'Auto-use',
|
|
140
143
|
autoActive: 'Auto-use · on',
|
|
141
144
|
expiry: 'expires {date}',
|
|
@@ -149,8 +152,10 @@ const COPY = {
|
|
|
149
152
|
succeeded: 'Reset done',
|
|
150
153
|
failed: 'Reset failed',
|
|
151
154
|
loadFailed: 'Could not read reset cards',
|
|
152
|
-
|
|
153
|
-
|
|
155
|
+
// Same three-cell grid as zh: label · used note.
|
|
156
|
+
autoFiveHour: 'Auto-use (5h)',
|
|
157
|
+
autoWeek: 'Auto-use (weekly)',
|
|
158
|
+
autoUsed: 'trigger at {threshold}% used',
|
|
154
159
|
autoImmediate: 'Currently {used} used — already past the threshold: turning this on spends a card immediately',
|
|
155
160
|
autoSaveFailed: 'Could not save the switch — retry',
|
|
156
161
|
autoPersistFailed: 'Switch applied, but it could not be written to disk (lost on restart)',
|
|
@@ -273,9 +278,11 @@ const FLOAT_STYLE_TEXT = `
|
|
|
273
278
|
.dqw-reset { border-top: 1px dashed var(--dsw-alias-border-secondary, rgba(128,128,128,.25)); padding-top: 6px; display: flex; flex-direction: column; gap: 4px; }
|
|
274
279
|
.dqw-reset-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 10px; line-height: 14px; }
|
|
275
280
|
.dqw-reset-title { opacity: .65; }
|
|
276
|
-
|
|
281
|
+
/* No underline: the full-width 「( 刷新 )」 brackets carry the affordance, the
|
|
282
|
+
hover opacity bump is the only hover signal. */
|
|
283
|
+
.dqw-reset-reload { border: 0; background: none; padding: 0; font: inherit; font-size: 10px; color: var(--dsw-alias-label-secondary, inherit); opacity: .65; cursor: pointer; }
|
|
277
284
|
.dqw-reset-reload:hover { opacity: 1; }
|
|
278
|
-
.dqw-reset-reload:disabled { cursor: default; opacity: .35;
|
|
285
|
+
.dqw-reset-reload:disabled { cursor: default; opacity: .35; }
|
|
279
286
|
.dqw-reset-head-left { display: flex; align-items: baseline; min-width: 0; }
|
|
280
287
|
.dqw-reset-head-left.is-en { gap: 4px; }
|
|
281
288
|
.dqw-auto-master { display: flex; align-items: center; gap: 4px; cursor: pointer; font-size: 10px; line-height: 14px; }
|
|
@@ -306,13 +313,21 @@ const FLOAT_STYLE_TEXT = `
|
|
|
306
313
|
.dqw-reset-notice.is-error { color: var(--dsw-alias-label-danger, #c93c3c); }
|
|
307
314
|
.dqw-reset-auto { font-size: 10px; line-height: 14px; opacity: .6; }
|
|
308
315
|
/* Auto-use switches: a real checkbox per window, backed by a host-side file so
|
|
309
|
-
automatic spending keeps working while no browser is open.
|
|
310
|
-
|
|
311
|
-
|
|
316
|
+
automatic spending keeps working while no browser is open. Both rows share one
|
|
317
|
+
grid (same recipe as .dqw-reset-lines): the window label stays left-aligned,
|
|
318
|
+
the · sits in its own narrow centered column so the two rows line up, and the
|
|
319
|
+
used note follows after the column gap. display:contents keeps the <label>
|
|
320
|
+
wrapping its checkbox for click-to-toggle while the cells join the grid. */
|
|
321
|
+
.dqw-auto-grid { display: grid; grid-template-columns: max-content max-content 12px minmax(0, 1fr); column-gap: 6px; row-gap: 2px; align-items: center; font-size: 10.5px; line-height: 16px; }
|
|
322
|
+
.dqw-auto { display: contents; }
|
|
323
|
+
.dqw-auto-row { display: contents; }
|
|
324
|
+
.dqw-auto-grid label > :is(input, span) { cursor: pointer; }
|
|
312
325
|
.dqw-auto-box { width: 12px; height: 12px; margin: 0; flex: none; cursor: pointer; accent-color: var(--dsw-alias-button-primary-fill, #5b8def); }
|
|
313
326
|
.dqw-auto-box:disabled { cursor: default; }
|
|
314
|
-
.dqw-auto-label { opacity: .75; }
|
|
315
|
-
.dqw-auto-
|
|
327
|
+
.dqw-auto-label { opacity: .75; white-space: nowrap; }
|
|
328
|
+
.dqw-auto-dot { justify-self: center; opacity: .75; }
|
|
329
|
+
.dqw-auto-used { opacity: .75; min-width: 0; }
|
|
330
|
+
.dqw-auto-hint { grid-column: 1 / -1; font-size: 10px; line-height: 14px; padding-left: 18px; color: var(--dsw-alias-label-warning, #d29922); }
|
|
316
331
|
.dqw-error { margin: 0; font-size: 10px; line-height: 14px; color: var(--dsw-alias-label-warning, #b46900); }
|
|
317
332
|
`
|
|
318
333
|
|
|
@@ -1100,9 +1115,13 @@ export function mountQuotaCard({
|
|
|
1100
1115
|
box.disabled = autoSaving === true
|
|
1101
1116
|
box.addEventListener('change', () => { void saveAutoReset(configKey, box.checked) })
|
|
1102
1117
|
const threshold = typeof entry?.threshold === 'number' ? entry.threshold : AUTO_RESET_THRESHOLD_FALLBACK
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1118
|
+
// Structured cells — window label (left), · (centered column, aligned across
|
|
1119
|
+
// rows), used note — joined by the shared .dqw-auto-grid column gap.
|
|
1120
|
+
const cards = copy.resetCards
|
|
1121
|
+
row.append(box,
|
|
1122
|
+
text(doc, 'span', 'dqw-auto-label', windowKey === '5h' ? cards.autoFiveHour : cards.autoWeek),
|
|
1123
|
+
text(doc, 'span', 'dqw-auto-dot', '·'),
|
|
1124
|
+
text(doc, 'span', 'dqw-auto-used', cards.autoUsed.replace('{threshold}', formatNumber(threshold, locale))))
|
|
1106
1125
|
wrap.append(row)
|
|
1107
1126
|
|
|
1108
1127
|
// Usage is already past the threshold: turning this on spends a card at the
|
|
@@ -1122,7 +1141,7 @@ export function mountQuotaCard({
|
|
|
1122
1141
|
section.className = 'dqw-reset'
|
|
1123
1142
|
const head = doc.createElement('div')
|
|
1124
1143
|
head.className = 'dqw-reset-head'
|
|
1125
|
-
// Left: the title carries the manual reload affordance
|
|
1144
|
+
// Left: the title carries the manual reload affordance —「额度重置卡( 刷新 )」.
|
|
1126
1145
|
const headLeft = doc.createElement('div')
|
|
1127
1146
|
headLeft.className = `dqw-reset-head-left${locale === 'en' ? ' is-en' : ''}`
|
|
1128
1147
|
headLeft.append(text(doc, 'span', 'dqw-reset-title', copy.resetCards.section))
|
|
@@ -1185,9 +1204,13 @@ export function mountQuotaCard({
|
|
|
1185
1204
|
if (auto !== undefined && typeof auto === 'object') {
|
|
1186
1205
|
// The two auto-use rows stay collapsed behind the header toggle; the event
|
|
1187
1206
|
// notices below still render while collapsed so auto activity stays visible.
|
|
1207
|
+
// One shared grid is what keeps the · column aligned across both rows.
|
|
1188
1208
|
if (autoOpen === true) {
|
|
1189
|
-
|
|
1190
|
-
|
|
1209
|
+
const grid = doc.createElement('div')
|
|
1210
|
+
grid.className = 'dqw-auto-grid'
|
|
1211
|
+
grid.append(renderAutoResetRow('5h', 'fiveHour', auto.fiveHour, auto),
|
|
1212
|
+
renderAutoResetRow('week', 'week', auto.week, auto))
|
|
1213
|
+
section.append(grid)
|
|
1191
1214
|
}
|
|
1192
1215
|
const last = auto.lastEvent
|
|
1193
1216
|
if (last?.kind === 'auto') {
|