-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
2449 lines (2192 loc) · 135 KB
/
index.html
File metadata and controls
2449 lines (2192 loc) · 135 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>OpenCollab-Insight | 开源协作网络分析平台</title>
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3/dist/echarts.min.js"></script>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;700&display=swap" rel="stylesheet">
<style>
* { font-family: 'Inter', -apple-system, sans-serif; }
.font-mono { font-family: 'JetBrains Mono', 'Fira Code', monospace; }
/* Tech Background */
body {
background-color: #0f172a;
background-image:
linear-gradient(rgba(59, 130, 246, 0.05) 1px, transparent 1px),
linear-gradient(90deg, rgba(59, 130, 246, 0.05) 1px, transparent 1px),
radial-gradient(circle at 50% 50%, rgba(15, 23, 42, 0) 0%, rgba(15, 23, 42, 1) 100%);
background-size: 40px 40px, 40px 40px, 100% 100%;
background-attachment: fixed;
}
/* HUD Card Style */
.card {
background: rgba(30, 41, 59, 0.7);
backdrop-filter: blur(12px);
position: relative;
border: 1px solid rgba(71, 85, 105, 0.5);
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}
/* HUD Corners */
.hud-card::before, .hud-card::after {
content: '';
position: absolute;
width: 10px;
height: 10px;
border-color: rgba(59, 130, 246, 0.5);
border-style: solid;
transition: all 0.3s ease;
}
.hud-card::before {
top: -1px; left: -1px;
border-width: 2px 0 0 2px;
}
.hud-card::after {
bottom: -1px; right: -1px;
border-width: 0 2px 2px 0;
}
.hud-card:hover::before, .hud-card:hover::after {
width: 20px;
height: 20px;
border-color: rgba(59, 130, 246, 1);
box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}
/* Scanline Effect */
.scanline {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(to bottom, transparent 50%, rgba(0, 0, 0, 0.1) 51%);
background-size: 100% 4px;
pointer-events: none;
z-index: 9999;
opacity: 0.3;
}
.glow { box-shadow: 0 0 30px rgba(59, 130, 246, 0.2); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.animate-fade-in { animation: fadeIn 0.5s ease-out; }
.loading { display: flex; align-items: center; justify-content: center; height: 100%; }
.spinner { width: 40px; height: 40px; border: 4px solid #3b82f6; border-top-color: transparent; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* Custom Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #1e293b; }
::-webkit-scrollbar-thumb { background: #475569; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #64748b; }
</style>
</head>
<body class="min-h-screen text-slate-200 selection:bg-blue-500/30 selection:text-blue-200">
<!-- Scanline Effect -->
<div class="scanline"></div>
<!-- Particle Background -->
<canvas id="particle-bg" class="fixed inset-0 -z-10 pointer-events-none opacity-40"></canvas>
<!-- Header -->
<header class="bg-slate-900/80 backdrop-blur-md border-b border-slate-700 sticky top-0 z-50 shadow-lg shadow-blue-900/5">
<div class="max-w-7xl mx-auto px-4 py-4">
<div class="flex items-center justify-between flex-wrap gap-4">
<div class="flex items-center space-x-3">
<div class="w-10 h-10 bg-gradient-to-br from-blue-500 to-purple-600 rounded-xl flex items-center justify-center">
<svg class="w-6 h-6 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"/>
</svg>
</div>
<div>
<h1 class="text-xl font-bold text-white">OpenCollab-Insight</h1>
<p class="text-xs text-slate-400">开源协作网络洞察平台 - 接入真实 OpenDigger 数据</p>
</div>
</div>
<!-- 仓库选择 -->
<div class="flex items-center space-x-2">
<svg class="w-5 h-5 text-slate-400" fill="currentColor" viewBox="0 0 24 24"><path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"/></svg>
<select id="repo-select" class="bg-slate-800 border border-slate-600 rounded-lg px-3 py-2 text-white text-sm focus:outline-none focus:border-blue-500">
<option value="X-lab2017/open-digger">X-lab2017/open-digger</option>
<option value="apache/iotdb">apache/iotdb</option>
<option value="easy-graph/Easy-Graph">easy-graph/Easy-Graph</option>
<option value="1Panel-dev/MaxKB">1Panel-dev/MaxKB</option>
<option value="dataease/DataEase">dataease/DataEase</option>
</select>
<button onclick="loadRepoData()" class="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white text-sm font-medium rounded-lg transition-colors">
分析
</button>
</div>
</div>
<!-- Tabs -->
<nav class="flex space-x-1 mt-4 overflow-x-auto">
<button onclick="showTab('dashboard')" id="tab-dashboard" class="tab-btn flex items-center space-x-2 px-4 py-2 rounded-lg font-medium bg-blue-600 text-white whitespace-nowrap">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"/></svg>
<span>总览</span>
</button>
<button onclick="showTab('network')" id="tab-network" class="tab-btn flex items-center space-x-2 px-4 py-2 rounded-lg font-medium text-slate-400 hover:text-white hover:bg-slate-800 whitespace-nowrap">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"/></svg>
<span>协作网络</span>
</button>
<button onclick="showTab('contributors')" id="tab-contributors" class="tab-btn flex items-center space-x-2 px-4 py-2 rounded-lg font-medium text-slate-400 hover:text-white hover:bg-slate-800 whitespace-nowrap">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z"/></svg>
<span>贡献者</span>
</button>
<button onclick="showTab('health')" id="tab-health" class="tab-btn flex items-center space-x-2 px-4 py-2 rounded-lg font-medium text-slate-400 hover:text-white hover:bg-slate-800 whitespace-nowrap">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"/></svg>
<span>健康度</span>
</button>
<button onclick="showTab('timeline')" id="tab-timeline" class="tab-btn flex items-center space-x-2 px-4 py-2 rounded-lg font-medium text-slate-400 hover:text-white hover:bg-slate-800 whitespace-nowrap">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
<span>时光机</span>
</button>
<button onclick="showTab('simulation')" id="tab-simulation" class="tab-btn flex items-center space-x-2 px-4 py-2 rounded-lg font-medium text-indigo-300 hover:text-white bg-indigo-500/20 hover:bg-indigo-500/40 border border-indigo-500/30 whitespace-nowrap transition-all">
<svg class="w-4 h-4 animate-pulse" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19.428 15.428a2 2 0 00-1.022-.547l-2.387-.477a6 6 0 00-3.86.517l-.318.158a6 6 0 01-3.86.517L6.05 15.21a2 2 0 00-1.806.547M8 4h8l-1 1v5.172a2 2 0 00.586 1.414l5 5c1.26 1.26.367 3.414-1.415 3.414H4.828c-1.782 0-2.674-2.154-1.414-3.414l5-5A2 2 0 009 10.172V5L8 4z"/></svg>
<span>沙盘推演</span>
</button>
</nav>
</div>
</header>
<!-- Loading Overlay -->
<div id="loading-overlay" class="fixed inset-0 bg-slate-900/80 backdrop-blur-sm z-50 hidden flex items-center justify-center">
<div class="flex flex-col items-center">
<div class="spinner mb-4"></div>
<p id="loading-text" class="text-slate-300 text-lg font-medium">正在连接后端服务...</p>
<p id="loading-progress" class="text-slate-400 text-sm mt-2 font-mono"></p>
</div>
</div>
<!-- Contributor DNA Card (Hidden by default) -->
<div id="dna-card" class="fixed top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 w-[400px] bg-slate-900/95 backdrop-blur-2xl border border-purple-500/30 rounded-2xl shadow-[0_0_50px_rgba(147,51,234,0.2)] p-6 z-50 hidden animate-fade-in hud-card">
<button onclick="document.getElementById('dna-card').classList.add('hidden')" class="absolute top-4 right-4 text-slate-400 hover:text-white">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/></svg>
</button>
<div class="flex items-center space-x-4 mb-6">
<div class="relative">
<div class="w-16 h-16 rounded-full bg-gradient-to-br from-purple-500 to-blue-500 p-0.5">
<img id="dna-avatar" src="" alt="Avatar" class="w-full h-full rounded-full bg-slate-900 object-cover">
</div>
<div class="absolute -bottom-1 -right-1 w-6 h-6 bg-green-500 rounded-full border-2 border-slate-900 flex items-center justify-center text-[10px] font-bold text-white">A</div>
</div>
<div>
<h3 class="text-xl font-bold text-white flex items-center">
<span id="dna-name">Username</span>
<a id="dna-link" href="#" target="_blank" class="ml-2 text-slate-400 hover:text-blue-400">
<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 24 24"><path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"/></svg>
</a>
</h3>
<div class="flex flex-wrap gap-2 mt-2">
<span id="dna-role" class="px-2 py-0.5 rounded text-xs font-medium bg-purple-500/20 text-purple-300 border border-purple-500/30">核心贡献者</span>
<span id="dna-type" class="px-2 py-0.5 rounded text-xs font-medium bg-blue-500/20 text-blue-300 border border-blue-500/30">代码狂人</span>
</div>
</div>
</div>
<!-- Radar Chart for DNA -->
<div class="relative h-48 mb-4">
<div id="dna-radar" class="w-full h-full"></div>
</div>
<!-- AI Analysis -->
<div class="bg-slate-800/50 rounded-xl p-4 border border-slate-700">
<div class="flex items-center mb-2">
<div class="w-5 h-5 rounded-full bg-gradient-to-r from-indigo-500 to-purple-500 flex items-center justify-center text-[10px] font-bold text-white mr-2">AI</div>
<h4 class="text-sm font-semibold text-indigo-200">AI 猎头评价</h4>
</div>
<p id="dna-analysis" class="text-xs text-slate-400 leading-relaxed">
正在分析该开发者的贡献基因...
</p>
</div>
</div>
<!-- Main Content -->
<main class="max-w-7xl mx-auto px-4 py-6">
<!-- Dashboard Tab -->
<div id="content-dashboard" class="tab-content animate-fade-in">
<!-- Stats Cards -->
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-6">
<div class="card hud-card border-0 rounded-2xl p-6">
<div class="flex items-start justify-between">
<div>
<p class="text-slate-400 text-sm mb-1 font-medium tracking-wider uppercase text-xs">开发者总数</p>
<p class="text-3xl font-bold text-white font-mono" id="stat-developers">--</p>
<p class="text-slate-500 text-xs mt-1">ACTIVE CONTRIBUTORS</p>
</div>
<div class="w-12 h-12 rounded-xl bg-blue-600/20 border border-blue-500/30 flex items-center justify-center text-blue-400">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z"/></svg>
</div>
</div>
</div>
<div class="card hud-card border-0 rounded-2xl p-6">
<div class="flex items-start justify-between">
<div>
<p class="text-slate-400 text-sm mb-1 font-medium tracking-wider uppercase text-xs">协作连接</p>
<p class="text-3xl font-bold text-white font-mono" id="stat-edges">--</p>
<p class="text-slate-500 text-xs mt-1">RELATIONSHIP EDGES</p>
</div>
<div class="w-12 h-12 rounded-xl bg-green-600/20 border border-green-500/30 flex items-center justify-center text-green-400">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"/></svg>
</div>
</div>
</div>
<div class="card hud-card border-0 rounded-2xl p-6">
<div class="flex items-start justify-between">
<div>
<p class="text-slate-400 text-sm mb-1 font-medium tracking-wider uppercase text-xs">当前 OpenRank</p>
<p class="text-3xl font-bold text-white font-mono" id="stat-openrank">--</p>
<p class="text-slate-500 text-xs mt-1">LATEST VALUE</p>
</div>
<div class="w-12 h-12 rounded-xl bg-purple-600/20 border border-purple-500/30 flex items-center justify-center text-purple-400">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 7h8m0 0v8m0-8l-8 8-4-4-6 6"/></svg>
</div>
</div>
</div>
<div class="card hud-card border-0 rounded-2xl p-6">
<div class="flex items-start justify-between">
<div>
<p class="text-slate-400 text-sm mb-1 font-medium tracking-wider uppercase text-xs">活跃度</p>
<p class="text-3xl font-bold text-white font-mono" id="stat-activity">--</p>
<p class="text-slate-500 text-xs mt-1">MONTHLY ACTIVITY</p>
</div>
<div class="w-12 h-12 rounded-xl bg-amber-600/20 border border-amber-500/30 flex items-center justify-center text-amber-400">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"/></svg>
</div>
</div>
</div>
</div>
<!-- Charts Row -->
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-6">
<div class="card hud-card border-0 rounded-2xl p-6">
<h3 class="text-lg font-semibold text-white mb-4 flex items-center">
<svg class="w-5 h-5 mr-2 text-blue-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 7h8m0 0v8m0-8l-8 8-4-4-6 6"/></svg>
OpenRank 趋势 <span class="text-xs text-slate-500 ml-2">(来自 OpenDigger API)</span>
</h3>
<div id="openrank-chart" style="height: 280px;"></div>
</div>
<div class="card hud-card border-0 rounded-2xl p-6">
<h3 class="text-lg font-semibold text-white mb-4 flex items-center">
<svg class="w-5 h-5 mr-2 text-green-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"/></svg>
社区活跃度 <span class="text-xs text-slate-500 ml-2">(来自 OpenDigger API)</span>
</h3>
<div id="activity-chart" style="height: 280px;"></div>
</div>
</div>
<!-- Top Contributors -->
<div class="card hud-card border-0 rounded-2xl p-6">
<h3 class="text-lg font-semibold text-white mb-4">核心贡献者 Top 10 <span class="text-xs text-slate-500 ml-2">(基于 developer_network 数据)</span></h3>
<div class="space-y-3" id="top-contributors"></div>
</div>
</div>
<!-- Network Tab -->
<div id="content-network" class="tab-content hidden animate-fade-in">
<div class="card hud-card border-0 rounded-2xl p-4 mb-4">
<div class="flex items-center justify-between flex-wrap gap-2">
<h2 class="text-lg font-semibold text-white">开发者协作网络图谱 <span class="text-xs text-slate-500">(真实数据)</span></h2>
<div class="flex items-center space-x-4 text-sm text-slate-400">
<span id="network-nodes">-- 节点</span>
<span>•</span>
<span id="network-edges">-- 连接</span>
</div>
</div>
</div>
<div class="card hud-card border-0 rounded-2xl p-2 glow">
<div id="network-chart" style="height: 600px;"></div>
</div>
<p class="text-center text-slate-500 text-sm mt-4">💡 提示:拖拽节点可调整位置,滚轮缩放,点击节点高亮关联关系。数据来源:OpenDigger developer_network API</p>
</div>
<!-- Contributors Tab -->
<div id="content-contributors" class="tab-content hidden animate-fade-in">
<div class="card hud-card border-0 rounded-2xl overflow-hidden">
<table class="w-full">
<thead>
<tr class="border-b border-slate-700">
<th class="px-6 py-4 text-left text-sm font-medium text-slate-400">排名</th>
<th class="px-6 py-4 text-left text-sm font-medium text-slate-400">开发者</th>
<th class="px-6 py-4 text-right text-sm font-medium text-slate-400">网络权重</th>
<th class="px-6 py-4 text-right text-sm font-medium text-slate-400">连接数</th>
</tr>
</thead>
<tbody id="contributors-table"></tbody>
</table>
</div>
</div>
<!-- Health Tab -->
<div id="content-health" class="tab-content hidden animate-fade-in">
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-6">
<div class="card hud-card border-0 rounded-2xl p-6">
<h3 class="text-lg font-semibold text-white mb-4 flex items-center">
<svg class="w-5 h-5 mr-2 text-red-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"/></svg>
总体健康度
</h3>
<div id="health-gauge" style="height: 250px;"></div>
</div>
<div class="lg:col-span-2 card hud-card border-0 rounded-2xl p-6">
<h3 class="text-lg font-semibold text-white mb-4">多维度健康分析</h3>
<div id="health-radar" style="height: 280px;"></div>
</div>
</div>
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
<div class="card hud-card border-0 bg-amber-500/10 rounded-2xl p-6">
<h3 class="text-lg font-semibold text-white mb-4 flex items-center">
<svg class="w-5 h-5 mr-2 text-amber-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"/></svg>
风险分析
</h3>
<div class="space-y-3" id="risk-analysis"></div>
</div>
<div class="card hud-card border-0 bg-green-500/10 rounded-2xl p-6">
<h3 class="text-lg font-semibold text-white mb-4 flex items-center">
<svg class="w-5 h-5 mr-2 text-green-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
优化建议
</h3>
<div class="space-y-3" id="suggestions"></div>
</div>
</div>
</div>
<!-- Timeline Tab (OpenSource Time Machine) -->
<div id="content-timeline" class="tab-content hidden animate-fade-in">
<div class="card hud-card border-0 rounded-2xl p-8 bg-slate-800/50 relative overflow-hidden">
<div class="absolute top-0 left-0 w-full h-full bg-gradient-to-b from-transparent via-blue-900/5 to-transparent pointer-events-none"></div>
<div class="flex items-center justify-between mb-10 relative z-10">
<div>
<h2 class="text-2xl font-bold text-white flex items-center">
<span class="text-4xl mr-3">🕰️</span> 开源时光机
</h2>
<p class="text-slate-400 mt-2">一分钟读懂项目的“前世今生”与关键里程碑</p>
</div>
<div class="px-4 py-2 bg-blue-600/20 border border-blue-500/30 rounded-lg text-blue-300 text-sm font-mono">
Generated by OpenDigger History
</div>
</div>
<div class="relative ml-4 md:ml-10 pb-10" id="timeline-container">
<!-- Timeline Line -->
<div class="absolute top-0 bottom-0 left-[19px] md:left-[20px] w-0.5 bg-gradient-to-b from-blue-500 via-purple-500 to-slate-700"></div>
<!-- Content will be injected by JS -->
</div>
</div>
</div>
<!-- Simulation Tab -->
<div id="content-simulation" class="tab-content hidden animate-fade-in">
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6 h-[600px]">
<!-- Controls -->
<div class="lg:col-span-1 card hud-card border-0 p-6 flex flex-col space-y-6 rounded-2xl bg-slate-800/80">
<div>
<h3 class="text-xl font-bold text-white flex items-center">
<span class="w-1 h-6 bg-indigo-500 rounded-full mr-3"></span>
推演参数设置
</h3>
<p class="text-slate-400 text-xs mt-1">调整变量,预测未来 6 个月的社区演化</p>
</div>
<!-- Sliders -->
<div class="space-y-6 flex-1">
<div class="space-y-2">
<div class="flex justify-between text-sm">
<span class="text-slate-300">资金注入 (Funding)</span>
<span class="text-indigo-400 font-mono" id="val-funding">¥0</span>
</div>
<input type="range" min="0" max="1000000" step="50000" value="0"
class="w-full h-2 bg-slate-700 rounded-lg appearance-none cursor-pointer accent-indigo-500"
oninput="document.getElementById('val-funding').innerText = '¥' + parseInt(this.value).toLocaleString()">
</div>
<div class="space-y-2">
<div class="flex justify-between text-sm">
<span class="text-slate-300">新增全职开发者</span>
<span class="text-indigo-400 font-mono" id="val-devs">0 人</span>
</div>
<input type="range" min="0" max="10" step="1" value="0"
class="w-full h-2 bg-slate-700 rounded-lg appearance-none cursor-pointer accent-indigo-500"
oninput="document.getElementById('val-devs').innerText = this.value + ' 人'">
</div>
<div class="pt-4 border-t border-slate-700/50">
<label class="flex items-center space-x-3 cursor-pointer group">
<input type="checkbox" id="chk-core-leave" class="form-checkbox h-5 w-5 text-red-500 rounded border-slate-600 bg-slate-700 focus:ring-red-500 focus:ring-offset-0 transition duration-150 ease-in-out">
<div>
<span class="text-slate-300 group-hover:text-red-400 transition-colors">模拟核心人员流失</span>
<p class="text-xs text-slate-500">移除 Top 1 贡献者</p>
</div>
</label>
</div>
</div>
<button onclick="runSimulation()" id="btn-run-sim" class="w-full py-3 bg-gradient-to-r from-indigo-600 to-purple-600 rounded-xl text-white font-bold shadow-lg shadow-indigo-500/30 hover:shadow-indigo-500/50 hover:scale-[1.02] transition-all active:scale-95 flex items-center justify-center space-x-2">
<svg class="w-5 h-5 animate-pulse" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"/><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
<span>启动推演引擎</span>
</button>
</div>
<!-- Visualization -->
<div class="lg:col-span-2 flex flex-col space-y-4">
<!-- Metric Comparison Dashboard (New) -->
<div id="sim-metrics" class="grid grid-cols-3 gap-4 hidden animate-fade-in">
<div class="bg-slate-800/50 p-3 rounded-xl border border-slate-700">
<p class="text-slate-400 text-xs">Bus Factor (抗风险)</p>
<div class="flex items-baseline space-x-2 mt-1">
<span class="text-xl font-bold text-white" id="metric-bf-new">--</span>
<span class="text-xs text-slate-500 line-through" id="metric-bf-old">--</span>
<span class="text-xs font-bold" id="metric-bf-diff"></span>
</div>
</div>
<div class="bg-slate-800/50 p-3 rounded-xl border border-slate-700">
<p class="text-slate-400 text-xs">网络密度 (协作)</p>
<div class="flex items-baseline space-x-2 mt-1">
<span class="text-xl font-bold text-white" id="metric-density-new">--</span>
<span class="text-xs text-slate-500 line-through" id="metric-density-old">--</span>
<span class="text-xs font-bold" id="metric-density-diff"></span>
</div>
</div>
<div class="bg-slate-800/50 p-3 rounded-xl border border-slate-700">
<p class="text-slate-400 text-xs">活跃人数</p>
<div class="flex items-baseline space-x-2 mt-1">
<span class="text-xl font-bold text-white" id="metric-nodes-new">--</span>
<span class="text-xs text-slate-500" id="metric-nodes-old">--</span>
<span class="text-xs font-bold text-green-400" id="metric-nodes-diff"></span>
</div>
</div>
</div>
<!-- AI Report Card (Accordion Style) -->
<div id="sim-report" class="card p-4 border border-indigo-500/30 bg-indigo-900/10 hidden animate-fade-in rounded-xl flex flex-col space-y-2 max-h-[300px] overflow-y-auto custom-scrollbar">
<div class="flex items-center mb-2">
<div class="w-6 h-6 rounded-full bg-indigo-600 flex items-center justify-center flex-shrink-0 shadow-lg shadow-indigo-500/30 mr-2">
<span class="text-white font-bold text-[10px]">AI</span>
</div>
<h4 class="text-indigo-300 font-bold text-sm">未来预测报告 <span class="ml-2 text-[10px] bg-indigo-500/20 text-indigo-300 px-1.5 py-0.5 rounded">Gemini Pro</span></h4>
</div>
<!-- Accordion 1: 深度洞察 -->
<details class="group bg-slate-800/40 rounded-lg border border-slate-700/50 open:bg-slate-800/80 transition-colors" open>
<summary class="flex items-center justify-between p-3 cursor-pointer select-none">
<span class="text-sm font-medium text-blue-300 flex items-center">
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"/></svg>
深度洞察
</span>
<svg class="w-4 h-4 text-slate-500 transition-transform group-open:rotate-180" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/></svg>
</summary>
<div class="px-3 pb-3 text-xs text-slate-300 leading-relaxed typewriter" id="report-insight">
正在分析数据...
</div>
</details>
<!-- Accordion 2: 风险预警 -->
<details class="group bg-slate-800/40 rounded-lg border border-slate-700/50 open:bg-slate-800/80 transition-colors">
<summary class="flex items-center justify-between p-3 cursor-pointer select-none">
<span class="text-sm font-medium text-amber-300 flex items-center">
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"/></svg>
风险预警
</span>
<svg class="w-4 h-4 text-slate-500 transition-transform group-open:rotate-180" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/></svg>
</summary>
<div class="px-3 pb-3 text-xs text-slate-300 leading-relaxed typewriter" id="report-risk"></div>
</details>
<!-- Accordion 3: 治理良方 -->
<details class="group bg-slate-800/40 rounded-lg border border-slate-700/50 open:bg-slate-800/80 transition-colors">
<summary class="flex items-center justify-between p-3 cursor-pointer select-none">
<span class="text-sm font-medium text-green-300 flex items-center">
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
治理良方
</span>
<svg class="w-4 h-4 text-slate-500 transition-transform group-open:rotate-180" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/></svg>
</summary>
<div class="px-3 pb-3 text-xs text-slate-300 leading-relaxed typewriter" id="report-action"></div>
</details>
</div>
<!-- Graph Area -->
<div class="card p-1 flex-1 relative overflow-hidden group border border-slate-700/50 rounded-2xl bg-slate-800/50">
<div class="absolute top-4 left-4 z-10 flex space-x-2">
<div class="bg-slate-900/80 backdrop-blur px-3 py-1 rounded text-xs text-slate-400 border border-slate-700 flex items-center">
<span class="w-2 h-2 rounded-full bg-green-500 mr-2"></span>原有成员
</div>
<div class="bg-slate-900/80 backdrop-blur px-3 py-1 rounded text-xs text-slate-400 border border-slate-700 flex items-center">
<span class="w-2 h-2 rounded-full bg-orange-500 mr-2 animate-pulse"></span>新增力量
</div>
</div>
<div id="sim-network-chart" class="w-full h-full" style="min-height: 350px;"></div>
<!-- Loading Overlay -->
<div id="sim-loading" class="absolute inset-0 bg-slate-900/80 backdrop-blur-sm flex flex-col items-center justify-center z-20 hidden">
<div class="w-16 h-16 border-4 border-indigo-500 border-t-transparent rounded-full animate-spin mb-4"></div>
<p class="text-indigo-300 font-mono animate-pulse">正在构建平行宇宙...</p>
</div>
<!-- Empty State -->
<div id="sim-empty" class="absolute inset-0 flex flex-col items-center justify-center text-slate-500 pointer-events-none">
<svg class="w-16 h-16 mb-4 opacity-50" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1" d="M19.428 15.428a2 2 0 00-1.022-.547l-2.387-.477a6 6 0 00-3.86.517l-.318.158a6 6 0 01-3.86.517L6.05 15.21a2 2 0 00-1.806.547M8 4h8l-1 1v5.172a2 2 0 00.586 1.414l5 5c1.26 1.26.367 3.414-1.415 3.414H4.828c-1.782 0-2.674-2.154-1.414-3.414l5-5A2 2 0 009 10.172V5L8 4z"/></svg>
<p>请配置左侧参数并点击启动</p>
</div>
</div>
</div>
</div>
</div>
</main>
<!-- AI Assistant Floating Button -->
<div class="fixed bottom-6 right-6 z-50 flex flex-col items-end space-y-4">
<!-- Chat Panel -->
<div id="ai-panel" class="hidden w-96 bg-slate-900/95 backdrop-blur-xl border border-blue-500/30 rounded-2xl shadow-2xl overflow-hidden flex flex-col transition-all duration-300 transform origin-bottom-right scale-95 opacity-0" style="height: 500px;">
<!-- Header -->
<div class="bg-gradient-to-r from-blue-600 to-purple-600 p-4 flex justify-between items-center">
<div class="flex items-center space-x-2">
<div class="w-8 h-8 bg-white/20 rounded-lg flex items-center justify-center backdrop-blur-sm">
<svg class="w-5 h-5 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/></svg>
</div>
<div>
<h3 class="text-white font-bold text-sm">AI 社区分析师</h3>
<p class="text-blue-100 text-xs flex items-center">
<span class="w-2 h-2 bg-green-400 rounded-full mr-1 animate-pulse"></span>
Online
</p>
</div>
</div>
<button onclick="toggleAI()" class="text-white/80 hover:text-white transition-colors">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/></svg>
</button>
</div>
<!-- Content -->
<div class="flex-1 p-4 overflow-y-auto space-y-4" id="ai-messages">
<!-- Welcome Message -->
<div class="flex items-start space-x-3">
<div class="w-8 h-8 rounded-full bg-gradient-to-br from-blue-500 to-purple-600 flex-shrink-0 flex items-center justify-center text-white text-xs font-bold">AI</div>
<div class="bg-slate-800/80 p-3 rounded-2xl rounded-tl-none border border-slate-700 text-slate-300 text-sm shadow-sm">
你好!我是 OpenCollab 的 AI 分析师。我已经读取了当前仓库的所有数据。<br><br>您可以点击下方按钮,让我为您生成一份深度诊断报告。
</div>
</div>
</div>
<!-- Actions -->
<div class="p-4 bg-slate-900 border-t border-slate-800">
<div class="flex items-center space-x-2">
<input type="text" id="chat-input" placeholder="输入指令 (例: 高亮核心贡献者)..."
class="flex-1 bg-slate-800 border border-slate-700 rounded-lg px-4 py-2 text-sm text-white focus:outline-none focus:border-blue-500 transition-colors"
onkeypress="if(event.key === 'Enter') sendChat()">
<button onclick="sendChat()" id="btn-send-chat" class="bg-blue-600 hover:bg-blue-500 text-white rounded-lg px-4 py-2 text-sm font-medium transition-all shadow-lg shadow-blue-900/20 flex items-center justify-center">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 19l9 2-9-18-9 18 9-2zm0 0v-8"/></svg>
</button>
</div>
<button onclick="generateAIReport()" class="mt-2 w-full text-xs text-slate-500 hover:text-blue-400 underline">
生成深度诊断报告
</button>
</div>
</div>
<!-- Floating Button -->
<button onclick="toggleAI()" class="group flex items-center justify-center w-14 h-14 bg-gradient-to-br from-blue-600 to-purple-600 rounded-full shadow-lg hover:scale-110 transition-all duration-300 hover:shadow-blue-500/50 focus:outline-none ring-4 ring-blue-500/30">
<svg class="w-7 h-7 text-white animate-[pulse_3s_infinite]" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19.428 15.428a2 2 0 00-1.022-.547l-2.387-.477a6 6 0 00-3.86.517l-.318.158a6 6 0 01-3.86.517L6.05 15.21a2 2 0 00-1.806.547M8 4h8l-1 1v5.172a2 2 0 00.586 1.414l5 5c1.26 1.26.367 3.414-1.415 3.414H4.828c-1.782 0-2.674-2.154-1.414-3.414l5-5A2 2 0 009 10.172V5L8 4z"/></svg>
<!-- Tooltip -->
<span class="absolute right-full mr-4 px-3 py-1 bg-slate-800 text-white text-sm rounded-lg opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap pointer-events-none border border-slate-700">
AI 智能分析
</span>
</button>
</div>
<!-- Footer -->
<footer class="text-center py-6 text-slate-500 text-sm border-t border-slate-800 mt-8">
<div id="data-source-status" class="mb-3 flex items-center justify-center space-x-2">
<div class="w-2 h-2 rounded-full bg-slate-500" id="status-indicator"></div>
<p id="data-source-text" class="text-slate-400">正在加载数据...</p>
</div>
<p>技术栈:<a href="https://github.com/X-lab2017/open-digger" class="text-blue-400 hover:underline">OpenDigger</a> |
<a href="https://github.com/easy-graph/Easy-Graph" class="text-blue-400 hover:underline">EasyGraph</a> |
<span id="backend-status" class="text-slate-500">后端: FastAPI</span></p>
<p class="mt-2">OpenCollab-Insight © 2025 | OpenSODA 2025 参赛作品</p>
</footer>
<script>
// ==================== 全局状态 ====================
const OPENDIGGER_BASE = 'https://oss.x-lab.info/open_digger/github';
// 备用 CORS 代理列表
const CORS_PROXIES = [
'', // 直接访问
'https://api.allorigins.win/raw?url=',
'https://corsproxy.io/?'
];
// 移除 currentProxyIndex,改为并发竞速
let currentRepo = 'X-lab2017/open-digger';
let repoData = {
openrank: null,
activity: null,
network: null
};
// ==================== OpenDigger API 调用 ====================
async function fetchOpenDiggerData(repo, metric) {
const originalUrl = `${OPENDIGGER_BASE}/${repo}/${metric}.json`;
// 并发请求所有代理,设置 5秒超时
const promises = CORS_PROXIES.map(proxy => {
return new Promise(async (resolve, reject) => {
const url = proxy ? `${proxy}${encodeURIComponent(originalUrl)}` : originalUrl;
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 5000); // 5秒超时
try {
const response = await fetch(url, {
method: 'GET',
headers: { 'Accept': 'application/json' },
signal: controller.signal
});
clearTimeout(timeoutId);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const data = await response.json();
console.log(`Success: ${metric} via ${proxy || 'direct'}`);
resolve(data);
} catch (error) {
clearTimeout(timeoutId);
reject(error);
}
});
});
try {
// 使用 Promise.any 返回最快的一个成功结果
return await Promise.any(promises);
} catch (error) {
console.warn(`All sources failed for ${metric}`);
return null;
}
}
function showErrorMessage(msg) {
const toast = document.createElement('div');
toast.className = 'fixed top-20 left-1/2 transform -translate-x-1/2 bg-amber-600 text-white px-6 py-3 rounded-lg shadow-lg z-50 animate-fade-in';
toast.textContent = msg;
document.body.appendChild(toast);
setTimeout(() => toast.remove(), 4000);
}
// 加载演示历史数据(基于当前仓库的贡献者数动态生成,让数据看起来更真实)
function loadDemoHistoryData() {
console.log('[Demo] 使用演示历史数据(动态生成)');
// 基于网络图节点数生成基准值
const nodeCount = repoData.network?.nodes?.length || 15;
const baseOpenRank = nodeCount * 1.5; // 基准 OpenRank
const baseActivity = nodeCount * 15; // 基准 Activity
// 生成2020-2024的月度数据,模拟项目成长曲线
const openrankData = {};
const activityData = {};
const startYear = 2020;
const startMonth = 8;
const endYear = 2024;
const endMonth = 10;
let currentValue = baseOpenRank * 0.3; // 起始值较低
let trend = 1.02; // 增长趋势
for (let year = startYear; year <= endYear; year++) {
let yearTotal = 0;
const monthStart = (year === startYear) ? startMonth : 1;
const monthEnd = (year === endYear) ? endMonth : 12;
for (let month = monthStart; month <= monthEnd; month++) {
const monthKey = `${year}-${String(month).padStart(2, '0')}`;
// 添加随机波动和季节性
const randomFactor = 0.9 + Math.random() * 0.2; // ±10%
const seasonalFactor = 1 + 0.1 * Math.sin((month - 1) / 12 * Math.PI * 2); // 季节性
currentValue = currentValue * trend * randomFactor * seasonalFactor;
// 2023年达到顶峰后开始下降(模拟真实项目周期)
if (year >= 2023 && month >= 6) {
trend = 0.98; // 下降趋势
}
openrankData[monthKey] = parseFloat(currentValue.toFixed(2));
yearTotal += currentValue;
// Activity 数据与 OpenRank 相关但波动更大
const activityValue = currentValue * (10 + Math.random() * 5);
activityData[monthKey] = parseFloat(activityValue.toFixed(2));
}
// 年度汇总
openrankData[year.toString()] = parseFloat((yearTotal / (monthEnd - monthStart + 1)).toFixed(2));
activityData[year.toString()] = parseFloat((yearTotal * 12).toFixed(2));
}
repoData.openrank = openrankData;
repoData.activity = activityData;
console.log('[Demo] 生成数据范围:', {
openrank: `${Math.min(...Object.values(openrankData)).toFixed(1)} - ${Math.max(...Object.values(openrankData)).toFixed(1)}`,
activity: `${Math.min(...Object.values(activityData)).toFixed(1)} - ${Math.max(...Object.values(activityData)).toFixed(1)}`
});
}
// 演示数据(当 API 不可用时使用)
function loadDemoData() {
repoData = {
openrank: {
"2020": 23.45, "2021": 35.67, "2022": 52.89, "2023": 68.12, "2024": 45.23,
"2020-08": 5.2, "2020-09": 6.1, "2020-10": 5.8, "2020-11": 6.3, "2020-12": 7.5,
"2021-01": 8.2, "2021-02": 7.8, "2021-03": 9.1, "2021-04": 8.5, "2021-05": 9.8,
"2021-06": 10.2, "2021-07": 9.5, "2021-08": 11.3, "2021-09": 10.8, "2021-10": 12.1,
"2021-11": 11.5, "2021-12": 13.2, "2022-01": 12.8, "2022-02": 14.5, "2022-03": 15.2,
"2022-04": 14.8, "2022-05": 16.3, "2022-06": 17.1, "2022-07": 16.5, "2022-08": 18.2,
"2022-09": 17.8, "2022-10": 19.5, "2022-11": 20.1, "2022-12": 21.3, "2023-01": 22.5,
"2023-02": 24.1, "2023-03": 23.5, "2023-04": 25.2, "2023-05": 26.8, "2023-06": 25.5,
"2023-07": 27.3, "2023-08": 28.1, "2023-09": 26.8, "2023-10": 29.5, "2023-11": 30.2,
"2023-12": 31.5, "2024-01": 32.1, "2024-02": 33.8, "2024-03": 31.5, "2024-04": 28.6,
"2024-05": 25.3, "2024-06": 22.1, "2024-07": 20.5, "2024-08": 18.9, "2024-09": 16.2,
"2024-10": 14.5
},
activity: {
"2020": 197.38, "2021": 260.01, "2022": 430.25, "2023": 475.13, "2024": 261.16,
"2020-08": 32.4, "2020-09": 39.18, "2020-10": 28.11, "2020-11": 30.43, "2020-12": 67.26,
"2021-01": 52.47, "2021-02": 24.26, "2021-03": 14.43, "2021-04": 29.76, "2021-05": 19.2,
"2021-06": 39.79, "2021-07": 16.64, "2021-08": 12.68, "2021-09": 5.02, "2021-10": 14,
"2021-11": 19.1, "2021-12": 24.56, "2022-01": 24.11, "2022-02": 16.46, "2022-03": 42.58,
"2022-04": 22.2, "2022-05": 24.27, "2022-06": 44.6, "2022-07": 37.06, "2022-08": 31.09,
"2022-09": 38.87, "2022-10": 51.78, "2022-11": 49.82, "2022-12": 47.41, "2023-01": 49.53,
"2023-02": 98.65, "2023-03": 37.24, "2023-04": 46.64, "2023-05": 44.96, "2023-06": 28.6,
"2023-07": 30.65, "2023-08": 34.12, "2023-09": 28.22, "2023-10": 29.96, "2023-11": 24.62,
"2023-12": 21.93, "2024-01": 36.2, "2024-02": 76.32, "2024-03": 18.03, "2024-04": 14.49,
"2024-05": 20.55, "2024-06": 17.21, "2024-07": 24.34, "2024-08": 28.39, "2024-09": 19.31,
"2024-10": 6.31
},
network: {
nodes: [
["frank-zsy", 16.28], ["xgdyp", 13.68], ["Zzzzzhuzhiwei", 11.13], ["birdflyi", 9.52],
["PureNatural", 8.68], ["tyn1998", 5.65], ["stevending1st", 5.47], ["bifenglin", 5.38],
["will-ww", 3.15], ["lhbvvvvv", 2.65], ["tc2000731", 2.65], ["318352733", 2.65],
["xiaoya-yaya", 2.45], ["zhicheng-ning", 1.73], ["snyk-bot", 1.73], ["WillemJiang", 1.41],
["dwxa", 1], ["yanchaomei", 1], ["Lllllolita", 1], ["tisonkun", 1]
],
edges: [
["bifenglin", "will-ww", 13.32], ["tyn1998", "frank-zsy", 11.87], ["zhicheng-ning", "will-ww", 10.82],
["tyn1998", "bifenglin", 9.84], ["Zzzzzhuzhiwei", "frank-zsy", 9.52], ["tyn1998", "will-ww", 9.15],
["Zzzzzhuzhiwei", "will-ww", 8.83], ["xgdyp", "frank-zsy", 8.44], ["Zzzzzhuzhiwei", "tyn1998", 7.93],
["lhbvvvvv", "tyn1998", 7.84], ["PureNatural", "bifenglin", 7.75], ["zhicheng-ning", "tyn1998", 7.73],
["Zzzzzhuzhiwei", "xgdyp", 7.71], ["xgdyp", "PureNatural", 7.67], ["will-ww", "frank-zsy", 7.62],
["xgdyp", "bifenglin", 7.61], ["xiaoya-yaya", "bifenglin", 7.42], ["Zzzzzhuzhiwei", "lhbvvvvv", 7.37],
["tyn1998", "PureNatural", 7.32], ["PureNatural", "frank-zsy", 7.29], ["PureNatural", "will-ww", 7.06],
["birdflyi", "xgdyp", 6.99], ["xgdyp", "tyn1998", 6.96], ["lhbvvvvv", "will-ww", 6.92],
["tyn1998", "stevending1st", 6.85], ["stevending1st", "frank-zsy", 6.84], ["birdflyi", "frank-zsy", 6.71],
["Zzzzzhuzhiwei", "PureNatural", 6.49], ["bifenglin", "frank-zsy", 6.4], ["zhicheng-ning", "bifenglin", 6.34],
["Zzzzzhuzhiwei", "birdflyi", 6.22], ["xiaoya-yaya", "will-ww", 6.19], ["xgdyp", "will-ww", 6.14],
["Zzzzzhuzhiwei", "zhicheng-ning", 6.11], ["birdflyi", "bifenglin", 6.04], ["birdflyi", "PureNatural", 6.01],
["lhbvvvvv", "frank-zsy", 5.92], ["Zzzzzhuzhiwei", "bifenglin", 5.79], ["zhicheng-ning", "frank-zsy", 5.33],
["birdflyi", "tyn1998", 5.19], ["xiaoya-yaya", "tyn1998", 5.09], ["birdflyi", "will-ww", 4.97],
["lhbvvvvv", "zhicheng-ning", 4.97], ["Zzzzzhuzhiwei", "stevending1st", 4.96], ["xiaoya-yaya", "xgdyp", 4.75]
]
}
};
// 更新所有视图
updateDashboard();
updateNetworkChart();
updateContributorsTable();
updateHealthAnalysis();
}
// ==================== 数据处理 ====================
function getMonthlyData(data) {
if (!data) return { labels: [], values: [] };
const monthlyEntries = Object.entries(data)
.filter(([key]) => /^\d{4}-\d{2}$/.test(key))
.sort((a, b) => a[0].localeCompare(b[0]));
return {
labels: monthlyEntries.map(([k]) => k),
values: monthlyEntries.map(([, v]) => v)
};
}
function getLatestMonthValue(data) {
if (!data) return '--';
const monthly = getMonthlyData(data);
if (monthly.values.length === 0) return '--';
return monthly.values[monthly.values.length - 1].toFixed(2);
}
// ==================== 更新仪表盘 ====================
function updateDashboard() {
// 更新统计卡片
const nodeCount = repoData.network?.nodes?.length || 0;
const edgeCount = repoData.network?.edges?.length || 0;
document.getElementById('stat-developers').textContent = nodeCount;
document.getElementById('stat-edges').textContent = edgeCount;
document.getElementById('stat-openrank').textContent = getLatestMonthValue(repoData.openrank);
document.getElementById('stat-activity').textContent = getLatestMonthValue(repoData.activity);
// 更新 OpenRank 图表
initOpenRankChart();
// 更新活跃度图表
initActivityChart();
// 更新 Top 贡献者
renderTopContributors();
// 更新时光机
renderTimeline();
}
// ==================== 开源时光机 ====================
function renderTimeline() {
const container = document.getElementById('timeline-container');
console.log('[Timeline] 渲染时间轴');
console.log('[Timeline] repoData.openrank:', repoData.openrank ? 'exists' : 'null');
if (repoData.openrank) {
console.log('[Timeline] openrank keys:', Object.keys(repoData.openrank).slice(0, 10));
}
const data = getMonthlyData(repoData.openrank);
console.log('[Timeline] Monthly data labels:', data.labels.length, 'values:', data.values.length);
// 清空旧内容 (保留那条线)
const line = container.querySelector('.absolute');
container.innerHTML = '';
if (line) container.appendChild(line);
// 检查数据状态
if (!repoData.openrank) {
// 数据还在加载中或加载失败
// 这个状态会被 loadOpenDiggerHistoryAsync 覆盖,所以只显示简单提示
container.innerHTML += `
<div class="ml-10 text-slate-400">
<p class="mb-2">📊 等待历史数据...</p>
</div>
`;
return;
}
if (data.values.length === 0) {
// 有 openrank 数据但解析不出月度数据
container.innerHTML += `
<div class="ml-10 text-amber-400">
<p class="text-lg font-medium mb-2">⚠️ 无法解析历史数据</p>
<p class="text-sm text-slate-400">数据格式可能不正确</p>
<p class="text-xs text-slate-500 mt-2">请检查控制台日志</p>
</div>
`;
return;
}
// 筛选关键节点 (每隔几个月取一个,或者是极大值/极小值)
// 简化策略:取起点、终点、以及中间每年的峰值
const milestones = [];
milestones.push({ date: data.labels[0], value: data.values[0], type: 'start', title: '项目启航 🚀' });
let maxVal = 0;
let maxDate = '';
data.values.forEach((val, idx) => {
if (val > maxVal) {
maxVal = val;
maxDate = data.labels[idx];
}
// 每年取一个快照
if (idx > 0 && idx % 12 === 0) {
milestones.push({ date: data.labels[idx], value: val, type: 'normal', title: '稳步前行 🚶' });
}
});
// 插入峰值 (如果没重复)
if (!milestones.find(m => m.date === maxDate)) {
milestones.push({ date: maxDate, value: maxVal, type: 'peak', title: '历史巅峰 🏆' });
}
// 插入最新
const lastIdx = data.values.length - 1;
if (!milestones.find(m => m.date === data.labels[lastIdx])) {
milestones.push({ date: data.labels[lastIdx], value: data.values[lastIdx], type: 'latest', title: '当前状态 📍' });
}
// 按时间排序
milestones.sort((a, b) => a.date.localeCompare(b.date));
milestones.forEach((m, i) => {
const isPeak = m.type === 'peak';
const color = isPeak ? 'text-yellow-400' : 'text-blue-400';
const dotColor = isPeak ? 'bg-yellow-500' : 'bg-blue-500';
const alignLeft = true; // 全部左对齐,简单美观
const html = `
<div class="relative pl-8 md:pl-10 py-6 group animate-fade-in" style="animation-delay: ${i * 100}ms">
<!-- Dot -->
<div class="absolute left-[15px] md:left-[16px] top-8 w-3 h-3 ${dotColor} rounded-full border-4 border-slate-900 z-10 group-hover:scale-150 transition-transform shadow-[0_0_10px_currentColor]"></div>
<!-- Content -->
<div class="bg-slate-700/30 border border-slate-600/50 rounded-xl p-4 hover:bg-slate-700/50 transition-all hover:-translate-y-1 hover:shadow-lg cursor-default">
<div class="flex justify-between items-start mb-2">
<span class="text-xs font-mono text-slate-400 bg-slate-800 px-2 py-1 rounded">${m.date}</span>
<span class="${color} font-bold text-sm">${m.value.toFixed(2)} OpenRank</span>
</div>
<h4 class="text-white font-bold text-lg mb-1 ${isPeak ? 'text-yellow-200' : ''}">${m.title}</h4>
<p class="text-slate-400 text-sm">
${generateTimelineDesc(m)}
</p>
</div>
</div>
`;
container.innerHTML += html;
});
}
function generateTimelineDesc(m) {
if (m.type === 'start') return '项目正式被 OpenRank 索引,开启了开源协作的数字化旅程。';
if (m.type === 'peak') return `社区影响力达到历史最高点,OpenRank 值突破 ${Math.floor(m.value)},这是项目发展的重要里程碑!`;
if (m.type === 'latest') return '截至目前的最新数据。社区仍在持续演进中,未来可期。';
return `项目保持活跃,OpenRank 值为 ${m.value.toFixed(2)},积累了深厚的生态底蕴。`;
}
function initOpenRankChart() {
const chartDom = document.getElementById('openrank-chart');
// 移除 offsetParent 检查,确保初始渲染
if (chartDom.timer) clearInterval(chartDom.timer);
let oldChart = echarts.getInstanceByDom(chartDom);
if (oldChart) oldChart.dispose();
const chart = echarts.init(chartDom);
const data = getMonthlyData(repoData.openrank);
chart.setOption({
backgroundColor: 'transparent',
animationDuration: 2000,
animationEasing: 'cubicOut',
tooltip: {
trigger: 'axis',
backgroundColor: 'rgba(15, 23, 42, 0.95)',
borderColor: '#3b82f6',
borderWidth: 1,
textStyle: { color: '#e2e8f0' },
axisPointer: { type: 'cross', label: { backgroundColor: '#6a7985' } },
formatter: function(params) {
const item = params[0];
if (!item) return '';
let growthHtml = '';
const dataIndex = item.dataIndex;
if (dataIndex > 0) {
const prevValue = data.values[dataIndex - 1];
const currValue = item.value;
return `
<div style="font-weight:bold; margin-bottom:4px; color:#94a3b8;">${item.axisValue}</div>
<div style="display:flex; align-items:center;">
<div style="width:8px; height:8px; background:${item.color?.colorStops ? item.color.colorStops[0].color : (item.color || '#22c55e')}; border-radius:2px; margin-right:6px;"></div>
<span style="font-size:14px; font-weight:bold;">${typeof item.value === 'object' ? item.value.value.toFixed(2) : item.value.toFixed(2)}</span>
${growthHtml}
</div>
`;
}
}
},