forked from blueeggs1125-art/bluekard
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimage2.html
More file actions
591 lines (505 loc) · 20.9 KB
/
image2.html
File metadata and controls
591 lines (505 loc) · 20.9 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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<link rel="icon" type="image/png" sizes="16x16" href="icon/16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="icon/32x32.png">
<link rel="icon" type="image/png" sizes="48x48" href="icon/48x48.png">
<link rel="icon" type="image/png" sizes="64x64" href="icon/64x64.png">
<link rel="icon" type="image/png" sizes="128x128" href="icon/128x128.png">
<link rel="icon" type="image/png" sizes="256x256" href="icon/256x256.png">
<link rel="icon" type="image/png" sizes="512x512" href="icon/512x512.png">
<link rel="apple-touch-icon" sizes="180x180" href="icon/180x180.png">
<link rel="manifest" href="site.webmanifest">
<meta name="theme-color" content="#ffffff">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="favicon.ico" type="image/x-icon">
<title>FUCK 1939</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
padding: 10px;
background-color: #f5f5f5;
}
.container {
max-width: 1200px;
margin: 0 auto;
}
h1 {
text-align: center;
margin-bottom: 20px;
color: #333;
font-size: 24px;
}
.selector-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 5px;
font-weight: bold;
color: #555;
}
select, input {
width: 100%;
padding: 10px;
border-radius: 5px;
border: 1px solid #ddd;
background-color: white;
font-size: 16px;
margin-bottom: 10px;
}
.image-container {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
gap: 15px;
margin-top: 10px;
}
.image-item {
position: relative;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 2px 8px rgba(0,0,0,0.15);
background-color: white;
aspect-ratio: 2/3;
}
.image-item img {
width: 100%;
height: 100%;
object-fit: cover;
display: block;
-webkit-touch-callout: default; /* 允许iOS上的长按菜单 */
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.image-item .image-name {
padding: 5px;
font-size: 11px;
text-align: center;
background-color: rgba(0,0,0,0.8);
color: white;
position: absolute;
bottom: 0;
left: 0;
right: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.no-images {
text-align: center;
padding: 40px 20px;
color: #999;
font-style: italic;
grid-column: 1 / -1;
}
.loading {
text-align: center;
padding: 40px 20px;
color: #666;
grid-column: 1 / -1;
}
/* 添加导航链接样式 */
.nav-link {
display: block;
text-align: center;
margin: 15px 0;
color: #1e90ff;
text-decoration: none;
font-weight: bold;
}
.nav-link:hover {
text-decoration: underline;
}
@media (max-width: 768px) {
.container {
padding: 0 10px;
}
.image-container {
grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
gap: 8px;
}
h1 {
font-size: 20px;
}
}
@media (max-width: 480px) {
.image-container {
grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
gap: 5px;
}
.image-item .image-name {
font-size: 8px;
padding: 2px;
}
}
</style>
</head>
<body>
<style>
/* 统一的页面载入动画 */
@keyframes pageSlideIn {
from {
opacity: 0;
transform: translateY(10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
/* 应用到所有页面容器 */
.container {
animation: pageSlideIn 0.4s ease-out forwards;
}
/* 为已有动画的页面调整动画 */
.content {
animation: pageSlideIn 0.4s ease-out forwards;
}
/* 视频列表动画 */
.video-list {
animation: pageSlideIn 0.4s ease-out forwards;
}
/* 音效容器动画 */
#sound-display {
animation: pageSlideIn 0.4s ease-out forwards;
}
/* 图片容器动画 */
#image-display {
animation: pageSlideIn 0.4s ease-out forwards;
}
/* 导航栏动画 */
.bottom-nav {
animation: pageSlideIn 0.4s ease-out 0.1s forwards;
animation-fill-mode: both;
}
/* 初始状态设置 */
.container,
.content,
.video-list,
#sound-display,
#image-display,
.bottom-nav {
opacity: 0;
}
/* 延迟显示内容,避免闪烁 */
@media (prefers-reduced-motion: reduce) {
.container,
.content,
.video-list,
#sound-display,
#image-display,
.bottom-nav {
animation: none;
opacity: 1;
}
}
</style>
<style>
.image-item .image-name {
display: none;
}
</style>
<!-- 在 </body> 标签前添加 -->
<div style="position: fixed; bottom: 0; left: 0; right: 0; background-color: #fff; border-top: 1px solid #ddd; display: flex; justify-content: space-around; padding: 10px 0; z-index: 1000; font-size: 14px;">
<a href="index.html" style="text-decoration: none; color: #1e90ff; text-align: center;">卡图</a>
<a href="image2.html" style="text-decoration: none; color: #1e90ff; text-align: center;">其他素材</a>
<a href="suck.html" style="text-decoration: none; color: #1e90ff; text-align: center;">音效库</a>
<a href="zaza.html" style="text-decoration: none; color: #1e90ff; text-align: center;">加载动画</a>
<a href="team.html" style="text-decoration: none; color: #1e90ff; text-align: center;">关于</a>
</div>
<div class="container">
<h1>其他素材</h1>
<div class="selector-group">
<label for="folder-select">选种类:</label>
<select id="folder-select">
<option value="">请选择...</option>
</select>
</div>
<div class="selector-group" id="subfolder-group" style="display: none;">
<label for="subfolder-select">选子项目:</label>
<select id="subfolder-select">
<option value="">请选择...</option>
<option value="__direct__">直接图片</option>
</select>
</div>
<div id="image-display">
<div class="no-images">请先选择文件夹</div>
</div>
</div>
<script>
function encodeImagePath(path) {
return path.split('/').map(part => encodeURIComponent(part)).join('/');
}
const folderSelect = document.getElementById('folder-select');
const subfolderGroup = document.getElementById('subfolder-group');
const subfolderSelect = document.getElementById('subfolder-select');
const imageDisplay = document.getElementById('image-display');
// 页面加载时获取文件夹列表
window.addEventListener('DOMContentLoaded', function() {
loadFolderList();
});
folderSelect.addEventListener('change', function() {
const folder = this.value;
if (folder) {
handleFolderSelection(folder);
} else {
subfolderGroup.style.display = 'none';
imageDisplay.innerHTML = '<div class="no-images">请先选择主文件夹</div>';
}
});
subfolderSelect.addEventListener('change', function() {
const folder = folderSelect.value;
const subfolder = this.value;
if (folder) {
if (subfolder === '__direct__') {
displayDirectImages(folder);
} else {
displayImages(folder, subfolder);
}
} else {
imageDisplay.innerHTML = '<div class="no-images">请选择子文件夹</div>';
}
});
// 加载文件夹列表
async function loadFolderList() {
try {
const response = await fetch('data/newimages2.json');
if (!response.ok) {
throw new Error('data/newimages2.json 网络响应错误');
}
const imagesData = await response.json();
// 清空现有选项
folderSelect.innerHTML = '<option value="">请选择...</option>';
// 提取所有主文件夹名称
const folders = new Set();
imagesData.forEach(imagePath => {
const parts = imagePath.split('/');
if (parts.length > 1) {
folders.add(parts[1]); // 第二个部分是主文件夹名
}
});
// 添加文件夹选项
folders.forEach(folder => {
const option = document.createElement('option');
option.value = folder;
option.textContent = folder;
folderSelect.appendChild(option);
});
if (folders.size === 0) {
imageDisplay.innerHTML = '<div class="no-images">未找到主文件夹</div>';
}
} catch (error) {
console.error('加载文件夹列表出错:', error);
imageDisplay.innerHTML = '<div class="no-images">加载文件夹列表失败</div>';
}
}
// 处理文件夹选择
function handleFolderSelection(folder) {
fetch('data/newimages2.json')
.then(response => response.json())
.then(imagesData => {
// 获取该文件夹下的所有路径
const folderPaths = imagesData.filter(imagePath => {
const parts = imagePath.split('/');
return parts.length > 1 && parts[1] === folder;
});
// 分析文件夹结构
const subfolders = new Set();
const directImages = [];
folderPaths.forEach(imagePath => {
const parts = imagePath.split('/');
if (parts.length === 3) {
// 直接在主文件夹下的图片
directImages.push(imagePath);
} else if (parts.length > 3) {
// 子文件夹
subfolders.add(parts[2]);
}
});
// 根据结构决定显示方式
if (subfolders.size > 0) {
// 有子文件夹,显示子文件夹下拉框
subfolderGroup.style.display = 'block';
updateSubfolderOptions(subfolders, directImages.length > 0);
// 如果同时有直接图片和子文件夹,先显示直接图片
if (directImages.length > 0) {
renderImages(directImages);
} else {
imageDisplay.innerHTML = '<div class="no-images">请选择子文件夹</div>';
}
} else if (directImages.length > 0) {
// 没有子文件夹,直接显示图片
subfolderGroup.style.display = 'none';
renderImages(directImages);
} else {
// 没有内容
subfolderGroup.style.display = 'none';
imageDisplay.innerHTML = '<div class="no-images">该文件夹中暂无图片</div>';
}
})
.catch(error => {
console.error('处理文件夹选择出错:', error);
imageDisplay.innerHTML = '<div class="no-images">加载内容失败</div>';
});
}
// 更新子文件夹选项
function updateSubfolderOptions(subfolders, hasDirectImages) {
subfolderSelect.innerHTML = '<option value="">请选择...</option>';
// 如果有直接图片,添加"直接图片"选项
if (hasDirectImages) {
const directOption = document.createElement('option');
directOption.value = '__direct__';
directOption.textContent = '直接图片';
subfolderSelect.appendChild(directOption);
}
subfolders.forEach(subfolder => {
const option = document.createElement('option');
option.value = subfolder;
option.textContent = subfolder;
subfolderSelect.appendChild(option);
});
}
// 显示主文件夹中的直接图片
async function displayDirectImages(folder) {
imageDisplay.innerHTML = '<div class="loading">加载中...</div>';
try {
const response = await fetch('data/newimages2.json');
if (!response.ok) {
throw new Error('data/newimages2.json 网络响应错误');
}
const imagesData = await response.json();
// 筛选主文件夹中的直接图片
const filteredImages = imagesData.filter(imagePath => {
const parts = imagePath.split('/');
return parts.length === 3 && parts[1] === folder;
});
if (filteredImages.length === 0) {
imageDisplay.innerHTML = '<div class="no-images">该文件夹中暂无直接图片</div>';
return;
}
renderImages(filteredImages);
} catch (error) {
console.error('加载图片出错:', error);
imageDisplay.innerHTML = '<div class="no-images">加载图片失败</div>';
}
}
// 显示特定子文件夹中的图片
async function displayImages(folder, subfolder) {
imageDisplay.innerHTML = '<div class="loading">加载中...</div>';
try {
const response = await fetch('data/newimages2.json');
if (!response.ok) {
throw new Error('data/newimages2.json 网络响应错误');
}
const imagesData = await response.json();
// 筛选指定文件夹中的图片
const filteredImages = imagesData.filter(imagePath => {
const parts = imagePath.split('/');
return parts.length > 2 && parts[1] === folder && parts[2] === subfolder;
});
if (filteredImages.length === 0) {
imageDisplay.innerHTML = '<div class="no-images">该文件夹中暂无图片</div>';
return;
}
renderImages(filteredImages);
} catch (error) {
console.error('加载图片出错:', error);
imageDisplay.innerHTML = '<div class="no-images">加载图片失败</div>';
}
}
// 渲染图片列表
function renderImages(images) {
let html = '<div class="image-container">';
images.forEach(imagePath => {
// 对整个路径进行编码以支持中文
const encodedImagePath = encodeImagePath(imagePath);
const fileName = imagePath.split('/').pop();
const displayName = fileName;
// 对文件名进行编码用于下载
const encodedFileName = encodeURIComponent(fileName);
html += `
<div class="image-item">
<img src="${encodedImagePath}" alt="${displayName}"
data-url="${encodedImagePath}"
data-filename="${encodedFileName}"
onload="this.parentNode.classList.add('loaded')">
<div class="image-name">${displayName}</div>
</div>
`;
});
html += '</div>';
imageDisplay.innerHTML = html;
// 为所有图片添加触摸事件
document.querySelectorAll('.image-item img').forEach(img => {
new ImageTouchHandler(img);
});
}
// 图片触摸处理类
class ImageTouchHandler {
constructor(element) {
this.element = element;
this.touchStartTime = 0;
this.touchTimer = null;
this.touchHandled = false;
this.init();
}
init() {
// 添加触摸事件监听器
this.element.addEventListener('touchstart', (e) => this.handleTouchStart(e), { passive: false });
this.element.addEventListener('touchend', (e) => this.handleTouchEnd(e), { passive: false });
this.element.addEventListener('touchmove', (e) => this.handleTouchMove(e), { passive: false });
this.element.addEventListener('contextmenu', (e) => this.handleContextMenu(e));
}
handleTouchStart(event) {
this.touchStartTime = Date.now();
this.touchHandled = false;
clearTimeout(this.touchTimer);
// 长按800ms后触发下载
this.touchTimer = setTimeout(() => {
if (!this.touchHandled) {
this.downloadImage();
this.touchHandled = true;
}
}, 800);
// 阻止默认行为和事件冒泡
// 注意:不要完全阻止,否则可能影响长按菜单
// event.preventDefault();
// event.stopPropagation();
}
handleTouchMove(event) {
// 如果用户移动手指,取消长按下载
clearTimeout(this.touchTimer);
this.touchHandled = true;
}
handleTouchEnd(event) {
// 如果用户提前结束触摸,取消长按下载
clearTimeout(this.touchTimer);
this.touchHandled = true;
}
handleContextMenu(event) {
// 右键菜单触发下载
event.preventDefault();
this.downloadImage();
}
downloadImage() {
const url = this.element.dataset.url;
const filename = decodeURIComponent(this.element.dataset.filename);
const link = document.createElement('a');
link.href = url;
link.download = filename;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
}
</script>
</body>
</html>