-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
2029 lines (1831 loc) · 76.4 KB
/
index.html
File metadata and controls
2029 lines (1831 loc) · 76.4 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">
<meta name="description" content="鲁虺军网(http://mil.luhui.net)是中国领先的军事知识数据库与军事资源平台,致力于为用户提供全面、权威的军事信息服务。作为鲁虺军事知识图书馆的核心,平台整合了军事知识数据库、军事论文和军事图书资源,构建了高效的知识查询与管理集合器。秉持“军事知识,规范约束人类本性之恶”的理念,鲁虺军网为军事从业者、学者及公众提供便捷的军事数据库搜索与管理工具,助力法治建设,净化社会风气,促进公平正义。无论是专业研究还是日常军事咨询,鲁虺军网都是您信赖的中国军事门户网站!">
<meta name="keywords" content="鲁虺,法网,军事知识,军事数据库,知识数据库,军事资源,法治,正义,军事门户,知识查询,军事图书馆,军事论文,军事图书,知识管理,军事搜索,军事信息,法治建设,公平正义,知识平台,军事服务,鲁虺知识,军事研究,知识资源,军事咨询,法治教育,知识检索,军事知识,知识导航,军事工具,法治宣传,人性约束,军事规范,知识整合,军事平台,法治文化,知识搜索,军事管理,知识库,军事文献,法治精神,知识信息,军事普及,知识整理,军事导航,法治资源,知识系统,军事支持,知识研究,军事学习,法治理念,知识服务,军事查询,知识数据库管理,军事信息平台,法治工具,知识知识,军事数据库搜索,知识整理平台,军事资源整合,法治信息,知识导航平台,军事知识库,法治推广,知识查询工具,军事文献库,法治教育平台,知识信息管理,军事搜索工具,法治资源整合,知识数据库系统,军事信息搜索,法治服务平台,知识研究工具,军事知识传播,法治文化推广,知识信息平台,军事资源导航,法治知识库,知识查询平台,军事文献搜索,法治信息整合,知识管理工具,军事知识管理,法治教育资源,知识信息搜索,军事服务平台,法治研究工具,知识知识库,军事信息导航,法治文化传播,知识查询系统,军事资源平台,法治信息管理,知识研究资源,军事知识整合,法治服务平台,知识信息导航,军事文献管理,法治教育工具,知识知识传播,军事资源搜索,法治文化资源,知识查询管理,军事信息系统,法治知识平台,知识研究导航,军事文献整合,法治信息工具,知识管理平台,军事知识资源,法治教育导航,知识信息整合,军事资源管理,法治文化工具,知识查询资源,军事信息传播,法治知识整合,知识研究系统,军事文献平台,法治信息导航,知识管理资源,军事知识工具,法治教育系统,知识信息管理,军事资源整合,法治文化导航,知识查询工具,军事信息资源,法治知识传播,知识研究管理,军事文献导航,法治信息平台,知识管理整合,军事知识系统,法治教育资源,知识信息工具,军事资源导航,法治文化整合,知识查询系统,军事信息管理,法治知识平台,知识研究资源,军事文献整合,法治信息工具,知识管理导航,军事知识资源,法治教育整合,知识信息系统,军事资源平台,法治文化管理,知识查询导航,军事信息整合,法治知识工具,知识研究系统,军事文献资源,法治信息导航,知识管理平台,军事知识整合,法治教育工具,知识信息资源,军事资源管理,法治文化系统,知识查询整合,军事信息导航,法治知识资源,知识研究工具,军事文献平台,法治信息整合,知识管理资源,军事知识导航,法治教育平台,知识信息系统,军事资源工具,法治文化资源,知识查询管理,军事信息平台,法治知识整合,知识研究导航,军事文献工具,法治信息资源,知识管理整合,军事知识系统,法治教育导航,知识信息工具,军事资源整合,法治文化平台,知识查询资源,军事信息管理,法治知识工具,知识研究系统,军事文献导航,法治信息平台,知识管理资源,军事知识整合,法治教育资源,知识信息导航,军事资源系统,法治文化工具,知识查询整合,军事信息资源,法治,正义约束,军事规范,知识体系,军事权威,法治精神,知识保障,军事秩序,法治社会,知识执行,军事公正,法治理念,知识监督,军事保护,法治建设,知识宣传,军事普及,法治教育,知识查询,军事支持,法治文化,知识资源,军事服务,法治平台,知识导航,军事工具,法治传播,知识整合,军事研究,法治管理,知识搜索,军事信息,法治知识,知识系统,军事数据库,法治资源,知识研究,军事文献,法治工具,知识平台,军事导航,法治信息,知识管理,军事知识,法治教育,知识查询,军事服务,法治文化,知识资源,军事平台,法治导航,知识工具,军事传播,法治整合,知识研究,军事管理,法治搜索,知识信息,军事知识,法治系统,知识数据库,军事资源,法治研究,知识文献,军事工具,法治平台,知识导航,军事信息,法治文化,知识资源,军事服务,法治教育,知识查询,军事传播,法治整合,知识管理,军事研究,法治搜索,知识信息,军事知识,法治系统,知识数据库,军事资源,法治研究,知识文献,军事工具,法治平台,知识导航,军事信息,法治文化,知识资源,军事服务,法治教育,知识查询,军事传播,法治整合,知识管理,军事研究,法治搜索,知识信息,军事知识,法治系统,知识数据库,军事资源,法治研究,知识文献,军事工具,法治平台,知识导航,军事信息,法治文化,知识资源,军事服务,法治教育,知识查询,军事传播,法治整合,知识管理,军事研究,法治搜索,知识信息,军事知识,法治系统,知识数据库,军事资源,法治研究,知识文献,军事工具,法治平台,知识导航,军事信息,法治文化,知识资源,军事服务,法治教育,知识查询,军事传播,法治整合,知识管理,军事研究,法治搜索,知识信息,军事知识,法治系统,知识数据库,军事资源,法治研究,知识文献,军事工具,法治平台,知识导航,军事信息,法治文化,知识资源,军事服务,法治教育,知识查询,军事传播,法治整合,知识管理,军事研究,法治搜索,知识信息,军事知识,法治系统,知识数据库,军事资源,法治研究,知识文献,军事工具,法治平台,知识导航,军事信息,法治文化,知识资源,军事服务,法治教育,知识查询,军事传播,法治整合,知识管理,军事研究,法治搜索,知识信息,军事知识,法治系统,知识数据库,军事资源,法治研究,知识文献,军事工具,法治平台,知识导航,军事信息,法治文化,知识资源,军事服务,法治教育,知识查询,军事传播,法治整合,知识管理,军事研究,法治搜索,知识信息,军事知识,法治系统,知识数据库,军事资源,法治研究,知识文献,军事工具,法治平台,知识导航,军事信息,法治文化,知识资源,军事服务,法治教育,知识查询,军事传播,法治整合,知识管理,军事研究,法治搜索,知识信息,军事知识,法治系统,知识数据库,军事资源,法治研究,知识文献,军事工具,法治平台,知识导航,军事信息,法治文化,知识资源,军事服务,法治教育,知识查询,军事传播,法治整合,知识管理,军事研究,法治搜索,知识信息,军事知识,法治系统,知识数据库,军事资源,法治研究,知识文献,军事工具,法治平台,知识导航,军事信息,法治文化,知识资源,军事服务,法治教育,知识查询,军事传播,法治整合,知识管理,军事研究,法治搜索,知识信息,军事知识,法治系统,知识数据库,军事资源,法治研究,知识文献,军事工具,法治平台,知识导航,军事信息,法治文化,知识资源,军事服务,法治教育,知识查询,军事传播,法治整合,知识管理,军事研究,法治搜索,知识信息,军事知识,法治系统,知识数据库,军事资源,法治研究,知识文献,军事工具,法治平台,知识导航,军事信息,法治文化">
<!-- 外部资源引入 -->
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/iconv-lite@0.6.3/dist/iconv-lite.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/encoding-japanese@2.0.0/encoding.min.js"></script>
<!-- 动态标题 -->
<title id="page-title">鲁虺军网 http://mil.luhui.net 鲁虺军事网|鲁虺军事知识图书馆|军事知识数据库|军事论文|军事图书,军事知识数据库|军事数据库|知识数据库|中国军事门户网站|军事知识资源搜索管理集合器</title>
<style>
/* 基础样式 */
body {
font-family: 'Segoe UI', system-ui, sans-serif;
background-color: #f8fafc;
transition: background-color 0.3s ease, color 0.3s ease;
}
/* 黑白模式样式 */
body.dark-mode {
background-color: #121212;
color: #e0e0e0;
}
body.dark-mode .bg-white { background-color: #1e1e1e; }
body.dark-mode .text-gray-800,
body.dark-mode .text-gray-900 { color: #e0e0e0; }
body.dark-mode .text-gray-700 { color: #d0d0d0; }
body.dark-mode .text-gray-600,
body.dark-mode .text-gray-500 { color: #b0b0b0; }
body.dark-mode .bg-gray-900 { background-color: #0a0a0a; }
body.dark-mode .bg-gray-200 { background-color: #333333; }
body.dark-mode .bg-gray-200:hover { background-color: #444444; }
body.dark-mode .bg-red-50 { background-color: #1a2b4a; }
body.dark-mode .bg-green-50 { background-color: #1a4a2b; }
body.dark-mode .bg-purple-50 { background-color: #3a1a4a; }
body.dark-mode .bg-amber-50 { background-color: #4a3a1a; }
body.dark-mode .border-gray-300,
body.dark-mode .border-gray-200 { border-color: #444444; }
body.dark-mode .image-fallback {
background-color: #2d2d2d;
border-color: #555555;
color: #b0b0b0;
}
/* 内容区域样式 */
.content-container { min-height: calc(100vh - 120px); }
/* 文章卡片样式 */
.article-card { transition: all 0.3s ease; }
.article-card:hover { transform: translateY(-3px); }
/* Markdown内容样式 */
.markdown-content { line-height: 1.8; }
.markdown-content img {
max-width: 100%;
height: auto;
margin: 1.5rem auto;
border-radius: 6px;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
body.dark-mode .markdown-content img { filter: grayscale(100%); }
.markdown-content a { color: #2563eb; text-decoration: underline; }
body.dark-mode .markdown-content a { color: #8ab4f8; }
.markdown-content a:hover { color: #1d4ed8; }
body.dark-mode .markdown-content a:hover { color: #a8c7fa; }
.markdown-content h1,
.markdown-content h2,
.markdown-content h3 {
font-weight: 700;
margin-top: 1.5rem;
margin-bottom: 1rem;
color: #1e293b;
}
body.dark-mode .markdown-content h1,
body.dark-mode .markdown-content h2,
body.dark-mode .markdown-content h3 { color: #ffffff; }
.markdown-content p { margin-bottom: 1rem; }
.markdown-content ul,
.markdown-content ol {
margin-left: 1.5rem;
margin-bottom: 1rem;
}
.markdown-content ul { list-style-type: disc; }
.markdown-content ol { list-style-type: decimal; }
.markdown-content blockquote {
border-left: 4px solid #94a3b8;
padding-left: 1rem;
margin: 1rem 0;
color: #64748b;
}
body.dark-mode .markdown-content blockquote {
border-left-color: #666666;
color: #999999;
}
.markdown-content pre {
background-color: #1e293b;
color: #f8fafc;
padding: 1rem;
border-radius: 6px;
overflow-x: auto;
margin: 1rem 0;
}
/* 加载动画 */
.loader {
width: 40px;
height: 40px;
border: 4px solid rgba(37, 99, 235, 0.2);
border-radius: 50%;
border-top-color: #2563eb;
animation: spin 1s ease-in-out infinite;
}
body.dark-mode .loader {
border-color: rgba(150, 150, 150, 0.2);
border-top-color: #aaaaaa;
}
@keyframes spin { to { transform: rotate(360deg); } }
/* 导航样式 */
.nav-link { position: relative; }
.nav-link.active::after {
content: '';
position: absolute;
bottom: -2px;
left: 0;
width: 100%;
height: 2px;
background-color: #2563eb;
}
body.dark-mode .nav-link.active::after { background-color: #8ab4f8; }
/* 图片加载失败样式 */
.image-fallback {
background-color: #f1f5f9;
border: 1px dashed #94a3b8;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
padding: 2rem;
color: #64748b;
}
/* 搜索历史样式 */
.search-history-container { position: relative; }
.search-history-dropdown {
position: absolute;
top: 100%;
left: 0;
right: 0;
z-index: 100;
background-color: white;
border: 1px solid #e2e8f0;
border-radius: 0 0 0.5rem 0.5rem;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
max-height: 0;
overflow: hidden;
transition: max-height 0.3s ease-out;
}
body.dark-mode .search-history-dropdown {
background-color: #1e1e1e;
border-color: #444444;
}
.search-history-dropdown.active {
max-height: 300px;
overflow-y: auto;
}
.history-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.75rem 1rem;
border-bottom: 1px solid #e2e8f0;
font-size: 0.875rem;
}
body.dark-mode .history-header { border-bottom-color: #444444; }
.history-title { font-weight: 500; color: #64748b; }
.clear-history {
color: #2563eb;
cursor: pointer;
font-size: 0.75rem;
}
body.dark-mode .clear-history { color: #8ab4f8; }
.clear-history:hover { color: #1d4ed8; text-decoration: underline; }
.history-list { list-style: none; margin: 0; padding: 0; }
.history-item {
padding: 0.75rem 1rem;
border-bottom: 1px solid #f1f5f9;
cursor: pointer;
transition: background-color 0.2s ease;
display: flex;
justify-content: space-between;
align-items: center;
}
body.dark-mode .history-item { border-bottom-color: #333333; }
.history-item:hover { background-color: #f8fafc; }
body.dark-mode .history-item:hover { background-color: #2d2d2d; }
.history-item:last-child { border-bottom: none; }
.history-text { color: #334155; }
body.dark-mode .history-text { color: #e0e0e0; }
.history-time {
font-size: 0.75rem;
color: #94a3b8;
margin-left: 0.5rem;
}
.remove-history {
color: #94a3b8;
cursor: pointer;
padding: 0.25rem;
opacity: 0;
transition: opacity 0.2s ease;
}
body.dark-mode .remove-history { color: #777777; }
body.dark-mode .remove-history:hover { color: #ff6b6b; }
.history-item:hover .remove-history { opacity: 1; }
.remove-history:hover { color: #ef4444; }
.no-history {
padding: 1rem;
text-align: center;
color: #94a3b8;
font-size: 0.875rem;
}
/* 黑白模式切换按钮 */
.theme-toggle {
background: none;
border: none;
cursor: pointer;
color: inherit;
display: flex;
align-items: center;
justify-content: center;
width: 40px;
height: 40px;
border-radius: 50%;
transition: background-color 0.2s ease;
}
.theme-toggle:hover { background-color: rgba(0, 0, 0, 0.1); }
body.dark-mode .theme-toggle:hover { background-color: rgba(255, 255, 255, 0.1); }
/* 内容加载失败提示 */
.content-error {
background-color: #fff3cd;
border-left: 4px solid #ffc107;
padding: 1rem;
margin: 1rem 0;
border-radius: 4px;
color: #856404;
}
body.dark-mode .content-error {
background-color: #3d3511;
border-left-color: #d4a72c;
color: #e0c568;
}
/* 备用渲染样式 */
.plain-text-content {
white-space: pre-wrap;
line-height: 1.8;
word-wrap: break-word;
}
/* 加载marked.js提示 */
.marked-loading-indicator {
position: fixed;
bottom: 20px;
right: 20px;
background-color: rgba(37, 99, 235, 0.9);
color: white;
padding: 8px 12px;
border-radius: 4px;
font-size: 0.875rem;
display: flex;
align-items: center;
z-index: 1000;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
.marked-loading-indicator .mini-loader {
width: 16px;
height: 16px;
border: 2px solid rgba(255, 255, 255, 0.3);
border-radius: 50%;
border-top-color: white;
animation: spin 1s ease-in-out infinite;
margin-right: 8px;
}
/* 搜索链接容器样式 */
#search-link-container {
transition: all 0.3s ease;
margin-bottom: 1.5rem;
padding: 1rem;
background-color: #f1f5f9;
border-radius: 0.5rem;
border: 1px solid #e2e8f0;
}
body.dark-mode #search-link-container {
background-color: #2d2d2d;
border-color: #444444;
}
body.dark-mode #search-link-container a {
color: #8ab4f8;
}
body.dark-mode #search-link-container a:hover {
color: #a8c7fa;
}
/* 滚动控制按钮样式 */
#scroll-controls button {
transition: all 0.3s ease;
}
#scroll-controls button:hover {
transform: scale(1.1);
}
#scroll-controls button.visible {
opacity: 1;
visibility: visible;
}
body.dark-mode #scroll-controls button {
background-color: #3b82f6;
}
body.dark-mode #scroll-controls button:hover {
background-color: #2563eb;
}
</style>
</head>
<body class="text-gray-800">
<!-- 在页脚上方添加按钮 -->
<div id="scroll-controls" class="fixed right-6 bottom-6 flex flex-col gap-3 z-40">
<button id="back-to-top-btn" class="bg-red-600 hover:bg-red-700 text-white w-12 h-12 rounded-full flex items-center justify-center shadow-lg transition-all opacity-0 invisible">
<i class="fas fa-angle-double-up text-xl"></i>
</button>
<button id="back-to-bottom-btn" class="bg-red-600 hover:bg-red-700 text-white w-12 h-12 rounded-full flex items-center justify-center shadow-lg transition-all opacity-0 invisible">
<i class="fas fa-angle-double-down text-xl"></i>
</button>
</div>
<!-- 顶部导航栏 -->
<header class="bg-white shadow-sm sticky top-0 z-50">
<div class="container mx-auto px-4 py-4 flex flex-col md:flex-row justify-between items-center">
<div class="mb-4 md:mb-0">
<h1 class="text-2xl md:text-3xl font-bold text-gray-900">
<i class="fa fa-font-awesome text-red-600 mr-2"></i>鲁虺军事观察网
</h1>
<p class="text-gray-500 text-sm">普及推广军事知识,止戈为武,遏止不义!</p>
</div>
<div class="flex items-center space-x-6">
<nav class="flex space-x-6">
<a href="/" class="nav-link active text-red-600 hover:text-red-800 transition">
<i class="fas fa-home mr-1"></i>首页
</a>
<a href="./?category=worldpeace" class="nav-link text-gray-600 hover:text-red-600 transition">
<i class="fa fa-earth-americas mr-1"></i>和平
</a>
<a href="./?category=militaryregulations" class="nav-link text-gray-600 hover:text-red-600 transition">
<i class="fa fa-file-invoice mr-1"></i>军规
</a>
<a href="./?category=militarymuseum" class="nav-link text-gray-600 hover:text-red-600 transition">
<i class="fa fa-gavel mr-1"></i>军博
</a>
<a href="./?category=militaryliterature" class="nav-link text-gray-600 hover:text-red-600 transition">
<i class="fa fa-address-card mr-1"></i>文献
</a>
</nav>
<!-- 黑白模式切换按钮 -->
<button id="theme-toggle" class="theme-toggle" aria-label="切换黑白模式">
<i class="fas fa-moon text-gray-600"></i>
</button>
</div>
</div>
</header>
<!-- 主内容区 -->
<main class="container mx-auto px-4 py-8 content-container">
<!-- 搜索区域 -->
<section class="mb-8 bg-white p-6 rounded-lg shadow-sm">
<div class="flex flex-col md:flex-row gap-4">
<div class="flex-grow search-history-container">
<div class="flex flex-wrap gap-4 mb-3">
<label class="inline-flex items-center cursor-pointer">
<input type="radio" name="search-type" value="title" class="form-radio text-red-600" checked>
<span class="ml-2 text-gray-700">标题搜索</span>
</label>
<label class="inline-flex items-center cursor-pointer">
<input type="radio" name="search-type" value="content" class="form-radio text-red-600">
<span class="ml-2 text-gray-700">内容搜索</span>
</label>
<label class="inline-flex items-center cursor-pointer">
<input type="radio" name="search-type" value="both" class="form-radio text-red-600">
<span class="ml-2 text-gray-700">标题和内容</span>
</label>
</div>
<div class="flex gap-2">
<input type="text" id="search-input" placeholder="输入关键词搜索..." class="flex-grow px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-red-500 focus:border-red-500 transition">
<button id="search-btn" class="bg-red-600 hover:bg-red-700 text-white px-6 py-2 rounded-lg transition flex items-center">
<i class="fas fa-search mr-2"></i>搜索
</button>
<button id="reset-btn" class="bg-gray-200 hover:bg-gray-300 text-gray-700 px-4 py-2 rounded-lg transition">
<i class="fas fa-sync-alt"></i>
</button>
</div>
<!-- 搜索历史下拉框 -->
<div id="search-history" class="search-history-dropdown">
<div class="history-header">
<span class="history-title">搜索历史</span>
<span id="clear-history" class="clear-history">清除全部</span>
</div>
<ul id="history-list" class="history-list"></ul>
<div id="no-history" class="no-history hidden">暂无搜索历史</div>
</div>
</div>
</div>
</section>
<!-- 分类导航 -->
<section class="mb-8 overflow-x-auto">
<div class="flex space-x-2 md:space-x-4 min-w-max pb-2">
<button class="category-btn active px-4 py-2 bg-red-600 text-white rounded-lg transition" data-category="all">全部内容</button>
<button class="category-btn px-4 py-2 bg-gray-200 hover:bg-gray-300 text-gray-700 rounded-lg transition" data-category="politicaltheory">政治理论</button>
<button class="category-btn px-4 py-2 bg-gray-200 hover:bg-gray-300 text-gray-700 rounded-lg transition" data-category="militarythought">军事思想</button>
<button class="category-btn px-4 py-2 bg-gray-200 hover:bg-gray-300 text-gray-700 rounded-lg transition" data-category="partyandgovernmentorgans">党政机关</button>
<button class="category-btn px-4 py-2 bg-gray-200 hover:bg-gray-300 text-gray-700 rounded-lg transition" data-category="socialorganizations">社会团体</button>
<button class="category-btn px-4 py-2 bg-gray-200 hover:bg-gray-300 text-gray-700 rounded-lg transition" data-category="militarytechnologyweapons">军事技术、武器</button>
<button class="category-btn px-4 py-2 bg-gray-200 hover:bg-gray-300 text-gray-700 rounded-lg transition" data-category="strategycampaigntactics">战略、战役、战术</button>
<button class="category-btn px-4 py-2 bg-gray-200 hover:bg-gray-300 text-gray-700 rounded-lg transition" data-category="militaryfacilitiesandequipment">军事设施装备</button>
<button class="category-btn px-4 py-2 bg-gray-200 hover:bg-gray-300 text-gray-700 rounded-lg transition" data-category="politicalmovementsandtheinternationalsituation">政治运动与国际形势</button>
<button class="category-btn px-4 py-2 bg-gray-200 hover:bg-gray-300 text-gray-700 rounded-lg transition" data-category="diplomacyinternationalrelations">外交、国际关系</button>
<button class="category-btn px-4 py-2 bg-gray-200 hover:bg-gray-300 text-gray-700 rounded-lg transition" data-category="historyofhumanwarfare">人类战争史</button>
<button class="category-btn px-4 py-2 bg-gray-200 hover:bg-gray-300 text-gray-700 rounded-lg transition" data-category="crimesagainsthumanity">反人类行为</button>
<button class="category-btn px-4 py-2 bg-gray-200 hover:bg-gray-300 text-gray-700 rounded-lg transition" data-category="territorialwaters">领海</button>
<button class="category-btn px-4 py-2 bg-gray-200 hover:bg-gray-300 text-gray-700 rounded-lg transition" data-category="territory">领地</button>
<button class="category-btn px-4 py-2 bg-gray-200 hover:bg-gray-300 text-gray-700 rounded-lg transition" data-category="airspace">领空</button>
<button class="category-btn px-4 py-2 bg-gray-200 hover:bg-gray-300 text-gray-700 rounded-lg transition" data-category="militaryspace">太空军事</button>
<button class="category-btn px-4 py-2 bg-gray-200 hover:bg-gray-300 text-gray-700 rounded-lg transition" data-category="strongmilitaryculture">强军文化</button>
<button class="category-btn px-4 py-2 bg-gray-200 hover:bg-gray-300 text-gray-700 rounded-lg transition" data-category="cyberinformationwarfare">网络信息战</button>
</div>
</section>
<!-- 统计信息 -->
<section id="stats-section" class="mb-8 bg-white p-6 rounded-lg shadow-sm">
<h2 class="text-xl font-semibold mb-4 text-gray-800">
<i class="fas fa-chart-pie text-red-600 mr-2"></i>内容统计
</h2>
</a>
<a href="http://web.luhui.net" class="nav-link text-gray-600 hover:text-red-600 transition">
<i class="fa fa-link mr-1"></i>网站推荐
</a>
<a href="http://search.luhui.net" class="nav-link text-gray-600 hover:text-red-600 transition">
<i class="fa fa-search mr-1"></i>搜索
</a>
<a href="http://zhongyi.luhui.net" class="nav-link text-gray-600 hover:text-red-600 transition">
<i class="fa fa-medkit mr-1"></i>中医
</a>
<a href="http://piano.luhui.net" class="nav-link text-gray-600 hover:text-red-600 transition">
<i class="fa fa-music mr-1"></i>抚琴
</a>
<a href="http://qi.luhui.net" class="nav-link text-gray-600 hover:text-red-600 transition">
<i class="fa fa-keyboard mr-1"></i>棋迷
</a>
<a href="http://book.luhui.net" class="nav-link text-gray-600 hover:text-red-600 transition">
<i class="fa fa-book mr-1"></i>书库
</a>
<a href="http://images.luhui.net" class="nav-link text-gray-600 hover:text-red-600 transition">
<i class="fa fa-image mr-1"></i>画图
</a>
<a href="http://game.luhui.net" class="nav-link text-gray-600 hover:text-red-600 transition">
<i class="fa fa-gamepad mr-1"></i>游玩
</a>
<a href="http://mil.luhui.net" class="nav-link text-gray-600 hover:text-red-600 transition">
<i class="fa fa-balance-scale mr-1"></i>军事
</a>
<div class="grid grid-cols-2 md:grid-cols-4 gap-4">
<div class="bg-red-50 p-4 rounded-lg">
<p class="text-sm text-gray-500 mb-1">总文章数</p>
<p id="total-articles" class="text-2xl font-bold text-red-600">0</p>
</div>
<div class="bg-green-50 p-4 rounded-lg">
<p class="text-sm text-gray-500 mb-1">资讯文章</p>
<p id="news-articles" class="text-2xl font-bold text-green-600">0</p>
</div>
<div class="bg-purple-50 p-4 rounded-lg">
<p class="text-sm text-gray-500 mb-1">教程文章</p>
<p id="tutorial-articles" class="text-2xl font-bold text-purple-600">0</p>
</div>
<div class="bg-amber-50 p-4 rounded-lg">
<p class="text-sm text-gray-500 mb-1">资源文章</p>
<p id="resource-articles" class="text-2xl font-bold text-amber-600">0</p>
</div>
</div>
</section>
<!-- 加载状态 -->
<section id="loading-section" class="mb-8 hidden">
<div class="flex flex-col items-center justify-center py-12 bg-white rounded-lg shadow-sm">
<div class="loader mb-4"></div>
<p class="text-gray-600">正在加载内容,请稍候...</p>
<p id="loading-detail" class="text-gray-500 text-sm mt-2">准备加载文章数据</p>
</div>
</section>
<!-- 错误信息 -->
<section id="error-section" class="mb-8 hidden">
<div class="bg-red-50 border border-red-200 p-6 rounded-lg">
<div class="flex items-start">
<i class="fas fa-exclamation-circle text-red-500 text-xl mt-0.5 mr-3"></i>
<div>
<h3 class="font-medium text-red-800 mb-1">加载失败</h3>
<p id="error-message" class="text-red-700">无法加载内容,请稍后重试</p>
<button id="retry-btn" class="mt-3 text-sm text-red-600 hover:text-red-800 font-medium">
<i class="fas fa-redo-alt mr-1"></i>重试
</button>
</div>
</div>
</div>
</section>
<!-- 文章列表 -->
<section id="articles-section">
<div class="flex justify-between items-center mb-4">
<h2 class="text-xl font-semibold text-gray-800">
<i class="fas fa-list-alt text-red-600 mr-2"></i>文章列表
</h2>
<div class="text-sm text-gray-500">
找到 <span id="articles-count">0</span> 篇文章
</div>
</div>
<div id="articles-grid" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"></div>
<!-- 空状态 -->
<div id="empty-state" class="hidden py-16 text-center bg-white rounded-lg shadow-sm">
<i class="fas fa-file-search text-gray-300 text-5xl mb-4"></i>
<h3 class="text-lg font-medium text-gray-700 mb-2">未找到相关文章</h3>
<p class="text-gray-500 max-w-md mx-auto">尝试使用不同的搜索词或浏览其他分类</p>
<button id="empty-reset-btn" class="mt-4 px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg transition">
查看全部文章
</button>
</div>
<!-- 分页控件 -->
<div id="pagination" class="mt-8 flex justify-center items-center gap-2 flex-wrap">
<button id="prev-page" class="px-4 py-2 bg-gray-200 hover:bg-gray-300 text-gray-700 rounded-lg transition disabled:opacity-50 disabled:cursor-not-allowed" disabled>
<i class="fas fa-chevron-left mr-1"></i>上一页
</button>
<div id="page-numbers" class="flex gap-1"></div>
<button id="next-page" class="px-4 py-2 bg-gray-200 hover:bg-gray-300 text-gray-700 rounded-lg transition disabled:opacity-50 disabled:cursor-not-allowed" disabled>
下一页<i class="fas fa-chevron-right ml-1"></i>
</button>
</div>
</section>
<!-- 文章详情 -->
<section id="article-detail">
<button id="back-to-list" class="mb-6 inline-flex items-center px-4 py-2 bg-gray-200 hover:bg-gray-300 text-gray-700 rounded-lg transition">
<i class="fas fa-arrow-left mr-2"></i>返回列表
</button>
<!-- 详情加载状态 -->
<div id="detail-loading" class="hidden bg-white rounded-lg shadow-sm overflow-hidden mb-6 p-8">
<div class="flex flex-col items-center justify-center py-12">
<div class="loader mb-4"></div>
<p class="text-gray-600">正在加载文章内容,请稍候...</p>
</div>
</div>
<!-- 详情内容容器 -->
<article id="detail-content-container" class="bg-white rounded-lg shadow-sm overflow-hidden mb-6 hidden">
<div class="p-6 md:p-8">
<div class="mb-4 flex items-center text-sm text-gray-500">
<span class="inline-flex items-center mr-4">
<i class="fas fa-folder-open mr-1"></i>
<span id="detail-category"></span>
</span>
<span class="inline-flex items-center">
<i class="fas fa-file-code mr-1"></i>
<span id="detail-id"></span>
</span>
</div>
<h1 id="detail-title" class="text-2xl md:text-3xl font-bold text-gray-900 mb-6"></h1>
<!-- 搜索看看链接(基于当前文章标题) -->
<div id="search-link-container">
搜索看看 <a id="article-search-link" href="" target="_blank" class="text-red-600 hover:underline"></a>
</div>
<!-- 内容渲染容器 -->
<div id="detail-content-container-inner" class="markdown-content"></div>
<!-- 渲染错误提示 -->
<div id="render-error-container" class="hidden mt-4">
<div class="bg-amber-50 border-l-4 border-amber-400 p-4">
<div class="flex">
<div class="flex-shrink-0">
<i class="fas fa-exclamation-triangle text-amber-500"></i>
</div>
<div class="ml-3">
<p class="text-sm text-amber-700">Markdown渲染失败,已自动切换为纯文本显示。</p>
<div class="mt-2 text-sm">
<button id="retry-render-btn" class="text-amber-600 hover:text-amber-800">
<i class="fas fa-redo-alt mr-1"></i>重试渲染
</button>
<button id="use-basic-renderer-btn" class="text-amber-600 hover:text-amber-800 ml-3">
<i class="fas fa-pencil-alt mr-1"></i>使用基础渲染器
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</article>
<!-- 详情错误状态 -->
<div id="detail-error" class="hidden bg-white rounded-lg shadow-sm overflow-hidden mb-6 p-8">
<div class="bg-red-50 border border-red-200 p-6 rounded-lg">
<div class="flex items-start">
<i class="fas fa-exclamation-circle text-red-500 text-xl mt-0.5 mr-3"></i>
<div>
<h3 class="font-medium text-red-800 mb-1">加载文章失败</h3>
<p id="detail-error-message" class="text-red-700">无法加载文章内容,请稍后重试</p>
<button id="detail-retry-btn" class="mt-3 text-sm text-red-600 hover:text-red-800 font-medium">
<i class="fas fa-redo-alt mr-1"></i>重试
</button>
<button id="show-plaintext-btn" class="mt-3 text-sm text-red-600 hover:text-red-800 font-medium ml-3">
<i class="fas fa-file-alt mr-1"></i>查看纯文本
</button>
</div>
</div>
</div>
</div>
<!-- 上下篇导航 -->
<div class="flex justify-between">
<button id="prev-article" class="px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg transition disabled:opacity-50 disabled:cursor-not-allowed" disabled>
<i class="fas fa-chevron-left mr-2"></i>上一篇
</button>
<button id="next-article" class="px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg transition disabled:opacity-50 disabled:cursor-not-allowed" disabled>
下一篇<i class="fas fa-chevron-right ml-2"></i>
</button>
</div>
</section>
</main>
<!-- 页脚 -->
<footer class="bg-gray-900 text-gray-300 py-8">
<div class="container mx-auto px-4">
<div class="flex flex-col md:flex-row justify-between items-center">
<div class="mb-4 md:mb-0">
<h3 class="text-xl font-bold text-white mb-2">鲁虺军网,除暴安良,捍卫天下太平!</h3>
<p class="text-sm">以理为盾,挡人性之恶;以武为剑,护万民苍生安宁!</p>
</div>
<div class="flex space-x-4">
<a href="/?q=关于我们" class="text-gray-400 hover:text-white transition">
<i class="fa fa-address-card mr-1"> 关于我们</i>
</a>
<a href="/?q=商务合作" class="text-gray-400 hover:text-white transition">
<i class="fa fa-handshake mr-1"> 商务合作</i>
</a>
<a href="/?q=版权声明" class="text-gray-400 hover:text-white transition">
<i class="fa fa-copy mr-1"> 版权声明</i>
</a>
<a href="/?q=隐私保护" class="text-gray-400 hover:text-white transition">
<i class="fa fa-eye-low-vision mr-1"> 隐私保护</i>
</a>
<a href="/?q=意见反馈" class="text-gray-400 hover:text-white transition">
<i class="fa fa-comment-dots mr-1"> 意见反馈</i>
</a>
<a href="/?q=联系方式" class="text-gray-400 hover:text-white transition">
<i class="fa fa-id-card-clip mr-1"> 联系方式</i>
</a>
</div>
</div>
<div class="border-t border-gray-800 mt-6 pt-6 text-center text-sm">
<p>鲁虺文化网-致力于数字文化遗产的保存与传播</p>
</div>
<div class="footer-inner mt-6">
<p align="center"> Copyright © 2004-01-11 <a href="http://luhui.net" title="鲁虺文化网" target="_top">luhui.net</a> all rights reserved.</p>
<div id="back-to-top-btn" style="display:none;"><i class="fas fa-angle-double-up" style="font-size: 25px;"></i></div>
</div>
</div>
</footer>
<!-- marked.js加载指示器 -->
<div id="marked-loading-indicator" class="marked-loading-indicator hidden">
<div class="mini-loader"></div>
<span>正在加载内容渲染组件...</span>
</div>
<script>
// 配置与状态管理
const config = {
baseUrl: '',
imageBasePath: '/luhuitxtcms/',
itemsPerPage: 12,
maxDetectionAttempts: 110,
timeout: 15000,
maxSearchHistory: 10,
categories: {
'politicaltheory': '政治理论',
'militarythought': '军事思想',
'partyandgovernmentorgans': '党政机关',
'socialorganizations': '社会团体',
'militarytechnologyweapons': '军事技术、武器',
'strategycampaigntactics': '战略、战役、战术',
'militaryfacilitiesandequipment': '军事设施装备',
'politicalmovementsandtheinternationalsituation': '政治运动与国际形势',
'diplomacyinternationalrelations': '外交、国际关系',
'historyofhumanwarfare': '人类战争史',
'crimesagainsthumanity': '反人类行为',
'territorialwaters': '领海',
'territory': '领地',
'airspace': '领空',
'militaryspace': '太空军事',
'strongmilitaryculture': '强军文化',
'worldpeace': '世界和平',
'militaryregulations': '军规',
'militarymuseum': '军博',
'militaryliterature': '军事文献',
'cyberinformationwarfare': '网络信息战'
},
supportedEncodings: ['utf8','gbk','gb2312','GB18030','iso-8859-1','iso-8859-2','big5','euc-kr','shift-jis'],
markedCdnUrls: [
'https://cdn.jsdelivr.net/npm/marked/marked.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/marked/4.0.2/marked.min.js',
'https://unpkg.com/marked@4.0.2/marked.min.js'
]
};
const state = {
currentCategory: 'all',
currentPage: 1,
searchTerm: '',
searchType: 'title',
totalArticles: 0,
totalPages: 0,
allArticles: [],
filteredArticles: [],
articleCache: new Map(),
categoryCounts: {},
searchHistory: [],
darkMode: false,
markedRenderer: null,
markedLoaded: false,
usingFallbackRenderer: false,
currentArticle: null // 当前显示的文章
};
// DOM元素映射
const elements = {
// 主题切换
themeToggle: document.getElementById('theme-toggle'),
// 搜索相关
searchInput: document.getElementById('search-input'),
searchBtn: document.getElementById('search-btn'),
resetBtn: document.getElementById('reset-btn'),
searchTypeRadios: document.querySelectorAll('input[name="search-type"]'),
// 搜索历史相关
searchHistoryDropdown: document.getElementById('search-history'),
historyList: document.getElementById('history-list'),
clearHistoryBtn: document.getElementById('clear-history'),
noHistoryMsg: document.getElementById('no-history'),
// 分类相关
categoryBtns: document.querySelectorAll('.category-btn'),
// 内容区域
articlesGrid: document.getElementById('articles-grid'),
articlesCount: document.getElementById('articles-count'),
emptyState: document.getElementById('empty-state'),
emptyResetBtn: document.getElementById('empty-reset-btn'),
// 加载与错误状态
loadingSection: document.getElementById('loading-section'),
loadingDetail: document.getElementById('loading-detail'),
errorSection: document.getElementById('error-section'),
errorMessage: document.getElementById('error-message'),
retryBtn: document.getElementById('retry-btn'),
// 分页
pagination: document.getElementById('pagination'),
prevPageBtn: document.getElementById('prev-page'),
nextPageBtn: document.getElementById('next-page'),
pageNumbers: document.getElementById('page-numbers'),
// 统计信息
totalArticles: document.getElementById('total-articles'),
newsArticles: document.getElementById('news-articles'),
tutorialArticles: document.getElementById('tutorial-articles'),
resourceArticles: document.getElementById('resource-articles'),
// 文章详情
articlesSection: document.getElementById('articles-section'),
articleDetail: document.getElementById('article-detail'),
backToListBtn: document.getElementById('back-to-list'),
detailTitle: document.getElementById('detail-title'),
detailContentInner: document.getElementById('detail-content-container-inner'),
detailCategory: document.getElementById('detail-category'),
detailId: document.getElementById('detail-id'),
prevArticleBtn: document.getElementById('prev-article'),
nextArticleBtn: document.getElementById('next-article'),
// 渲染错误相关
renderErrorContainer: document.getElementById('render-error-container'),
retryRenderBtn: document.getElementById('retry-render-btn'),
useBasicRendererBtn: document.getElementById('use-basic-renderer-btn'),
// 详情页加载和错误状态
detailLoading: document.getElementById('detail-loading'),
detailContentContainer: document.getElementById('detail-content-container'),
detailError: document.getElementById('detail-error'),
detailErrorMessage: document.getElementById('detail-error-message'),
detailRetryBtn: document.getElementById('detail-retry-btn'),
showPlaintextBtn: document.getElementById('show-plaintext-btn'),
// Marked加载指示器
markedLoadingIndicator: document.getElementById('marked-loading-indicator'),
// 动态标题和搜索链接元素
pageTitle: document.getElementById('page-title'),
searchLinkContainer: document.getElementById('search-link-container'),
articleSearchLink: document.getElementById('article-search-link')
};
// 动态更新页面标题(根据分类/文章状态)
function updatePageTitle() {
const baseTitle = "鲁虺军网 http://mil.luhui.net 鲁虺军事网|鲁虺军事知识图书馆|军事知识数据库|军事论文|军事图书,军事知识数据库|军事数据库|知识数据库|中国军事门户网站|军事知识资源搜索管理集合器";
// 校验必要元素
if (!elements.pageTitle) return;
// 场景1:查看特定文章(优先显示文章标题)
if (state.currentArticle) {
elements.pageTitle.textContent = `${state.currentArticle.title} - ${baseTitle}`;
// 同步更新搜索链接(编码标题防止特殊字符问题)
if (elements.articleSearchLink) {
const encodedTitle = encodeURIComponent(state.currentArticle.title);
elements.articleSearchLink.href = `http://search.luhui.net/?q=${encodedTitle}`;
elements.articleSearchLink.textContent = state.currentArticle.title;
}
// 显示搜索链接容器(仅文章详情页需要)
if (elements.searchLinkContainer) {
elements.searchLinkContainer.classList.remove('hidden');
}
}
// 场景2:浏览特定分类(显示分类名称)
else if (state.currentCategory && state.currentCategory !== 'all') {
const categoryName = config.categories[state.currentCategory] || state.currentCategory;
elements.pageTitle.textContent = `${categoryName} - ${baseTitle}`;
// 隐藏搜索链接容器
if (elements.searchLinkContainer) {
elements.searchLinkContainer.classList.add('hidden');
}
}
// 场景3:首页/默认状态(显示基础标题)
else {
elements.pageTitle.textContent = baseTitle;
// 隐藏搜索链接容器
if (elements.searchLinkContainer) {
elements.searchLinkContainer.classList.add('hidden');
}
}
}
// 加载marked.js库
async function loadMarkedLibrary() {
if (window.marked) {
state.markedLoaded = true;
return true;
}
elements.markedLoadingIndicator.classList.remove('hidden');
for (const url of config.markedCdnUrls) {
try {
const script = document.createElement('script');
script.src = url;
script.integrity = url.includes('cdn.jsdelivr.net') ? 'sha256-EGkF67+wL2NqgM7UeA1tM52Bx5j5tQl3Zp9V4qM2aZg=' : '';
script.crossOrigin = 'anonymous';
const loadPromise = new Promise((resolve, reject) => {
const timeoutId = setTimeout(() => reject(new Error('加载超时')), 10000);
script.onload = () => {
clearTimeout(timeoutId);
resolve();
};
script.onerror = () => {
clearTimeout(timeoutId);
reject(new Error('加载失败'));
};
});
document.head.appendChild(script);
await loadPromise;
if (window.marked && typeof window.marked === 'function') {
state.markedLoaded = true;
elements.markedLoadingIndicator.classList.add('hidden');
return true;
}
} catch (error) {
console.error(`加载marked.js失败 (${url}):`, error);
continue;
}
}
console.warn('所有marked.js CDN加载失败,将使用备用渲染器');
state.usingFallbackRenderer = true;
elements.markedLoadingIndicator.classList.add('hidden');
return false;
}
// 初始化marked渲染器
async function initMarkedRenderer() {
if (state.usingFallbackRenderer) return;
if (window.marked) {
try {
const renderer = new marked.Renderer();
// 自定义图片渲染
renderer.image = function(href, title, text) {
let imageUrl = href;
if (href && !href.startsWith('http://') && !href.startsWith('https://') && !href.startsWith('/')) {
const urlParams = new URLSearchParams(window.location.search);
const category = urlParams.get('category');
if (category && config.categories[category]) {
imageUrl = `${config.imageBasePath}${category}/${href}`;
} else {
imageUrl = `${config.imageBasePath}${href}`;
}
}
const titleAttr = title ? `title="${title}"` : '';
return `<img src="${imageUrl}" alt="${text}" ${titleAttr} loading="lazy" onerror="this.onerror=null;this.outerHTML='<div class=\'image-fallback\'><i class=\'fas fa-image mb-2\'></i><p>图片加载失败</p><p class=\'text-xs\'>${text}</p></div>'">`;
};
// 自定义链接渲染
renderer.link = function(href, title, text) {
const titleAttr = title ? `title="${title}"` : '';
const isExternal = href && (href.startsWith('http://') || href.startsWith('https://'));
const targetAttr = isExternal ? 'target="_blank" rel="noopener noreferrer"' : '';
return `<a href="${href}" ${titleAttr} ${targetAttr}>${text}</a>`;
};
state.markedRenderer = renderer;
marked.setOptions({ breaks: true, gfm: true, renderer: state.markedRenderer });
console.log('marked.js 初始化成功');
} catch (error) {
console.error('marked.js 初始化失败:', error);
state.usingFallbackRenderer = true;
}
} else {
console.warn('marked.js 未加载,将使用备用渲染器');
state.usingFallbackRenderer = true;
}
}
// 基础备用渲染器
function basicMarkdownRenderer(text) {
if (!text) return '';
let html = text;
// 处理标题
html = html.replace(/^(#{1,6})\s+(.*?)$/gm, (match, hashes, title) => {
const level = hashes.length;
return `<h${level} class="font-bold mt-4 mb-2">${title}</h${level}>`;
});
// 处理粗体/斜体
html = html.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>');
html = html.replace(/__(.*?)__/g, '<strong>$1</strong>');
html = html.replace(/\*(.*?)\*/g, '<em>$1</em>');
html = html.replace(/_(.*?)_/g, '<em>$1</em>');
// 处理链接
html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2" target="_blank">$1</a>');
// 处理图片
html = html.replace(/!\[([^\]]*)\]\(([^)]+)\)/g, (match, alt, src) => {
let imageUrl = src;
if (src && !src.startsWith('http://') && !src.startsWith('https://') && !src.startsWith('/')) {
if (state.currentArticle && state.currentArticle.category) {
imageUrl = `${config.imageBasePath}${state.currentArticle.category}/${src}`;
} else {
imageUrl = `${config.imageBasePath}${src}`;
}
}
return `<img src="${imageUrl}" alt="${alt}" loading="lazy" onerror="this.onerror=null;this.outerHTML='<div class=\'image-fallback\'><i class=\'fas fa-image mb-2\'></i><p>图片加载失败</p><p class=\'text-xs\'>${alt}</p></div>'">`;
});
// 处理列表
html = processLists(html);
// 处理代码块
html = html.replace(/```([\s\S]*?)```/g, '<pre><code>$1</code></pre>');
html = html.replace(/`(.*?)`/g, '<code>$1</code>');
// 处理引用
html = html.replace(/^> (.*?)$/gm, '<blockquote>$1</blockquote>');