-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
3551 lines (3263 loc) · 139 KB
/
Copy pathindex.html
File metadata and controls
3551 lines (3263 loc) · 139 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">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PR 代码变更统计</title>
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='15' fill='%231d1d1f'/%3E%3Cpath d='M20 18v28M20 24h16a8 8 0 0 1 8 8v14' fill='none' stroke='%230a84ff' stroke-width='5' stroke-linecap='round'/%3E%3Ccircle cx='20' cy='18' r='6' fill='%23f5f5f7'/%3E%3Ccircle cx='20' cy='46' r='6' fill='%2330d158'/%3E%3Ccircle cx='44' cy='46' r='6' fill='%23f5f5f7'/%3E%3C/svg%3E">
<style>
/* ========== Reset & Variables ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
--bg: #161617;
--card: #1c1c1e;
--input-bg: #2c2c2e;
--primary: #0a84ff;
--primary-hover: #0070e3;
--text: #f5f5f7;
--text-2: #86868b;
--text-3: rgba(245, 245, 247, 0.5);
--border: rgba(255, 255, 255, 0.08);
--border-2: rgba(255, 255, 255, 0.1);
--focus: #0a84ff;
--success: #30d158;
--warn: #ff9f0a;
--error: #ff453a;
--radius: 10px;
--radius-sm: 6px;
--shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
--font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
--mono: 'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
}
html { font-size: 14px; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.25); }
body {
font-family: var(--font);
color: var(--text);
background: var(--bg);
line-height: 1.5;
min-height: 100vh;
-webkit-font-smoothing: antialiased;
}
/* ========== Layout ========== */
.app { max-width: 1340px; margin: 0 auto; padding: 32px; }
.app-header { margin-bottom: 28px; }
.header-top {
display: flex;
justify-content: space-between;
align-items: center;
gap: 16px;
flex-wrap: wrap;
margin-bottom: 16px;
}
.app-header h1 {
font-size: 1.5rem;
font-weight: 600;
margin-bottom: 0;
letter-spacing: -0.01em;
}
.repo-link {
color: var(--text-2);
font-size: .85rem;
font-weight: 500;
transition: color .15s;
flex-shrink: 0;
}
.repo-link:hover { color: var(--primary); text-decoration: none; }
.tabs {
display: inline-flex;
gap: 2px;
padding: 2px;
background: var(--card);
border: 1px solid var(--border);
border-radius: 8px;
}
.tab {
padding: 4px 16px;
border: none;
background: transparent;
cursor: pointer;
font-size: .85rem;
color: var(--text-2);
border-radius: var(--radius-sm);
transition: all 0.15s ease-out;
font-weight: 500;
}
.tab:hover { color: var(--text); }
.tab.active {
background: rgba(255, 255, 255, 0.12);
color: var(--text);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }
/* ========== Card ========== */
.card {
background: var(--card);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 20px;
margin-bottom: 16px;
box-shadow: var(--shadow);
}
.card h2 { font-size: 1rem; font-weight: 600; margin-bottom: 12px; color: var(--text); }
.card p { color: var(--text-2); margin-bottom: 8px; }
.card ul { margin-left: 20px; color: var(--text-2); }
.card ul li { margin-bottom: 4px; }
.card code {
font-family: var(--mono);
font-size: .85rem;
background: var(--input-bg);
padding: 2px 6px;
border-radius: 4px;
color: var(--text);
}
/* ========== Forms ========== */
.form-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.form-row label { min-width: 100px; font-weight: 500; flex-shrink: 0; color: var(--text-2); font-size: .85rem; }
.form-row input[type="text"], .form-row input[type="password"], .form-row input[type="email"],
.form-row input[type="date"], .form-row select {
flex: 1; min-width: 180px; padding: 7px 10px; border: 1px solid var(--border);
border-radius: var(--radius-sm); font-size: .85rem; font-family: var(--font); outline: none;
background: var(--input-bg); color: var(--text);
transition: all 0.15s ease-out;
}
.form-row input:focus, .form-row select:focus {
border-color: var(--focus);
box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.3);
}
.form-row input[type="date"]::-webkit-calendar-picker-indicator,
.filter-group input[type="date"]::-webkit-calendar-picker-indicator {
filter: invert(1);
opacity: 0.8;
cursor: pointer;
}
.form-row .token-display { font-family: var(--mono); font-size: .85rem; color: var(--text-2); margin-left: 4px; }
/* ========== Buttons ========== */
.btn {
display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px;
border: none; border-radius: var(--radius-sm);
background: var(--input-bg); color: var(--text); cursor: pointer;
font-size: .85rem; font-family: var(--font);
transition: all 0.15s ease-out; white-space: nowrap;
}
.btn:hover { background: #3a3a3c; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-danger { color: var(--error); background: rgba(255, 69, 58, 0.1); }
.btn-danger:hover:not(:disabled) { background: rgba(255, 69, 58, 0.18); }
.btn-sm { padding: 4px 10px; font-size: .8rem; }
/* ========== Status ========== */
.status { display: inline-flex; align-items: center; gap: 4px; font-size: .8rem; padding: 2px 6px; border-radius: 4px; font-weight: 500; }
.status-ok { color: var(--success); background: rgba(48, 209, 88, 0.12); }
.status-warn { color: var(--warn); background: rgba(255, 159, 10, 0.12); }
.status-err { color: var(--error); background: rgba(255, 69, 58, 0.12); }
/* ========== Toolbar ========== */
.toolbar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.toolbar-right { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
/* ========== Tables ========== */
.table-wrap {
overflow-x: auto; margin-bottom: 16px;
border: 1px solid var(--border); border-radius: var(--radius);
background: var(--card);
}
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
thead th {
background: var(--input-bg);
padding: 8px 12px; text-align: left; font-weight: 500;
border-bottom: 1px solid var(--border-2);
color: var(--text-2);
font-size: 0.8rem;
white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--text); }
thead th.sortable .sort-arrows {
display: inline-flex;
flex-direction: column;
line-height: 1;
margin-left: 4px;
vertical-align: middle;
gap: 1px;
}
thead th.sortable .sort-arrow {
color: var(--text-3);
font-size: .55rem;
}
thead th.sortable .sort-arrow.active { color: var(--primary); }
tbody td { padding: 7px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text); }
tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.015); }
tbody tr:hover { background: rgba(255, 255, 255, 0.04); }
tbody tr:last-child td { border-bottom: none; }
td.num { text-align: right; font-family: var(--mono); font-size: .85rem; font-variant-numeric: tabular-nums; }
td.actions { white-space: nowrap; }
.branch-combobox { position: relative; display: inline-block; }
.branch-combobox-input { background: var(--input-bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 3px 6px; font-size: .8rem; width: 140px; outline: none; }
.branch-combobox-input:focus { border-color: var(--primary); }
.branch-combobox-list { position: absolute; top: 100%; left: 0; min-width: 100%; max-height: 200px; overflow-y: auto; background: var(--card); border: 1px solid var(--border); border-radius: 6px; z-index: 100; display: none; margin-top: 2px; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.branch-combobox-list.open { display: block; }
.branch-combobox-item { padding: 4px 8px; font-size: .8rem; cursor: pointer; white-space: nowrap; }
.branch-combobox-item:hover, .branch-combobox-item.selected { background: var(--primary); color: #fff; }
.branch-combobox-item.no-match { color: var(--text-2); cursor: default; padding: 6px 8px; }
.branch-combobox-item.no-match:hover { background: transparent; color: var(--text-2); }
.empty-row td { text-align: center; color: var(--text-2); padding: 30px; }
/* Additions / deletions coloring (summary columns shifted after collaboration columns) */
#summary-tbody tr.summary-row td:nth-child(8).num { color: var(--success); }
#summary-tbody tr.summary-row td:nth-child(9).num { color: var(--error); }
#summary-tbody tr.summary-row td:nth-child(8).num::before { content: '+'; margin-right: 1px; }
/* Detail development tab: additions/deletions columns */
#detail-tbody tr td:nth-child(6).num { color: var(--success); }
#detail-tbody tr td:nth-child(7).num { color: var(--error); }
#detail-tbody tr td:nth-child(6).num::before { content: '+'; margin-right: 1px; }
/* Active detail tab styling */
.detail-tab.active { background: rgba(255, 255, 255, 0.15); color: var(--text); }
.completeness-cell { text-align: center; vertical-align: middle; }
.completeness-full {
display: inline-flex; align-items: center; justify-content: center;
color: var(--success); background: rgba(48, 209, 88, 0.12);
padding: 2px 6px; border-radius: 4px; font-size: 0.75rem; font-weight: 500;
}
.completeness-partial {
display: inline-flex; align-items: center; justify-content: center;
color: var(--warn); background: rgba(255, 159, 10, 0.12);
padding: 2px 6px; border-radius: 4px; font-size: 0.75rem; font-weight: 500;
}
.completeness-failed {
display: inline-flex; align-items: center; justify-content: center;
color: var(--error); background: rgba(255, 69, 58, 0.12);
padding: 2px 6px; border-radius: 4px; font-size: 0.75rem; font-weight: 500;
}
/* ========== Filters ========== */
.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 0; }
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: .8rem; color: var(--text-2); font-weight: 500; }
.filter-group input, .filter-group select {
padding: 7px 10px; border: 1px solid var(--border);
border-radius: var(--radius-sm); font-size: .85rem; font-family: var(--font); outline: none;
background: var(--input-bg); color: var(--text);
transition: all 0.15s ease-out;
}
.filter-group input:focus, .filter-group select:focus {
border-color: var(--focus);
box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.3);
}
.filter-actions {
display: flex;
align-items: center;
align-self: flex-end;
gap: 6px;
}
.filter-actions .btn { min-height: 34px; }
/* ========== Local data notice ========== */
.privacy-note {
display: flex;
gap: 12px;
padding: 14px 16px;
margin-bottom: 16px;
border: 1px solid rgba(10, 132, 255, 0.24);
border-radius: var(--radius);
background: rgba(10, 132, 255, 0.07);
}
.privacy-note-icon {
width: 30px;
height: 30px;
flex: 0 0 30px;
display: grid;
place-items: center;
border-radius: 8px;
color: var(--primary);
background: rgba(10, 132, 255, 0.14);
}
.privacy-note-icon svg { width: 17px; height: 17px; }
.privacy-note strong { display: block; margin-bottom: 3px; font-size: .9rem; }
.privacy-note p { margin: 0; color: var(--text-2); font-size: .82rem; }
.privacy-note p + p { margin-top: 4px; }
/* ========== Progress ========== */
.progress-box {
background: var(--card);
border: 1px solid var(--border); border-radius: var(--radius);
padding: 16px; margin-bottom: 16px;
box-shadow: var(--shadow);
}
.progress-title { font-weight: 600; margin-bottom: 10px; color: var(--text); font-size: .9rem; }
.progress-list { list-style: none; font-size: .85rem; }
.progress-list li { padding: 4px 0; display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.progress-list .icon { width: 18px; text-align: center; flex-shrink: 0; }
.error-summary { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.error-summary details > summary {
list-style: none;
cursor: pointer;
font-size: .85rem;
color: var(--error);
margin-bottom: 8px;
font-weight: 500;
}
.error-summary details > summary::-webkit-details-marker { display: none; }
.error-summary ul { margin: 8px 0 0 0; list-style: none; }
.error-summary li { margin-bottom: 10px; }
.error-detail-line {
white-space: pre-wrap;
word-break: break-word;
color: var(--text);
line-height: 1.5;
}
.error-detail-full {
margin: 6px 0 0 0;
padding: 8px 10px;
background: var(--input-bg);
border-radius: 6px;
font-size: .78rem;
color: var(--text-2);
white-space: pre-wrap;
word-break: break-word;
line-height: 1.5;
}
.listing-warning {
margin-bottom: 12px; padding: 10px 14px;
background: rgba(255, 159, 10, 0.12);
border: 1px solid rgba(255, 159, 10, 0.3);
border-radius: var(--radius);
color: #ff9f0a; font-size: .85rem; line-height: 1.5;
}
.listing-warning .warning-title { font-weight: 600; margin-bottom: 4px; }
.listing-warning .warning-detail { color: var(--text-2); font-size: .8rem; }
/* ========== Dialog ========== */
dialog {
border: none; padding: 0;
max-width: 700px; width: 90vw; margin: auto;
background: #1e1e1e;
border: 1px solid rgba(255, 255, 255, 0.12);
box-shadow: 0 20px 50px rgba(0,0,0,0.45);
border-radius: 12px; overflow: hidden;
}
dialog::backdrop { backdrop-filter: blur(20px); background: rgba(0, 0, 0, 0.45); }
.dialog-header {
padding: 16px 20px;
border-bottom: 1px solid var(--border);
display: flex; justify-content: space-between; align-items: center;
}
.dialog-header h3 { font-size: 1rem; font-weight: 600; color: var(--text); }
.dialog-body { padding: 20px; max-height: 60vh; overflow-y: auto; }
.dialog-footer {
padding: 12px 20px;
border-top: 1px solid var(--border);
display: flex; justify-content: flex-end; gap: 8px;
}
.dialog-close { background: none; border: none; cursor: pointer; font-size: 1.2rem; color: var(--text-2); padding: 4px; transition: color .15s; }
.dialog-close:hover { color: var(--text); }
/* ========== Import Preview ========== */
.import-summary { margin-bottom: 12px; font-size: .9rem; color: var(--text); }
.import-summary .ok { color: var(--success); font-weight: 500; }
.import-summary .bad { color: var(--error); font-weight: 500; }
.import-table tr.row-valid { background: rgba(48, 209, 88, 0.08); }
.import-table tr.row-invalid { background: rgba(255, 69, 58, 0.08); }
.import-table .err-msg { color: var(--error); font-size: .8rem; }
/* ========== Toggle Switch ========== */
.toggle { position: relative; display: inline-block; width: 36px; height: 20px; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
position: absolute; inset: 0;
background: #3a3a3c;
border-radius: 20px; transition: background .15s;
}
.toggle .slider::before {
content: ''; position: absolute; width: 16px; height: 16px; left: 2px; bottom: 2px;
background: #fff; border-radius: 50%; transition: transform .15s;
box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.toggle input:checked + .slider { background: var(--success); }
.toggle input:checked + .slider::before { transform: translateX(16px); }
/* ========== Misc ========== */
.text-muted { color: var(--text-2); }
.text-sm { font-size: .8rem; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.hidden { display: none !important; }
a { color: var(--primary); text-decoration: none; transition: color .15s; }
a:hover { color: var(--primary-hover); text-decoration: underline; }
.checkbox-label { display: flex; align-items: center; gap: 6px; cursor: pointer; color: var(--text-2); }
.checkbox-label input { width: 16px; height: 16px; accent-color: var(--primary); }
/* ========== Edit Form (in dialog) ========== */
.edit-form .form-field { margin-bottom: 12px; }
.edit-form .form-field label { display: block; font-weight: 500; margin-bottom: 4px; font-size: .85rem; color: var(--text-2); }
.edit-form .form-field input, .edit-form .form-field select {
width: 100%; padding: 7px 10px; border: 1px solid var(--border);
border-radius: var(--radius-sm); font-size: .85rem; font-family: var(--font); outline: none;
background: var(--input-bg); color: var(--text);
transition: all 0.15s ease-out;
}
.edit-form .form-field input:focus, .edit-form .form-field select:focus {
border-color: var(--focus);
box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.3);
}
.edit-form .form-field .hint { font-size: .8rem; color: var(--text-3); margin-top: 2px; }
.edit-form .form-field .field-error { font-size: .8rem; color: var(--error); margin-top: 2px; }
/* ========== Grand total & summary row ========== */
tr.grand-total td {
font-weight: 600;
background: transparent;
border-top: 1px solid rgba(255, 255, 255, 0.15);
border-bottom: 3px double rgba(255, 255, 255, 0.15);
color: var(--text);
}
tr.summary-row { cursor: pointer; transition: background .15s; }
tr.summary-row:hover td { background: rgba(255, 255, 255, 0.04); }
tr.summary-row.selected td { background: rgba(255, 255, 255, 0.08); }
/* ========== Responsive ========== */
@media (max-width: 768px) {
.app { padding: 16px; }
.app-header h1 { font-size: 1.3rem; }
.tabs { display: flex; width: 100%; }
.tab { flex: 1; text-align: center; }
.form-row { flex-direction: column; align-items: stretch; }
.form-row label { min-width: auto; }
.filters { flex-direction: column; }
.filter-group { width: 100%; }
.filter-group input, .filter-group select { width: 100%; }
.filter-actions { width: 100%; align-self: stretch; }
.filter-actions .btn { flex: 1; justify-content: center; }
.toolbar { flex-direction: column; align-items: stretch; }
.toolbar-right { margin-left: 0; }
.card { padding: 16px; }
}
</style>
</head>
<body>
<div class="app">
<header class="app-header">
<div class="header-top">
<h1>PR 代码变更统计</h1>
<a class="repo-link" href="https://github.com/mindfn/code-statistics" target="_blank" rel="noopener">GitHub 仓库</a>
</div>
<nav class="tabs" id="tab-nav">
<button class="tab active" data-tab="stats">统计数据</button>
<button class="tab" data-tab="users">用户</button>
<button class="tab" data-tab="config">配置</button>
</nav>
</header>
<main>
<!-- ==================== 配置 ==================== -->
<section id="tab-config" class="tab-panel">
<aside class="privacy-note" id="local-data-notice" role="note" aria-label="本地数据与隐私说明">
<span class="privacy-note-icon" aria-hidden="true">
<svg viewBox="0 0 24 24" fill="none">
<path d="M7 10V7a5 5 0 0 1 10 0v3M6 10h12v10H6z" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M12 14v2" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>
</svg>
</span>
<div>
<strong>配置数据仅保存在当前浏览器</strong>
<p>Token、用户和仓库配置保存在浏览器 <code>localStorage</code>,不会上传到本工具的服务器;Token 仅通过请求头直接发送给 GitHub / GitCode API,导出的 CSV 不包含 Token。</p>
<p>通过 <code>http(s)</code>(含 GitHub Pages)使用时,已合入 PR 的代码量、Comments 和 Approve 会缓存在本机 <code>IndexedDB</code>;直接双击 <code>file://</code> 使用时只缓存于当前页面内存。</p>
<p>清除本网站的浏览器数据会同时清除全部配置和 PR 缓存,请勿在不受信任的公共设备上保存 Token。</p>
</div>
</aside>
<div class="card">
<h2>GitHub Token</h2>
<div class="form-row">
<label for="github-token">Token</label>
<input type="password" id="github-token" placeholder="ghp_... 或 github_pat_..."
oninput="scheduleAutoSaveToken('github')" onchange="scheduleAutoSaveToken('github')">
<button class="btn btn-sm" onclick="toggleTokenVisibility('github-token')">显示</button>
</div>
<div class="form-row">
<label></label>
<button class="btn btn-danger btn-sm" onclick="clearToken('github')">清除</button>
<button class="btn btn-sm" onclick="testConnection('github')">测试</button>
<span id="github-status"></span>
</div>
<div class="form-row">
<label></label>
<span class="text-sm text-muted">需要 repo 权限(私有仓库)或 public_repo 权限(公开仓库)。Fine-grained Token 需要 Pull requests 只读权限。</span>
</div>
</div>
<div class="card">
<h2>GitCode Token</h2>
<div class="form-row">
<label for="gitcode-token">Token</label>
<input type="password" id="gitcode-token" placeholder="私人令牌"
oninput="scheduleAutoSaveToken('gitcode')" onchange="scheduleAutoSaveToken('gitcode')">
<button class="btn btn-sm" onclick="toggleTokenVisibility('gitcode-token')">显示</button>
</div>
<div class="form-row">
<label></label>
<button class="btn btn-danger btn-sm" onclick="clearToken('gitcode')">清除</button>
<button class="btn btn-sm" onclick="testConnection('gitcode')">测试</button>
<span id="gitcode-status"></span>
</div>
</div>
<div class="card">
<h2>仓库管理</h2>
<p class="text-sm text-muted mb-8">添加需要统计的 GitHub / GitCode 仓库。所有用户的 PR 将从这些仓库中查询。</p>
<div class="form-row">
<input type="text" id="new-repo-url" placeholder="https://github.com/owner/repo" style="flex:2">
<button class="btn btn-primary btn-sm" onclick="addRepo()">添加</button>
</div>
<div id="repo-list" class="mt-8"></div>
</div>
<div class="card">
<h2>数据管理</h2>
<p class="text-sm text-muted mb-8">已合入 PR 的代码量数据会缓存在本机 IndexedDB(<code>code-statistics.pr-cache.v1</code>),加快后续查询速度。可在浏览器 DevTools → Application → IndexedDB 中查看。如果数据异常,可清除缓存后重新查询。</p>
<div class="form-row">
<button class="btn btn-danger btn-sm" onclick="clearPRCache()">清除 PR 缓存</button>
<span id="cache-clear-status" class="text-sm"></span>
</div>
</div>
<div class="card">
<h2>网络与代理</h2>
<p>本工具沿用操作系统或浏览器的代理设置,不提供应用内代理配置。</p>
<p>请确保您的浏览器可以正常访问以下地址:</p>
<ul>
<li><code>https://api.github.com</code></li>
<li><code>https://api.gitcode.com</code></li>
</ul>
<p class="mt-8 text-sm text-muted">如果在公司网络环境下无法访问,请配置系统代理或浏览器代理后重试。</p>
</div>
</section>
<!-- ==================== 用户信息 ==================== -->
<section id="tab-users" class="tab-panel">
<div class="toolbar">
<button class="btn btn-primary" onclick="showUserDialog()">新增</button>
<button class="btn" onclick="triggerImportCSV()">CSV 导入</button>
<button class="btn" onclick="downloadTemplate()">下载模板</button>
<input type="file" id="csv-file-input" accept=".csv" class="hidden" onchange="handleCSVFile(event)">
<div class="toolbar-right">
<span class="text-sm text-muted" id="user-count"></span>
</div>
</div>
<div class="table-wrap">
<table>
<thead>
<tr>
<th>用户标识</th>
<th>显示名</th>
<th>邮箱</th>
<th>GitHub 账号</th>
<th>GitCode 账号</th>
<th>启用</th>
<th>操作</th>
</tr>
</thead>
<tbody id="users-tbody"></tbody>
</table>
</div>
</section>
<!-- ==================== 统计数据 ==================== -->
<section id="tab-stats" class="tab-panel active">
<div class="card">
<div class="filters">
<div class="filter-group">
<label for="stat-start">开始日期</label>
<input type="date" id="stat-start">
</div>
<div class="filter-group">
<label for="stat-end">结束日期</label>
<input type="date" id="stat-end">
</div>
<div class="filter-group">
<label for="stat-platform">平台</label>
<select id="stat-platform">
<option value="">全部</option>
<option value="github">GitHub</option>
<option value="gitcode">GitCode</option>
</select>
</div>
<div class="filter-group">
<label for="stat-user-type">用户范围</label>
<select id="stat-user-type">
<option value="matched">已匹配用户</option>
<option value="all">全部(含未匹配)</option>
<option value="unmatched">仅未匹配</option>
</select>
</div>
<div class="filter-group">
<label for="stat-user">用户</label>
<select id="stat-user"><option value="">全部</option></select>
</div>
<div class="filter-group">
<label for="stat-repo">仓库</label>
<select id="stat-repo"><option value="">全部</option></select>
</div>
<div class="filter-actions">
<button class="btn btn-primary" id="btn-query" onclick="runQuery()">查询</button>
<button class="btn btn-danger hidden" id="btn-cancel" onclick="cancelQuery()">取消</button>
</div>
</div>
</div>
<div id="progress-section" class="hidden">
<div class="progress-box">
<div class="progress-title" id="progress-title">准备查询...</div>
<ul class="progress-list" id="progress-list"></ul>
</div>
</div>
<div id="results-section" class="hidden">
<div id="listing-warning" class="listing-warning hidden"></div>
<div class="toolbar">
<span class="text-sm text-muted" id="results-summary"></span>
<div class="toolbar-right">
<button class="btn btn-sm" onclick="exportCSV('summary')">导出汇总 CSV</button>
<button class="btn btn-sm" onclick="exportCSV('detail')">导出明细 CSV</button>
</div>
</div>
<h3 class="mb-8">汇总</h3>
<div class="table-wrap" style="max-height:400px; overflow-y:auto;">
<table>
<thead id="summary-thead"></thead>
<tbody id="summary-tbody"></tbody>
</table>
</div>
<div id="detail-section" class="hidden">
<h3 class="mb-8 mt-16"><span id="detail-title"></span></h3>
<div class="detail-tabs" style="display:flex; gap:8px; margin-bottom:12px;">
<button class="btn detail-tab active" data-tab="development" aria-selected="true" role="tab" onclick="switchDetailTab('development')">开发 PR</button>
<button class="btn detail-tab" data-tab="comments" aria-selected="false" role="tab" onclick="switchDetailTab('comments')">Comments</button>
<button class="btn detail-tab" data-tab="approvals" aria-selected="false" role="tab" onclick="switchDetailTab('approvals')">审核 PR</button>
</div>
<div class="table-wrap" style="max-height:500px; overflow-y:auto;">
<table>
<thead id="detail-thead">
<tr>
<th>平台</th><th>仓库</th><th>PR</th><th>标题</th><th>合并时间</th>
<th>新增行</th><th>删除行</th><th>变更文件数</th><th>链接</th><th>完整性</th>
</tr>
</thead>
<tbody id="detail-tbody"></tbody>
</table>
</div>
</div>
</div>
</section>
</main>
</div>
<!-- ==================== 用户编辑对话框 ==================== -->
<dialog id="user-dialog">
<div class="dialog-header">
<h3 id="user-dialog-title">新增用户</h3>
<button class="dialog-close" onclick="closeUserDialog()">×</button>
</div>
<div class="dialog-body">
<form class="edit-form" id="user-form" onsubmit="return saveUser(event)">
<input type="hidden" id="edit-index" value="-1">
<div class="form-field">
<label for="edit-user-key">用户标识 *</label>
<input type="text" id="edit-user-key" required placeholder="唯一标识,如工号或英文名">
</div>
<div class="form-field">
<label for="edit-display-name">显示名</label>
<input type="text" id="edit-display-name" placeholder="姓名">
</div>
<div class="form-field">
<label for="edit-email">邮箱</label>
<input type="email" id="edit-email" placeholder="user@example.com">
</div>
<div class="form-field">
<label for="edit-github-login">GitHub 账号</label>
<input type="text" id="edit-github-login" placeholder="GitHub 用户名">
</div>
<div class="form-field">
<label for="edit-gitcode-login">GitCode 账号</label>
<input type="text" id="edit-gitcode-login" placeholder="GitCode 用户名">
</div>
<!-- 仓库已移至配置页签,启用默认开启、通过表格 toggle 控制 -->
</form>
</div>
<div class="dialog-footer">
<button class="btn" onclick="closeUserDialog()">取消</button>
<button class="btn btn-primary" onclick="document.getElementById('user-form').requestSubmit()">保存</button>
</div>
</dialog>
<!-- ==================== CSV 导入预览对话框 ==================== -->
<dialog id="import-dialog">
<div class="dialog-header">
<h3>CSV 导入预览</h3>
<button class="dialog-close" onclick="closeImportDialog()">×</button>
</div>
<div class="dialog-body">
<div class="import-summary" id="import-summary"></div>
<div class="table-wrap">
<table class="import-table">
<thead id="import-thead"></thead>
<tbody id="import-tbody"></tbody>
</table>
</div>
</div>
<div class="dialog-footer">
<button class="btn" onclick="closeImportDialog()">取消</button>
<button class="btn btn-primary" id="btn-confirm-import" onclick="confirmImport()">确认导入</button>
</div>
</dialog>
<script>
/* ================================================================
* PR 代码变更统计 — 单文件实现
* 模块边界:Storage / CsvHelper / GitHubProvider / GitCodeProvider / StatsEngine / UI
* ================================================================ */
// ========== Utilities ==========
function escapeHtml(s) {
if (s == null) return '';
return String(s).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"');
}
function maskToken(token) {
if (!token) return '';
if (token.length <= 8) return '••••••••';
return token.slice(0, 4) + '••••' + token.slice(-4);
}
function parseRepoUrl(url) {
if (!url) return null;
url = url.trim();
// HTTPS — allow dots in repo names, strip trailing .git
var m = url.match(/^https?:\/\/(github\.com|gitcode\.com)\/([^\/\s]+)\/([^\/\s]+)/);
if (m) { var repo = m[3].replace(/\.git$/, ''); return { platform: m[1] === 'github.com' ? 'github' : 'gitcode', owner: m[2], repo: repo }; }
// SSH
m = url.match(/^git@(github\.com|gitcode\.com):([^\/\s]+)\/([^\/\s]+)/);
if (m) { var repo = m[3].replace(/\.git$/, ''); return { platform: m[1] === 'github.com' ? 'github' : 'gitcode', owner: m[2], repo: repo }; }
return null;
}
function repoKey(platform, owner, repo) {
return platform + ':' + owner + '/' + repo;
}
/**
* Normalize repo entry: supports legacy string format and new {url, branch} format.
* Returns { url: string, branch: string } — branch may be '' (auto-detect).
*/
function normalizeRepoEntry(entry) {
if (typeof entry === 'string') return { url: entry, branch: '' };
return { url: entry.url || '', branch: entry.branch || '' };
}
function formatNum(n) {
if (n == null) return '-';
return n.toLocaleString('en-US');
}
function formatDate(isoStr) {
if (!isoStr) return '-';
var d = new Date(isoStr);
return d.getFullYear() + '-' + String(d.getMonth()+1).padStart(2,'0') + '-' +
String(d.getDate()).padStart(2,'0') + ' ' + String(d.getHours()).padStart(2,'0') + ':' +
String(d.getMinutes()).padStart(2,'0');
}
function todayStr() {
var d = new Date();
return d.getFullYear() + '-' + String(d.getMonth()+1).padStart(2,'0') + '-' + String(d.getDate()).padStart(2,'0');
}
function monthStartStr() {
var d = new Date();
return d.getFullYear() + '-' + String(d.getMonth()+1).padStart(2,'0') + '-01';
}
/** Half-open interval: [startDate 00:00 local, endDate+1day 00:00 local) */
function dateRangeToTimestamps(startStr, endStr) {
var start = new Date(startStr + 'T00:00:00');
var endNext = new Date(endStr + 'T00:00:00');
endNext.setDate(endNext.getDate() + 1);
return { start: start, end: endNext };
}
function sleep(ms) { return new Promise(function(r) { setTimeout(r, ms); }); }
function classifyError(message) {
var m = String(message || '');
if (m.indexOf('429') >= 0 || m.indexOf('限流') >= 0 || m.indexOf('rate limit') >= 0 || m.indexOf('rate_limit') >= 0) {
return { category: 'rate-limit', short: '请求过于频繁(429,上游限流)', detail: m };
}
if (m.indexOf('401') >= 0 || m.indexOf('认证失败') >= 0 || m.indexOf('Unauthorized') >= 0) {
return { category: 'auth', short: '认证失败,请检查 Token', detail: m };
}
if (m.indexOf('403') >= 0 || m.indexOf('Forbidden') >= 0) {
return { category: 'forbidden', short: '权限不足或请求被阻止', detail: m };
}
if (m.indexOf('Failed to fetch') >= 0 || m.indexOf('NetworkError') >= 0 || m.indexOf('网络错误') >= 0) {
return { category: 'network', short: '网络错误,请检查代理和网络连接', detail: m };
}
return { category: 'other', short: '请求失败', detail: m };
}
function formatStageName(stage) {
var map = {
'comments': 'Comments',
'review_comments': 'Review Comments',
'reviews': 'Reviews',
'获取 PR 列表': 'PR 列表',
'搜索 PR 中': 'PR 搜索',
'获取 PR 详情': 'PR 详情'
};
return map[stage] || (stage || '请求');
}
// Simple concurrency limiter
function createLimiter(concurrency, delayMs) {
var active = 0, queue = [];
function tryNext() {
if (active >= concurrency || queue.length === 0) return;
active++;
var item = queue.shift();
item.fn().then(item.resolve, item.reject).finally(function() {
active--;
if (delayMs > 0) { setTimeout(tryNext, delayMs); } else { tryNext(); }
});
}
return function limit(fn) {
return new Promise(function(resolve, reject) {
queue.push({ fn: fn, resolve: resolve, reject: reject });
tryNext();
});
};
}
var ProviderRequestBudget = {
limits: { github: 8, gitcode: 16 },
_limiters: {},
schedule: function(platform, fn) {
if (!this._limiters[platform]) {
this._limiters[platform] = createLimiter(this.limits[platform], 0);
}
return this._limiters[platform](fn);
}
};
// ========== Storage ==========
var Storage = {
CONFIG_KEY: 'code-statistics.config.v1',
USERS_KEY: 'code-statistics.users.v1',
_available: null,
isAvailable: function() {
if (this._available !== null) return this._available;
try { localStorage.setItem('__cs_test__', '1'); localStorage.removeItem('__cs_test__'); this._available = true; }
catch(e) { this._available = false; }
return this._available;
},
loadConfig: function() {
if (!this.isAvailable()) return { githubToken: '', gitcodeToken: '', repositories: [] };
try {
var cfg = JSON.parse(localStorage.getItem(this.CONFIG_KEY)) || {};
if (!cfg.repositories) cfg.repositories = [];
return cfg;
} catch(e) { return { githubToken: '', gitcodeToken: '', repositories: [] }; }
},
saveConfig: function(cfg) {
if (!this.isAvailable()) return;
localStorage.setItem(this.CONFIG_KEY, JSON.stringify(cfg));
},
loadUsers: function() {
if (!this.isAvailable()) return [];
try { return JSON.parse(localStorage.getItem(this.USERS_KEY)) || []; }
catch(e) { return []; }
},
saveUsers: function(users) {
if (!this.isAvailable()) return;
localStorage.setItem(this.USERS_KEY, JSON.stringify(users));
}
};
var CACHE_SCHEMA_VERSION = 1;
function prCacheKey(platform, repository, prNumber) {
return String(platform || '') + ':' + String(repository || '').toLowerCase() + '#' + String(prNumber);
}
function cloneCacheValue(value) {
if (value == null) return value;
return JSON.parse(JSON.stringify(value));
}
var CacheStore = {
DB_NAME: 'code-statistics.pr-cache.v1',
STORE_NAME: 'prs',
_backend: null,
_backendPromise: null,
mode: '',
degradedReason: '',
createMemoryBackend: function() {
var entries = {};
return {
mode: 'memory',
get: async function(key) {
return Object.prototype.hasOwnProperty.call(entries, key) ? cloneCacheValue(entries[key]) : null;
},
put: async function(key, value) {
entries[key] = cloneCacheValue(value);
},
delete: async function(key) {
delete entries[key];
},
clear: async function() {
entries = {};
},
close: function() {}
};
},
openIndexedDbBackend: function(dbName) {
var self = this;
return new Promise(function(resolve, reject) {
var request;
try {
request = indexedDB.open(dbName || self.DB_NAME, 1);
} catch (err) {
reject(err);
return;
}
request.onupgradeneeded = function() {
var db = request.result;
if (!db.objectStoreNames.contains(self.STORE_NAME)) {
db.createObjectStore(self.STORE_NAME);
}
};
request.onerror = function() {
reject(request.error || new Error('IndexedDB 打开失败'));
};
request.onblocked = function() {
reject(new Error('IndexedDB 被其他页面占用'));
};
request.onsuccess = function() {
var db = request.result;
function transact(mode, action) {
return new Promise(function(resolveTx, rejectTx) {
var tx;
try {
tx = db.transaction(self.STORE_NAME, mode);
action(tx.objectStore(self.STORE_NAME), resolveTx, rejectTx, tx);
} catch (err) {
rejectTx(err);
return;
}
tx.onerror = function() {
rejectTx(tx.error || new Error('IndexedDB 事务失败'));
};
tx.onabort = function() {
rejectTx(tx.error || new Error('IndexedDB 事务已取消'));
};
});
}
resolve({
mode: 'indexeddb',
get: function(key) {
return transact('readonly', function(store, resolveTx, rejectTx) {
var getRequest = store.get(key);
getRequest.onsuccess = function() {
resolveTx(getRequest.result == null ? null : cloneCacheValue(getRequest.result));
};