-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathreadme-generator.html
More file actions
972 lines (899 loc) · 33.8 KB
/
readme-generator.html
File metadata and controls
972 lines (899 loc) · 33.8 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
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>README 生成器 - WebUtils</title>
<!-- SEO Meta Tags -->
<meta name="description" content="README 生成器 - WebUtils" />
<meta name="keywords" content="readme-generator,dev,tools,webutils" />
<meta name="author" content="WebUtils" />
<meta name="robots" content="index, follow" />
<link rel="canonical" href="https://tools.realtime-ai.chat/tools/dev/readme-generator.html" />
<!-- Open Graph -->
<meta property="og:title" content="README 生成器 - WebUtils" />
<meta property="og:description" content="README 生成器 - WebUtils" />
<meta property="og:type" content="website" />
<meta
property="og:url"
content="https://tools.realtime-ai.chat/tools/dev/readme-generator.html"
/>
<meta property="og:site_name" content="WebUtils" />
<meta property="og:locale" content="zh_CN" />
<meta property="og:image" content="https://tools.realtime-ai.chat/social-preview.png" />
<meta property="og:image:width" content="1280" />
<meta property="og:image:height" content="640" />
<meta property="og:image:type" content="image/png" />
<!-- Twitter Card -->
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="README 生成器 - WebUtils" />
<meta name="twitter:description" content="README 生成器 - WebUtils" />
<meta name="twitter:image" content="https://tools.realtime-ai.chat/social-preview.png" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css" />
<style>
/* CSS 变量兼容垫片 (修复 d03c9548 改名遗留) */
:root {
/* color-* 家族 → 新设计系统 */
--color-bg-deep: var(--bg-deep, #0a0a0f);
--color-bg-surface: var(--bg-surface, #12121a);
--color-bg-subtle: var(--bg-card, #1a1a24);
--color-bg-card: var(--bg-card, #1a1a24);
--color-bg-input: var(--bg-input, #0e0e14);
--color-text-primary: var(--text-primary, #e8e8ed);
--color-text-secondary: var(--text-secondary, #8888a0);
--color-text-muted: var(--text-muted, #55556a);
--color-border-default: var(--border-subtle, #2a2a3a);
--color-border-subtle: var(--border-subtle, #2a2a3a);
--color-border-strong: var(--border-strong, #3a3a4a);
--color-accent-primary: var(--accent-cyan, #00f5d4);
--color-accent-secondary: var(--accent-magenta, #f72585);
--color-accent-tertiary: var(--accent-blue, #4cc9f0);
--color-accent-cyan: var(--accent-cyan, #00f5d4);
--color-accent-purple: var(--accent-purple, #8b5cf6);
--color-accent-pink: var(--accent-magenta, #f72585);
--color-accent-orange: #ff9f1c;
--color-success: var(--accent-green, #10b981);
--color-warning: var(--accent-yellow, #fbbf24);
--color-error: var(--accent-red, #f43f5e);
--color-danger: var(--accent-red, #f43f5e);
--color-info: var(--accent-blue, #4cc9f0);
--color-safe: var(--accent-green, #10b981);
/* 玻璃拟态 */
--glass-bg: rgba(26, 26, 36, 0.72);
--glass-border: rgba(255, 255, 255, 0.08);
--glass-blur: 24px;
--glass-saturate: 180%;
--glass-radius: 16px;
--glass-border-width: 1px;
--glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
/* 间距尺度 */
--space-1: 4px;
--space-2: 8px;
--space-3: 12px;
--space-4: 16px;
--space-5: 20px;
--space-6: 24px;
--space-8: 32px;
--spacing-sm: 8px;
--spacing-md: 16px;
--spacing-lg: 24px;
--spacing-card: 16px;
/* 阴影 */
--shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
--shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
--shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
--shadow-glow: 0 0 20px rgba(0, 245, 212, 0.15);
--card-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
/* 辉光 */
--glow-cyan: 0 0 20px rgba(0, 245, 212, 0.4);
--glow-purple: 0 0 20px rgba(139, 92, 246, 0.4);
--glow-green: 0 0 20px rgba(16, 185, 129, 0.4);
--glow-red: 0 0 20px rgba(244, 63, 94, 0.4);
--glow-magenta: 0 0 20px rgba(247, 37, 133, 0.4);
--accent-glow: 0 0 20px rgba(0, 245, 212, 0.4);
/* 过渡 */
--transition-fast: 150ms ease;
--transition-normal: 250ms ease;
--transition: 200ms ease;
/* 圆角 */
--radius-full: 9999px;
--radius-xl: 24px;
--border-radius: 8px;
/* 布局 */
--nav-height: 56px;
--container-max: 1400px;
--container-bg: var(--bg-card, #1a1a24);
--safe-area-top: env(safe-area-inset-top, 0px);
--safe-area-bottom: env(safe-area-inset-bottom, 0px);
/* 单名旧约定 */
--bg-color: var(--bg-deep, #0a0a0f);
--bg-secondary: var(--bg-surface, #12121a);
--bg-tertiary: var(--bg-card, #1a1a24);
--bg-elevated: var(--bg-card-hover, #22222e);
--bg-hover: var(--bg-card-hover, #22222e);
--bg-card-hover: #22222e;
--bg-gradient: linear-gradient(135deg, #0a0a0f 0%, #12121a 100%);
--primary-gradient: linear-gradient(135deg, #00f5d4 0%, #4cc9f0 100%);
--text-color: var(--text-primary, #e8e8ed);
--primary-color: var(--accent-cyan, #00f5d4);
--primary-focus: rgba(0, 245, 212, 0.25);
--secondary-color: var(--accent-magenta, #f72585);
--tertiary-color: var(--text-muted, #55556a);
--accent-color: var(--accent-cyan, #00f5d4);
--accent-hover: #2dffe2;
--accent-light: rgba(0, 245, 212, 0.15);
--accent-pink: var(--accent-magenta, #f72585);
--accent-orange: #ff9f1c;
--accent-gold: #ffd166;
--accent-brown: #a0522d;
--success-color: var(--accent-green, #10b981);
--good-color: var(--accent-green, #10b981);
--warning-color: var(--accent-yellow, #fbbf24);
--error-color: var(--accent-red, #f43f5e);
--danger-color: var(--accent-red, #f43f5e);
--info-color: var(--accent-blue, #4cc9f0);
--muted-color: var(--text-muted, #55556a);
--muted-border-color: var(--border-subtle, #2a2a3a);
--hover-color: var(--accent-cyan, #00f5d4);
--border-default: var(--border-subtle, #2a2a3a);
--border-focus: var(--accent-cyan, #00f5d4);
--border-accent: var(--accent-cyan, #00f5d4);
--card-background-color: var(--bg-card, #1a1a24);
--code-background-color: var(--bg-input, #0e0e14);
/* Pico CSS 框架默认 */
--pico-background-color: var(--bg-deep, #0a0a0f);
--pico-color: var(--text-primary, #e8e8ed);
--pico-muted-color: var(--text-muted, #55556a);
--pico-muted-border-color: var(--border-subtle, #2a2a3a);
--pico-muted-background: var(--bg-surface, #12121a);
--pico-card-background-color: var(--bg-card, #1a1a24);
--pico-code-background-color: var(--bg-input, #0e0e14);
--pico-primary: var(--accent-cyan, #00f5d4);
--pico-primary-background: var(--accent-cyan, #00f5d4);
--pico-primary-inverse: #0a0a0f;
--pico-primary-focus: rgba(0, 245, 212, 0.25);
--pico-primary-rgb: 0, 245, 212;
--pico-secondary: var(--text-secondary, #8888a0);
--pico-secondary-background: var(--bg-card, #1a1a24);
--pico-border-radius: 8px;
--pico-contrast: var(--text-primary, #e8e8ed);
--pico-contrast-background: var(--bg-card-hover, #22222e);
--pico-del-color: var(--accent-red, #f43f5e);
--pico-ins-color: var(--accent-green, #10b981);
--pico-form-element-border-color: var(--border-strong, #3a3a4a);
--pico-form-element-background-color: var(--bg-input, #0e0e14);
}
/* 浅色主题覆盖:glass/shadow/glow 等主题敏感变量 */
[data-theme="light"] {
/* 玻璃拟态 — 浅色版(半透明白) */
--glass-bg: rgba(255, 255, 255, 0.78);
--glass-border: rgba(0, 0, 0, 0.06);
--glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
/* 阴影 — 浅色版(更淡) */
--shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
--shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
--shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
--shadow-glow: 0 0 20px rgba(0, 184, 148, 0.12);
--card-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
/* 辉光 — 浅色版(透明度降低) */
--glow-cyan: 0 0 16px rgba(0, 184, 148, 0.18);
--glow-purple: 0 0 16px rgba(139, 92, 246, 0.18);
--glow-green: 0 0 16px rgba(16, 185, 129, 0.18);
--glow-red: 0 0 16px rgba(244, 63, 94, 0.18);
--glow-magenta: 0 0 16px rgba(247, 37, 133, 0.18);
--accent-glow: 0 0 16px rgba(0, 184, 148, 0.18);
/* 渐变 — 浅色版 */
--bg-gradient: linear-gradient(135deg, #f8fafc 0%, #fff 100%);
/* hover/elevated 替换为浅色调 */
--bg-card-hover: #f1f5f9;
--bg-elevated: #fff;
--bg-hover: #f1f5f9;
--accent-light: rgba(0, 184, 148, 0.12);
--accent-hover: #00d4aa;
/* Pico 浅色覆盖(默认 Pico 行为) */
--pico-primary-inverse: #fff;
--pico-contrast-background: #f1f5f9;
}
:root {
--bg-deep: #0a0a0f;
--bg-surface: #12121a;
--bg-card: #1a1a24;
--bg-input: #0e0e14;
--text-primary: #e8e8ed;
--text-secondary: #8888a0;
--text-muted: #55556a;
--border-subtle: #2a2a3a;
--border-strong: #3a3a4a;
--accent-cyan: #00f5d4;
--accent-magenta: #f72585;
--accent-green: #10b981;
--accent-red: #f43f5e;
--accent-yellow: #fbbf24;
--accent-blue: #4cc9f0;
--accent-purple: #7b2cbf;
--radius-sm: 4px;
--radius-md: 8px;
--radius-lg: 12px;
--font-sans:
"Space Grotesk", -apple-system, blinkmacsystemfont, "Segoe UI", roboto, sans-serif;
--font-mono: "JetBrains Mono", "Courier New", monospace;
--shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
[data-theme="light"] {
--bg-deep: #fafafa;
--bg-surface: #fff;
--bg-card: #fff;
--bg-input: #f5f5f5;
--text-primary: #1a1a1a;
--text-secondary: #666;
--text-muted: #999;
--border-subtle: #e5e5e5;
--border-strong: #d5d5d5;
--accent-cyan: #00d4b8;
--accent-magenta: #e63975;
--shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.theme-toggle {
position: fixed;
top: 1rem;
right: 1rem;
width: 40px;
height: 40px;
border-radius: 50%;
border: 1px solid var(--border-subtle);
background: var(--color-bg-card);
cursor: pointer;
font-size: 1.2rem;
z-index: 100;
transition: all 0.2s;
display: flex;
align-items: center;
justify-content: center;
}
.theme-toggle:hover {
transform: scale(1.1);
}
:root {
--primary: #06b6d4;
--primary-hover: #0891b2;
}
body {
padding: 1rem;
}
.container {
max-width: 1200px;
margin: 0 auto;
}
header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 1.5rem;
}
h1 {
margin: 0;
font-size: 1.5rem;
}
.main-grid {
display: grid;
grid-template-columns: 350px 1fr;
gap: 1rem;
}
@media (max-width: 900px) {
.main-grid {
grid-template-columns: 1fr;
}
}
.panel {
background: var(--pico-card-background-color);
border-radius: 8px;
padding: 1rem;
}
.section {
margin-bottom: 1.5rem;
}
.section-title {
font-weight: 600;
margin-bottom: 0.5rem;
font-size: 0.9rem;
color: var(--pico-muted-color);
display: flex;
align-items: center;
gap: 0.5rem;
}
.section-title input[type="checkbox"] {
margin: 0;
}
input[type="text"],
input[type="url"],
textarea,
select {
width: 100%;
padding: 0.5rem;
font-size: 0.9rem;
margin-bottom: 0.5rem;
}
textarea {
min-height: 80px;
resize: vertical;
}
.badge-row {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
margin-bottom: 0.5rem;
}
.badge-item {
display: flex;
align-items: center;
gap: 0.25rem;
padding: 0.25rem 0.5rem;
background: var(--pico-muted-border-color);
border-radius: 4px;
font-size: 0.8rem;
}
.badge-item button {
background: none;
border: none;
cursor: pointer;
color: var(--pico-del-color);
padding: 0;
font-size: 1rem;
line-height: 1;
}
.add-badge {
display: flex;
gap: 0.5rem;
}
.add-badge select {
flex: 1;
}
.add-badge button {
padding: 0.5rem 1rem;
}
.tech-tags {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
margin-bottom: 0.5rem;
}
.tech-tag {
padding: 0.25rem 0.5rem;
border: 1px solid var(--pico-muted-border-color);
border-radius: 4px;
font-size: 0.8rem;
cursor: pointer;
transition: all 0.2s;
}
.tech-tag:hover {
border-color: var(--accent-cyan);
}
.tech-tag.selected {
background: var(--accent-cyan);
color: white;
border-color: var(--accent-cyan);
}
.feature-list {
margin-bottom: 0.5rem;
}
.feature-item {
display: flex;
gap: 0.5rem;
margin-bottom: 0.5rem;
}
.feature-item input {
flex: 1;
}
.feature-item button {
padding: 0.5rem;
}
.output-area {
position: relative;
}
.output-area textarea {
min-height: 600px;
font-family: Monaco, Menlo, monospace;
font-size: 0.85rem;
}
.btn-group {
display: flex;
gap: 0.5rem;
margin-bottom: 0.5rem;
}
.btn-group button {
flex: 1;
padding: 0.5rem;
font-size: 0.85rem;
}
.tabs {
display: flex;
gap: 0.5rem;
margin-bottom: 1rem;
}
.tabs button {
padding: 0.5rem 1rem;
border: none;
background: none;
cursor: pointer;
border-bottom: 2px solid transparent;
}
.tabs button.active {
border-bottom-color: var(--accent-cyan);
color: var(--accent-cyan);
}
.preview {
padding: 1rem;
background: var(--pico-background-color);
border-radius: 4px;
overflow: auto;
max-height: 600px;
}
.preview h1,
.preview h2,
.preview h3 {
margin-top: 1rem;
}
.preview pre {
background: #1e1e1e;
color: #d4d4d4;
padding: 1rem;
border-radius: 4px;
overflow-x: auto;
}
.preview code {
font-family: Monaco, Menlo, monospace;
}
.preview table {
width: 100%;
border-collapse: collapse;
}
.preview th,
.preview td {
border: 1px solid var(--pico-muted-border-color);
padding: 0.5rem;
text-align: left;
}
.preview img {
max-width: 100%;
height: auto;
}
.preview blockquote {
border-left: 4px solid var(--accent-cyan);
padding-left: 1rem;
margin: 1rem 0;
color: var(--pico-muted-color);
}
.breadcrumb {
background: rgba(255, 255, 255, 0.95);
padding: 8px 15px;
border-radius: 20px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
font-size: 0.85rem;
}
.breadcrumb a {
color: #667eea;
text-decoration: none;
}
.breadcrumb a:hover {
text-decoration: underline;
}
.breadcrumb span {
color: #999;
margin: 0 5px;
}
</style>
<!-- Google Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap"
rel="stylesheet"
/>
</head>
<body>
<button class="theme-toggle" onclick="toggleTheme()" aria-label="切换主题">
<span id="theme-icon">🌙</span>
</button>
<nav class="breadcrumb">
<a href="../../index.html">首页</a>
<span>›</span>
README 生成器
</nav>
<div class="container">
<header>
<h1>📝 README 生成器</h1>
<button id="themeToggle" class="outline">🌙</button>
</header>
<div class="main-grid">
<div class="panel" style="max-height: 85vh; overflow-y: auto">
<!-- Basic Info -->
<div class="section">
<div class="section-title">基本信息</div>
<input type="text" id="projectName" placeholder="项目名称" value="My Awesome Project" />
<textarea id="projectDesc" placeholder="项目简介">
一个非常棒的开源项目,帮助开发者提高效率。</textarea
>
<input type="url" id="projectUrl" placeholder="项目 URL (可选)" />
</div>
<!-- Badges -->
<div class="section">
<label class="section-title">
<input type="checkbox" id="showBadges" checked />
徽章
</label>
<div id="badgeList" class="badge-row"></div>
<div class="add-badge">
<select id="badgeType">
<option value="license-MIT">License MIT</option>
<option value="license-Apache">License Apache 2.0</option>
<option value="version">Version</option>
<option value="build-passing">Build Passing</option>
<option value="build-failing">Build Failing</option>
<option value="coverage">Coverage</option>
<option value="npm">npm</option>
<option value="downloads">Downloads</option>
<option value="stars">GitHub Stars</option>
<option value="issues">GitHub Issues</option>
<option value="prs">PRs Welcome</option>
</select>
<button onclick="addBadge()">添加</button>
</div>
</div>
<!-- Features -->
<div class="section">
<label class="section-title">
<input type="checkbox" id="showFeatures" checked />
特性
</label>
<div id="featureList" class="feature-list">
<div class="feature-item">
<input type="text" value="简单易用,开箱即用" />
<button onclick="removeFeature(this)">✕</button>
</div>
<div class="feature-item">
<input type="text" value="高性能,轻量级" />
<button onclick="removeFeature(this)">✕</button>
</div>
<div class="feature-item">
<input type="text" value="完善的文档和示例" />
<button onclick="removeFeature(this)">✕</button>
</div>
</div>
<button onclick="addFeature()" style="width: 100%">+ 添加特性</button>
</div>
<!-- Tech Stack -->
<div class="section">
<label class="section-title">
<input type="checkbox" id="showTech" checked />
技术栈
</label>
<div class="tech-tags">
<span class="tech-tag selected" data-tech="JavaScript">JavaScript</span>
<span class="tech-tag" data-tech="TypeScript">TypeScript</span>
<span class="tech-tag" data-tech="Python">Python</span>
<span class="tech-tag" data-tech="Go">Go</span>
<span class="tech-tag" data-tech="Rust">Rust</span>
<span class="tech-tag selected" data-tech="Node.js">Node.js</span>
<span class="tech-tag" data-tech="React">React</span>
<span class="tech-tag" data-tech="Vue">Vue</span>
<span class="tech-tag" data-tech="Docker">Docker</span>
<span class="tech-tag" data-tech="PostgreSQL">PostgreSQL</span>
<span class="tech-tag" data-tech="MongoDB">MongoDB</span>
<span class="tech-tag" data-tech="Redis">Redis</span>
</div>
</div>
<!-- Installation -->
<div class="section">
<label class="section-title">
<input type="checkbox" id="showInstall" checked />
安装
</label>
<select id="packageManager">
<option value="npm">npm</option>
<option value="yarn">yarn</option>
<option value="pnpm">pnpm</option>
<option value="pip">pip</option>
<option value="go">go get</option>
<option value="cargo">cargo</option>
</select>
<input type="text" id="packageName" placeholder="包名" value="my-package" />
</div>
<!-- Usage -->
<div class="section">
<label class="section-title">
<input type="checkbox" id="showUsage" checked />
使用示例
</label>
<textarea id="usageCode" style="min-height: 120px; font-family: monospace">
import myPackage from 'my-package';
const result = myPackage.doSomething();
console.log(result);</textarea
>
</div>
<!-- API -->
<div class="section">
<label class="section-title">
<input type="checkbox" id="showApi" />
API 文档
</label>
<textarea id="apiDoc" placeholder="API 文档内容...">
### doSomething(options)
执行主要操作。
**参数:**
- `options.name` (string): 名称
- `options.count` (number): 数量,默认 1
**返回:** Promise<Result></textarea
>
</div>
<!-- Contributing -->
<div class="section">
<label class="section-title">
<input type="checkbox" id="showContrib" checked />
贡献指南
</label>
</div>
<!-- License -->
<div class="section">
<label class="section-title">
<input type="checkbox" id="showLicense" checked />
许可证
</label>
<select id="licenseType">
<option value="MIT">MIT</option>
<option value="Apache-2.0">Apache 2.0</option>
<option value="GPL-3.0">GPL 3.0</option>
<option value="BSD-3-Clause">BSD 3-Clause</option>
<option value="ISC">ISC</option>
<option value="Unlicense">Unlicense</option>
</select>
<input type="text" id="authorName" placeholder="作者名" />
</div>
<button onclick="generate()" style="width: 100%">生成 README</button>
</div>
<div class="panel output-area">
<div class="tabs">
<button class="active" data-tab="code">Markdown</button>
<button data-tab="preview">预览</button>
</div>
<div id="codeTab">
<div class="btn-group">
<button id="copyBtn">📋 复制</button>
<button id="downloadBtn">💾 下载</button>
</div>
<textarea id="output" readonly></textarea>
</div>
<div id="previewTab" style="display: none">
<div id="preview" class="preview"></div>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script>
let badges = ["license-MIT", "build-passing", "prs"];
const badgeTemplates = {
"license-MIT": "",
"license-Apache": "",
version: "",
"build-passing": "",
"build-failing": "",
coverage: "",
npm: "",
downloads: "",
stars: "",
issues: "",
prs: ""
};
function renderBadges() {
const container = document.getElementById("badgeList");
container.innerHTML = badges
.map(
(b) => `
<span class="badge-item">
${b}
<button onclick="removeBadge('${b}')">✕</button>
</span>
`
)
.join("");
}
window.addBadge = function () {
const type = document.getElementById("badgeType").value;
if (!badges.includes(type)) {
badges.push(type);
renderBadges();
generate();
}
};
window.removeBadge = function (type) {
badges = badges.filter((b) => b !== type);
renderBadges();
generate();
};
window.addFeature = function () {
const list = document.getElementById("featureList");
const div = document.createElement("div");
div.className = "feature-item";
div.innerHTML = `
<input type="text" placeholder="新特性">
<button onclick="removeFeature(this)">✕</button>
`;
list.appendChild(div);
div.querySelector("input").focus();
};
window.removeFeature = function (btn) {
btn.parentElement.remove();
generate();
};
function getSelectedTechs() {
return Array.from(document.querySelectorAll(".tech-tag.selected")).map(
(t) => t.dataset.tech
);
}
window.generate = function () {
const name = document.getElementById("projectName").value || "My Project";
const desc = document.getElementById("projectDesc").value;
const url = document.getElementById("projectUrl").value;
const pkgMgr = document.getElementById("packageManager").value;
const pkgName = document.getElementById("packageName").value || "my-package";
const usageCode = document.getElementById("usageCode").value;
const apiDoc = document.getElementById("apiDoc").value;
const license = document.getElementById("licenseType").value;
const author = document.getElementById("authorName").value;
const techs = getSelectedTechs();
const features = Array.from(document.querySelectorAll("#featureList input"))
.map((i) => i.value)
.filter((v) => v.trim());
let md = `# ${name}\n\n`;
// Badges
if (document.getElementById("showBadges").checked && badges.length) {
md +=
badges
.map((b) => {
let badge = badgeTemplates[b] || "";
badge = badge.replace(/PACKAGE/g, pkgName);
if (url) {
const match = url.match(/github\.com\/([^\/]+)\/([^\/]+)/);
if (match) {
badge = badge.replace(/USER/g, match[1]).replace(/REPO/g, match[2]);
}
}
return badge;
})
.join(" ") + "\n\n";
}
// Description
if (desc) {
md += `${desc}\n\n`;
}
// Tech stack
if (document.getElementById("showTech").checked && techs.length) {
md += "## 🛠️ 技术栈\n\n";
md += techs.map((t) => `- ${t}`).join("\n") + "\n\n";
}
// Features
if (document.getElementById("showFeatures").checked && features.length) {
md += "## ✨ 特性\n\n";
md += features.map((f) => `- ${f}`).join("\n") + "\n\n";
}
// Installation
if (document.getElementById("showInstall").checked) {
md += "## 📦 安装\n\n";
const cmds = {
npm: `npm install ${pkgName}`,
yarn: `yarn add ${pkgName}`,
pnpm: `pnpm add ${pkgName}`,
pip: `pip install ${pkgName}`,
go: `go get ${pkgName}`,
cargo: `cargo add ${pkgName}`
};
md += "```bash\n" + cmds[pkgMgr] + "\n```\n\n";
}
// Usage
if (document.getElementById("showUsage").checked && usageCode) {
md += "## 🚀 使用\n\n";
const lang =
pkgMgr === "pip"
? "python"
: pkgMgr === "go"
? "go"
: pkgMgr === "cargo"
? "rust"
: "javascript";
md += "```" + lang + "\n" + usageCode + "\n```\n\n";
}
// API
if (document.getElementById("showApi").checked && apiDoc) {
md += `## 📖 API\n\n${apiDoc}\n\n`;
}
// Contributing
if (document.getElementById("showContrib").checked) {
md += "## 🤝 贡献\n\n";
md += "欢迎贡献代码!请查看 [贡献指南](CONTRIBUTING.md) 了解详情。\n\n";
md += "1. Fork 本仓库\n";
md += "2. 创建特性分支 (`git checkout -b feature/AmazingFeature`)\n";
md += "3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)\n";
md += "4. 推送到分支 (`git push origin feature/AmazingFeature`)\n";
md += "5. 提交 Pull Request\n\n";
}
// License
if (document.getElementById("showLicense").checked) {
md += "## 📄 许可证\n\n";
md += `本项目采用 [${license}](LICENSE) 许可证`;
if (author) md += ` - 版权所有 © ${new Date().getFullYear()} ${author}`;
md += "。\n";
}
document.getElementById("output").value = md;
updatePreview(md);
};
window.updatePreview = function (md) {
document.getElementById("preview").innerHTML = marked.parse(md);
};
// Event listeners
document.querySelectorAll(".tech-tag").forEach((tag) => {
tag.addEventListener("click", () => {
tag.classList.toggle("selected");
generate();
});
});
document.querySelectorAll(".tabs button").forEach((btn) => {
btn.addEventListener("click", () => {
document.querySelectorAll(".tabs button").forEach((b) => b.classList.remove("active"));
btn.classList.add("active");
const tab = btn.dataset.tab;
document.getElementById("codeTab").style.display = tab === "code" ? "block" : "none";
document.getElementById("previewTab").style.display =
tab === "preview" ? "block" : "none";
});
});
document.getElementById("copyBtn").addEventListener("click", () => {
navigator.clipboard.writeText(document.getElementById("output").value);
document.getElementById("copyBtn").textContent = "✓ 已复制";
setTimeout(() => (document.getElementById("copyBtn").textContent = "📋 复制"), 2000);
});
document.getElementById("downloadBtn").addEventListener("click", () => {
const blob = new Blob([document.getElementById("output").value], { type: "text/markdown" });
const a = document.createElement("a");
a.href = URL.createObjectURL(blob);
a.download = "README.md";
a.click();
});
// Auto-generate on input changes
document.querySelectorAll("input, textarea, select").forEach((el) => {
el.addEventListener("input", generate);
el.addEventListener("change", generate);
});
// Feature input listener (delegated)
document.getElementById("featureList").addEventListener("input", generate);
// Theme toggle
const theme = localStorage.getItem("theme") || "light";
document.documentElement.setAttribute("data-theme", theme);
document.getElementById("themeToggle").textContent = theme === "dark" ? "☀️" : "🌙";
document.getElementById("themeToggle").addEventListener("click", () => {
const current = document.documentElement.getAttribute("data-theme");
const next = current === "dark" ? "light" : "dark";
document.documentElement.setAttribute("data-theme", next);
localStorage.setItem("theme", next);
document.getElementById("themeToggle").textContent = next === "dark" ? "☀️" : "🌙";
});
// Initial render
renderBadges();
generate();
// Theme toggle
function toggleTheme() {
const html = document.documentElement;
const currentTheme = html.getAttribute("data-theme");
const newTheme = currentTheme === "light" ? "dark" : "light";
html.setAttribute("data-theme", newTheme);
document.getElementById("theme-icon").textContent = newTheme === "light" ? "☀️" : "🌙";
localStorage.setItem("theme", newTheme);
}
// Load saved theme
const savedTheme = localStorage.getItem("theme") || "dark";
if (savedTheme === "light") {
document.documentElement.setAttribute("data-theme", "light");
document.getElementById("theme-icon").textContent = "☀️";
}
</script>
</body>
</html>