-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1404 lines (1217 loc) · 46.1 KB
/
Copy pathindex.html
File metadata and controls
1404 lines (1217 loc) · 46.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>学术讨论班 - 课程文件管理系统</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
/* 基础样式 */
:root {
--primary-color: #2c3e50;
--secondary-color: #3498db;
--accent-color: #1abc9c;
--danger-color: #e74c3c;
--light-color: #ecf0f1;
--dark-color: #34495e;
--text-color: #333;
--light-text: #7f8c8d;
--shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
--border-radius: 8px;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
body {
background-color: #f9f9f9;
color: var(--text-color);
line-height: 1.6;
}
a {
text-decoration: none;
color: var(--secondary-color);
transition: color 0.3s;
}
a:hover {
color: var(--accent-color);
}
.container {
width: 90%;
max-width: 1200px;
margin: 0 auto;
padding: 0 15px;
}
/* 头部样式 */
header {
background-color: var(--primary-color);
color: white;
padding: 1.5rem 0;
box-shadow: var(--shadow);
position: sticky;
top: 0;
z-index: 100;
}
.header-content {
display: flex;
justify-content: space-between;
align-items: center;
}
.logo {
font-size: 1.8rem;
font-weight: 700;
display: flex;
align-items: center;
}
.logo-icon {
margin-right: 10px;
font-size: 2rem;
}
nav ul {
display: flex;
list-style: none;
}
nav li {
margin-left: 1.5rem;
}
nav a {
color: white;
font-weight: 500;
padding: 5px 0;
position: relative;
}
nav a::after {
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 0;
height: 2px;
background-color: var(--accent-color);
transition: width 0.3s;
}
nav a:hover::after {
width: 100%;
}
.mobile-menu {
display: none;
font-size: 1.5rem;
cursor: pointer;
background: none;
border: none;
color: white;
}
/* 主要内容区域 */
.hero {
background: linear-gradient(135deg, var(--primary-color), var(--dark-color));
color: white;
padding: 4rem 0;
text-align: center;
margin-bottom: 3rem;
}
.hero h1 {
font-size: 2.5rem;
margin-bottom: 1rem;
}
.hero p {
font-size: 1.2rem;
max-width: 700px;
margin: 0 auto;
opacity: 0.9;
}
/* 文件上传区域 */
.upload-section {
background-color: white;
border-radius: var(--border-radius);
padding: 2rem;
box-shadow: var(--shadow);
margin-bottom: 2rem;
}
.section-title {
font-size: 1.5rem;
margin-bottom: 1.5rem;
color: var(--primary-color);
display: flex;
align-items: center;
}
.section-title i {
margin-right: 10px;
color: var(--accent-color);
}
.upload-area {
border: 2px dashed #ddd;
border-radius: var(--border-radius);
padding: 2rem;
text-align: center;
margin-bottom: 1.5rem;
transition: all 0.3s;
cursor: pointer;
}
.upload-area:hover, .upload-area.drag-over {
border-color: var(--accent-color);
background-color: rgba(26, 188, 156, 0.05);
}
.upload-icon {
font-size: 3rem;
color: var(--light-text);
margin-bottom: 1rem;
}
.upload-text {
margin-bottom: 1rem;
}
.upload-btn {
background-color: var(--secondary-color);
color: white;
border: none;
padding: 0.8rem 1.5rem;
border-radius: var(--border-radius);
cursor: pointer;
font-weight: 500;
transition: background-color 0.3s;
}
.upload-btn:hover {
background-color: var(--accent-color);
}
.file-input {
display: none;
}
/* 文件列表区域 */
.files-section {
background-color: white;
border-radius: var(--border-radius);
padding: 2rem;
box-shadow: var(--shadow);
margin-bottom: 2rem;
}
.file-filters {
display: flex;
gap: 1rem;
margin-bottom: 1.5rem;
flex-wrap: wrap;
}
.filter-btn {
background-color: var(--light-color);
border: none;
padding: 0.5rem 1rem;
border-radius: 20px;
cursor: pointer;
transition: all 0.3s;
}
.filter-btn:hover {
background-color: #dde4e6;
}
.filter-btn.active {
background-color: var(--secondary-color);
color: white;
}
.file-list {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 1.5rem;
}
.file-card {
border: 1px solid #eee;
border-radius: var(--border-radius);
padding: 1.5rem;
transition: all 0.3s;
display: flex;
flex-direction: column;
position: relative;
}
.file-card:hover {
transform: translateY(-5px);
box-shadow: var(--shadow);
}
.file-header {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: 1rem;
}
.file-icon {
font-size: 2.5rem;
color: var(--secondary-color);
margin-right: 1rem;
}
.file-info {
flex: 1;
}
.file-name {
font-weight: 600;
margin-bottom: 0.5rem;
word-break: break-word;
}
.file-meta {
font-size: 0.9rem;
color: var(--light-text);
}
.file-actions {
display: flex;
gap: 0.5rem;
}
.action-btn {
background: none;
border: none;
color: var(--light-text);
cursor: pointer;
font-size: 1.2rem;
transition: color 0.3s;
padding: 5px;
border-radius: 4px;
}
.action-btn:hover {
color: var(--secondary-color);
background-color: rgba(52, 152, 219, 0.1);
}
.delete-btn {
color: var(--light-text);
}
.delete-btn:hover {
color: var(--danger-color);
background-color: rgba(231, 76, 60, 0.1);
}
.file-description {
margin-top: auto;
color: var(--light-text);
font-size: 0.9rem;
}
/* 模态框样式 */
.modal {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
z-index: 1000;
align-items: center;
justify-content: center;
}
.modal-content {
background-color: white;
padding: 2rem;
border-radius: var(--border-radius);
max-width: 500px;
width: 90%;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}
.modal-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 1.5rem;
}
.modal-title {
font-size: 1.5rem;
color: var(--primary-color);
}
.close-btn {
background: none;
border: none;
font-size: 1.5rem;
cursor: pointer;
color: var(--light-text);
}
.close-btn:hover {
color: var(--text-color);
}
.form-group {
margin-bottom: 1.5rem;
}
.form-label {
display: block;
margin-bottom: 0.5rem;
font-weight: 500;
}
.form-input, .form-textarea, .form-select {
width: 100%;
padding: 0.8rem;
border: 1px solid #ddd;
border-radius: var(--border-radius);
font-size: 1rem;
}
.form-textarea {
min-height: 100px;
resize: vertical;
}
.form-actions {
display: flex;
justify-content: flex-end;
gap: 1rem;
margin-top: 1.5rem;
}
.btn {
padding: 0.8rem 1.5rem;
border: none;
border-radius: var(--border-radius);
cursor: pointer;
font-weight: 500;
transition: all 0.3s;
}
.btn-primary {
background-color: var(--secondary-color);
color: white;
}
.btn-primary:hover {
background-color: var(--accent-color);
}
.btn-secondary {
background-color: var(--light-color);
color: var(--text-color);
}
.btn-secondary:hover {
background-color: #dde4e6;
}
.btn-danger {
background-color: var(--danger-color);
color: white;
}
.btn-danger:hover {
background-color: #c0392b;
}
/* 删除确认模态框 */
.delete-modal .modal-content {
max-width: 400px;
}
.delete-icon {
text-align: center;
font-size: 3rem;
color: var(--danger-color);
margin-bottom: 1rem;
}
.delete-text {
text-align: center;
margin-bottom: 1.5rem;
}
/* 下载进度条 */
.progress-container {
margin-top: 1rem;
display: none;
}
.progress-bar {
height: 8px;
background-color: var(--light-color);
border-radius: 4px;
overflow: hidden;
margin-bottom: 0.5rem;
}
.progress {
height: 100%;
background-color: var(--accent-color);
width: 0%;
transition: width 0.3s;
}
.progress-text {
font-size: 0.9rem;
color: var(--light-text);
text-align: center;
}
/* 消息提示 */
.toast {
position: fixed;
bottom: 20px;
right: 20px;
padding: 1rem 1.5rem;
background-color: var(--primary-color);
color: white;
border-radius: var(--border-radius);
box-shadow: var(--shadow);
transform: translateY(100px);
opacity: 0;
transition: all 0.3s;
z-index: 1001;
}
.toast.show {
transform: translateY(0);
opacity: 1;
}
.toast.success {
background-color: var(--accent-color);
}
.toast.error {
background-color: var(--danger-color);
}
/* 空状态 */
.empty-state {
grid-column: 1 / -1;
text-align: center;
padding: 3rem;
color: var(--light-text);
}
.empty-icon {
font-size: 4rem;
margin-bottom: 1rem;
opacity: 0.5;
}
/* 页脚样式 */
footer {
background-color: var(--primary-color);
color: white;
padding: 2rem 0;
margin-top: 3rem;
}
.footer-content {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
}
.footer-section {
flex: 1;
min-width: 250px;
margin-bottom: 1.5rem;
}
.footer-section h3 {
margin-bottom: 1rem;
font-size: 1.2rem;
}
.footer-section p, .footer-section a {
color: #bdc3c7;
margin-bottom: 0.5rem;
display: block;
}
.copyright {
text-align: center;
padding-top: 1.5rem;
border-top: 1px solid rgba(255, 255, 255, 0.1);
margin-top: 1.5rem;
color: #bdc3c7;
font-size: 0.9rem;
}
/* 响应式设计 */
@media (max-width: 768px) {
.header-content {
flex-direction: column;
text-align: center;
}
.logo {
margin-bottom: 1rem;
}
nav ul {
flex-direction: column;
width: 100%;
display: none;
}
nav ul.show {
display: flex;
}
nav li {
margin: 0.5rem 0;
}
.mobile-menu {
display: block;
position: absolute;
right: 15px;
top: 1.5rem;
}
.hero h1 {
font-size: 2rem;
}
.hero p {
font-size: 1rem;
}
.file-list {
grid-template-columns: 1fr;
}
.footer-content {
flex-direction: column;
}
}
@media (max-width: 480px) {
.upload-area {
padding: 1.5rem;
}
.files-section, .upload-section {
padding: 1.5rem;
}
.file-filters {
justify-content: center;
}
.modal-content {
padding: 1.5rem;
}
}
</style>
</head>
<body>
<!-- 头部区域 -->
<header>
<div class="container">
<div class="header-content">
<div class="logo">
<span class="logo-icon">📚</span>
<span>学术讨论班</span>
</div>
<nav>
<ul id="nav-menu">
<li><a href="#"><i class="fas fa-home"></i> 首页</a></li>
<li><a href="#" class="active"><i class="fas fa-file-alt"></i> 课程资料</a></li>
<li><a href="#"><i class="fas fa-comments"></i> 讨论区</a></li>
<li><a href="#"><i class="fas fa-users"></i> 成员</a></li>
<li><a href="#"><i class="fas fa-info-circle"></i> 关于</a></li>
</ul>
</nav>
<button class="mobile-menu" id="mobile-menu">☰</button>
</div>
</div>
</header>
<!-- 主要内容区域 -->
<main>
<!-- 英雄区域 -->
<section class="hero">
<div class="container">
<h1>课程文件与资料管理系统</h1>
<p>在这里上传、查看、管理和下载讨论班的所有课程资料、讲义和补充材料</p>
</div>
</section>
<div class="container">
<!-- 文件上传区域 -->
<section class="upload-section">
<h2 class="section-title">
<i class="fas fa-cloud-upload-alt"></i> 上传新文件
</h2>
<div class="upload-area" id="upload-area">
<div class="upload-icon"><i class="fas fa-folder-open"></i></div>
<p class="upload-text">拖放文件到此处或点击上传</p>
<button class="upload-btn" id="upload-trigger"><i class="fas fa-plus"></i> 选择文件</button>
<input type="file" id="file-input" class="file-input" multiple>
</div>
<p><i class="fas fa-info-circle"></i> 支持格式:PDF, DOC, PPT, ZIP, 图片等 (最大 50MB)</p>
</section>
<!-- 文件列表区域 -->
<section class="files-section">
<h2 class="section-title">
<i class="fas fa-folder"></i> 课程文件
<span style="font-size: 1rem; margin-left: 10px; color: var(--light-text);" id="file-count">(6个文件)</span>
</h2>
<div class="file-filters">
<button class="filter-btn active" data-filter="all">全部文件</button>
<button class="filter-btn" data-filter="lecture">讲义</button>
<button class="filter-btn" data-filter="reading">阅读材料</button>
<button class="filter-btn" data-filter="homework">作业</button>
<button class="filter-btn" data-filter="other">其他</button>
</div>
<div class="file-list" id="file-list">
<!-- 文件卡片将通过JavaScript动态生成 -->
</div>
</section>
</div>
</main>
<!-- 上传文件模态框 -->
<div class="modal" id="upload-modal">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title"><i class="fas fa-upload"></i> 上传文件</h3>
<button class="close-btn" id="close-upload-modal">×</button>
</div>
<form id="upload-form">
<div class="form-group">
<label class="form-label" for="file-name">文件名称</label>
<input type="text" id="file-name" class="form-input" required>
</div>
<div class="form-group">
<label class="form-label" for="file-type">文件类型</label>
<select id="file-type" class="form-select">
<option value="lecture">讲义</option>
<option value="reading">阅读材料</option>
<option value="homework">作业</option>
<option value="other">其他</option>
</select>
</div>
<div class="form-group">
<label class="form-label" for="file-description">文件描述</label>
<textarea id="file-description" class="form-textarea" placeholder="请输入文件描述..."></textarea>
</div>
<div class="form-actions">
<button type="button" class="btn btn-secondary" id="cancel-upload">取消</button>
<button type="submit" class="btn btn-primary">确认上传</button>
</div>
</form>
</div>
</div>
<!-- 文件详情模态框 -->
<div class="modal" id="file-modal">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title" id="file-modal-title"><i class="fas fa-file"></i> 文件详情</h3>
<button class="close-btn" id="close-file-modal">×</button>
</div>
<div id="file-modal-content">
<!-- 文件详情内容将通过JavaScript动态生成 -->
</div>
</div>
</div>
<!-- 删除确认模态框 -->
<div class="modal delete-modal" id="delete-modal">
<div class="modal-content">
<div class="delete-icon">
<i class="fas fa-exclamation-triangle"></i>
</div>
<div class="delete-text">
<h3>确认删除</h3>
<p>您确定要删除这个文件吗?此操作无法撤销。</p>
</div>
<div class="form-actions">
<button class="btn btn-secondary" id="cancel-delete">取消</button>
<button class="btn btn-danger" id="confirm-delete">确认删除</button>
</div>
</div>
</div>
<!-- 下载进度条 -->
<div class="progress-container" id="download-progress">
<div class="progress-bar">
<div class="progress" id="progress-bar"></div>
</div>
<div class="progress-text" id="progress-text">准备下载...</div>
</div>
<!-- 消息提示 -->
<div class="toast" id="toast"></div>
<!-- 页脚区域 -->
<footer>
<div class="container">
<div class="footer-content">
<div class="footer-section">
<h3>学术讨论班</h3>
<p>致力于提供高质量的学术资源与交流平台</p>
</div>
<div class="footer-section">
<h3>快速链接</h3>
<a href="#"><i class="fas fa-file-alt"></i> 课程资料</a>
<a href="#"><i class="fas fa-comments"></i> 讨论区</a>
<a href="#"><i class="fas fa-users"></i> 成员列表</a>
<a href="#"><i class="fas fa-envelope"></i> 联系我们</a>
</div>
<div class="footer-section">
<h3>联系信息</h3>
<p><i class="fas fa-envelope"></i> 邮箱: contact@seminar.edu</p>
<p><i class="fas fa-phone"></i> 电话: (123) 456-7890</p>
<p><i class="fas fa-map-marker-alt"></i> 地址: 某大学数学系</p>
</div>
</div>
<div class="copyright">
© 2023 学术讨论班. 保留所有权利.
</div>
</div>
</footer>
<script>
// 示例文件数据
let filesData = [
{
id: 1,
name: "线性代数基础讲义.pdf",
type: "lecture",
description: "第一章:向量与矩阵的基本概念",
size: "2.3 MB",
uploadDate: "2023-10-15",
icon: "📄",
content: "这是线性代数基础讲义的内容..."
},
{
id: 2,
name: "数据分析案例研究.pptx",
type: "lecture",
description: "基于真实数据集的统计分析案例",
size: "5.7 MB",
uploadDate: "2023-10-10",
icon: "📊",
content: "这是数据分析案例研究的内容..."
},
{
id: 3,
name: "第3周作业要求.docx",
type: "homework",
description: "截止日期:2023年10月20日",
size: "0.8 MB",
uploadDate: "2023-10-08",
icon: "📝",
content: "这是第3周作业要求的内容..."
},
{
id: 4,
name: "推荐阅读材料.zip",
type: "reading",
description: "包含5篇相关领域的重要论文",
size: "12.4 MB",
uploadDate: "2023-10-05",
icon: "📚",
content: "这是推荐阅读材料的内容..."
},
{
id: 5,
name: "课程大纲与安排.pdf",
type: "other",
description: "本学期课程安排与考核方式",
size: "1.2 MB",
uploadDate: "2023-09-28",
icon: "📋",
content: "这是课程大纲与安排的内容..."
},
{
id: 6,
name: "图表参考集.png",
type: "other",
description: "学术图表制作规范与示例",
size: "3.5 MB",
uploadDate: "2023-09-25",
icon: "🖼️",
content: "这是图表参考集的内容..."
}
];
// DOM元素
const navMenu = document.getElementById('nav-menu');
const mobileMenu = document.getElementById('mobile-menu');
const uploadArea = document.getElementById('upload-area');
const uploadTrigger = document.getElementById('upload-trigger');
const fileInput = document.getElementById('file-input');
const fileList = document.getElementById('file-list');
const fileCount = document.getElementById('file-count');
const filterBtns = document.querySelectorAll('.filter-btn');
const uploadModal = document.getElementById('upload-modal');
const closeUploadModal = document.getElementById('close-upload-modal');
const cancelUpload = document.getElementById('cancel-upload');
const uploadForm = document.getElementById('upload-form');
const fileModal = document.getElementById('file-modal');
const closeFileModal = document.getElementById('close-file-modal');
const deleteModal = document.getElementById('delete-modal');
const cancelDelete = document.getElementById('cancel-delete');
const confirmDelete = document.getElementById('confirm-delete');
const downloadProgress = document.getElementById('download-progress');
const progressBar = document.getElementById('progress-bar');
const progressText = document.getElementById('progress-text');
const toast = document.getElementById('toast');
// 当前筛选类型和待删除文件ID
let currentFilter = 'all';
let fileToDelete = null;
// 初始化
document.addEventListener('DOMContentLoaded', function() {
updateFileCount();
renderFileList(filesData);
setupEventListeners();
});
// 设置事件监听器
function setupEventListeners() {
// 移动端菜单切换
mobileMenu.addEventListener('click', function() {
navMenu.classList.toggle('show');
});
// 文件筛选
filterBtns.forEach(btn => {
btn.addEventListener('click', function() {
const filter = this.getAttribute('data-filter');
filterFiles(filter);
// 更新激活状态
filterBtns.forEach(b => b.classList.remove('active'));
this.classList.add('active');
});
});
// 上传区域点击事件
uploadTrigger.addEventListener('click', function() {
fileInput.click();
});
uploadArea.addEventListener('click', function(e) {
if (e.target === uploadArea) {
fileInput.click();
}
});
// 文件输入变化
fileInput.addEventListener('change', function() {
if (this.files.length > 0) {
showUploadModal();
}
});
// 拖放功能
uploadArea.addEventListener('dragover', function(e) {
e.preventDefault();
uploadArea.classList.add('drag-over');
});
uploadArea.addEventListener('dragleave', function() {
uploadArea.classList.remove('drag-over');
});
uploadArea.addEventListener('drop', function(e) {
e.preventDefault();
uploadArea.classList.remove('drag-over');
if (e.dataTransfer.files.length > 0) {
fileInput.files = e.dataTransfer.files;
showUploadModal();
}
});
// 模态框关闭
closeUploadModal.addEventListener('click', hideUploadModal);
cancelUpload.addEventListener('click', hideUploadModal);
closeFileModal.addEventListener('click', hideFileModal);
cancelDelete.addEventListener('click', hideDeleteModal);
// 上传表单提交
uploadForm.addEventListener('submit', function(e) {
e.preventDefault();
handleFileUpload();
});
// 删除确认
confirmDelete.addEventListener('click', handleFileDelete);
// 点击模态框外部关闭
window.addEventListener('click', function(e) {
if (e.target === uploadModal) {
hideUploadModal();
}
if (e.target === fileModal) {
hideFileModal();
}
if (e.target === deleteModal) {
hideDeleteModal();
}
});
}
// 渲染文件列表
function renderFileList(files) {
fileList.innerHTML = '';
if (files.length === 0) {
fileList.innerHTML = `
<div class="empty-state">
<div class="empty-icon"><i class="far fa-folder-open"></i></div>