-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGitignoreGenerator.html
More file actions
640 lines (550 loc) · 12.4 KB
/
Copy pathGitignoreGenerator.html
File metadata and controls
640 lines (550 loc) · 12.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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gitignore生成器 - JustHTML 只需网页</title>
<script>
/**
* 动态加载(强制去除缓存) CSS 的函数
* @param {string} src - 要加载的 CSS 的 src 链接
* @returns {Promise} 返回一个 Promise 对象,用于处理异步加载
*/
function loadStyle(src) {
return new Promise((resolve, reject) => {
const link = document.createElement('link');
link.rel = 'stylesheet';
link.href = src + '?v=' + new Date().getTime(); // 使用时间戳避免缓存
link.async = true;
link.onload = resolve;
link.onerror = reject;
document.head.appendChild(link);
});
}
/**
* 动态加载(强制去除缓存) JS 的函数
* @param {string} src - 要加载的 JS 的 src 链接
* @returns {Promise} 返回一个 Promise 对象,用于处理异步加载
*/
function loadScript(src) {
return new Promise((resolve, reject) => {
const script = document.createElement('script');
script.src = src + '?v=' + new Date().getTime(); // 使用时间戳避免缓存
script.async = true;
script.onload = resolve;
script.onerror = reject;
document.head.appendChild(script);
});
}
</script>
<script>
loadStyle('../assets/style.css')
let scriptArray = [
"../assets/AddHeader_Tools.js",
"../assets/AddFooter.js",
"../assets/AddIco.js",
"../assets/AutoRun.js",
]
scriptArray.forEach(script => {
loadScript(script);
});
</script>
<script src="../package/Vue/code/vue.global.prod.js"></script>
<script type="module" src="../package/Sober/code/main.js"></script>
<style>
.tech-selector {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 15px;
margin: 15px 0;
}
.tech-item {
display: flex;
align-items: center;
}
.tech-item input[type="checkbox"] {
margin-right: 8px;
}
.controls {
display: flex;
flex-wrap: wrap;
gap: 10px;
margin: 15px 0;
}
.info-box {
background-color: var(--bg-tertiary);
padding: 10px;
border-radius: var(--border-radius);
margin: 10px 0;
}
</style>
</head>
<body>
<div id="app">
<div class="container">
<a href="../index.html" class="back-link">← 返回首页</a>
<div class="tool-section">
<h2>Gitignore生成器</h2>
<p>生成gitignore文件内容</p>
<div class="info-box">
<p><strong>功能说明:</strong></p>
<p>• 选择技术栈来自动生成对应的gitignore规则</p>
<p>• 支持多种编程语言和技术栈</p>
<p>• 可自定义添加额外的忽略规则</p>
</div>
<div>
<h3>选择技术栈</h3>
<div class="tech-selector">
<div class="tech-item">
<input type="checkbox" id="node" v-model="selectedTech.node">
<label for="node">Node.js</label>
</div>
<div class="tech-item">
<input type="checkbox" id="python" v-model="selectedTech.python">
<label for="python">Python</label>
</div>
<div class="tech-item">
<input type="checkbox" id="java" v-model="selectedTech.java">
<label for="java">Java</label>
</div>
<div class="tech-item">
<input type="checkbox" id="php" v-model="selectedTech.php">
<label for="php">PHP</label>
</div>
<div class="tech-item">
<input type="checkbox" id="dotnet" v-model="selectedTech.dotnet">
<label for="dotnet">.NET</label>
</div>
<div class="tech-item">
<input type="checkbox" id="ruby" v-model="selectedTech.ruby">
<label for="ruby">Ruby</label>
</div>
<div class="tech-item">
<input type="checkbox" id="go" v-model="selectedTech.go">
<label for="go">Go</label>
</div>
<div class="tech-item">
<input type="checkbox" id="rust" v-model="selectedTech.rust">
<label for="rust">Rust</label>
</div>
<div class="tech-item">
<input type="checkbox" id="react" v-model="selectedTech.react">
<label for="react">React</label>
</div>
<div class="tech-item">
<input type="checkbox" id="vue" v-model="selectedTech.vue">
<label for="vue">Vue</label>
</div>
<div class="tech-item">
<input type="checkbox" id="angular" v-model="selectedTech.angular">
<label for="angular">Angular</label>
</div>
<div class="tech-item">
<input type="checkbox" id="docker" v-model="selectedTech.docker">
<label for="docker">Docker</label>
</div>
</div>
<h3>自定义规则</h3>
<textarea
v-model="customRules"
placeholder="在此添加自定义的gitignore规则,每行一个规则..."
rows="5"
></textarea>
<div class="controls">
<button @click="generateGitignore">生成gitignore</button>
<button @click="selectAll">全选</button>
<button @click="clearSelection">清除选择</button>
<button @click="clearAll">清空所有</button>
<button @click="copyResult">复制结果</button>
</div>
<div class="result" v-if="result">
<h3>生成的.gitignore内容:</h3>
<pre>{{ result }}</pre>
</div>
</div>
</div>
</div>
</div>
<script>
const { createApp, ref, reactive, watch } = Vue;
createApp({
setup() {
// 技术栈选择状态
const selectedTech = reactive({
node: false,
python: false,
java: false,
php: false,
dotnet: false,
ruby: false,
go: false,
rust: false,
react: false,
vue: false,
angular: false,
docker: false
});
const customRules = ref('');
const result = ref('');
// 不同技术栈的gitignore规则
const gitignoreTemplates = {
node: `# Dependency directories
node_modules/
jspm_packages/
# Production builds
/dist
/build
/.next
/.vercel
# Environment
.env
.env.local
.env.development.local
.env.test.local
.env.production.local
# IDEs
.vscode/
.idea/
# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Coverage directory used by tools like istanbul
coverage/
*.lcov
# Temporary folders
tmp/
temp/
`,
python: `# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
# Virtual environments
venv/
env/
ENV/
# IDEs
.pytest_cache/
.coverage
.vscode/
.idea/
# Environment
.env
.venv
env.bak
`,
java: `# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*
# misc
*.orig
# Cast
cast.log
# MT
.mt
# STS
.apt_generated
.springBeans
# Checkstyle
checkstyle*
# JSHint
jshint*
`,
php: `# Composer
vendor/
composer.phar
# Framework specifics
/app/storage/**
!/app/storage/.gitkeep
!/public/uploads/*
/storage/**
!/storage/.gitkeep
!/storage/logs/.gitkeep
/bootstrap/cache/**
!/bootstrap/cache/.gitkeep
# Environment
.env*
!.env.example
# IDEs
.idea/
.vscode/
# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
`,
dotnet: `# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]ogs/
# User-specific files
*.rs.user
*.suo
*.user
*.userosscache
*.sln.docstates
# Visual Studio cache/options
.vs/
.vsconfig
.directory
.history/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
`,
ruby: `# Gemfile dependencies
/vendor/bundle/
/Gemfile.lock
# Environment
.env
# IDEs
.idea/
.vscode/
*.swp
*.swo
# Documentation
doc/
.rdoc_options
# Coverage
coverage/
*.cov
.codeclimate.yml
# Logs
/log/
*.log
# Temp
/tmp/
`,
go: `# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Test binary, built with \`go test -c\`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# IDEs
.vscode/
.idea/
# Environment
.env
`,
rust: `# Generated by Cargo
# Will have compiled files and executables
/target/
# Remove Cargo.lock from gitignore if it's a binary crate
# Since this is an example of a library, we don't actually want to ignore it
# Cargo.lock
**/*.rs.bk
# Many test frameworks and coverage tools generate a file that ends in .profraw
# This is excluded to prevent those files from being committed
*.profraw
# Benchmark outputs
**/benches/**/*.txt
# IDEs
.vscode/
.idea/
`,
react: `# Dependencies
node_modules/
# Production builds
build/
dist/
coverage/
# Environment
.env*
# IDEs
.vscode/
.idea/
# OS
.DS_Store
Thumbs.db
`,
vue: `# Dependencies
node_modules/
# Production builds
dist/
dist-ssr/
.nuxt/
coverage/
# Environment
.env*
# IDEs
.vscode/
.idea/
# OS
.DS_Store
Thumbs.db
`,
angular: `# Dependencies
node_modules/
# Production builds
dist/
dist-prod/
output/
dist-server/
.angular/
# E2E
/e2e/screenshots/
*.log
# Environment
.env*
# IDEs
.vscode/
.idea/
# OS
.DS_Store
Thumbs.db
`,
docker: `# Docker build context
!Dockerfile
!docker-compose.yml
!docker-compose.*.yml
# Log files
*.log
# Environment
.env
.dockerenv
# IDEs
.vscode/
.idea/
`
};
// 监听技术栈选择变化,自动生成结果
watch(() => ({...selectedTech}), () => {
generateGitignore();
}, { deep: true });
// 监听自定义规则变化
watch(customRules, () => {
generateGitignore();
});
// 生成gitignore
const generateGitignore = () => {
let gitignoreContent = '';
// 添加选中的技术栈规则
for (const [tech, isSelected] of Object.entries(selectedTech)) {
if (isSelected && gitignoreTemplates[tech]) {
gitignoreContent += `# ${tech.toUpperCase()}\n`;
gitignoreContent += gitignoreTemplates[tech];
gitignoreContent += '\n';
}
}
// 添加自定义规则
if (customRules.value.trim()) {
gitignoreContent += '# Custom Rules\n';
gitignoreContent += customRules.value.trim();
gitignoreContent += '\n';
}
result.value = gitignoreContent.trim();
};
// 全选
const selectAll = () => {
for (const tech in selectedTech) {
selectedTech[tech] = true;
}
};
// 清除选择
const clearSelection = () => {
for (const tech in selectedTech) {
selectedTech[tech] = false;
}
};
// 清空所有
const clearAll = () => {
clearSelection();
customRules.value = '';
result.value = '';
};
// 复制结果
const copyResult = () => {
if (result.value) {
navigator.clipboard.writeText(result.value)
.then(() => {
alert('gitignore内容已复制到剪贴板!');
})
.catch(err => {
console.error('复制失败: ', err);
alert('复制失败');
});
}
};
return {
selectedTech,
customRules,
result,
generateGitignore,
selectAll,
clearSelection,
clearAll,
copyResult
};
}
}).mount('#app');
</script>
</body>
</html>