Repository navigation
Expand file tree
/
Copy pathdashboard.html
More file actions
2035 lines (1899 loc) · 108 KB
/
Copy pathdashboard.html
File metadata and controls
2035 lines (1899 loc) · 108 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="zh-CN" data-theme="light">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>ZCode2API · 控制台</title>
<style>
:root,
[data-theme="light"] {
--bg-canvas: #fafaf8;
--bg-surface: #f2f1ee;
--bg-surface-inner: #ffffff;
--bg-surface-hover: #eae8e3;
--bg-elevated: rgba(255, 255, 255, 0.9);
--border-subtle: rgba(20, 20, 19, 0.07);
--border-strong: rgba(20, 20, 19, 0.14);
--border-focus: #d96b16;
--text-primary: #141413;
--text-secondary: #5f5e59;
--text-muted: #8c8a82;
--brand: #d96b16;
--brand-hover: #c25d10;
--brand-soft: #f7e6d5;
--brand-text: #9a4708;
--ok: #0d9456;
--ok-soft: #e3f5ec;
--ok-border: rgba(13, 148, 86, 0.22);
--daily: #0277bd;
--daily-soft: #e1f1fb;
--daily-border: rgba(2, 119, 189, 0.22);
--warn: #d97706;
--warn-soft: #fef3c7;
--warn-border: rgba(217, 119, 6, 0.26);
--bad: #dc2626;
--bad-soft: #fee2e2;
--bad-border: rgba(220, 38, 38, 0.24);
--shadow-card: 0 1px 2px rgba(20, 20, 19, 0.03);
--shadow-float: 0 12px 36px rgba(20, 20, 19, 0.10), 0 2px 8px rgba(20, 20, 19, 0.05);
--scrim: rgba(20, 20, 19, 0.42);
--bar-track: #e7e5e0;
}
[data-theme="dark"] {
--bg-canvas: #0b0c0e;
--bg-surface: #131519;
--bg-surface-inner: #191c22;
--bg-surface-hover: #21252d;
--bg-elevated: rgba(25, 28, 34, 0.9);
--border-subtle: rgba(255, 255, 255, 0.07);
--border-strong: rgba(255, 255, 255, 0.14);
--border-focus: #f59e0b;
--text-primary: #f2f3f5;
--text-secondary: #9ca1ab;
--text-muted: #6c717b;
--brand: #f59e0b;
--brand-hover: #d97706;
--brand-soft: rgba(245, 158, 11, 0.15);
--brand-text: #fbbf24;
--ok: #10b981;
--ok-soft: rgba(16, 185, 129, 0.14);
--ok-border: rgba(16, 185, 129, 0.28);
--daily: #38bdf8;
--daily-soft: rgba(56, 189, 248, 0.14);
--daily-border: rgba(56, 189, 248, 0.28);
--warn: #fbbf24;
--warn-soft: rgba(251, 191, 36, 0.15);
--warn-border: rgba(251, 191, 36, 0.3);
--bad: #f87171;
--bad-soft: rgba(248, 113, 113, 0.15);
--bad-border: rgba(248, 113, 113, 0.3);
--shadow-card: 0 1px 2px rgba(0, 0, 0, 0.25);
--shadow-float: 0 16px 40px rgba(0, 0, 0, 0.55), 0 2px 10px rgba(0, 0, 0, 0.35);
--scrim: rgba(5, 6, 8, 0.7);
--bar-track: #262a32;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg-canvas); color: var(--text-primary); }
body {
font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
padding: 22px 32px 108px;
max-width: 1520px;
margin: 0 auto;
overflow-x: hidden;
}
@media (max-width: 640px) { body { padding: 14px 14px 100px; } }
button, input, a, [tabindex="0"] {
transition: background-color 150ms cubic-bezier(0.16, 1, 0.3, 1),
border-color 150ms cubic-bezier(0.16, 1, 0.3, 1),
color 150ms cubic-bezier(0.16, 1, 0.3, 1),
opacity 150ms cubic-bezier(0.16, 1, 0.3, 1),
transform 120ms cubic-bezier(0.16, 1, 0.3, 1);
}
button:focus-visible, input:focus-visible, a:focus-visible, [tabindex="0"]:focus-visible, select:focus-visible {
outline: 2px solid var(--border-focus);
outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.num { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--text-secondary); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.icon { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.75; fill: none; flex: none; }
.icon-sm { width: 14px; height: 14px; }
/* ── Top utility bar ── */
.topbar { display: flex; justify-content: flex-end; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.pill-btn {
display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px;
border-radius: 999px; background: var(--bg-surface); border: 1px solid var(--border-subtle);
color: var(--text-secondary); font-size: 13px; font-weight: 500; cursor: pointer;
}
.pill-btn:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.kbd {
display: inline-block; padding: 1px 7px; border-radius: 999px; background: var(--bg-surface-inner);
border: 1px solid var(--border-subtle); font-size: 12px; color: var(--text-muted);
font-family: ui-monospace, "SF Mono", Consolas, monospace;
}
/* ── Tab bar 移除,合并入底栏 ── */
.tabbar { display: none !important; }
.panel { display: none; }
.panel.active { display: block; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 23px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 4px; text-wrap: balance; }
.page-head p { margin: 0; color: var(--text-secondary); font-size: 13px; text-wrap: pretty; }
/* ── KPI ── */
.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
@media (max-width: 1480px) { .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1000px) { .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .kpi-grid { grid-template-columns: 1fr; } }
.kpi-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1180px) { .kpi-grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .kpi-grid.four { grid-template-columns: 1fr; } }
.bento { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: 18px; padding: 18px 20px; }
.kpi-top { display: flex; justify-content: space-between; align-items: center; color: var(--text-secondary); font-size: 13px; font-weight: 500; margin-bottom: 10px; }
.kpi-ico {
width: 32px; height: 32px; border-radius: 999px; background: var(--bg-surface-inner);
border: 1px solid var(--border-subtle); display: inline-flex; align-items: center; justify-content: center; color: var(--text-secondary);
}
.kpi-ico.ok { color: var(--ok); } .kpi-ico.brand { color: var(--brand); } .kpi-ico.daily { color: var(--daily); }
.kpi-val {
font-size: clamp(23px, 1.75vw, 28px); font-weight: 700; letter-spacing: -0.03em; line-height: 1.15;
margin-bottom: 8px; display: flex; align-items: baseline; gap: 8px; row-gap: 5px; flex-wrap: wrap;
}
.kpi-val.ok { color: var(--ok); } .kpi-val.brand { color: var(--brand); } .kpi-val.daily { color: var(--daily); }
.kpi-pill { font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-text); white-space: nowrap; }
.kpi-sub { font-size: 12px; color: var(--text-secondary); line-height: 1.45; text-wrap: pretty; }
.kpi-sub.ok { color: var(--ok); font-weight: 500; } .kpi-sub.brand { color: var(--brand); }
.overview-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; margin-bottom: 16px; }
@media (max-width: 1100px) { .overview-grid { grid-template-columns: 1fr; } }
.overview-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .overview-grid.three { grid-template-columns: 1fr; } }
.overview-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1100px) { .overview-grid.two { grid-template-columns: 1fr; } }
/* 隐私模式:昵称列模糊 */
body.privacy .acc-subname { filter: blur(4px); user-select: none; }
/* ── 安全面板 ── */
.sec-toggles { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.switch-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; font-weight: 600; }
.switch-hint { display: block; font-size: 12px; color: var(--text-secondary); font-weight: 400; margin-top: 2px; }
.toggle { width: 44px; height: 25px; border-radius: 13px; border: 1px solid var(--border-strong); background: var(--bg-inset); position: relative; cursor: pointer; flex: none; transition: background .18s; }
.toggle i { position: absolute; top: 2px; left: 2px; width: 19px; height: 19px; border-radius: 50%; background: var(--text-secondary); transition: transform .18s, background .18s; }
.toggle.on { background: var(--ok); border-color: var(--ok); }
.toggle.on i { transform: translateX(19px); background: #fff; }
.sec-add-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.btn-danger { color: var(--bad, #d92d20); border-color: var(--bad, #d92d20); }
.bento-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.bento-title { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; }
.bento-meta { font-size: 12px; color: var(--text-secondary); }
.subcards-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 760px) { .subcards-3 { grid-template-columns: 1fr; } }
.subcard { background: var(--bg-surface-inner); border: 1px solid var(--border-subtle); border-radius: 14px; padding: 14px 16px; }
.subcard-lbl { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
.subcard-val { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 6px; }
.subcard-foot { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.bar { height: 6px; background: var(--bar-track); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--ok); }
.bar.brand > i { background: var(--brand); }
.bar.daily > i { background: var(--daily); }
.gw-list { display: flex; flex-direction: column; gap: 9px; }
.gw-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--text-secondary); }
.gw-row b { color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; }
.gw-row b.ok { color: var(--ok); }
.gw-row b.warn { color: var(--warn); }
/* ── Buttons ── */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn {
display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px;
padding: 0 15px; border-radius: 10px; background: var(--bg-surface); border: 1px solid var(--border-subtle);
color: var(--text-primary); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--bg-surface-hover); border-color: var(--border-strong); }
.btn:active:not(:disabled) { transform: scale(0.985); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--text-primary); color: var(--bg-canvas); border-color: var(--text-primary); font-weight: 600; }
.btn-primary:hover:not(:disabled) { opacity: .9; background: var(--text-primary); }
.btn-brand { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 600; }
.btn-brand:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-sm { min-height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn-danger { color: var(--bad); border-color: var(--bad-border); background: var(--bad-soft); }
.btn-danger:hover:not(:disabled) { background: var(--bad-soft); border-color: var(--bad); }
.link-btn { background: none; border: none; padding: 0; color: var(--brand); font-size: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.link-btn:hover { color: var(--brand-hover); }
/* ── Segment control ── */
.seg { display: inline-flex; align-items: center; padding: 3px; border-radius: 999px; background: var(--bg-surface); border: 1px solid var(--border-subtle); gap: 2px; }
.seg > button {
height: 30px; padding: 0 14px; border-radius: 999px; border: none; background: transparent;
color: var(--text-secondary); font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.seg > button:hover { color: var(--text-primary); }
.seg > button[aria-pressed="true"] { background: var(--bg-surface-inner); color: var(--text-primary); box-shadow: var(--shadow-card); }
/* ── Table ── */
.table-wrap { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: 18px; overflow: hidden; }
.table-scroll { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 720px; }
table.tbl th {
text-align: left; font-weight: 600; font-size: 12px; color: var(--text-secondary);
padding: 12px 14px; background: var(--bg-surface-inner); border-bottom: 1px solid var(--border-subtle); white-space: nowrap;
}
table.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover td { background: var(--bg-surface-hover); }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 12.5px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px;
font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid transparent;
}
.badge-cn { background: var(--brand-soft); color: var(--brand-text); border-color: var(--warn-border); }
.badge-intl { background: var(--daily-soft); color: var(--daily); border-color: var(--daily-border); }
.badge-unknown { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-border); cursor: pointer; }
.badge-promo { background: var(--brand-soft); color: var(--brand-text); }
.badge-daily { background: var(--daily-soft); color: var(--daily); }
.badge-paid, .badge-offpeak, .badge-other { background: var(--ok-soft); color: var(--ok); }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-border); }
.badge-off { background: var(--bg-surface-hover); color: var(--text-muted); }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-border); }
.badge-bad { background: var(--bad-soft); color: var(--bad); border-color: var(--bad-border); }
.badge-plain { background: var(--bg-surface-inner); color: var(--text-secondary); border-color: var(--border-subtle); }
/* ── Chart ── */
.chart { display: flex; align-items: flex-end; gap: 2px; height: 120px; margin-top: 6px; }
.chart .col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; position: relative; }
.chart .col > i {
display: block; width: 100%; max-width: 16px; margin: 0 auto;
background: var(--brand); border-radius: 3px 3px 0 0; opacity: .85; min-height: 0;
}
.chart .col:hover > i { opacity: 1; }
.chart .col.has-fail > i { background: var(--bad); }
.chart-x { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.chart-empty { display: flex; align-items: center; justify-content: center; height: 120px; color: var(--text-muted); font-size: 12.5px; }
/* ── Accounts ── */
.filter-strip { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.group-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.group-pill {
display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 13px; border-radius: 999px;
background: var(--bg-surface); border: 1px solid var(--border-subtle); color: var(--text-secondary);
font-size: 12.5px; font-weight: 500; cursor: pointer;
}
.group-pill[aria-pressed="true"] { background: var(--text-primary); color: var(--bg-canvas); border-color: var(--text-primary); font-weight: 600; }
.search-box { position: relative; width: 260px; flex: 0 0 260px; }
@media (max-width: 640px) { .search-box { width: 100%; flex: 1 1 100%; } }
.search-box input {
width: 100%; height: 34px; padding: 0 12px 0 32px; border-radius: 999px; background: var(--bg-surface);
border: 1px solid var(--border-subtle); color: var(--text-primary); font-size: 12.5px;
}
.search-box svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.acc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(430px, 1fr)); gap: 14px; }
@media (max-width: 520px) { .acc-grid { grid-template-columns: 1fr; } }
.acc-card { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.acc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.acc-id-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.status-dot { width: 10px; height: 10px; border-radius: 999px; background: var(--ok); flex: none; box-shadow: 0 0 0 3px var(--ok-soft); }
.status-dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.acc-ident { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.acc-ident-btn {
background: var(--warn-soft); color: var(--warn); border: 1px dashed var(--warn-border); border-radius: 8px;
padding: 4px 10px; font-size: 13px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.acc-subname { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.quota-box { background: var(--bg-surface-inner); border: 1px solid var(--border-subtle); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.q-item { display: flex; flex-direction: column; gap: 5px; }
.q-item + .q-item { padding-top: 9px; border-top: 1px solid var(--border-subtle); }
.q-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; }
.q-left { display: flex; align-items: center; gap: 7px; min-width: 0; font-weight: 600; }
.q-right { font-size: 12.5px; color: var(--text-secondary); white-space: nowrap; }
.q-right b { color: var(--text-primary); }
.plan-strip { display: flex; flex-wrap: wrap; gap: 6px; }
.plan-tag {
display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 8px;
background: var(--bg-surface-inner); border: 1px solid var(--border-subtle); font-size: 12px; color: var(--text-secondary);
}
.plan-tag i { width: 6px; height: 6px; border-radius: 999px; background: var(--ok); }
.acc-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }
.acc-meta { font-size: 12px; color: var(--text-secondary); }
.acc-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ident-hint {
display: flex; align-items: flex-start; gap: 7px; padding: 9px 12px; border-radius: 10px;
background: var(--warn-soft); border: 1px solid var(--warn-border); color: var(--warn); font-size: 12.5px; line-height: 1.5;
}
.ident-hint svg { margin-top: 2px; }
.onboard-card { background: var(--bg-surface); border: 1.5px solid var(--brand); border-radius: 18px; padding: 18px 20px; margin-bottom: 16px; }
.empty-state { background: var(--bg-surface); border: 1px dashed var(--border-strong); border-radius: 18px; padding: 36px 24px; text-align: center; color: var(--text-secondary); }
/* ── Dock (完全参考 wb2api 的悬浮底栏) ── */
.dock-wrap { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 40; }
.dock {
display: inline-flex; align-items: center; gap: 4px; padding: 5px 8px; border-radius: 999px;
background: var(--bg-elevated); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
border: 1px solid var(--border-strong); box-shadow: var(--shadow-float);
}
.dock-btn {
display: inline-flex; align-items: center; justify-content: center;
width: 40px; height: 40px; border-radius: 999px; border: 1px solid transparent;
background: transparent; color: var(--text-secondary); cursor: pointer; position: relative;
}
.dock-btn:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.dock-btn.active {
background: #d1fae5; color: #047857; border-color: #a7f3d0;
}
[data-theme="dark"] .dock-btn.active {
background: rgba(16, 185, 129, 0.2); color: #34d399; border-color: rgba(16, 185, 129, 0.4);
}
.dock-sep { width: 1px; height: 20px; background: var(--border-subtle); margin: 0 2px; }
/* ── Toast ── */
#toasts {
position: fixed; top: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column;
gap: 8px; z-index: 50; align-items: center; pointer-events: none; width: max-content; max-width: 92vw;
}
.toast {
pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; min-width: 280px;
max-width: min(560px, 92vw); background: var(--bg-surface-inner); border: 1px solid var(--border-strong);
border-radius: 14px; padding: 12px 16px; color: var(--text-primary); box-shadow: var(--shadow-float);
animation: toast-in 160ms cubic-bezier(0.16, 1, 0.3, 1);
}
.toast-ico { width: 22px; height: 22px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; flex: none; margin-top: 1px; }
.toast.ok .toast-ico { background: var(--ok-soft); color: var(--ok); }
.toast.warn .toast-ico { background: var(--warn-soft); color: var(--warn); }
.toast.err .toast-ico { background: var(--bad-soft); color: var(--bad); }
.toast .t-title { font-weight: 600; font-size: 13.5px; }
.toast .t-body { color: var(--text-secondary); font-size: 12.5px; margin-top: 2px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
/* ── Modal ── */
.modal-bg {
position: fixed; inset: 0; background: var(--scrim); backdrop-filter: blur(4px);
display: flex; align-items: center; justify-content: center; z-index: 45; padding: 16px;
}
.modal {
background: var(--bg-surface-inner); border: 1px solid var(--border-strong); border-radius: 18px;
padding: 22px; width: min(620px, 94vw); max-height: 86vh; overflow-y: auto; box-shadow: var(--shadow-float);
}
.modal .grid-2 {
display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; align-items: start;
}
@media (max-width: 640px) { .modal .grid-2 { grid-template-columns: 1fr; } }
.modal .sect-label {
font-size: 12.5px; font-weight: 700; color: var(--brand); margin: 14px 0 4px;
grid-column: 1 / -1;
}
.modal .hint { font-size: 12px; color: var(--text-muted); margin-top: 3px; line-height: 1.4; }
.modal h3 { margin: 0 0 6px; font-size: 17px; font-weight: 700; }
.modal p { margin: 0 0 14px; color: var(--text-secondary); font-size: 13px; }
.modal label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); margin: 12px 0 6px; }
.modal input, .modal select {
width: 100%; height: 40px; background: var(--bg-surface); border: 1px solid var(--border-subtle);
border-radius: 10px; color: var(--text-primary); padding: 0 12px; font-size: 14px;
}
.modal .hint { font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
pre.codebox {
background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: 12px;
padding: 12px 14px; font-size: 12px; overflow-x: auto; margin: 8px 0 0; color: var(--text-primary);
font-family: ui-monospace, "SF Mono", Consolas, monospace; word-break: break-all; white-space: pre-wrap;
}
</style>
</head>
<body>
<header class="topbar" role="banner">
<button class="pill-btn" id="btn-cmdk" type="button" aria-label="打开快捷命令面板">
<svg class="icon icon-sm" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>
<span>搜索与命令</span><span class="kbd">Ctrl K</span>
</button>
<button class="pill-btn" id="btn-theme" type="button" aria-label="切换浅色或深色外观">
<svg class="icon icon-sm" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"/></svg>
<span id="lbl-theme">浅色外观</span>
</button>
<button class="pill-btn" id="btn-privacy" type="button" aria-label="切换隐私模式(脱敏)" title="隐私模式:脱敏邮箱/手机号/昵称,方便截图分享">
<svg class="icon icon-sm" viewBox="0 0 24 24" aria-hidden="true"><path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"/><line x1="1" y1="1" x2="23" y2="23"/></svg>
<span id="lbl-privacy">隐私模式</span>
</button>
<div class="seg" role="tablist" aria-label="账号归属筛选">
<button type="button" data-realm-tab="all" aria-pressed="true">全部 <span class="num" id="tab-cnt-all">0</span></button>
<button type="button" data-realm-tab="cn" aria-pressed="false">国内 <span class="num" id="tab-cnt-cn">0</span></button>
<button type="button" data-realm-tab="intl" aria-pressed="false">国际 <span class="num" id="tab-cnt-intl">0</span></button>
</div>
</header>
<main>
<!-- ══════ 仪表盘 ══════ -->
<section class="panel active" id="panel-dashboard" role="tabpanel" aria-labelledby="tab-dashboard">
<div class="page-head">
<div>
<h1>仪表盘</h1>
<p id="dash-sub">账号池健康度、反代网关与今日用量总览(每 30 秒自动刷新)</p>
</div>
</div>
<div class="kpi-grid">
<div class="bento">
<div class="kpi-top"><span>账号总数</span>
<span class="kpi-ico" aria-hidden="true"><svg class="icon" viewBox="0 0 24 24"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75"/></svg></span>
</div>
<div class="kpi-val num" id="kpi-total">—</div>
<div class="kpi-sub" id="kpi-total-sub">正在读取账号池…</div>
</div>
<div class="bento">
<div class="kpi-top"><span>有效期内</span>
<span class="kpi-ico ok" aria-hidden="true"><svg class="icon" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="m9 12 2 2 4-4"/></svg></span>
</div>
<div class="kpi-val ok num" id="kpi-avail">—</div>
<div class="kpi-sub ok" id="kpi-avail-sub">—</div>
</div>
<div class="bento">
<div class="kpi-top"><span>即将过期</span>
<span class="kpi-ico" style="color:var(--ok)" aria-hidden="true"><svg class="icon" viewBox="0 0 24 24"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg></span>
</div>
<div class="kpi-val ok num" id="kpi-expiring">0</div>
<div class="kpi-sub" id="kpi-expiring-sub">暂无风险</div>
</div>
<div class="bento">
<div class="kpi-top"><span>臭鸡蛋余额</span>
<span class="kpi-ico brand" aria-hidden="true"><svg class="icon" viewBox="0 0 24 24"><path d="M20 12v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8"/><rect x="2" y="7" width="20" height="5" rx="1"/><path d="M12 22V7M12 7H7.5a2.5 2.5 0 1 1 0-5C11 2 12 7 12 7ZM12 7h4.5a2.5 2.5 0 0 0 0-5C13 2 12 7 12 7Z"/></svg></span>
</div>
<div class="kpi-val brand num">
<span id="kpi-promo">—</span>
<span class="kpi-pill" id="kpi-promo-pill" style="display:none"></span>
</div>
<div class="kpi-sub brand" id="kpi-promo-sub">GLM-5.3-Flash 专项额度</div>
</div>
<div class="bento">
<div class="kpi-top"><span>今日 Token</span>
<span class="kpi-ico daily" aria-hidden="true"><svg class="icon" viewBox="0 0 24 24"><path d="M13 2 3 14h9l-1 8 10-12h-9l1-8Z"/></svg></span>
</div>
<div class="kpi-val daily num" id="kpi-today">—</div>
<div class="kpi-sub" id="kpi-today-sub">—</div>
</div>
</div>
<!-- 近 14 天调用趋势 + 反代上游 -->
<div class="overview-grid" style="grid-template-columns: 2fr 1fr; margin-bottom: 16px">
<div class="bento" style="display:flex; flex-direction:column; justify-content:space-between">
<div>
<div class="bento-head">
<div class="bento-title">
<span>近 14 天调用趋势</span>
</div>
<span class="bento-meta" id="trend-14d-meta">近 14 天 0 次失败 · 全部版本</span>
</div>
<div id="trend-14d-chart" style="height: 220px"></div>
</div>
</div>
<div class="bento">
<div class="bento-head">
<div class="bento-title">
<svg class="icon" viewBox="0 0 24 24" aria-hidden="true"><rect x="2" y="3" width="20" height="7" rx="2"/><rect x="2" y="14" width="20" height="7" rx="2"/><circle cx="6" cy="6.5" r="1"/><circle cx="6" cy="17.5" r="1"/></svg>
<span>反代上游</span>
</div>
<span class="bento-meta">127.0.0.1:8787</span>
</div>
<div class="gw-list">
<div class="gw-row"><span>连接状态</span><b class="ok">● 正常</b></div>
<div class="gw-row"><span>健康账号</span><b id="gw-healthy">—</b></div>
<div class="gw-row"><span>冷却中</span><b id="gw-cooling">0</b></div>
<div class="gw-row"><span>连败降权</span><b id="gw-degraded">0</b></div>
<div class="gw-row"><span>已禁用</span><b id="gw-disabled">0</b></div>
<div class="gw-row"><span>在途请求</span><b id="gw-inflight">0</b></div>
<div class="gw-row"><span>粘性会话</span><b id="gw-sticky">0</b></div>
<div class="gw-row"><span>对外密钥</span><b id="gw-keys">0</b></div>
<div class="gw-row"><span>默认模型</span><b id="gw-model">GLM-5.3-Flash</b></div>
</div>
</div>
</div>
<!-- 额度分类总览 (对应 wb2api 的积分收支卡片位置) -->
<div class="bento" style="margin-bottom: 16px">
<div class="bento-head">
<div class="bento-title">
<svg class="icon" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="3"/><path d="M3 9h18M9 21V9"/></svg>
<span>额度分类总览</span>
</div>
<span class="bento-meta" id="quota-meta">按套餐类型与模型实时聚合</span>
</div>
<div class="subcards-3" id="quota-subcards"><div class="subcard"><div class="subcard-lbl">正在加载…</div></div></div>
<div style="display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:8px;margin-top:14px;padding-top:12px;border-top:1px solid var(--border-subtle);font-size:12.5px;color:var(--text-secondary)">
<span>同会话 30 分钟粘性路由(保 prompt 缓存命中);遇限流自动换号</span>
<span class="num" id="last-sync">—</span>
</div>
</div>
<!-- 账号健康快照 (底栏 3 列网格卡片) -->
<div class="bento">
<div class="bento-head">
<div class="bento-title">
<span>账号健康快照</span>
<span class="num" id="snap-online" style="font-size: 12px; font-weight: 600; color: var(--ok); margin-left: 6px">● 在线 0</span>
<span class="num" id="snap-cooling" style="font-size: 12px; font-weight: 600; color: var(--warn); margin-left: 4px">● 冷却中 0</span>
</div>
<button type="button" class="btn btn-sm" onclick="goTab('accounts')" style="height: 28px; padding: 0 10px; font-size: 12px">管理账号 →</button>
</div>
<div id="acc-snapshot-grid" style="display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px"></div>
</div>
</section>
<!-- ══════ 账号 ══════ -->
<section class="panel" id="panel-accounts" role="tabpanel" aria-labelledby="tab-accounts">
<div class="page-head">
<div>
<h1>账号管理</h1>
<p>国内显示脱敏手机号,国际显示邮箱;展示每项额度剩余与到期时间</p>
</div>
<div class="toolbar">
<button class="btn" id="btn-mask" type="button" title="脱敏邮箱/手机号/昵称,方便截图分享">
<svg class="icon icon-sm" viewBox="0 0 24 24" aria-hidden="true"><path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"/><line x1="1" y1="1" x2="23" y2="23"/></svg>
<span id="lbl-mask">脱敏</span>
</button>
<button class="btn" id="btn-reset" type="button">
<svg class="icon icon-sm" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/></svg>
<span>解除冷却</span>
</button>
<button class="btn" id="btn-refresh" type="button">
<svg class="icon icon-sm" viewBox="0 0 24 24" aria-hidden="true"><path d="M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16"/><path d="M16 16h5v5"/></svg>
<span>刷新余额</span>
</button>
<button class="btn" id="btn-claim-all" type="button">
<svg class="icon icon-sm" viewBox="0 0 24 24" aria-hidden="true"><path d="M20 12v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8"/><rect x="2" y="7" width="20" height="5" rx="1"/><path d="M12 22V7"/></svg>
<span>一键领取全部</span>
</button>
<button class="btn" id="btn-pool-settings" type="button">
<svg class="icon icon-sm" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1Z"/></svg>
<span>轮换设置</span>
</button>
<button class="btn" id="btn-paste-jwt" type="button">
<svg class="icon icon-sm" viewBox="0 0 24 24" aria-hidden="true"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/><rect x="8" y="2" width="8" height="4" rx="1"/></svg>
<span>粘贴 Token</span>
</button>
<button class="btn btn-brand" id="btn-onboard" type="button">
<svg class="icon icon-sm" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg>
<span>登录新账号并领取</span>
</button>
</div>
</div>
<div id="onboard-box" hidden></div>
<div class="filter-strip">
<div class="group-pills" role="group" aria-label="账号分组筛选">
<button class="group-pill" data-filter="all" aria-pressed="true" type="button">全部账号</button>
<button class="group-pill" data-filter="cn" aria-pressed="false" type="button">国内 · 手机号</button>
<button class="group-pill" data-filter="intl" aria-pressed="false" type="button">国际 · 邮箱</button>
</div>
<div class="search-box">
<svg class="icon icon-sm" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>
<label for="inp-search" class="sr-only">筛选账号</label>
<input id="inp-search" type="search" placeholder="筛选手机号、邮箱或备注…">
</div>
</div>
<div class="acc-grid" id="acc-grid"></div>
</section>
<!-- ══════ 密钥 ══════ -->
<section class="panel" id="panel-keys" role="tabpanel" aria-labelledby="tab-keys">
<div class="page-head">
<div>
<h1>API 密钥</h1>
<p>对外反代网关的分发密钥,支持版本限定、有效期、IP 白名单、模型白名单与配额</p>
</div>
<div class="toolbar">
<button class="btn btn-brand" id="btn-new-key" type="button">
<svg class="icon icon-sm" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg>
<span>新建密钥</span>
</button>
</div>
</div>
<div class="filter-strip">
<div class="group-pills">
<span class="group-pill" aria-pressed="true" style="cursor:default">普通密钥 · <b class="num" id="key-count">0</b></span>
<span class="group-pill" aria-pressed="false" style="cursor:default">总用量 · <b class="num" id="key-used">0</b> tokens</span>
</div>
<span class="muted" style="font-size:12.5px" id="key-mode"></span>
</div>
<div class="table-wrap">
<div class="table-scroll">
<table class="tbl">
<thead>
<tr>
<th>名称</th><th>密钥前缀</th><th>状态</th><th>版本</th><th>有效期</th>
<th>IP / 模型</th><th>已用 Token</th><th>最近使用</th><th>操作</th>
</tr>
</thead>
<tbody id="key-rows">
<tr><td colspan="9" class="muted">加载中…</td></tr>
</tbody>
</table>
</div>
</div>
<div class="bento" style="margin-top:16px">
<div class="bento-head">
<div class="bento-title">
<svg class="icon" viewBox="0 0 24 24" aria-hidden="true"><path d="m16 18 6-6-6-6M8 6l-6 6 6 6"/></svg>
<span>客户端接入方式</span>
</div>
</div>
<p class="muted" style="margin:0 0 8px;font-size:13px">新建密钥后完整 key 只显示一次,请立即复制。pi 用 <span class="mono">x-api-key</span>,其它 SDK 用 <span class="mono">Authorization: Bearer</span>,两种都认。</p>
<pre class="codebox" id="key-sample"></pre>
</div>
</section>
<!-- ══════ 用量统计 ══════ -->
<section class="panel" id="panel-stats" role="tabpanel" aria-labelledby="tab-stats">
<div class="page-head">
<div>
<h1>用量统计</h1>
<p id="stats-sub">按时间、模型与密钥维度统计 Token 消耗与请求量</p>
</div>
<div class="toolbar">
<div class="seg" role="group" aria-label="统计范围">
<button type="button" data-range="today" aria-pressed="true">今日</button>
<button type="button" data-range="7d" aria-pressed="false">近 7 天</button>
<button type="button" data-range="30d" aria-pressed="false">近 30 天</button>
</div>
<button class="btn" id="btn-stats-refresh" type="button">
<svg class="icon icon-sm" viewBox="0 0 24 24" aria-hidden="true"><path d="M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16"/><path d="M16 16h5v5"/></svg>
<span>刷新</span>
</button>
</div>
</div>
<div class="kpi-grid four">
<div class="bento">
<div class="kpi-top"><span>请求数</span><span class="kpi-ico"><svg class="icon" viewBox="0 0 24 24"><path d="M3 12h4l3-9 4 18 3-9h4"/></svg></span></div>
<div class="kpi-val num" id="st-req">—</div>
<div class="kpi-sub" id="st-req-sub">—</div>
</div>
<div class="bento">
<div class="kpi-top"><span>Token 总量</span><span class="kpi-ico brand"><svg class="icon" viewBox="0 0 24 24"><path d="M4 7h16M4 12h16M4 17h10"/></svg></span></div>
<div class="kpi-val brand num" id="st-tokens">—</div>
<div class="kpi-sub" id="st-tokens-sub">—</div>
</div>
<div class="bento">
<div class="kpi-top"><span>缓存命中率</span><span class="kpi-ico ok"><svg class="icon" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="m9 12 2 2 4-4"/></svg></span></div>
<div class="kpi-val ok num" id="st-cache">—</div>
<div class="kpi-sub" id="st-cache-sub">prompt 缓存命中占比</div>
</div>
<div class="bento">
<div class="kpi-top"><span>平均延迟</span><span class="kpi-ico"><svg class="icon" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg></span></div>
<div class="kpi-val num" id="st-latency">—</div>
<div class="kpi-sub" id="st-latency-sub">—</div>
</div>
</div>
<div class="bento" style="margin-bottom:16px">
<div class="bento-head">
<div class="bento-title">
<svg class="icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 3v18h18"/><path d="m7 14 4-4 3 3 5-6"/></svg>
<span>Token 消耗趋势</span>
</div>
<span class="bento-meta" id="stats-trend-meta">—</span>
</div>
<div id="stats-chart"></div>
</div>
<div class="overview-grid three">
<div class="bento">
<div class="bento-head"><div class="bento-title"><span>按模型</span></div></div>
<div class="table-scroll"><table class="tbl" style="min-width:0"><thead><tr><th>模型</th><th>请求</th><th>Token</th></tr></thead><tbody id="st-by-model"></tbody></table></div>
</div>
<div class="bento">
<div class="bento-head"><div class="bento-title"><span>按密钥</span></div></div>
<div class="table-scroll"><table class="tbl" style="min-width:0"><thead><tr><th>密钥</th><th>请求</th><th>Token</th></tr></thead><tbody id="st-by-key"></tbody></table></div>
</div>
<div class="bento">
<div class="bento-head"><div class="bento-title"><span>按账号</span></div></div>
<div class="table-scroll"><table class="tbl" style="min-width:0"><thead><tr><th>账号</th><th>请求</th><th>Token</th></tr></thead><tbody id="st-by-acc"></tbody></table></div>
</div>
</div>
<div class="bento">
<div class="bento-head">
<div class="bento-title">
<svg class="icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 6h16M4 12h16M4 18h10"/></svg>
<span>最近请求</span>
</div>
<span class="bento-meta">最多 50 条</span>
</div>
<div class="table-scroll">
<table class="tbl">
<thead><tr><th>时间</th><th>密钥</th><th>来源 IP</th><th>账号</th><th>模型</th><th>Token(入/出/缓存)</th><th>延迟</th><th>状态</th></tr></thead>
<tbody id="st-logs"></tbody>
</table>
</div>
</div>
</section>
<!-- ══════ 安全与 IP 管控 ══════ -->
<section class="panel" id="panel-security" role="tabpanel" aria-labelledby="tab-security">
<div class="page-head">
<div>
<h1>安全与 IP 管控</h1>
<p>入站 IP 白/黑名单、访问审计与全局拦截开关(每 60 秒自动刷新)</p>
</div>
<div class="toolbar">
<button class="btn" id="btn-sec-clear" type="button">
<svg class="icon icon-sm" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6"/></svg>
<span>清空拦截日志</span>
</button>
<button class="btn btn-brand" id="btn-sec-refresh" type="button">
<svg class="icon icon-sm" viewBox="0 0 24 24" aria-hidden="true"><path d="M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16"/><path d="M16 16h5v5"/></svg>
<span>刷新</span>
</button>
</div>
</div>
<div class="kpi-grid four">
<div class="bento">
<div class="kpi-top"><span>拦截开关</span></div>
<div class="kpi-val" id="sec-state">—</div>
<div class="kpi-sub" id="sec-mode-sub">—</div>
</div>
<div class="bento">
<div class="kpi-top"><span>拦截模式</span></div>
<div class="kpi-val" id="sec-mode">—</div>
<div class="kpi-sub">黑名单=默认放行 / 白名单=默认拒绝</div>
</div>
<div class="bento">
<div class="kpi-top"><span>规则数</span></div>
<div class="kpi-val num" id="sec-rules-count">—</div>
<div class="kpi-sub" id="sec-rules-sub">—</div>
</div>
<div class="bento">
<div class="kpi-top"><span>累计拦截</span></div>
<div class="kpi-val num" id="sec-blocked-count">—</div>
<div class="kpi-sub">最近保留 500 条审计</div>
</div>
</div>
<div class="overview-grid two">
<div class="bento">
<div class="bento-head">
<div class="bento-title"><span>拦截策略</span></div>
</div>
<div class="sec-toggles">
<label class="switch-row">
<span>启用 IP 管控<span class="switch-hint">关闭时放行所有来源 IP</span></span>
<button type="button" class="toggle" id="sec-toggle" role="switch" aria-checked="false"><i></i></button>
</label>
<label class="switch-row">
<span>拦截模式<span class="switch-hint">blacklist=仅拒绝命中项;whitelist=仅放行命中项</span></span>
<select id="sec-mode-sel" class="inp" style="width:auto">
<option value="blacklist">黑名单(默认放行)</option>
<option value="whitelist">白名单(默认拒绝)</option>
</select>
</label>
</div>
<div class="sec-add-row">
<select id="sec-new-type" class="inp" style="width:auto">
<option value="deny">拒绝</option>
<option value="allow">放行</option>
</select>
<input id="sec-new-cidr" class="inp" placeholder="IP / CIDR,如 1.2.3.4 或 10.0.0.0/8" style="flex:1">
<input id="sec-new-note" class="inp" placeholder="备注(可选)" style="width:130px">
<button type="button" class="btn btn-brand" id="sec-add">添加</button>
</div>
<div class="table-scroll">
<table class="tbl" style="min-width:0">
<thead><tr><th>类型</th><th>IP / CIDR</th><th>备注</th><th>创建时间</th><th>操作</th></tr></thead>
<tbody id="sec-rules"></tbody>
</table>
</div>
</div>
<div class="bento">
<div class="bento-head">
<div class="bento-title"><span>IP 访问拦截日志</span></div>
<span class="bento-meta">仅记录被拦截的请求;放行的调用见「用量统计」</span>
</div>
<div class="table-scroll" style="max-height:420px">
<table class="tbl" style="min-width:0">
<thead><tr><th>时间</th><th>IP</th><th>路径</th><th>结果</th><th>User-Agent</th></tr></thead>
<tbody id="sec-blocked"></tbody>
</table>
</div>
</div>
</div>
</section>
</main>
<nav class="dock-wrap" aria-label="底栏导航">
<div class="dock">
<button class="dock-btn active" data-dock="dashboard" type="button" aria-label="仪表盘" title="仪表盘">
<svg class="icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 3v18h18"/><path d="M7 16v-5M12 16V8M17 16v-3"/></svg>
</button>
<button class="dock-btn" data-dock="accounts" type="button" aria-label="账号" title="账号">
<svg class="icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75"/></svg>
</button>
<button class="dock-btn" data-dock="keys" type="button" aria-label="密钥" title="密钥">
<svg class="icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="7.5" cy="15.5" r="3.5"/><path d="m10 13 8-8 3 3-3 3-2-2"/></svg>
</button>
<button class="dock-btn" data-dock="stats" type="button" aria-label="用量统计" title="用量统计">
<svg class="icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 3v18h18"/><path d="m7 14 4-4 3 3 5-6"/></svg>
</button>
<button class="dock-btn" data-dock="security" type="button" aria-label="安全" title="安全与 IP 管控">
<svg class="icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10Z"/></svg>
</button>
<div class="dock-sep" aria-hidden="true"></div>
<button class="dock-btn" id="dock-claim" type="button" aria-label="一键领取全部" title="一键领取全部">
<svg class="icon" viewBox="0 0 24 24" aria-hidden="true"><path d="M20 12v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8"/><rect x="2" y="7" width="20" height="5" rx="1"/><path d="M12 22V7"/></svg>
</button>
<button class="dock-btn" id="dock-add" type="button" aria-label="登录新账号" title="登录新账号">
<svg class="icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 8v8M8 12h8"/></svg>
</button>
</div>
</nav>
<div id="toasts" role="status" aria-live="polite"></div>
<script>
const $ = (s) => document.querySelector(s);
const $$ = (s) => [...document.querySelectorAll(s)];
const fmt = (n) => (n == null ? '—' : Number(n).toLocaleString('en-US'));
const fmtCompact = (n) => {
const v = Number(n || 0);
if (v >= 1e8) return (v / 1e8).toFixed(2) + ' 亿';
if (v >= 1e4) return (v / 1e4).toFixed(1) + ' 万';
return v.toLocaleString('en-US');
};
const fmtDate = (ms) => (!ms ? '—' : new Date(ms).toLocaleString('zh-CN', { month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', hour12: false }));
const fmtDay = (ms) => (!ms ? '—' : new Date(ms).toLocaleDateString('zh-CN', { month: '2-digit', day: '2-digit' }));
const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
const REALM_TEXT = { cn: '国内版', intl: '国际版', unknown: '待确认' };
const KIND_TEXT = { promo: '臭鸡蛋', daily: '注册礼包', paid: '付费套餐', offpeak: '夜间不限量', other: '其他额度' };
const KIND_ORDER = ['promo', 'daily', 'paid', 'offpeak', 'other'];
const state = {
tab: 'dashboard',
pool: [],
quota: [],
keys: [],
statsRange: 'today',
stats: null,
realmFilter: 'all',
searchQuery: '',
stickySessions: 0,
loaded: { dashboard: false, accounts: false, keys: false, stats: false },
};
/* ── 主题 ── */
function applyTheme(t) {
document.documentElement.setAttribute('data-theme', t);
localStorage.setItem('zcgw_theme', t);
$('#lbl-theme').textContent = t === 'dark' ? '深色外观' : '浅色外观';
}
applyTheme(localStorage.getItem('zcgw_theme') || 'light');
$('#btn-theme').onclick = () => applyTheme(document.documentElement.getAttribute('data-theme') === 'dark' ? 'light' : 'dark');
/* ── 隐私模式(脱敏):方便截图分享不泄露邮箱/手机号/昵称 ── */
let privacyOn = localStorage.getItem('zcgw_privacy') === '1';
function maskIdentity(s) {
const str = String(s || '');
if (!privacyOn || !str) return str;
if (str.includes('@')) {
// 邮箱:保留首字符与域名后缀
const [local, domain] = str.split('@');
return `${local.slice(0, 1)}${'•'.repeat(Math.max(2, Math.min(5, local.length - 1)))}@${domain || '***'}`;
}
if (/^1\d{10}$/.test(str)) return str.slice(0, 3) + '****' + str.slice(-4);
if (/^\d{3}\*{4}\d{4}$/.test(str)) return str;
return str.slice(0, 1) + '•••';
}
function applyPrivacy() {
document.body.classList.toggle('privacy', privacyOn);
$('#lbl-privacy').textContent = privacyOn ? '隐私模式 开' : '隐私模式';
const maskLbl = $('#lbl-mask');
if (maskLbl) maskLbl.textContent = privacyOn ? '脱敏 开' : '脱敏';
const maskBtn = $('#btn-mask');
if (maskBtn) maskBtn.classList.toggle('btn-brand', privacyOn);
$('#btn-privacy').classList.toggle('active', privacyOn);
localStorage.setItem('zcgw_privacy', privacyOn ? '1' : '0');
// 立即重绘当前页
if (state.tab === 'accounts') renderAccounts();
else if (state.tab === 'dashboard') loadDashboard().catch(() => {});
else if (state.tab === 'stats') loadStats(state.statsRange).catch(() => {});
}
$('#btn-privacy').onclick = () => { privacyOn = !privacyOn; applyPrivacy(); toast('ok', privacyOn ? '隐私模式已开启' : '隐私模式已关闭', privacyOn ? '邮箱/手机号/昵称已脱敏,可放心截图' : '完整信息已恢复显示'); };
$('#btn-mask').onclick = () => $('#btn-privacy').click();
/* ── Toast ── */
function toast(kind, title, body) {
const el = document.createElement('div');
el.className = `toast ${kind}`;
const svg = {
ok: '<svg class="icon icon-sm" viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>',
warn: '<svg class="icon icon-sm" viewBox="0 0 24 24"><path d="M12 9v4M12 17h.01"/><path d="M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0Z"/></svg>',
err: '<svg class="icon icon-sm" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="m15 9-6 6M9 9l6 6"/></svg>',
};
el.innerHTML = `<span class="toast-ico" aria-hidden="true">${svg[kind] || svg.ok}</span>
<div><div class="t-title"></div>${body ? '<div class="t-body"></div>' : ''}</div>`;
el.querySelector('.t-title').textContent = title;
if (body) el.querySelector('.t-body').textContent = body;
$('#toasts').appendChild(el);
setTimeout(() => { el.style.opacity = '0'; }, 3400);
setTimeout(() => el.remove(), 3700);
}
async function api(path, opts) {
const r = await fetch(path, opts);
const text = await r.text();
let data;
try { data = text ? JSON.parse(text) : {}; } catch { throw new Error(`服务端响应异常(HTTP ${r.status})`); }
if (!r.ok) throw new Error(data.error || `请求失败(HTTP ${r.status})`);
return data;
}
const postJson = (path, body) => api(path, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body ?? {}) });
/* ── 路由 ── */
function goTab(name, push = true) {
if (!['dashboard', 'accounts', 'keys', 'stats', 'security'].includes(name)) name = 'dashboard';
state.tab = name;
$$('.panel').forEach((p) => p.classList.toggle('active', p.id === `panel-${name}`));
$$('.dock-btn[data-dock]').forEach((b) => b.classList.toggle('active', b.dataset.dock === name));
if (push && location.hash !== `#/${name}`) history.replaceState(null, '', `#/${name}`);
loadTab(name).catch((e) => toast('err', '加载失败', e.message));
}
async function loadTab(name) {
if (name === 'dashboard') return loadDashboard();
if (name === 'accounts') return loadAccounts();
if (name === 'keys') return loadKeys();
if (name === 'stats') return loadStats(state.statsRange);
if (name === 'security') return loadSecurity();
}
$$('.tabbtn').forEach((b) => { b.onclick = () => goTab(b.dataset.tab); });
$$('.dock-btn[data-dock]').forEach((b) => { b.onclick = () => goTab(b.dataset.dock); });
window.addEventListener('hashchange', () => goTab((location.hash || '').replace(/^#\//, '') || 'dashboard', false));
/* ── 归属筛选(全局)── */
function setRealmFilter(f) {
state.realmFilter = f;
$$('[data-realm-tab]').forEach((b) => b.setAttribute('aria-pressed', String(b.dataset.realmTab === f)));
$$('[data-filter]').forEach((b) => b.setAttribute('aria-pressed', String(b.dataset.filter === f)));
if (state.pool.length) { renderDashboard(); renderAccounts(); }
}
$$('[data-realm-tab]').forEach((b) => { b.onclick = () => setRealmFilter(b.dataset.realmTab); });
$$('[data-filter]').forEach((b) => { b.onclick = () => setRealmFilter(b.dataset.filter); });
function scopedPool() {
return state.pool.filter((a) => {
if (state.realmFilter === 'cn') return a.realm === 'cn';
if (state.realmFilter === 'intl') return a.realm === 'intl';
return true;
});
}
/* ══════ 仪表盘 ══════ */
async function loadDashboard() {
const [pool, quota, keys, stats14d] = await Promise.all([
api('/pool'),
api('/quota'),
api('/keys').catch(() => ({ keys: [] })),
api('/stats?range=14d').catch(() => null),
]);
state.pool = pool.accounts ?? [];
state.stickySessions = pool.stickySessions ?? 0;