agy-family 0.6.5 → 0.6.7
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agy-family",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.7",
|
|
4
4
|
"description": "Zero-privacy-leak transparent usage dashboard, /family slash command, and fair-use budget guardrail for Google One / Antigravity family groups.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -890,7 +890,7 @@ export async function runHeadlessSync({ cfg, fullSync = false, home = homedir(),
|
|
|
890
890
|
const { payload, scan, nextSyncedHashes, nextAccountLedger } = await buildSyncPayload({
|
|
891
891
|
deviceId,
|
|
892
892
|
clientKind: 'cli',
|
|
893
|
-
clientVersion: '0.6.
|
|
893
|
+
clientVersion: '0.6.7',
|
|
894
894
|
home,
|
|
895
895
|
fileCache: cache,
|
|
896
896
|
syncedHashes: prevHashes,
|
|
@@ -83,7 +83,7 @@ export function diffSyncBuckets(buckets, syncedHashes = null, { fullSync = false
|
|
|
83
83
|
export async function buildSyncPayload({
|
|
84
84
|
deviceId,
|
|
85
85
|
clientKind = 'cli',
|
|
86
|
-
clientVersion = '0.6.
|
|
86
|
+
clientVersion = '0.6.7',
|
|
87
87
|
home,
|
|
88
88
|
roots = null,
|
|
89
89
|
sourceFilter = 'all',
|
|
@@ -164,7 +164,7 @@ export async function buildSyncPayload({
|
|
|
164
164
|
deviceId: String(deviceId || deriveAnonymousDeviceId()).slice(0, 32),
|
|
165
165
|
client: {
|
|
166
166
|
kind: clientKind === 'extension' ? 'extension' : 'cli',
|
|
167
|
-
version: String(clientVersion || '0.6.
|
|
167
|
+
version: String(clientVersion || '0.6.7').slice(0, 24),
|
|
168
168
|
...(platformLabel ? { platform: platformLabel } : {}),
|
|
169
169
|
},
|
|
170
170
|
account: {
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
import { FAVICON_SVG, renderDashboardHtml } from './ui.mjs';
|
|
27
27
|
import { dispatchWebhook, sendDedupedAlert, validateWebhookUrl } from './webhooks.mjs';
|
|
28
28
|
|
|
29
|
-
export const SERVER_VERSION = '0.6.
|
|
29
|
+
export const SERVER_VERSION = '0.6.7';
|
|
30
30
|
const MAX_BUCKETS_PER_SYNC = 1000;
|
|
31
31
|
const MAX_DEVICES_PER_MEMBER = 8;
|
|
32
32
|
const MAX_TOKENS_PER_BUCKET = 500_000_000;
|
|
@@ -180,7 +180,231 @@ export function renderDashboardHtml({ boardTitle = 'Antigravity 家庭组' } = {
|
|
|
180
180
|
border-radius: 50%;
|
|
181
181
|
background: var(--good);
|
|
182
182
|
flex-shrink: 0;
|
|
183
|
+
transition: background 0.15s ease;
|
|
183
184
|
}
|
|
185
|
+
.sync-dot.paused {
|
|
186
|
+
background: var(--muted);
|
|
187
|
+
opacity: 0.6;
|
|
188
|
+
}
|
|
189
|
+
.sync-sep {
|
|
190
|
+
opacity: 0.45;
|
|
191
|
+
user-select: none;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/* Unified Custom Select & Popover Menu (matches .range-popover aesthetic) */
|
|
195
|
+
.cselect-native {
|
|
196
|
+
position: absolute !important;
|
|
197
|
+
opacity: 0 !important;
|
|
198
|
+
pointer-events: none !important;
|
|
199
|
+
width: 0 !important;
|
|
200
|
+
height: 0 !important;
|
|
201
|
+
margin: 0 !important;
|
|
202
|
+
padding: 0 !important;
|
|
203
|
+
border: 0 !important;
|
|
204
|
+
}
|
|
205
|
+
.cselect-trigger {
|
|
206
|
+
width: 100%;
|
|
207
|
+
display: inline-flex;
|
|
208
|
+
align-items: center;
|
|
209
|
+
justify-content: space-between;
|
|
210
|
+
gap: 8px;
|
|
211
|
+
min-height: 34px;
|
|
212
|
+
padding: 6px 10px;
|
|
213
|
+
border-radius: var(--r-md);
|
|
214
|
+
border: 1px solid var(--hairline-strong);
|
|
215
|
+
background: var(--surface-card);
|
|
216
|
+
color: var(--ink);
|
|
217
|
+
font-family: inherit;
|
|
218
|
+
font-size: 13px;
|
|
219
|
+
line-height: 1.35;
|
|
220
|
+
text-align: left;
|
|
221
|
+
cursor: pointer;
|
|
222
|
+
transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
|
|
223
|
+
}
|
|
224
|
+
.cselect-trigger:hover {
|
|
225
|
+
border-color: var(--muted);
|
|
226
|
+
background: var(--canvas-soft);
|
|
227
|
+
}
|
|
228
|
+
.cselect-trigger:focus-visible,
|
|
229
|
+
.cselect-trigger.open {
|
|
230
|
+
outline: none;
|
|
231
|
+
border-color: var(--primary);
|
|
232
|
+
box-shadow: 0 0 0 3px var(--primary-soft);
|
|
233
|
+
}
|
|
234
|
+
.cselect-trigger.is-compact {
|
|
235
|
+
width: auto;
|
|
236
|
+
min-height: 20px;
|
|
237
|
+
padding: 1px 5px;
|
|
238
|
+
gap: 3px;
|
|
239
|
+
border: none;
|
|
240
|
+
border-radius: 5px;
|
|
241
|
+
background: transparent;
|
|
242
|
+
color: var(--body);
|
|
243
|
+
font-family: var(--font-mono);
|
|
244
|
+
font-size: 11px;
|
|
245
|
+
line-height: 1.2;
|
|
246
|
+
box-shadow: none;
|
|
247
|
+
}
|
|
248
|
+
.cselect-trigger.is-compact:hover,
|
|
249
|
+
.cselect-trigger.is-compact.open,
|
|
250
|
+
.cselect-trigger.is-compact:focus-visible {
|
|
251
|
+
background: var(--hover);
|
|
252
|
+
color: var(--ink);
|
|
253
|
+
border-color: transparent;
|
|
254
|
+
box-shadow: none;
|
|
255
|
+
}
|
|
256
|
+
.cselect-label {
|
|
257
|
+
overflow: hidden;
|
|
258
|
+
text-overflow: ellipsis;
|
|
259
|
+
white-space: nowrap;
|
|
260
|
+
flex: 1;
|
|
261
|
+
min-width: 0;
|
|
262
|
+
}
|
|
263
|
+
.cselect-chev {
|
|
264
|
+
flex-shrink: 0;
|
|
265
|
+
color: var(--muted);
|
|
266
|
+
transition: transform 0.16s ease, color 0.15s ease;
|
|
267
|
+
}
|
|
268
|
+
.cselect-trigger.open .cselect-chev {
|
|
269
|
+
transform: rotate(180deg);
|
|
270
|
+
color: var(--ink);
|
|
271
|
+
}
|
|
272
|
+
.cselect-menu {
|
|
273
|
+
display: none;
|
|
274
|
+
position: fixed;
|
|
275
|
+
top: 0;
|
|
276
|
+
left: 0;
|
|
277
|
+
z-index: 2600;
|
|
278
|
+
padding: 4px;
|
|
279
|
+
background: var(--surface-card);
|
|
280
|
+
border: 1px solid var(--hairline-strong);
|
|
281
|
+
border-radius: var(--r-lg);
|
|
282
|
+
box-shadow: 0 12px 32px rgba(0, 0, 0, 0.11), 0 2px 6px rgba(0, 0, 0, 0.05);
|
|
283
|
+
max-height: 268px;
|
|
284
|
+
max-width: calc(100vw - 16px);
|
|
285
|
+
overflow-y: auto;
|
|
286
|
+
}
|
|
287
|
+
[data-theme="dark"] .cselect-menu {
|
|
288
|
+
box-shadow: 0 16px 38px rgba(0, 0, 0, 0.48);
|
|
289
|
+
}
|
|
290
|
+
.cselect-menu.open {
|
|
291
|
+
display: block;
|
|
292
|
+
animation: agf-pane-in 0.13s cubic-bezier(0.22, 1, 0.36, 1);
|
|
293
|
+
}
|
|
294
|
+
.cselect-opt {
|
|
295
|
+
width: 100%;
|
|
296
|
+
display: flex;
|
|
297
|
+
align-items: center;
|
|
298
|
+
justify-content: space-between;
|
|
299
|
+
gap: 10px;
|
|
300
|
+
padding: 7px 9px;
|
|
301
|
+
border: none;
|
|
302
|
+
border-radius: 7px;
|
|
303
|
+
background: transparent;
|
|
304
|
+
color: var(--body);
|
|
305
|
+
font-family: inherit;
|
|
306
|
+
font-size: 12.5px;
|
|
307
|
+
line-height: 1.35;
|
|
308
|
+
text-align: left;
|
|
309
|
+
cursor: pointer;
|
|
310
|
+
transition: background 0.1s ease, color 0.1s ease;
|
|
311
|
+
}
|
|
312
|
+
.cselect-menu.is-compact .cselect-opt {
|
|
313
|
+
font-family: var(--font-mono);
|
|
314
|
+
font-size: 11.5px;
|
|
315
|
+
padding: 5px 8px;
|
|
316
|
+
}
|
|
317
|
+
.cselect-opt:hover,
|
|
318
|
+
.cselect-opt.is-focused {
|
|
319
|
+
background: var(--hover);
|
|
320
|
+
color: var(--ink);
|
|
321
|
+
}
|
|
322
|
+
.cselect-opt.is-selected {
|
|
323
|
+
background: var(--primary-soft);
|
|
324
|
+
color: var(--ink);
|
|
325
|
+
font-weight: 500;
|
|
326
|
+
}
|
|
327
|
+
.cselect-opt-text {
|
|
328
|
+
overflow: hidden;
|
|
329
|
+
text-overflow: ellipsis;
|
|
330
|
+
white-space: nowrap;
|
|
331
|
+
}
|
|
332
|
+
.cselect-check {
|
|
333
|
+
flex-shrink: 0;
|
|
334
|
+
color: var(--primary);
|
|
335
|
+
opacity: 0;
|
|
336
|
+
}
|
|
337
|
+
.cselect-opt.is-selected .cselect-check {
|
|
338
|
+
opacity: 1;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/* Unified Custom Confirm Dialog */
|
|
342
|
+
.confirm-overlay {
|
|
343
|
+
display: none;
|
|
344
|
+
position: fixed;
|
|
345
|
+
inset: 0;
|
|
346
|
+
z-index: 2550;
|
|
347
|
+
background: rgba(38, 37, 30, 0.32);
|
|
348
|
+
backdrop-filter: blur(4px);
|
|
349
|
+
-webkit-backdrop-filter: blur(4px);
|
|
350
|
+
align-items: center;
|
|
351
|
+
justify-content: center;
|
|
352
|
+
padding: 16px;
|
|
353
|
+
}
|
|
354
|
+
[data-theme="dark"] .confirm-overlay {
|
|
355
|
+
background: rgba(0, 0, 0, 0.55);
|
|
356
|
+
}
|
|
357
|
+
.confirm-overlay.open {
|
|
358
|
+
display: flex;
|
|
359
|
+
animation: agf-fade-in 0.14s ease;
|
|
360
|
+
}
|
|
361
|
+
.confirm-card {
|
|
362
|
+
width: 100%;
|
|
363
|
+
max-width: 392px;
|
|
364
|
+
background: var(--surface-card);
|
|
365
|
+
border: 1px solid var(--hairline-strong);
|
|
366
|
+
border-radius: var(--r-lg);
|
|
367
|
+
padding: 18px 20px 16px;
|
|
368
|
+
box-shadow: 0 20px 48px rgba(0, 0, 0, 0.16), 0 2px 8px rgba(0, 0, 0, 0.06);
|
|
369
|
+
animation: agf-pane-in 0.16s cubic-bezier(0.22, 1, 0.36, 1);
|
|
370
|
+
}
|
|
371
|
+
[data-theme="dark"] .confirm-card {
|
|
372
|
+
box-shadow: 0 24px 56px rgba(0, 0, 0, 0.56);
|
|
373
|
+
}
|
|
374
|
+
.confirm-head {
|
|
375
|
+
display: flex;
|
|
376
|
+
align-items: flex-start;
|
|
377
|
+
gap: 10px;
|
|
378
|
+
}
|
|
379
|
+
.confirm-ico {
|
|
380
|
+
width: 30px;
|
|
381
|
+
height: 30px;
|
|
382
|
+
border-radius: 8px;
|
|
383
|
+
display: grid;
|
|
384
|
+
place-items: center;
|
|
385
|
+
flex-shrink: 0;
|
|
386
|
+
background: var(--danger-soft);
|
|
387
|
+
color: var(--danger);
|
|
388
|
+
}
|
|
389
|
+
.confirm-title {
|
|
390
|
+
font-size: 14.5px;
|
|
391
|
+
font-weight: 600;
|
|
392
|
+
color: var(--ink);
|
|
393
|
+
line-height: 1.35;
|
|
394
|
+
}
|
|
395
|
+
.confirm-msg {
|
|
396
|
+
margin-top: 4px;
|
|
397
|
+
font-size: 12.5px;
|
|
398
|
+
color: var(--body);
|
|
399
|
+
line-height: 1.55;
|
|
400
|
+
}
|
|
401
|
+
.confirm-actions {
|
|
402
|
+
display: flex;
|
|
403
|
+
justify-content: flex-end;
|
|
404
|
+
gap: 8px;
|
|
405
|
+
margin-top: 16px;
|
|
406
|
+
}
|
|
407
|
+
@keyframes agf-fade-in { from { opacity: 0; } to { opacity: 1; } }
|
|
184
408
|
.icon-refresh {
|
|
185
409
|
display: inline-grid;
|
|
186
410
|
place-items: center;
|
|
@@ -1740,8 +1964,17 @@ export function renderDashboardHtml({ boardTitle = 'Antigravity 家庭组' } = {
|
|
|
1740
1964
|
<div class="brand-mark" aria-hidden="true">${FAVICON_SVG}</div>
|
|
1741
1965
|
<h1 class="brand-title" id="boardTitle">${safeTitle}</h1>
|
|
1742
1966
|
<span class="sync-pill">
|
|
1743
|
-
<span class="sync-dot"></span>
|
|
1967
|
+
<span class="sync-dot" id="syncDot"></span>
|
|
1744
1968
|
<span id="updatedLine">--:--</span>
|
|
1969
|
+
<span class="sync-sep" aria-hidden="true">·</span>
|
|
1970
|
+
<select class="refresh-select" id="autoRefreshSelect" data-compact="true" aria-label="自动刷新间隔" title="自动刷新间隔">
|
|
1971
|
+
<option value="10">10s</option>
|
|
1972
|
+
<option value="15">15s</option>
|
|
1973
|
+
<option value="30" selected>30s</option>
|
|
1974
|
+
<option value="60">1m</option>
|
|
1975
|
+
<option value="300">5m</option>
|
|
1976
|
+
<option value="0">关闭</option>
|
|
1977
|
+
</select>
|
|
1745
1978
|
<button class="icon-refresh" id="refreshBtn" title="Refresh" aria-label="Refresh">
|
|
1746
1979
|
<svg width="11" height="11" viewBox="0 0 16 16" fill="none" aria-hidden="true">
|
|
1747
1980
|
<path d="M13.5 8A5.5 5.5 0 1 1 11.9 4.1M13.5 2.5V5.2H10.8" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
|
@@ -1924,7 +2157,7 @@ export function renderDashboardHtml({ boardTitle = 'Antigravity 家庭组' } = {
|
|
|
1924
2157
|
|
|
1925
2158
|
<footer class="foot">
|
|
1926
2159
|
<span data-i18n="privacyNote">隐私承诺:客户端仅只读扫描本地 SQLite 数值元数据,绝不上传 Prompt、代码、文件路径或 Google 凭据。</span>
|
|
1927
|
-
<span class="mono">agy-family v0.6.
|
|
2160
|
+
<span class="mono">agy-family v0.6.7 · MIT</span>
|
|
1928
2161
|
</footer>
|
|
1929
2162
|
</main>
|
|
1930
2163
|
|
|
@@ -2215,6 +2448,29 @@ export function renderDashboardHtml({ boardTitle = 'Antigravity 家庭组' } = {
|
|
|
2215
2448
|
</div>
|
|
2216
2449
|
</div>
|
|
2217
2450
|
|
|
2451
|
+
<div class="cselect-menu" id="agfSelectMenu" role="listbox" aria-hidden="true"></div>
|
|
2452
|
+
|
|
2453
|
+
<div class="confirm-overlay" id="confirmOverlay" role="dialog" aria-modal="true" aria-labelledby="confirmTitle">
|
|
2454
|
+
<div class="confirm-card">
|
|
2455
|
+
<div class="confirm-head">
|
|
2456
|
+
<div class="confirm-ico" aria-hidden="true">
|
|
2457
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none">
|
|
2458
|
+
<path d="M8 2.2L14.2 13.2H1.8L8 2.2Z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/>
|
|
2459
|
+
<path d="M8 6.4V9.5M8 11.4V11.6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
2460
|
+
</svg>
|
|
2461
|
+
</div>
|
|
2462
|
+
<div>
|
|
2463
|
+
<div class="confirm-title" id="confirmTitle">确认操作</div>
|
|
2464
|
+
<div class="confirm-msg" id="confirmMsg"></div>
|
|
2465
|
+
</div>
|
|
2466
|
+
</div>
|
|
2467
|
+
<div class="confirm-actions">
|
|
2468
|
+
<button type="button" class="btn btn-sm" id="confirmCancelBtn">取消</button>
|
|
2469
|
+
<button type="button" class="btn btn-sm btn-danger" id="confirmOkBtn">确认</button>
|
|
2470
|
+
</div>
|
|
2471
|
+
</div>
|
|
2472
|
+
</div>
|
|
2473
|
+
|
|
2218
2474
|
<div class="toast" id="toast" role="status" aria-live="polite"><span class="toast-dot"></span><span id="toastText"></span></div>
|
|
2219
2475
|
|
|
2220
2476
|
<script>
|
|
@@ -2481,6 +2737,16 @@ function applyI18n() {
|
|
|
2481
2737
|
if (tpBtn) tpBtn.textContent = lang === 'zh' ? '查看 / 自定义单价' : 'View / Edit rates';
|
|
2482
2738
|
const advSum = document.getElementById('advancedRulesSummary');
|
|
2483
2739
|
if (advSum) advSum.textContent = lang === 'zh' ? '高级设置与群通知(时区 / 预警 / 查看密码 / Webhook)' : 'Advanced & Notifications (Timezone / Warn / View Key / Webhook)';
|
|
2740
|
+
const arSel = document.getElementById('autoRefreshSelect');
|
|
2741
|
+
if (arSel) {
|
|
2742
|
+
arSel.title = lang === 'zh' ? '页面自动刷新间隔' : 'Auto-refresh interval';
|
|
2743
|
+
arSel.setAttribute('aria-label', arSel.title);
|
|
2744
|
+
const offOpt = arSel.querySelector('option[value="0"]');
|
|
2745
|
+
if (offOpt) offOpt.textContent = lang === 'zh' ? '关闭' : 'Off';
|
|
2746
|
+
}
|
|
2747
|
+
const rfBtn = document.getElementById('refreshBtn');
|
|
2748
|
+
if (rfBtn) rfBtn.title = lang === 'zh' ? '立即刷新' : 'Refresh now';
|
|
2749
|
+
syncCustomSelects();
|
|
2484
2750
|
updateRangeTriggerLabel(lastBoardData?.window || null);
|
|
2485
2751
|
updateAdminHeaderTitle();
|
|
2486
2752
|
renderGuideBody();
|
|
@@ -2724,6 +2990,7 @@ async function fetchBoard(opts) {
|
|
|
2724
2990
|
}
|
|
2725
2991
|
const isTabOrManual = !silent && hasLoadedBoard;
|
|
2726
2992
|
hasLoadedBoard = true;
|
|
2993
|
+
lastBoardFetchedAt = Date.now();
|
|
2727
2994
|
lastBoardData = data;
|
|
2728
2995
|
renderBoard(data);
|
|
2729
2996
|
if (isTabOrManual) {
|
|
@@ -3901,6 +4168,7 @@ async function loadAdmin() {
|
|
|
3901
4168
|
setN('mqTpwInput', tp.weeklyPct);
|
|
3902
4169
|
}
|
|
3903
4170
|
}
|
|
4171
|
+
syncCustomSelects(document.getElementById('adminOverlay') || document);
|
|
3904
4172
|
|
|
3905
4173
|
// Integrity events
|
|
3906
4174
|
const intEvents = data.integrityEvents || [];
|
|
@@ -4186,7 +4454,12 @@ document.getElementById('adminMemberList').addEventListener('click', async (e) =
|
|
|
4186
4454
|
return;
|
|
4187
4455
|
}
|
|
4188
4456
|
if (act === 'delete') {
|
|
4189
|
-
|
|
4457
|
+
const ok = await showConfirmDialog({
|
|
4458
|
+
title: lang === 'zh' ? '移除家庭成员' : 'Remove family member',
|
|
4459
|
+
message: lang === 'zh' ? '确认移除该成员并清空其统计数据?移除后其登录会话将立即失效。' : 'Remove this member and clear their usage records? Their web session will be revoked immediately.',
|
|
4460
|
+
confirmText: lang === 'zh' ? '确认移除' : 'Remove',
|
|
4461
|
+
});
|
|
4462
|
+
if (!ok) return;
|
|
4190
4463
|
await withBtnLoading(btn, async () => {
|
|
4191
4464
|
await adminReq('/api/admin/members/' + encodeURIComponent(id), { method: 'DELETE' });
|
|
4192
4465
|
if (expandedMemberId === id) expandedMemberId = null;
|
|
@@ -4206,7 +4479,12 @@ document.getElementById('copyMasterCmdBtn')?.addEventListener('click', async ()
|
|
|
4206
4479
|
|
|
4207
4480
|
document.getElementById('clearMasterQuotaBtn')?.addEventListener('click', async () => {
|
|
4208
4481
|
const btn = document.getElementById('clearMasterQuotaBtn');
|
|
4209
|
-
|
|
4482
|
+
const ok = await showConfirmDialog({
|
|
4483
|
+
title: lang === 'zh' ? '清除订阅额度记录' : 'Clear subscription quota',
|
|
4484
|
+
message: lang === 'zh' ? '确认清除已同步的家庭组主号及协同订阅额度快照?清除后将在下一次对话重新捕获。' : 'Clear synced subscription quota snapshots? They will be re-captured on the next turn.',
|
|
4485
|
+
confirmText: lang === 'zh' ? '确认清除' : 'Clear',
|
|
4486
|
+
});
|
|
4487
|
+
if (!ok) return;
|
|
4210
4488
|
await withBtnLoading(btn, async () => {
|
|
4211
4489
|
await adminReq('/api/admin/master-quota', { method: 'DELETE' });
|
|
4212
4490
|
showToast(lang === 'zh' ? '已清除主号订阅额度记录' : 'Cleared');
|
|
@@ -4228,7 +4506,12 @@ document.getElementById('adminIntegrityList').addEventListener('click', async (e
|
|
|
4228
4506
|
|
|
4229
4507
|
document.getElementById('clearIntegrityBtn').addEventListener('click', async () => {
|
|
4230
4508
|
const btn = document.getElementById('clearIntegrityBtn');
|
|
4231
|
-
|
|
4509
|
+
const ok = await showConfirmDialog({
|
|
4510
|
+
title: lang === 'zh' ? '清空防篡改审计记录' : 'Clear integrity audit log',
|
|
4511
|
+
message: lang === 'zh' ? '确认清空全部防篡改审计与离线巡检历史记录?此操作不可撤销。' : 'Clear all integrity audit events? This cannot be undone.',
|
|
4512
|
+
confirmText: lang === 'zh' ? '确认清空' : 'Clear all',
|
|
4513
|
+
});
|
|
4514
|
+
if (!ok) return;
|
|
4232
4515
|
await withBtnLoading(btn, async () => {
|
|
4233
4516
|
await adminReq('/api/admin/integrity/clear', { method: 'POST' });
|
|
4234
4517
|
await loadAdmin();
|
|
@@ -4255,7 +4538,270 @@ document.getElementById('checkOfflineBtn').addEventListener('click', async () =>
|
|
|
4255
4538
|
});
|
|
4256
4539
|
});
|
|
4257
4540
|
|
|
4258
|
-
|
|
4541
|
+
// --- Unified Custom Select Popover & Confirm Dialog Engine ---
|
|
4542
|
+
let activeCustomSelect = null;
|
|
4543
|
+
let activeCustomBtn = null;
|
|
4544
|
+
let activeCustomFocusIdx = -1;
|
|
4545
|
+
let confirmResolver = null;
|
|
4546
|
+
|
|
4547
|
+
function resolveConfirmDialog(val) {
|
|
4548
|
+
const ov = document.getElementById('confirmOverlay');
|
|
4549
|
+
if (ov) ov.classList.remove('open');
|
|
4550
|
+
if (confirmResolver) {
|
|
4551
|
+
const fn = confirmResolver;
|
|
4552
|
+
confirmResolver = null;
|
|
4553
|
+
fn(Boolean(val));
|
|
4554
|
+
}
|
|
4555
|
+
}
|
|
4556
|
+
|
|
4557
|
+
function showConfirmDialog(opts) {
|
|
4558
|
+
const ov = document.getElementById('confirmOverlay');
|
|
4559
|
+
if (!ov) return Promise.resolve(false);
|
|
4560
|
+
closeCustomSelect();
|
|
4561
|
+
const titleEl = document.getElementById('confirmTitle');
|
|
4562
|
+
const msgEl = document.getElementById('confirmMsg');
|
|
4563
|
+
const okBtn = document.getElementById('confirmOkBtn');
|
|
4564
|
+
const cancelBtn = document.getElementById('confirmCancelBtn');
|
|
4565
|
+
if (titleEl) titleEl.textContent = (opts && opts.title) || (lang === 'zh' ? '确认操作' : 'Confirm action');
|
|
4566
|
+
if (msgEl) msgEl.textContent = (opts && opts.message) || '';
|
|
4567
|
+
if (okBtn) okBtn.textContent = (opts && opts.confirmText) || (lang === 'zh' ? '确认' : 'Confirm');
|
|
4568
|
+
if (cancelBtn) cancelBtn.textContent = (opts && opts.cancelText) || (lang === 'zh' ? '取消' : 'Cancel');
|
|
4569
|
+
ov.classList.add('open');
|
|
4570
|
+
setTimeout(() => okBtn?.focus(), 20);
|
|
4571
|
+
return new Promise((resolve) => {
|
|
4572
|
+
confirmResolver = resolve;
|
|
4573
|
+
});
|
|
4574
|
+
}
|
|
4575
|
+
|
|
4576
|
+
document.getElementById('confirmCancelBtn')?.addEventListener('click', () => resolveConfirmDialog(false));
|
|
4577
|
+
document.getElementById('confirmOkBtn')?.addEventListener('click', () => resolveConfirmDialog(true));
|
|
4578
|
+
document.getElementById('confirmOverlay')?.addEventListener('click', (e) => {
|
|
4579
|
+
if (e.target === e.currentTarget) resolveConfirmDialog(false);
|
|
4580
|
+
});
|
|
4581
|
+
|
|
4582
|
+
function closeCustomSelect(returnFocus) {
|
|
4583
|
+
const menu = document.getElementById('agfSelectMenu');
|
|
4584
|
+
if (menu) {
|
|
4585
|
+
menu.classList.remove('open', 'is-compact');
|
|
4586
|
+
menu.setAttribute('aria-hidden', 'true');
|
|
4587
|
+
menu.innerHTML = '';
|
|
4588
|
+
}
|
|
4589
|
+
if (activeCustomBtn) {
|
|
4590
|
+
activeCustomBtn.classList.remove('open');
|
|
4591
|
+
activeCustomBtn.setAttribute('aria-expanded', 'false');
|
|
4592
|
+
if (returnFocus) activeCustomBtn.focus();
|
|
4593
|
+
}
|
|
4594
|
+
activeCustomSelect = null;
|
|
4595
|
+
activeCustomBtn = null;
|
|
4596
|
+
activeCustomFocusIdx = -1;
|
|
4597
|
+
}
|
|
4598
|
+
|
|
4599
|
+
function updateCustomSelectTrigger(sel) {
|
|
4600
|
+
if (!sel || !sel._cselectBtn) return;
|
|
4601
|
+
const btn = sel._cselectBtn;
|
|
4602
|
+
const lbl = btn.querySelector('.cselect-label');
|
|
4603
|
+
const opt = sel.options[sel.selectedIndex] || sel.options[0];
|
|
4604
|
+
if (lbl) lbl.textContent = opt ? opt.textContent : '';
|
|
4605
|
+
if (sel.title) btn.title = sel.title;
|
|
4606
|
+
const ariaLbl = sel.getAttribute('aria-label');
|
|
4607
|
+
if (ariaLbl) btn.setAttribute('aria-label', ariaLbl);
|
|
4608
|
+
}
|
|
4609
|
+
|
|
4610
|
+
function setMenuFocusIndex(idx) {
|
|
4611
|
+
const menu = document.getElementById('agfSelectMenu');
|
|
4612
|
+
if (!menu) return;
|
|
4613
|
+
const items = Array.from(menu.querySelectorAll('.cselect-opt'));
|
|
4614
|
+
if (!items.length) return;
|
|
4615
|
+
const clamped = ((idx % items.length) + items.length) % items.length;
|
|
4616
|
+
activeCustomFocusIdx = clamped;
|
|
4617
|
+
items.forEach((el, i) => el.classList.toggle('is-focused', i === clamped));
|
|
4618
|
+
items[clamped]?.scrollIntoView({ block: 'nearest' });
|
|
4619
|
+
}
|
|
4620
|
+
|
|
4621
|
+
function openCustomSelect(sel, btn) {
|
|
4622
|
+
const menu = document.getElementById('agfSelectMenu');
|
|
4623
|
+
if (!menu || !sel || !btn) return;
|
|
4624
|
+
if (activeCustomSelect === sel && menu.classList.contains('open')) {
|
|
4625
|
+
closeCustomSelect(false);
|
|
4626
|
+
return;
|
|
4627
|
+
}
|
|
4628
|
+
if (typeof closeRangePopover === 'function') closeRangePopover();
|
|
4629
|
+
closeCustomSelect(false);
|
|
4630
|
+
|
|
4631
|
+
const isCompact = sel.getAttribute('data-compact') === 'true';
|
|
4632
|
+
const checkSvg = '<svg class="cselect-check" width="13" height="13" viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M3.2 8.4L6.4 11.6L12.8 4.8" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>';
|
|
4633
|
+
|
|
4634
|
+
menu.classList.toggle('is-compact', isCompact);
|
|
4635
|
+
const opts = Array.from(sel.options);
|
|
4636
|
+
menu.innerHTML = opts.map((o, idx) => {
|
|
4637
|
+
const selected = idx === sel.selectedIndex;
|
|
4638
|
+
return '<button type="button" class="cselect-opt' + (selected ? ' is-selected' : '') + '" role="option" aria-selected="' + (selected ? 'true' : 'false') + '" data-idx="' + idx + '">' +
|
|
4639
|
+
'<span class="cselect-opt-text">' + esc(o.textContent || '') + '</span>' + checkSvg +
|
|
4640
|
+
'</button>';
|
|
4641
|
+
}).join('');
|
|
4642
|
+
|
|
4643
|
+
activeCustomSelect = sel;
|
|
4644
|
+
activeCustomBtn = btn;
|
|
4645
|
+
activeCustomFocusIdx = Math.max(0, sel.selectedIndex);
|
|
4646
|
+
btn.classList.add('open');
|
|
4647
|
+
btn.setAttribute('aria-expanded', 'true');
|
|
4648
|
+
menu.setAttribute('aria-hidden', 'false');
|
|
4649
|
+
|
|
4650
|
+
// Position menu cleanly within viewport, flipping upward if near bottom
|
|
4651
|
+
menu.style.visibility = 'hidden';
|
|
4652
|
+
menu.classList.add('open');
|
|
4653
|
+
const rect = btn.getBoundingClientRect();
|
|
4654
|
+
const minW = Math.max(Math.round(rect.width), isCompact ? 112 : 168);
|
|
4655
|
+
menu.style.minWidth = minW + 'px';
|
|
4656
|
+
menu.style.maxWidth = Math.max(minW, Math.min(360, window.innerWidth - 16)) + 'px';
|
|
4657
|
+
const mRect = menu.getBoundingClientRect();
|
|
4658
|
+
const spaceBelow = window.innerHeight - rect.bottom - 10;
|
|
4659
|
+
const spaceAbove = rect.top - 10;
|
|
4660
|
+
let top = rect.bottom + 5;
|
|
4661
|
+
if (spaceBelow < mRect.height && spaceAbove > spaceBelow) {
|
|
4662
|
+
top = Math.max(8, rect.top - mRect.height - 5);
|
|
4663
|
+
}
|
|
4664
|
+
let left = rect.left;
|
|
4665
|
+
if (left + mRect.width > window.innerWidth - 8) {
|
|
4666
|
+
left = Math.max(8, window.innerWidth - mRect.width - 8);
|
|
4667
|
+
}
|
|
4668
|
+
menu.style.top = Math.round(top) + 'px';
|
|
4669
|
+
menu.style.left = Math.round(left) + 'px';
|
|
4670
|
+
menu.style.visibility = '';
|
|
4671
|
+
setMenuFocusIndex(activeCustomFocusIdx);
|
|
4672
|
+
}
|
|
4673
|
+
|
|
4674
|
+
function enhanceCustomSelect(sel) {
|
|
4675
|
+
if (!sel || sel.tagName !== 'SELECT') return;
|
|
4676
|
+
if (sel._cselectBtn && sel._cselectBtn.isConnected) {
|
|
4677
|
+
updateCustomSelectTrigger(sel);
|
|
4678
|
+
return;
|
|
4679
|
+
}
|
|
4680
|
+
const isCompact = sel.getAttribute('data-compact') === 'true';
|
|
4681
|
+
sel.classList.add('cselect-native');
|
|
4682
|
+
sel.setAttribute('tabindex', '-1');
|
|
4683
|
+
const btn = document.createElement('button');
|
|
4684
|
+
btn.type = 'button';
|
|
4685
|
+
btn.className = 'cselect-trigger' + (isCompact ? ' is-compact' : '');
|
|
4686
|
+
btn.setAttribute('aria-haspopup', 'listbox');
|
|
4687
|
+
btn.setAttribute('aria-expanded', 'false');
|
|
4688
|
+
const chevSize = isCompact ? 10 : 12;
|
|
4689
|
+
btn.innerHTML =
|
|
4690
|
+
'<span class="cselect-label"></span>' +
|
|
4691
|
+
'<svg class="cselect-chev" width="' + chevSize + '" height="' + chevSize + '" viewBox="0 0 16 16" fill="none" aria-hidden="true">' +
|
|
4692
|
+
'<path d="M4.2 6.2L8 10L11.8 6.2" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>' +
|
|
4693
|
+
'</svg>';
|
|
4694
|
+
sel.insertAdjacentElement('afterend', btn);
|
|
4695
|
+
sel._cselectBtn = btn;
|
|
4696
|
+
updateCustomSelectTrigger(sel);
|
|
4697
|
+
|
|
4698
|
+
btn.addEventListener('click', (e) => {
|
|
4699
|
+
e.stopPropagation();
|
|
4700
|
+
openCustomSelect(sel, btn);
|
|
4701
|
+
});
|
|
4702
|
+
btn.addEventListener('keydown', (e) => {
|
|
4703
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp' || e.key === 'Enter' || e.key === ' ') {
|
|
4704
|
+
e.preventDefault();
|
|
4705
|
+
e.stopPropagation();
|
|
4706
|
+
if (activeCustomSelect !== sel) {
|
|
4707
|
+
openCustomSelect(sel, btn);
|
|
4708
|
+
} else if (e.key === 'ArrowDown') {
|
|
4709
|
+
setMenuFocusIndex(activeCustomFocusIdx + 1);
|
|
4710
|
+
} else if (e.key === 'ArrowUp') {
|
|
4711
|
+
setMenuFocusIndex(activeCustomFocusIdx - 1);
|
|
4712
|
+
} else if (activeCustomFocusIdx >= 0) {
|
|
4713
|
+
const picked = sel.options[activeCustomFocusIdx];
|
|
4714
|
+
if (picked) {
|
|
4715
|
+
sel.value = picked.value;
|
|
4716
|
+
updateCustomSelectTrigger(sel);
|
|
4717
|
+
sel.dispatchEvent(new Event('change', { bubbles: true }));
|
|
4718
|
+
}
|
|
4719
|
+
closeCustomSelect(true);
|
|
4720
|
+
}
|
|
4721
|
+
}
|
|
4722
|
+
});
|
|
4723
|
+
sel.addEventListener('change', () => updateCustomSelectTrigger(sel));
|
|
4724
|
+
}
|
|
4725
|
+
|
|
4726
|
+
function syncCustomSelects(root) {
|
|
4727
|
+
const scope = root || document;
|
|
4728
|
+
scope.querySelectorAll('select').forEach((s) => enhanceCustomSelect(s));
|
|
4729
|
+
}
|
|
4730
|
+
|
|
4731
|
+
document.getElementById('agfSelectMenu')?.addEventListener('click', (e) => {
|
|
4732
|
+
e.stopPropagation();
|
|
4733
|
+
const optBtn = e.target.closest('.cselect-opt');
|
|
4734
|
+
if (!optBtn || !activeCustomSelect) return;
|
|
4735
|
+
const idx = Number(optBtn.getAttribute('data-idx'));
|
|
4736
|
+
const opt = activeCustomSelect.options[idx];
|
|
4737
|
+
if (opt) {
|
|
4738
|
+
const changed = activeCustomSelect.value !== opt.value;
|
|
4739
|
+
activeCustomSelect.value = opt.value;
|
|
4740
|
+
updateCustomSelectTrigger(activeCustomSelect);
|
|
4741
|
+
if (changed) activeCustomSelect.dispatchEvent(new Event('change', { bubbles: true }));
|
|
4742
|
+
}
|
|
4743
|
+
closeCustomSelect(true);
|
|
4744
|
+
});
|
|
4745
|
+
|
|
4746
|
+
window.addEventListener('resize', () => closeCustomSelect(false));
|
|
4747
|
+
document.getElementById('adminContent')?.addEventListener('scroll', () => closeCustomSelect(false), { passive: true });
|
|
4748
|
+
|
|
4749
|
+
const ALLOWED_REFRESH_SECS = [0, 10, 15, 30, 60, 300];
|
|
4750
|
+
let autoRefreshSec = (() => {
|
|
4751
|
+
const raw = localStorage.getItem('agf_refresh_sec');
|
|
4752
|
+
if (raw === null || raw === '') return 30;
|
|
4753
|
+
const n = Number(raw);
|
|
4754
|
+
return ALLOWED_REFRESH_SECS.includes(n) ? n : 30;
|
|
4755
|
+
})();
|
|
4756
|
+
let autoRefreshTimer = null;
|
|
4757
|
+
let lastBoardFetchedAt = 0;
|
|
4758
|
+
|
|
4759
|
+
function formatRefreshLabel(sec) {
|
|
4760
|
+
if (!sec) return lang === 'zh' ? '关闭' : 'Off';
|
|
4761
|
+
if (sec < 60) return sec + 's';
|
|
4762
|
+
return Math.round(sec / 60) + 'm';
|
|
4763
|
+
}
|
|
4764
|
+
|
|
4765
|
+
function scheduleAutoRefresh() {
|
|
4766
|
+
if (autoRefreshTimer) {
|
|
4767
|
+
clearInterval(autoRefreshTimer);
|
|
4768
|
+
autoRefreshTimer = null;
|
|
4769
|
+
}
|
|
4770
|
+
const sel = document.getElementById('autoRefreshSelect');
|
|
4771
|
+
if (sel && String(sel.value) !== String(autoRefreshSec)) sel.value = String(autoRefreshSec);
|
|
4772
|
+
if (sel) updateCustomSelectTrigger(sel);
|
|
4773
|
+
const dot = document.getElementById('syncDot');
|
|
4774
|
+
if (dot) dot.classList.toggle('paused', autoRefreshSec <= 0);
|
|
4775
|
+
if (autoRefreshSec > 0) {
|
|
4776
|
+
autoRefreshTimer = setInterval(() => {
|
|
4777
|
+
if (document.hidden) return;
|
|
4778
|
+
fetchBoard({ silent: true });
|
|
4779
|
+
}, autoRefreshSec * 1000);
|
|
4780
|
+
}
|
|
4781
|
+
}
|
|
4782
|
+
|
|
4783
|
+
document.getElementById('autoRefreshSelect')?.addEventListener('change', (ev) => {
|
|
4784
|
+
const n = Number(ev.target.value);
|
|
4785
|
+
autoRefreshSec = ALLOWED_REFRESH_SECS.includes(n) ? n : 30;
|
|
4786
|
+
localStorage.setItem('agf_refresh_sec', String(autoRefreshSec));
|
|
4787
|
+
scheduleAutoRefresh();
|
|
4788
|
+
showToast(
|
|
4789
|
+
autoRefreshSec > 0
|
|
4790
|
+
? (lang === 'zh' ? '已设为每 ' + formatRefreshLabel(autoRefreshSec) + ' 自动刷新' : 'Auto-refresh set to every ' + formatRefreshLabel(autoRefreshSec))
|
|
4791
|
+
: (lang === 'zh' ? '已关闭自动刷新' : 'Auto-refresh turned off'),
|
|
4792
|
+
);
|
|
4793
|
+
});
|
|
4794
|
+
|
|
4795
|
+
document.addEventListener('visibilitychange', () => {
|
|
4796
|
+
if (!document.hidden && autoRefreshSec > 0 && Date.now() - lastBoardFetchedAt >= autoRefreshSec * 1000) {
|
|
4797
|
+
fetchBoard({ silent: true });
|
|
4798
|
+
}
|
|
4799
|
+
});
|
|
4800
|
+
|
|
4801
|
+
document.getElementById('refreshBtn')?.addEventListener('click', () => {
|
|
4802
|
+
fetchBoard();
|
|
4803
|
+
scheduleAutoRefresh();
|
|
4804
|
+
});
|
|
4259
4805
|
|
|
4260
4806
|
function fmtShortDate(isoKey) {
|
|
4261
4807
|
const parts = String(isoKey || '').split('-');
|
|
@@ -4407,6 +4953,7 @@ function renderRangeCalendar() {
|
|
|
4407
4953
|
}
|
|
4408
4954
|
|
|
4409
4955
|
function openRangePopover() {
|
|
4956
|
+
closeCustomSelect(false);
|
|
4410
4957
|
const picker = document.getElementById('rangePicker');
|
|
4411
4958
|
const trigger = document.getElementById('rangeTrigger');
|
|
4412
4959
|
if (!picker || !trigger) return;
|
|
@@ -4445,8 +4992,55 @@ document.getElementById('rangePopover')?.addEventListener('click', (e) => {
|
|
|
4445
4992
|
|
|
4446
4993
|
document.addEventListener('click', () => {
|
|
4447
4994
|
closeRangePopover();
|
|
4995
|
+
closeCustomSelect(false);
|
|
4448
4996
|
});
|
|
4449
4997
|
document.addEventListener('keydown', (e) => {
|
|
4998
|
+
if (confirmResolver) {
|
|
4999
|
+
if (e.key === 'Escape') {
|
|
5000
|
+
e.preventDefault();
|
|
5001
|
+
resolveConfirmDialog(false);
|
|
5002
|
+
}
|
|
5003
|
+
return;
|
|
5004
|
+
}
|
|
5005
|
+
if (activeCustomSelect) {
|
|
5006
|
+
if (e.key === 'Escape') {
|
|
5007
|
+
e.preventDefault();
|
|
5008
|
+
closeCustomSelect(true);
|
|
5009
|
+
return;
|
|
5010
|
+
}
|
|
5011
|
+
if (e.key === 'ArrowDown') {
|
|
5012
|
+
e.preventDefault();
|
|
5013
|
+
setMenuFocusIndex(activeCustomFocusIdx + 1);
|
|
5014
|
+
return;
|
|
5015
|
+
}
|
|
5016
|
+
if (e.key === 'ArrowUp') {
|
|
5017
|
+
e.preventDefault();
|
|
5018
|
+
setMenuFocusIndex(activeCustomFocusIdx - 1);
|
|
5019
|
+
return;
|
|
5020
|
+
}
|
|
5021
|
+
if (e.key === 'Home') {
|
|
5022
|
+
e.preventDefault();
|
|
5023
|
+
setMenuFocusIndex(0);
|
|
5024
|
+
return;
|
|
5025
|
+
}
|
|
5026
|
+
if (e.key === 'End') {
|
|
5027
|
+
e.preventDefault();
|
|
5028
|
+
setMenuFocusIndex(activeCustomSelect.options.length - 1);
|
|
5029
|
+
return;
|
|
5030
|
+
}
|
|
5031
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
5032
|
+
e.preventDefault();
|
|
5033
|
+
const opt = activeCustomSelect.options[activeCustomFocusIdx];
|
|
5034
|
+
if (opt) {
|
|
5035
|
+
const changed = activeCustomSelect.value !== opt.value;
|
|
5036
|
+
activeCustomSelect.value = opt.value;
|
|
5037
|
+
updateCustomSelectTrigger(activeCustomSelect);
|
|
5038
|
+
if (changed) activeCustomSelect.dispatchEvent(new Event('change', { bubbles: true }));
|
|
5039
|
+
}
|
|
5040
|
+
closeCustomSelect(true);
|
|
5041
|
+
return;
|
|
5042
|
+
}
|
|
5043
|
+
}
|
|
4450
5044
|
if (e.key === 'Escape') closeRangePopover();
|
|
4451
5045
|
});
|
|
4452
5046
|
|
|
@@ -4807,8 +5401,8 @@ document.getElementById('testWebhookBtn').addEventListener('click', async () =>
|
|
|
4807
5401
|
});
|
|
4808
5402
|
|
|
4809
5403
|
applyI18n();
|
|
5404
|
+
scheduleAutoRefresh();
|
|
4810
5405
|
fetchBoard();
|
|
4811
|
-
setInterval(() => fetchBoard({ silent: true }), 60000);
|
|
4812
5406
|
</script>
|
|
4813
5407
|
</body>
|
|
4814
5408
|
</html>`;
|