index.html 505 KB
Newer Older
LiangLiu's avatar
LiangLiu committed
1
2
<!DOCTYPE html>
<html lang="zh-CN">
LiangLiu's avatar
LiangLiu committed
3

LiangLiu's avatar
LiangLiu committed
4
5
6
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
LiangLiu's avatar
LiangLiu committed
7
8
9
10
    <title>LightX2V</title>
    <link rel="icon" type="image/png" href="/icon/logoblack.png">
    <link rel="shortcut icon" type="image/png" href="/icon/logoblack.png">
    <link rel="apple-touch-icon" href="/icon/logoblack.png">
LiangLiu's avatar
LiangLiu committed
11
12
13
14
    <script src="https://cdn.tailwindcss.com"></script>
    <!-- 主要图标库 -->
    <link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <!-- 备用图标库 -->
LiangLiu's avatar
LiangLiu committed
15
16
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet"
        media="print" onload="this.media='all'">
LiangLiu's avatar
LiangLiu committed
17
18
19
20
21
22
23
24
25
26
27
    <!-- 本地备用图标(如果CDN都失败) -->
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#9a72ff', // 主紫色
                        secondary: '#1b1240', // 深紫色背景
                        accent: '#b78bff', // 亮紫色强调
                        dark: '#0b0a20', // 深色背景
                        'dark-light': '#0f0e22', // 稍亮的深色
LiangLiu's avatar
LiangLiu committed
28
29
30
                        'laser-purple': '#d2c1ff', // 激光紫色
                        'neon-purple': '#a88bff', // 霓虹紫色
                        'electric-purple': '#8e88ff', // 电光紫色
LiangLiu's avatar
LiangLiu committed
31
32
33
34
35
36
37
                    },
                    fontFamily: {
                        inter: ['Inter', 'sans-serif'],
                    },
                    boxShadow: {
                        'neon': '0 0 10px rgba(154, 114, 255, 0.5), 0 0 20px rgba(154, 114, 255, 0.3)',
                        'neon-lg': '0 0 15px rgba(154, 114, 255, 0.7), 0 0 30px rgba(154, 114, 255, 0.5)',
LiangLiu's avatar
LiangLiu committed
38
39
40
41
42
                        'laser': '0 0 20px rgba(154, 114, 255, 0.8), 0 0 40px rgba(154, 114, 255, 0.6), ' +
                                '0 0 60px rgba(154, 114, 255, 0.4), 0 0 80px rgba(154, 114, 255, 0.2)',
                        'laser-intense': '0 0 25px rgba(154, 114, 255, 0.9), 0 0 50px rgba(154, 114, 255, 0.7), ' +
                                        '0 0 75px rgba(154, 114, 255, 0.5), 0 0 100px rgba(154, 114, 255, 0.3), ' +
                                        '0 0 125px rgba(154, 114, 255, 0.1)',
LiangLiu's avatar
LiangLiu committed
43
44
45
46
47
48
49
50
51
                        'electric': '0 0 15px rgba(124, 106, 255, 0.8), 0 0 30px rgba(124, 106, 255, 0.6), 0 0 45px rgba(124, 106, 255, 0.4)'
                    }
                }
            }
        }
    </script>
    <style type="text/tailwindcss">

        [v-cloak] { display: none; }
LiangLiu's avatar
LiangLiu committed
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

        /* 减少登录页面闪烁 */
        .login-container {
            transition: opacity 0.3s ease-in-out;
        }

        .main-container {
            transition: opacity 0.3s ease-in-out;
        }

        /* 防止翻译闪烁 */
        .app-loading {
            opacity: 0;
            transition: opacity 0.2s ease-in-out;
        }

        .app-loaded {
            opacity: 1;
        }
LiangLiu's avatar
LiangLiu committed
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
        /* 确保html和body能够正确填充 */
        html {
            height: 100%;
        }

        /* 确保body和app容器能够正确填充 */
        body {
            margin: 0;
            padding: 0;
            width: 125vw;
            height: 125vh;
            overflow-x: hidden;
            overflow-y: auto;
            /* 整体缩放80% */
            transform: scale(0.8);
            transform-origin: top left;
        }

        @layer utilities {
            .content-auto {
                content-visibility: auto;
            }
            .text-gradient {
                background-clip: text;
                -webkit-background-clip: text;
                -webkit-text-fill-color: transparent;
            }
            /* 新增渐变图标颜色类 */
            .text-gradient-icon {
                background: linear-gradient(135deg, #d2c1ff, #a88bff, #8e88ff);
                -webkit-background-clip: text;
                background-clip: text;
                -webkit-text-fill-color: transparent;
            }
            .scrollbar-thin {
                scrollbar-width: thin;
            }
            .scrollbar-thin::-webkit-scrollbar {
LiangLiu's avatar
LiangLiu committed
109
110
                width: 6px;
                height: 6px;
LiangLiu's avatar
LiangLiu committed
111
112
113
            }
            .scrollbar-thin::-webkit-scrollbar-thumb {
                background-color: rgba(210, 193, 255, 0.6);
LiangLiu's avatar
LiangLiu committed
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
                border-radius: 3px;
            }
            .scrollbar-thin::-webkit-scrollbar-track {
                background-color: rgba(31, 41, 55, 0.3);
                border-radius: 3px;
            }
            .scrollbar-thin::-webkit-scrollbar-thumb:hover {
                background-color: rgba(210, 193, 255, 0.8);
            }

            /* 自定义滚动条颜色 */
            .scrollbar-thumb-laser-purple\/30::-webkit-scrollbar-thumb {
                background-color: rgba(168, 85, 247, 0.3);
            }
            .scrollbar-track-gray-800\/30::-webkit-scrollbar-track {
                background-color: rgba(31, 41, 55, 0.3);
LiangLiu's avatar
LiangLiu committed
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
            }

            /* 历史任务区域滚动条样式 - 与主内容区域保持一致 */
            .history-tasks-scroll::-webkit-scrollbar {
                width: 8px !important;
            }

            .history-tasks-scroll::-webkit-scrollbar-track {
                background: rgba(27, 18, 64, 0.3) !important;
                border-radius: 4px;
            }

            .history-tasks-scroll::-webkit-scrollbar-thumb {
                background: linear-gradient(135deg, rgba(210, 193, 255, 0.8), rgba(168, 139, 255, 0.8)) !important;
                border-radius: 4px;
                border: 1px solid rgba(210, 193, 255, 0.3);
            }

            .history-tasks-scroll::-webkit-scrollbar-thumb:hover {
                background: linear-gradient(135deg, rgba(210, 193, 255, 1), rgba(168, 139, 255, 1)) !important;
            }

LiangLiu's avatar
LiangLiu committed
152
153
            /* 滚动条样式 */
            .main-scrollbar::-webkit-scrollbar {
LiangLiu's avatar
LiangLiu committed
154
155
                width: 8px;
            }
LiangLiu's avatar
LiangLiu committed
156
            .main-scrollbar::-webkit-scrollbar-track {
LiangLiu's avatar
LiangLiu committed
157
158
159
                border-radius: 4px;
            }

LiangLiu's avatar
LiangLiu committed
160
            .main-scrollbar::-webkit-scrollbar-thumb {
LiangLiu's avatar
LiangLiu committed
161
162
163
164
165
                background: linear-gradient(135deg, rgba(210, 193, 255, 0.8), rgba(168, 139, 255, 0.8));
                border-radius: 4px;
                border: 1px solid rgba(210, 193, 255, 0.3);
            }

LiangLiu's avatar
LiangLiu committed
166
            .main-scrollbar::-webkit-scrollbar-thumb:hover {
LiangLiu's avatar
LiangLiu committed
167
168
169
170
                background: linear-gradient(135deg, rgba(210, 193, 255, 1), rgba(168, 139, 255, 1));
            }

            /* 确保内容可以正常滚动 */
LiangLiu's avatar
LiangLiu committed
171
            .main-scrollbar {
LiangLiu's avatar
LiangLiu committed
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
                scroll-behavior: smooth;
                -webkit-overflow-scrolling: touch;
            }
            .animate-pulse-slow {
                animation: pulse 3s cubic-bezier(0.4, 0, 0.6, 0.5) infinite;
            }
            .animate-electric-pulse {
                animation: electricPulse 1.5s ease-in-out infinite;
            }
            @keyframes electricPulse {
                0%, 100% {
                    box-shadow: 0 0 15px rgba(142, 136, 255, 0.8), 0 0 30px rgba(142, 136, 255, 0.6);
                    transform: scale(1);
                }
                50% {
                    box-shadow: 0 0 25px rgba(142, 136, 255, 1), 0 0 50px rgba(142, 136, 255, 0.8), 0 0 75px rgba(142, 136, 255, 0.4);
                    transform: scale(1.02);
                }
            }
            .bg-laser-gradient {
                background: linear-gradient(135deg, #d2c1ff 0%, #a88bff 25%, #8e88ff 50%, #d2c1ff 75%, #a88bff 100%);
                background-size: 200% 200%;
                animation: gradientShift 3s ease-in-out infinite;
            }
            @keyframes gradientShift {
                0%, 100% { background-position: 0% 50%; }
                50% { background-position: 100% 50%; }
            }
            .text-laser-glow {
                text-shadow: 0 0 10px rgba(154, 114, 255, 0.8), 0 0 20px rgba(154, 114, 255, 0.6), 0 0 30px rgba(154, 114, 255, 0.4);
            }
            .border-laser {
                border-color: #d2c1ff;
                box-shadow: 0 0 15px rgba(154, 114, 255, 0.6), inset 0 0 15px rgba(154, 114, 255, 0.1);
            }
            .btn-primary{
                padding: 15px 25px;
                border-radius: 14px;
                font-weight: 500;
                font-size: 14px;
                letter-spacing: 0.2px;
                font-family: 'Inter', sans-serif;
                background: linear-gradient(135deg, #d2c1ff, #a88bff, #8e88ff);
                border: 0;
                text-decoration: none;
                box-shadow: 0 10px 30px rgba(140, 110, 255, 0.4);
                transition: transform 0.15s ease, box-shadow 0.15s ease;
            }
            .btn-primary:hover{
                transform: translateY(-1px);
                box-shadow: 0 14px 40px rgba(140, 110, 255, 0.55);
            }
            /* 修复布局问题 */
            .task-type-btn {
                padding: 0.75rem 1rem;
                font-size: 0.875rem;
                font-weight: 500;
                transition-property: color, background-color;
                transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
                transition-duration: 150ms;
            }

            .task-type-btn:hover {
                background-color: rgba(154, 114, 255, 0.1);
            }

            .model-selection {
                display: flex;
                flex-wrap: wrap;
                gap: 0.5rem;
            }

            .upload-section {
                display: grid;
                grid-template-columns: repeat(1, minmax(0, 1fr));
                gap: 1.5rem;
                margin-bottom: 1.5rem;
            }

            @media (min-width: 768px) {
                .upload-section {
                    grid-template-columns: repeat(2, minmax(0, 1fr));
                }
            }

            .upload-area {
                position: relative;
                border: 2px dashed rgba(154, 114, 255, 0.4);
                border-radius: 0.75rem;
                padding: 1.5rem;
                text-align: center;
LiangLiu's avatar
LiangLiu committed
263
264
                justify-content: center;
                align-items: center;
LiangLiu's avatar
LiangLiu committed
265
266
267
268
                transition-property: all;
                transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
                transition-duration: 150ms;
                cursor: pointer;
LiangLiu's avatar
LiangLiu committed
269
                height: 30vh;
LiangLiu's avatar
LiangLiu committed
270
                background-color: rgba(27, 18, 64, 0.1);
LiangLiu's avatar
LiangLiu committed
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
            }

            /* 光球按钮样式 */
            .floating-orb-btn {
                position: relative;
                width: 100px;
                height: 100px;
                border-radius: 50%;
                background: linear-gradient(135deg, #9a72ff, #a855f7, #ec4899);
                border: none;
                cursor: pointer;
                transition: all 0.3s ease;
                overflow: hidden;
                box-shadow: 0 4px 20px rgba(154, 114, 255, 0.4);
            }

            .floating-orb-btn:hover {
                transform: scale(1.1);
                box-shadow: 0 0 40px rgba(154, 114, 255, 0.8), 0 0 80px rgba(154, 114, 255, 0.6);
            }

            .orb-glow {
                position: absolute;
                inset: -15px;
                border-radius: 50%;
                background: radial-gradient(circle, rgba(154, 114, 255, 0.3) 0%, transparent 70%);
                animation: pulse 2s infinite;
            }

            .orb-content {
                position: relative;
                z-index: 2;
                display: flex;
                flex-direction: column;
                align-items: center;
                justify-content: center;
                height: 100%;
                color: white;
            }

            @keyframes pulse {
                0%, 100% { opacity: 0.5; transform: scale(1); }
                50% { opacity: 0.8; transform: scale(1.05); }
            }

            /* 创作区域样式 */
            .creation-area {
                opacity: 0;
                transform: scale(0.8) translateY(20px);
                pointer-events: none;
                transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
                transform-origin: center center;
            }

            .creation-area.show {
                opacity: 1;
                transform: scale(1) translateY(0);
                pointer-events: auto;
            }

            .creation-area.hide {
                opacity: 0;
                transform: scale(0.8) translateY(20px);
                pointer-events: none;
            }

            /* 提示文字淡入动画 */
            .animate-fade-in {
                animation: fadeIn 0.5s ease-in-out;
            }

            @keyframes fadeIn {
                from {
                    opacity: 0;
                    transform: translateY(10px);
                }
                to {
                    opacity: 1;
                    transform: translateY(0);
                }
            }

            /* 提示文字滚动动画 */
            .hint-fade-enter-active, .hint-fade-leave-active {
                transition: all 0.5s ease-in-out;
            }
            .hint-fade-enter-from {
                opacity: 0;
                transform: translateY(20px);
            }
            .hint-fade-leave-to {
                opacity: 0;
                transform: translateY(-20px);
LiangLiu's avatar
LiangLiu committed
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
            }

            .upload-area:hover {
                border-color: rgba(154, 114, 255, 0.7);
                box-shadow: 0 0 20px rgba(154, 114, 255, 0.8), 0 0 40px rgba(154, 114, 255, 0.6), 0 0 60px rgba(154, 114, 255, 0.4), 0 0 80px rgba(154, 114, 255, 0.2);
            }

            .upload-icon {
                margin: 0 auto;
                width: 4rem;
                height: 4rem;
                background-color: rgba(154, 114, 255, 0.2);
                border-radius: 9999px;
                display: flex;
                align-items: center;
                justify-content: center;
                margin-bottom: 1rem;
                transition-property: all;
                transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
                transition-duration: 150ms;
            }

LiangLiu's avatar
LiangLiu committed
386
            .upload-icon {
LiangLiu's avatar
LiangLiu committed
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
                background-color: rgba(154, 114, 255, 0.3);
            }

            /* 图片预览占据整个上传区域 */
            .image-preview {
                position: absolute;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
                overflow: hidden;
                z-index: 10;
                display: flex;
                align-items: center;
                justify-content: center;
LiangLiu's avatar
LiangLiu committed
402
                background-color: rgba(154, 114, 255, 0.1);
LiangLiu's avatar
LiangLiu committed
403
404
405
406
407
408
409
410
411
412
413
                cursor: pointer;
            }

            .image-preview img {
                height: 100%;
                width: auto;
                max-width: 100%;
                display: block;
                margin: 0 auto;
                object-fit: contain;
                transition: all 0.3s ease;
LiangLiu's avatar
LiangLiu committed
414
415
                background-color: rgba(154, 114, 255, 0.1);
                cursor: pointer;
LiangLiu's avatar
LiangLiu committed
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
            }

            /* 音频预览占据整个上传区域 */
            .audio-preview {
                position: absolute;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
                overflow: hidden;
                z-index: 10;
                display: flex;
                align-items: center;
                justify-content: center;
                background-color: rgba(154, 114, 255, 0.1);
                cursor: pointer;
            }

            .audio-preview audio {
                width: 90%;
                height: 60px;
                max-height: 80%;
                border-radius: 0.5rem;
                background-color: rgba(27, 18, 64, 0.3);
                display: block;
            }

            /* 确保音频控件在容器中正确显示 */
            .audio-preview audio::-webkit-media-controls {
                background-color: rgba(27, 18, 64, 0.5);
                border-radius: 0.5rem;
            }

            /* 上传内容样式 */
            .upload-content {
                width: 100%;
                height: 100%;
                display: flex;
                flex-direction: column;
                align-items: center;
                justify-content: center;
            }

            .btn-close {
                position: absolute;
                top: 0.5rem;
                right: 0.5rem;
                background-color: #ef4444;
                color: white;
                border-radius: 9999px;
                width: 1.5rem;
                height: 1.5rem;
                display: flex;
                align-items: center;
                justify-content: center;
                font-size: 0.75rem;
                cursor: pointer;
                z-index: 20;
                box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
            }

            /* 确保flexbox布局正确 */
            #app {
                display: flex;
                width: 100%;
                height: 100%;
            }

            .bg-linear-dark {
                background-color: linear-gradient(135deg, #0b0a20 0%, #1b1240 50%, #0f0e22 100%);
            }

            aside {
                flex-shrink: 0;
                width: 280px; /* 默认展开宽度 */
                min-width: 3rem; /* 最小宽度 */
                max-width: 500px; /* 最大宽度 */
LiangLiu's avatar
LiangLiu committed
493
                background-color: transparent;
LiangLiu's avatar
LiangLiu committed
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
                border-right: 1px solid rgba(154, 114, 255, 0.4);
                display: flex;
                flex-direction: column;
                transition-property: all;
                transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
                transition-duration: 300ms;
                z-index: 10;
                position: relative;
            }

            /* 拖拽调整器 */
            .resize-handle {
                position: absolute;
                top: 0;
                right: 0;
LiangLiu's avatar
LiangLiu committed
509
                width: 6px;
LiangLiu's avatar
LiangLiu committed
510
511
512
                height: 100%;
                background: transparent;
                cursor: col-resize;
LiangLiu's avatar
LiangLiu committed
513
                z-index: 50;
LiangLiu's avatar
LiangLiu committed
514
515
516
517
518
519
520
521
522
523
524
                transition: background-color 0.2s ease;
            }

            .resize-handle:hover {
                background: rgba(154, 114, 255, 0.5);
            }

            .resize-handle:active {
                background: rgba(154, 114, 255, 0.8);
            }

LiangLiu's avatar
LiangLiu committed
525
526
527
528
529
530
531
532
533
534
535
536
537
            /* 确保拖拽手柄可见 */
            .resize-handle::before {
                content: '';
                position: absolute;
                top: 50%;
                right: 1px;
                width: 2px;
                height: 20px;
                background: rgba(154, 114, 255, 0.3);
                transform: translateY(-50%);
                border-radius: 1px;
            }

LiangLiu's avatar
LiangLiu committed
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
            /* 拖拽时的视觉反馈 */
            .resizing {
                user-select: none;
                pointer-events: none;
            }

            .resizing * {
                pointer-events: none;
            }

            main {
                flex: 1;
                display: flex;
                flex-direction: column;
                min-width: 0;
                width: calc(100% - 280px); /* 主内容区域占据剩余宽度,适应展开的侧边栏 */
                height: 100%;
            }

            /* 内容区域全屏显示 */
            .content-area {
                flex: 1;
                overflow-y: auto;
LiangLiu's avatar
LiangLiu committed
561
562
                /* background-color: #0b0a20; */
                padding: 1rem;
LiangLiu's avatar
LiangLiu committed
563
564
565
566
567
568
569
                width: 100%;
                min-height: 0; /* 确保flex子元素可以收缩 */
            }

            /* 任务创建面板全屏 */
            #task-creator {
                max-width: none;
LiangLiu's avatar
LiangLiu committed
570
571
572
573
574
575
                width: 90%;
            }

            #inspiration-gallery {
                max-width: none;
                width: 90%;
LiangLiu's avatar
LiangLiu committed
576
577
578
                padding: 0 1rem;
            }

LiangLiu's avatar
LiangLiu committed
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
            /* 移动端全屏显示 */
            @media (max-width: 768px) {
                #task-creator {
                    width: 100%;
                    padding: 0 0.5rem;
                }

                #inspiration-gallery {
                    width: 100%;
                    padding: 0 0.5rem;
                }

                /* 任务详情面板移动端全屏 */
                .task-detail-panel {
                    width: 100%;
                    padding: 0 0.5rem;
                }

                /* 任务运行面板移动端全屏 */
                .task-running-panel {
                    width: 100%;
                    padding: 0 0.5rem;
                }

                /* 任务失败面板移动端全屏 */
                .task-failed-panel {
                    width: 100%;
                    padding: 0 0.5rem;
                }

                /* 任务取消面板移动端全屏 */
                .task-cancelled-panel {
                    width: 100%;
                    padding: 0 0.5rem;
                }

                /* 移动端内容区域调整 */
                .content-area {
                    padding: 0.5rem !important;
                }

                /* 移动端创作区域调整 */
                .creation-area-container {
                    padding: 0.5rem;
                }
            }

LiangLiu's avatar
LiangLiu committed
626
627
628
            /* 任务详情面板全屏 */
            .task-detail-panel {
                max-width: none;
LiangLiu's avatar
LiangLiu committed
629
                width: 90%;
LiangLiu's avatar
LiangLiu committed
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
                padding: 0 0rem;
            }

            /* 上传区域全屏布局 */
            .upload-section {
                display: grid;
                grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
                gap: 2rem;
                margin-bottom: 2rem;
                width: 100%;
            }

            /* 任务类型选择全屏 */
            .task-type-selection {
                width: 100%;
                margin-bottom: 2rem;
            }

            .task-type-buttons {
                display: flex;
                width: 100%;
                border-bottom: 1px solid rgba(154, 114, 255, 0.3);
            }

            .task-type-btn {
                flex: 1;
                padding: 1rem 1.5rem;
                font-size: 1rem;
                font-weight: 500;
                transition-property: color, background-color;
                transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
                transition-duration: 150ms;
                text-align: center;
            }

            /* 模型选择全屏 */
            .model-selection {
                display: flex;
                flex-wrap: wrap;
                gap: 1rem;
                width: 100%;
                justify-content: flex-start;
            }

            /* 提示词输入全屏 */
            .prompt-input-section {
                width: 100%;
                margin-bottom: 2rem;
            }

            .prompt-textarea {
                width: 100%;
                min-height: 150px;
                resize: vertical;
            }

LiangLiu's avatar
LiangLiu committed
686
687
688
            /* 历史任务区域收起样式 */
            .sidebar-collapsed .history-tasks-section {
                display: none !important;
LiangLiu's avatar
LiangLiu committed
689
690
691
            }

            /* 侧边栏展开样式 */
LiangLiu's avatar
LiangLiu committed
692
            aside {
LiangLiu's avatar
LiangLiu committed
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
                width: 280px !important;
            }

            .sidebar-collapsed .sidebar-content {
                display: none !important;
            }

            .sidebar-collapsed .resize-handle {
                display: none !important;
            }

            .sidebar-collapsed .user-info-section {
                display: none !important;
            }

            .sidebar-collapsed .sidebar-header {
                justify-content: center;
                padding: 1rem 0.5rem;
            }

            .sidebar-collapsed .sidebar-header h1 {
                display: none;
            }

            /* 展开状态下显示所有内容 */
            aside:not(.sidebar-collapsed) .sidebar-content {
                display: flex !important;
            }

            aside:not(.sidebar-collapsed) .resize-handle {
                display: block !important;
            }

            aside:not(.sidebar-collapsed) .sidebar-header {
                justify-content: space-between;
                padding: 1rem;
            }

            aside:not(.sidebar-collapsed) .sidebar-header h1 {
                display: flex;
            }

            aside:not(.sidebar-collapsed) .sidebar-header .toggle-btn {
                display: flex !important;
                align-items: center;
                justify-content: center;
            }

            aside:not(.sidebar-collapsed) .user-info-section {
                display: block !important;
            }

            .sidebar-collapsed .sidebar-header .toggle-btn {
                display: flex !important;
                align-items: center;
                justify-content: center;
                width: 2rem;
                height: 2rem;
                border-radius: 0.375rem;
                background-color: rgba(154, 114, 255, 0.1);
                border: 1px solid rgba(154, 114, 255, 0.3);
                margin: 0 auto;
            }

LiangLiu's avatar
LiangLiu committed
757
            /* 当历史任务区域折叠时,主内容区域调整 */
LiangLiu's avatar
LiangLiu committed
758
            .sidebar-collapsed + main {
LiangLiu's avatar
LiangLiu committed
759
                width: calc(100% - 256px); /* 只减去固定区域的宽度 */
LiangLiu's avatar
LiangLiu committed
760
761
            }

LiangLiu's avatar
LiangLiu committed
762
            /* 当历史任务区域展开时,主内容区域调整 */
LiangLiu's avatar
LiangLiu committed
763
            aside:not(.sidebar-collapsed) + main {
LiangLiu's avatar
LiangLiu committed
764
                width: calc(100% - 256px); /* 减去侧边栏的宽度 */
LiangLiu's avatar
LiangLiu committed
765
766
767
768
769
770
771
772
773
            }

            /* 响应式设计 */
            @media (max-width: 1200px) {
                aside:not(.sidebar-collapsed) {
                    width: 250px !important;
                }

                .sidebar-collapsed + main {
LiangLiu's avatar
LiangLiu committed
774
                    width: calc(100% - 250px);
LiangLiu's avatar
LiangLiu committed
775
776
777
778
779
780
781
782
783
784
785
786
787
                }

                aside:not(.sidebar-collapsed) + main {
                    width: calc(100% - 250px);
                }
            }

            @media (max-width: 768px) {
                aside:not(.sidebar-collapsed) {
                    width: 200px !important;
                }

                .sidebar-collapsed + main {
LiangLiu's avatar
LiangLiu committed
788
                    width: calc(100% - 200px);
LiangLiu's avatar
LiangLiu committed
789
790
791
792
793
794
795
796
797
798
799
                }

                aside:not(.sidebar-collapsed) + main {
                    width: calc(100% - 200px);
                }

                .upload-section {
                    grid-template-columns: 1fr;
                }
            }

LiangLiu's avatar
LiangLiu committed
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
            /* 移动端响应式设计 */
            @media (max-width: 640px) {
                /* 通用移动端样式 */
                .mobile-bottom-nav {
                    width: 100% !important;
                    height: auto !important;
                    padding: 0 !important;
                    backdrop-filter: blur(20px) !important;
                    border-top: 1px solid rgba(154, 114, 255, 0.2) !important;
                    z-index: 50 !important;
                }

                .mobile-nav-buttons {
                    display: flex !important;
                    flex-direction: row !important;
                    justify-content: space-around !important;
                    align-items: center !important;
                    gap: 0 !important;
                    padding: 1rem !important;
                    width: 100% !important;
                }

                .mobile-nav-btn {
                    width: 3rem !important;
                    height: 3rem !important;
                    flex-shrink: 0 !important;
                }

                .sms-login-form .input-group {
                    flex-direction: row !important;
                    gap: 12px !important;
                    margin-bottom: 1rem !important;
                    align-items: stretch !important;
                }

                .sms-login-form .form-control {
                    flex: 1 !important;
                    height: 48px !important;
                    font-size: 14px !important;
                    padding: 14px 18px !important;
                }

                .sms-login-form .btn-sms-code {
                    width: auto !important;
                    min-width: 110px !important;
                    height: 48px !important;
                    flex-shrink: 0 !important;
                }

                .sms-login-form .btn-placeholder {
                    min-width: 110px !important;
                    height: 48px !important;
                    flex-shrink: 0 !important;
                }
                /* 主布局调整为垂直布局 */
                .flex.flex-row {
                    flex-direction: column;
                }

                /* 左侧功能区在移动端移动到下方 */
LiangLiu's avatar
LiangLiu committed
860

LiangLiu's avatar
LiangLiu committed
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

                /* 功能导航在移动端水平排列 */
                .p-2.flex.flex-col.justify-center.h-full {
                    margin-top: 0 !important;
                    padding: 1rem !important;
                }

                .p-2.flex.flex-col.justify-center.h-full nav {
                    display: flex !important;
                    flex-direction: row !important;
                    justify-content: space-around !important;
                    align-items: center !important;
                    gap: 1rem !important;
                }

                .p-2.flex.flex-col.justify-center.h-full nav .space-y-3 {
                    display: flex !important;
                    flex-direction: row !important;
                    gap: 0 !important;
                    margin: 0 !important;
                    justify-content: space-around !important;
                    align-items: center !important;
                    width: 100% !important;
                }

                /* 重置 space-y-3 的 margin-top */
                .p-2.flex.flex-col.justify-center.h-full nav .space-y-3 > * {
                    margin-top: 0 !important;
                }

                /* 确保按钮容器在移动端完全对齐 */
                .mobile-nav-buttons .relative.group {
                    display: flex !important;
                    justify-content: center !important;
                    align-items: center !important;
                    flex: 1 !important;
                    margin: 0 !important;
                }

                /* 按钮在移动端调整大小 */
                .p-2.flex.flex-col.justify-center.h-full nav button {
                    width: 3rem !important;
                    height: 3rem !important;
                    flex-shrink: 0 !important;
                }


                /* 历史任务区域调整 */
                .flex-1.overflow-y-auto.p-10.content-area.main-scrollbar {
                    padding: 1rem !important;
                }

                /* 搜索和筛选区域在移动端垂直排列 */
                .flex.flex-col.gap-4.mb-6 {
                    flex-direction: column !important;
                    gap: 1rem !important;
                }

                /* 筛选按钮在移动端换行 */
                .flex.gap-2 {
                    flex-wrap: wrap !important;
                    gap: 0.5rem !important;
                }

                .flex.gap-2 button {
                    font-size: 0.75rem !important;
                    padding: 0.5rem 0.75rem !important;
                }

                /* 创建视频页面移动端适配 */
                .max-w-4xl.mx-auto {
                    max-width: 100% !important;
                    padding: 0 1rem !important;
                }

                /* 上传区域在移动端调整 */
                .upload-section {
                    grid-template-columns: 1fr !important;
                    gap: 1rem !important;
                }

                .upload-area {
                    padding: 1rem !important;
                }

                /* 任务类型选择在移动端调整 */
                .grid.grid-cols-1.gap-4 {
                    grid-template-columns: 1fr !important;
                    gap: 0.75rem !important;
                }

                /* 模型选择在移动端调整 */
                .grid.grid-cols-2.gap-3 {
                    grid-template-columns: repeat(2, 1fr) !important;
                    gap: 0.5rem !important;
                }

                /* 参数设置区域在移动端调整 */
                .bg-dark-light.rounded-xl.p-6 {
                    padding: 1rem !important;
                }

                /* 提交按钮在移动端调整 */
                .btn-primary.flex.items-center.justify-center.px-8.py-3 {
                    width: 100% !important;
                    padding: 1rem !important;
                }

                /* 灵感广场移动端适配 */
                .grid.grid-cols-1.gap-6 {
                    grid-template-columns: 1fr !important;
                    gap: 1rem !important;
                }

                /* 模态框在移动端调整 */
                .fixed.inset-0.z-50 {
                    padding: 1rem !important;
                }

                .bg-dark.rounded-2xl.shadow-2xl.max-w-4xl.w-full {
                    max-height: 90vh !important;
                    margin: 0 !important;
                }
LiangLiu's avatar
LiangLiu committed
984
985
            }

LiangLiu's avatar
LiangLiu committed
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
            /* 超小屏幕适配 (iPhone SE等) */
            @media (max-width: 375px) {
                /* 底部导航按钮更紧凑 */
                .p-2.flex.flex-col.justify-center.h-full nav button {
                    width: 2.5rem !important;
                    height: 2.5rem !important;
                }

                .p-2.flex.flex-col.justify-center.h-full nav .space-y-3 {
                    gap: 0 !important;
                    justify-content: space-around !important;
                    align-items: center !important;
                }

                /* 重置超小屏幕的 space-y-3 margin-top */
                .p-2.flex.flex-col.justify-center.h-full nav .space-y-3 > * {
                    margin-top: 0 !important;
                }

                /* 主内容区域调整 */
                .flex-1.flex.flex-col.min-h-0 {
                    margin-bottom: 4rem !important;
                }

                /* 搜索框和按钮调整 */
                .flex.flex-col.gap-4.mb-6 input {
                    font-size: 0.875rem !important;
                    padding: 0.75rem !important;
                }

                .flex.gap-2 button {
                    font-size: 0.7rem !important;
                    padding: 0.4rem 0.6rem !important;
                }

                /* 任务卡片在超小屏幕调整 */
                .bg-dark-light.rounded-xl.p-4 {
                    padding: 0.75rem !important;
                }

                /* 上传区域在超小屏幕调整 */
                .upload-area {
                    padding: 0.75rem !important;
                }

                .upload-area p {
                    font-size: 0.875rem !important;
                }

                /* 模态框在超小屏幕调整 */
                .fixed.inset-0.z-50 {
                    padding: 0.5rem !important;
                }

                .bg-dark.rounded-2xl.shadow-2xl.max-w-4xl.w-full {
                    max-height: 95vh !important;
                }

                /* 超小屏幕表单优化 */
                .sms-login-form .form-control {
                    font-size: 13px !important;
                    padding: 12px 16px !important;
                }

                .sms-login-form .btn-sms-code {
                    min-width: 100px !important;
                    font-size: 12px !important;
                    padding: 6px 12px !important;
                }

                .sms-login-form .btn-placeholder {
                    min-width: 100px !important;
                }
            }

            /* 分页组件样式 */
            .pagination-container {
                border-bottom: 1px solid rgba(154, 114, 255, 0.15);
                padding-bottom: 0.5rem;
            }

            .pagination-btn-compact {
                @apply px-1.5 py-0.5 rounded text-xs transition-all duration-200;
                background: rgba(27, 18, 64, 0.2);
                border: 1px solid rgba(154, 114, 255, 0.2);
                color: rgba(255, 255, 255, 0.6);
                min-width: 20px;
                height: 20px;
                display: flex;
                align-items: center;
                justify-content: center;
                font-size: 10px;
            }

            .pagination-btn-compact:hover:not(.disabled) {
                background: rgba(154, 114, 255, 0.15);
                border-color: rgba(154, 114, 255, 0.4);
                color: rgba(255, 255, 255, 0.8);
                transform: translateY(-0.5px);
            }

            .pagination-btn-compact.active {
                background: linear-gradient(135deg, rgba(154, 114, 255, 0.6), rgba(168, 139, 255, 0.6));
                border-color: rgba(154, 114, 255, 0.6);
                color: white;
                box-shadow: 0 0 6px rgba(154, 114, 255, 0.4);
            }

            .pagination-btn-compact.disabled {
                opacity: 0.3;
                cursor: not-allowed;
                background: rgba(27, 18, 64, 0.05);
                border-color: rgba(154, 114, 255, 0.05);
                color: rgba(255, 255, 255, 0.2);
            }

            .pagination-btn-compact.disabled:hover {
                transform: none;
                background: rgba(27, 18, 64, 0.05);
                border-color: rgba(154, 114, 255, 0.05);
                color: rgba(255, 255, 255, 0.2);
            }

            /* 页码输入框样式 */
            .page-input {
                @apply w-8 h-5 text-center text-xs rounded;
                background: linear-gradient(135deg, rgba(154, 114, 255, 0.3), rgba(168, 139, 255, 0.3));
                border: 1px solid rgba(154, 114, 255, 0.4);
                color: white;
                outline: none;
                transition: all 0.2s ease;
                font-weight: 500;
            }

            .page-input:focus {
                border-color: rgba(154, 114, 255, 0.8);
                background: linear-gradient(135deg, rgba(154, 114, 255, 0.5), rgba(168, 139, 255, 0.5));
                box-shadow: 0 0 6px rgba(154, 114, 255, 0.4);
            }

            .page-input::-webkit-outer-spin-button,
            .page-input::-webkit-inner-spin-button {
                -webkit-appearance: none;
                margin: 0;
            }

            .page-input[type=number] {
                -moz-appearance: textfield;
LiangLiu's avatar
LiangLiu committed
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
            }

            /* 修复状态指示器 */
            .status-indicator {
                width: 0.75rem;
                height: 0.75rem;
                border-radius: 9999px;
                box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
            }

            /* 修复按钮样式 */
            .btn-primary {
                padding: 12px 22px;
                border-radius: 14px;
                font-weight: 700;
                letter-spacing: 0.2px;
                color: #0c0920;
                background: linear-gradient(135deg, #d2c1ff, #a88bff, #8e88ff);
                border: 0;
                text-decoration: none;
                box-shadow: 0 10px 30px rgba(140, 110, 255, 0.4);
                transition: transform 0.15s ease, box-shadow 0.15s ease;
                cursor: pointer;
                display: inline-block;
            }

            .btn-primary:hover {
                transform: translateY(-1px);
                box-shadow: 0 14px 40px rgba(140, 110, 255, 0.55);
            }

            /* 修复模型按钮样式 */
            .model-btn {
                padding: 0.5rem 1rem;
                border-radius: 0.5rem;
                font-size: 0.875rem;
                transition-property: all;
                transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
                transition-duration: 150ms;
                cursor: pointer;
                border: 1px solid;
            }

            .model-btn.active {
                background-color: rgba(154, 114, 255, 0.2);
                border-color: rgba(154, 114, 255, 0.4);
                box-shadow: 0 0 20px rgba(154, 114, 255, 0.8), 0 0 40px rgba(154, 114, 255, 0.6), 0 0 60px rgba(154, 114, 255, 0.4), 0 0 80px rgba(154, 114, 255, 0.2);
                animation: electricPulse 1.5s ease-in-out infinite;
            }

            /* 确保内容区域正确滚动 */
            .content-scroll {
                flex: 1;
                overflow-y: auto;
            }

            /* 任务进行中面板样式 */
            .task-running-panel .animate-pulse-slow {
                animation: pulse 3s cubic-bezier(0.4, 0, 0.6, 0.5) infinite;
            }

LiangLiu's avatar
LiangLiu committed
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
            /* 进度条样式 */
            .progress-container {
                background: rgba(27, 18, 64, 0.3);
                border-radius: 8px;
                padding: 1rem;
                margin: 1rem 0;
            }

            .progress-bar {
                width: 100%;
                height: 8px;
                background: rgba(154, 114, 255, 0.2);
                border-radius: 4px;
                overflow: hidden;
                position: relative;
            }

            .progress-fill {
                height: 100%;
                background: linear-gradient(90deg, #9a72ff, #a88bff);
                border-radius: 4px;
                transition: width 0.3s ease;
                position: relative;
            }

            .progress-fill::after {
                content: '';
                position: absolute;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
                animation: shimmer 2s infinite;
            }

            @keyframes shimmer {
                0% { transform: translateX(-100%); }
                100% { transform: translateX(100%); }
            }

            .subtask-item {
                background: rgba(27, 18, 64, 0.2);
                border: 1px solid rgba(154, 114, 255, 0.2);
                border-radius: 8px;
                padding: 0.75rem;
                margin: 0.5rem 0;
            }

            .subtask-header {
                display: flex;
                justify-content: between;
                align-items: center;
                margin-bottom: 0.5rem;
            }

            .subtask-status {
                padding: 0.25rem 0.5rem;
                border-radius: 4px;
                font-size: 0.75rem;
                font-weight: 500;
            }

            .subtask-status.pending {
                background: rgba(251, 191, 36, 0.2);
                color: #fbbf24;
            }

            .subtask-status.running {
                background: rgba(59, 130, 246, 0.2);
                color: #3b82f6;
            }

            .subtask-info {
                font-size: 0.75rem;
                color: rgba(255, 255, 255, 0.6);
                margin-top: 0.25rem;
            }

LiangLiu's avatar
LiangLiu committed
1274
1275
1276
1277
1278
            /* 任务失败面板样式 */
            .task-failed-panel .bg-red-500\/10 {
                background-color: rgba(239, 68, 68, 0.1);
            }

LiangLiu's avatar
LiangLiu committed
1279
1280
1281
1282
1283
1284
1285
1286
            .error-details {
                background: rgba(239, 68, 68, 0.1);
                border: 1px solid rgba(239, 68, 68, 0.3);
                border-radius: 8px;
                padding: 1rem;
                margin: 1rem 0;
                text-align: left;
            }
LiangLiu's avatar
LiangLiu committed
1287

LiangLiu's avatar
LiangLiu committed
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
            .error-details pre {
                background: rgba(0, 0, 0, 0.3);
                border-radius: 4px;
                padding: 0.75rem;
                margin: 0.5rem 0 0 0;
                font-size: 0.75rem;
                color: #fca5a5;
                overflow-x: auto;
                white-space: pre-wrap;
                word-break: break-word;
LiangLiu's avatar
LiangLiu committed
1298
1299
            }

LiangLiu's avatar
LiangLiu committed
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
            .subtask-error {
                background: rgba(239, 68, 68, 0.05);
                border-left: 3px solid #ef4444;
                padding: 0.75rem;
                margin: 0.5rem 0;
                border-radius: 0 4px 4px 0;
            }

            .subtask-error pre {
                background: #1a1a1a;
                border: 1px solid #dc2626;
                border-radius: 6px;
                padding: 12px;
                margin: 8px 0;
                color: #fca5a5;
                font-size: 12px;
                line-height: 1.4;
                white-space: pre-wrap;
                word-break: break-word;
                max-height: 200px;
                overflow-y: auto;
LiangLiu's avatar
LiangLiu committed
1321
1322
            }

LiangLiu's avatar
LiangLiu committed
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
            .error-details {
                animation: slideDown 0.3s ease-out;
            }

            @keyframes slideDown {
                from {
                    opacity: 0;
                    transform: translateY(-10px);
                }
                to {
                    opacity: 1;
                    transform: translateY(0);
                }
LiangLiu's avatar
LiangLiu committed
1336
1337
            }

LiangLiu's avatar
LiangLiu committed
1338
1339
1340
1341
            .task-detail-panel video {
                width: 100%;
                height: 100%;
                object-fit: cover;
LiangLiu's avatar
LiangLiu committed
1342
1343
            }

LiangLiu's avatar
LiangLiu committed
1344
1345
            /* 素材预览样式 */

LiangLiu's avatar
LiangLiu committed
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
            /* 任务状态指示器增强 */
            .status-indicator {
                position: relative;
            }

            .status-indicator::after {
                content: '';
                position: absolute;
                top: 50%;
                left: 50%;
                transform: translate(-50%, -50%);
                width: 0.25rem;
                height: 0.25rem;
                background-color: currentColor;
                border-radius: 50%;
                opacity: 0.8;
            }

            /* 响应式任务面板 */
            @media (max-width: 768px) {
                .task-detail-panel {
                    padding: 0 0.5rem;
                }
            }

            /* 提示消息动画 */
            .animate-slide-down {
                animation: slideDown 0.3s ease-out;
            }

            @keyframes slideDown {
                0% {
                    opacity: 0;
                    transform: translate(-50%, -100%);
                }
                100% {
                    opacity: 1;
                    transform: translate(-50%, 0);
                }
            }

            /* 提示消息样式 - 统一浅色透明背景 */
            .alert {
                backdrop-filter: blur(15px);
LiangLiu's avatar
LiangLiu committed
1390
                background: rgba(0, 0, 0, 0.8);
LiangLiu's avatar
LiangLiu committed
1391
                border-radius: 0.75rem;
LiangLiu's avatar
LiangLiu committed
1392
1393
                box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
                color: #fff;
LiangLiu's avatar
LiangLiu committed
1394
1395
1396
            }
        }

LiangLiu's avatar
LiangLiu committed
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
             .floating-toggle-btn {
                 position: fixed;
                 top: 50%;
                 left: 256px; /* 默认位置,对应 w-64 (256px) */
                 transform: translateY(-50%);
                 width: 20px;
                 height: 40px;
                 background: linear-gradient(135deg, #1a1a2e 0%, #2a2a4e 50%, #1e1e3e 100%);
                 border: 1px solid rgba(139, 92, 246, 0.3);
                 border-left: none;
                 border-radius: 0 8px 8px 0;
                 color: #9ca3af;
                 display: flex;
                 align-items: center;
                 justify-content: center;
                 cursor: pointer;
                 transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
                 z-index: 20;
                 box-shadow: 2px 0 8px rgba(0, 0, 0, 0.3);
             }

             .floating-toggle-btn:hover {
                 background: linear-gradient(135deg, #2a2a4e 0%, #3a3a5e 50%, #2e2e4e 100%);
                 color: #8b5cf6;
                 box-shadow: 2px 0 12px rgba(139, 92, 246, 0.3);
             }

             .floating-toggle-btn.collapsed {
                 border-radius: 0 8px 8px 0;
                 border-left: 1px solid rgba(139, 92, 246, 0.3);
                 border-right: none;
             }

             .resizing .floating-toggle-btn {
                 transition: none !important;
             }

             .left-glow-zone.show-glow {
                 opacity: 1;
             }

             .history-section {
                 max-height: calc(100% - 200px);
                 border-radius: 0 12px 12px 0;
                 border: 2px solid rgba(139, 92, 246, 0.4);
                 box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
                 margin: 8px 8px 8px 0;
                 transition: all 0.3s ease;
                 cursor: pointer;
                 background: rgba(139, 92, 246, 0.05);
             }

             .history-section:hover {
                 background: rgba(139, 92, 246, 0.05) !important;
                 border-color: rgba(139, 92, 246, 0.15) !important;
                 box-shadow: 0 0 20px rgba(154, 114, 255, 0.8), 0 0 40px rgba(154, 114, 255, 0.6), 0 0 60px rgba(154, 114, 255, 0.4), 0 0 80px rgba(154, 114, 255, 0.2);
                 transform: translateY(-2px);
             }

             .history-section:hover {
                 background: rgba(139, 92, 246, 0.08) !important;
             }

                   /* 修复任务项样式 */
            .task-item {
                border: 1px solid rgba(139, 92, 246, 0.3);
                padding: 0.75rem;
                border-radius: 0.5rem;
                cursor: pointer;
                transition-property: all;
                transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
                transition-duration: 200ms;
                transition: all 0.2s ease;
            }
LiangLiu's avatar
LiangLiu committed
1471

LiangLiu's avatar
LiangLiu committed
1472
1473
1474
1475
1476
            .task-item:hover {
                border: 1px solid rgba(167, 132, 255, 0.2);
                background-color: rgba(167, 132, 255, 0.2);
                transform: translateX(5px);
            }
LiangLiu's avatar
LiangLiu committed
1477

LiangLiu's avatar
LiangLiu committed
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
            /* 任务操作菜单样式 */
            .task-menu-container {
                position: relative;
            }

            .task-menu-dropdown {
                animation: fadeInUp 0.2s ease-out;
            }

            @keyframes fadeInUp {
                from {
                    opacity: 0;
                    transform: translateY(10px);
                }
                to {
                    opacity: 1;
                    transform: translateY(0);
                }
            }

            .task-menu-item {
                transition: all 0.2s ease;
            }

            .task-menu-item:hover {
                transform: translateX(2px);
            }

            /* 语言切换器样式 */
            .language-switcher {
                position: relative;
            }

            .language-switcher button {
                transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            }

            .language-switcher button:hover {
                transform: translateY(-1px);
                box-shadow: 0 4px 12px rgba(154, 114, 255, 0.3);
            }

            .language-switcher .rotate-180 {
                transform: rotate(180deg);
            }

            /* 语言选择下拉菜单动画 */
            .language-switcher .absolute {
                animation: slideDown 0.2s ease-out;
            }

            /* 短信登录样式 */
            .sms-login-form {
                background: transparent;
                border-radius: 0;
                padding: 0;
                border: none;
                margin: 0 auto 2rem auto;
                max-width: 80%;
                animation: slideDown 0.3s ease-out;
            }

            /* 输入组样式 */
            .input-group {
                display: flex;
                gap: 12px;
                align-items: stretch;
                margin-bottom: 1rem;
            }

            .input-group .form-control {
                flex: 1;
                border-radius: 12px;
                border: 2px solid rgba(255, 255, 255, 0.2);
                background: rgba(255, 255, 255, 0.1);
                color: white;
                padding: 14px 18px;
                font-size: 14px;
                font-weight: 400;
                transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
                backdrop-filter: blur(10px);
                position: relative;
                min-width: 0;
                height: 48px;
            }

            .input-group .form-control:focus {
                outline: none;
                border-color: #9a72ff;
                background: rgba(255, 255, 255, 0.12);
                box-shadow: 0 0 0 4px rgba(154, 114, 255, 0.15),
                           0 8px 25px rgba(154, 114, 255, 0.1);
                transform: translateY(-1px);
            }

            .input-group .form-control:hover:not(:focus) {
                border-color: rgba(255, 255, 255, 0.25);
                background: rgba(255, 255, 255, 0.1);
            }

            .input-group .form-control::placeholder {
                color: rgba(255, 255, 255, 0.5);
                font-weight: 400;
                transition: color 0.3s ease;
            }

            .input-group .form-control:focus::placeholder {
                color: rgba(255, 255, 255, 0.3);
            }

            /* 单独的输入框样式 */
            .form-control {
                width: 50%;
                border: 2px solid rgba(255, 255, 255, 0.15);
                background: rgba(255, 255, 255, 0.08);
                color: white;
                padding: 16px 20px;
                font-size: 12px;
                font-weight: 400;
                transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
                backdrop-filter: blur(10px);
                position: relative;
            }

            .form-control:focus {
                outline: none;
                border-color: #9a72ff;
                background: rgba(255, 255, 255, 0.12);
                box-shadow: 0 0 0 4px rgba(154, 114, 255, 0.15),
                           0 8px 25px rgba(154, 114, 255, 0.1);
                transform: translateY(-1px);
            }

            .input-group .btn {
                border-radius: 16px;
                padding: 16px 16px;
                font-weight: 500;
                font-size: 14px;
                white-space: nowrap;
                min-width: 100px;
                flex-shrink: 0;
                border: 2px solid transparent;
                transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
                position: relative;
                overflow: hidden;
            }

            .input-group .btn:hover {
                transform: translateY(-1px);
                box-shadow: 0 8px 25px rgba(154, 114, 255, 0.2);
            }

            .input-group .btn:active {
                transform: translateY(0);
            }

            /* 分隔线样式 */
            .divider {
                position: relative;
                text-align: center;
                margin: 20px 0;
            }

            .divider::before {
                content: '';
                position: absolute;
                top: 50%;
                left: 0;
                right: 0;
                height: 1px;
                background: linear-gradient(90deg,
                    transparent 0%,
                    rgba(255, 255, 255, 0.1) 20%,
                    rgba(255, 255, 255, 0.3) 50%,
                    rgba(255, 255, 255, 0.1) 80%,
                    transparent 100%);
            }

            .divider-text {
                background: rgba(27, 18, 64, 0.9);
                padding: 8px 20px;
                color: rgba(255, 255, 255, 0.7);
                font-size: 13px;
                font-weight: 500;
                position: relative;
                z-index: 1;
                border-radius: 20px;
                border: 1px solid rgba(255, 255, 255, 0.1);
                backdrop-filter: blur(10px);
            }

            /* 社交登录按钮样式 */
            .social-login-buttons {
                display: flex;
                justify-content: center;
                gap: 20px;
            }

            .btn-icon {
                width: 48px;
                height: 48px;
                border-radius: 50%;
                border: 2px solid rgba(255, 255, 255, 0.2);
                background: rgba(255, 255, 255, 0.05);
                color: white;
                display: flex;
                align-items: center;
                justify-content: center;
                font-size: 20px;
                transition: all 0.3s ease;
                cursor: pointer;
                position: relative;
                overflow: hidden;
            }

            .btn-icon:hover {
                transform: translateY(-3px) scale(1.05);
                box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
            }

            .btn-icon:active {
                transform: translateY(-1px) scale(1.02);
            }

            .btn-icon:hover {
                background: rgba(255, 255, 255, 0.15);
                border-color: rgba(255, 255, 255, 0.6);
                box-shadow: 0 10px 30px rgba(255, 255, 255, 0.1);
            }

            .btn-icon:hover i {
                color: #ffffff;
                text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
            }

            .btn-icon {
                background: rgba(255, 255, 255, 0.08);
                border-color: rgba(255, 255, 255, 0.3);
            }

            /* 图标按钮的波纹效果 */
            .btn-icon::before {
                content: '';
                position: absolute;
                top: 50%;
                left: 50%;
                width: 0;
                height: 0;
                border-radius: 50%;
                background: rgba(255, 255, 255, 0.1);
                transform: translate(-50%, -50%);
                transition: width 0.3s ease, height 0.3s ease;
            }

            .btn-icon:hover::before {
                width: 100%;
                height: 100%;
            }

            /* 提交按钮区域样式 */
            .login-submit-section {
                display: flex;
                justify-content: center;
                margin-top: 24px;
            }

            .btn-submit {
                width: 200px;
                padding: 16px 28px;
                border-radius: 16px;
                font-weight: 600;
                font-size: 14px;
                letter-spacing: 0.5px;
                background: linear-gradient(135deg, #d2c1ff, #a88bff, #8e88ff);
                border: 2px solid transparent;
                color: #0c0920;
                transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
                position: relative;
                overflow: hidden;
                box-shadow: 0 8px 25px rgba(154, 114, 255, 0.3);
            }

            .btn-submit:hover:not(:disabled) {
                transform: translateY(-2px);
                box-shadow: 0 12px 35px rgba(154, 114, 255, 0.4);
            }

            .btn-submit:active:not(:disabled) {
                transform: translateY(0);
            }

            .btn-submit:disabled {
                opacity: 0.6;
                cursor: not-allowed;
                transform: none;
                box-shadow: 0 4px 15px rgba(154, 114, 255, 0.2);
            }

            .btn-submit::before {
                content: '';
                position: absolute;
                top: 0;
                left: -100%;
                width: 100%;
                height: 100%;
                background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
                transition: left 0.5s ease;
            }

            .btn-submit:hover::before {
                left: 100%;
            }

            /* 响应式设计 */
            @media (max-width: 768px) {
                .login-card .card-body {
                    padding: 1.5rem !important;
                }

                /* 登录表单的input-group保持水平布局 */
                .sms-login-form .input-group {
                    flex-direction: row !important;
                    gap: 12px !important;
                }

                .sms-login-form .input-group .btn {
                    width: auto !important;
                    min-width: 110px !important;
                }

                .social-login-buttons {
                    gap: 16px;
                }

                .btn-icon {
                    width: 42px;
                    height: 42px;
                    font-size: 18px;
                }

                .divider-text {
                    font-size: 12px;
                    padding: 0 12px;
                }
            }

            @media (max-width: 480px) {
                .login-card .card-body {
                    padding: 1rem !important;
                }

                .input-group .form-control {
                    padding: 14px 16px;
                    font-size: 14px;
                }

                .btn-icon {
                    width: 38px;
                    height: 38px;
                    font-size: 16px;
                }

                .social-login-buttons {
                    gap: 12px;
                }

                .btn-submit {
                    width: 100%;
                    max-width: 200px;
                    padding: 16px 28px;
                    font-size: 15px;
                }
            }

            @keyframes slideDown {
                from {
                    opacity: 0;
                    transform: translateY(-10px);
                }
                to {
                    opacity: 1;
                    transform: translateY(0);
                }
            }

            /* 语言切换时的文本过渡动画 */
            .language-transition {
                transition: all 0.3s ease-in-out;
            }

            /* 语言选项悬停效果 */
            .language-switcher .absolute > div:hover {
                background: bg-laser-purple/20;
                transform: translateX(2px);
            }

            /* 当前选中语言的样式 */
            .language-switcher .absolute > div[class*="bg-laser-purple"] {
                background: bg-laser-purple/20;
                border-left: 3px solid #9a72ff;
            }

            .sms-login-form .form-control {
                background: rgba(255, 255, 255, 0.1);
                border: 1px solid rgba(255, 255, 255, 0.2);
                color: white;
                border-radius: 8px;
                transition: all 0.3s ease;
                height: 50px;
                padding: 12px 16px;
                font-size: 16px;
            }

            .sms-login-form .form-control:focus {
                background: rgba(255, 255, 255, 0.15);
                border-color: #007bff;
                box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
                color: white;
            }

            .sms-login-form .form-control::placeholder {
                color: rgba(255, 255, 255, 1.0);
            }

            .sms-login-form .btn-primary:disabled {
                opacity: 0.6;
                cursor: not-allowed;
            }

            .sms-login-form .btn-primary {
                color: white;
                transition: all 0.3s ease;
                height: 50px;
                padding: 12px 20px;
                font-size: 16px;
                font-weight: 500;
            }

            /* 发送验证码按钮专用样式 */
            .btn-sms-code {
                background: linear-gradient(135deg, #9a72ff 0%, #7c6aff 100%);
                border: 2px solid rgba(255, 255, 255, 0.2);
                color: white;
                font-weight: 500;
                font-size: 13px;
                padding: 8px 16px;
                border-radius: 12px;
                transition: all 0.3s ease;
                box-shadow: 0 4px 12px rgba(154, 114, 255, 0.3);
                white-space: nowrap;
                min-width: 110px;
                height: 48px;
                display: flex;
                align-items: center;
                justify-content: center;
                flex-shrink: 0;
            }

            .btn-sms-code:hover:not(:disabled) {
                background: linear-gradient(135deg, #8a5fff 0%, #6b4aff 100%);
                transform: translateY(-1px);
                box-shadow: 0 6px 16px rgba(154, 114, 255, 0.4);
                border-color: rgba(255, 255, 255, 0.3);
            }

            .btn-sms-code:active:not(:disabled) {
                transform: translateY(0);
                box-shadow: 0 2px 8px rgba(154, 114, 255, 0.3);
            }

            .btn-sms-code:disabled {
                background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
                color: #d1d5db;
                cursor: not-allowed;
                transform: none;
                box-shadow: 0 1px 4px rgba(156, 163, 175, 0.2);
                border-color: rgba(255, 255, 255, 0.1);
            }

            /* 按钮占位符样式,用于对齐 */
            .btn-placeholder {
                min-width: 110px;
                height: 48px;
                flex-shrink: 0;
            }

            /* 表单整体优化 */
            .sms-login-form .input-group:last-child {
                margin-bottom: 0;
            }

            /* 输入框聚焦时的统一效果 */
            .sms-login-form .form-control:focus {
                border-color: #9a72ff;
                background: rgba(255, 255, 255, 0.15);
                box-shadow: 0 0 0 3px rgba(154, 114, 255, 0.2),
                           0 4px 12px rgba(154, 114, 255, 0.1);
                transform: translateY(-1px);
            }

            /* 占位符文字优化 */
            .sms-login-form .form-control::placeholder {
                color: rgba(255, 255, 255, 0.6);
                font-weight: 400;
                transition: color 0.3s ease;
            }

            .sms-login-form .form-control:focus::placeholder {
                color: rgba(255, 255, 255, 0.4);
            }
            /* 文本截断样式 */
.line-clamp-1 {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 侧边栏动画样式 */
.sidebar-expand {
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-text {
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(-10px);
}

.sidebar-text.show {
    opacity: 1;
    transform: translateX(0);
}

/* 平滑过渡动画 */
.smooth-transition {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 登录页面样式 */
.login-container {
    min-height: 100%;
    min-width: 100%;
    background: linear-gradient(135deg, #0b0a20 0%, #1b1240 50%, #0f0e22 100%);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 20% 80%, rgba(154, 114, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(183, 139, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(124, 106, 255, 0.05) 0%, transparent 50%);
    animation: backgroundShift 20s ease-in-out infinite;
}

/* 登录页面样式 */
.main-container {
    min-height: 100%;
    min-width: 100%;
    background: linear-gradient(135deg, #0b0a20 0%, #1b1240 50%, #0f0e22 100%);
    overflow-x: visible;
    overflow-y: hidden;
    display: flex;
    flex-direction: column;
}

/* 顶部栏样式 */
.top-bar {
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(11, 10, 32, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(154, 114, 255, 0.2);
    z-index: 1000;
    display: flex;
    align-items: center;
}

.top-bar-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.top-bar-left {
    display: flex;
    align-items: center;
}

.top-bar-logo {
    height: 50px;
    width: auto;
    filter: brightness(0) invert(1);
}

.top-bar-right {
    display: flex;
    align-items: center;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(154, 114, 255, 0.2);
    border: 1px solid rgba(154, 114, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-avatar i {
    color: #9a72ff;
    font-size: 16px;
}

.user-details {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.username {
    font-size: 14px;
    font-weight: 500;
    color: #ffffff;
    line-height: 1.2;
}

.user-email {
    font-size: 12px;
    color: #9ca3af;
    line-height: 1.2;
}

.logout-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: rgba(154, 114, 255, 0.1);
    border: 1px solid rgba(154, 114, 255, 0.2);
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    cursor: pointer;
}

.logout-btn:hover {
    background: rgba(154, 114, 255, 0.2);
    color: #9a72ff;
    border-color: rgba(154, 114, 255, 0.4);
}

@keyframes backgroundShift {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

.login-card {
    background: rgba(27, 18, 64, 0.8);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(154, 114, 255, 0.2);
    border-radius: 24px;
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.3),
        0 0 40px rgba(154, 114, 255, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    max-width: 500px;
    width: 100%;
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(154, 114, 255, 0.1), transparent);
    transition: left 0.5s ease;
}

.login-card:hover::before {
    left: 100%;
}

.login-card:hover {
    transform: translateY(-5px);
    box-shadow:
        0 25px 50px rgba(0, 0, 0, 0.4),
        0 0 60px rgba(154, 114, 255, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.login-logo {
    background: linear-gradient(135deg, #9a72ff, #b78bff, #7c6aff);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    animation: logoGlow 3s ease-in-out infinite alternate;
}

@keyframes logoGlow {
    0% {
        filter: drop-shadow(0 0 10px rgba(154, 114, 255, 0.5));
    }
    100% {
        filter: drop-shadow(0 0 20px rgba(154, 114, 255, 0.8));
    }
}

.login-subtitle {
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.1rem;
    margin-bottom: 2rem;
    font-weight: 300;
}

.floating-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(193, 169, 255, 0.6);
    border-radius: 50%;
    animation: floatParticle 15s linear infinite;
}

.particle:nth-child(1) { left: 10%; animation-delay: 0s; }
.particle:nth-child(2) { left: 20%; animation-delay: 12s; }
.particle:nth-child(3) { left: 30%; animation-delay: 10s; }
.particle:nth-child(4) { left: 40%; animation-delay: 6s; }
.particle:nth-child(5) { left: 50%; animation-delay: 8s; }
.particle:nth-child(6) { left: 60%; animation-delay: 14s; }
.particle:nth-child(7) { left: 70%; animation-delay: 16s; }
.particle:nth-child(8) { left: 80%; animation-delay: 2s; }
.particle:nth-child(9) { left: 90%; animation-delay: 4s; }

@keyframes floatParticle {
    0% {
        transform: translateY(100vh) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100px) scale(1);
        opacity: 0;
    }
}

.login-features {
    padding-top: 2rem;
    padding-left: 10rem;
    border-top: 1px solid rgba(154, 114, 255, 0.2);
}

.feature-item {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

.feature-icon {
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #9a72ff, #b78bff);
    border-radius: 50%;
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: white;
}

/* 登录页面进入动画 */
.login-container {
    animation: fadeInUp 0.8s ease-out;
}

.login-card {
    animation: slideInUp 0.6s ease-out 0.2s both;
}

.login-logo {
    animation: logoGlow 3s ease-in-out infinite alternate, fadeInScale 0.8s ease-out 0.4s both;
}

.login-subtitle {
    animation: fadeIn 0.8s ease-out 0.6s both;
}

.login-features {
    animation: fadeIn 0.8s ease-out 1s both;
}

.feature-item {
    animation: slideInLeft 0.6s ease-out both;
}

.feature-item:nth-child(1) { animation-delay: 1.2s; }
.feature-item:nth-child(2) { animation-delay: 1.4s; }
.feature-item:nth-child(3) { animation-delay: 1.6s; }
.feature-item:nth-child(4) { animation-delay: 1.8s; }
.feature-item:nth-child(5) { animation-delay: 2.0s; }
.feature-item:nth-child(6) { animation-delay: 2.2s; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .login-logo {
        font-size: 2.5rem;
    }

    .login-subtitle {
        font-size: 1rem;
    }

    .login-card {
        margin: 20px;
        border-radius: 20px;
    }
}

@media (max-width: 480px) {
    .login-logo {
        font-size: 2rem;
    }

    .login-subtitle {
        font-size: 0.9rem;
    }

    .login-card .card-body {
        padding: 2rem !important;
    }
}

/* Alert动画 */
@keyframes slide-down {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.animate-slide-down {
    animation: slide-down 0.3s ease-out;
}
    </style>
</head>

<body class="text-gray-100 font-inter">

    <div id="app" v-cloak>
        <!-- 加载状态 -->
        <div v-if="isLoggedIn === null" class="login-container flex items-center justify-center">
            <div class="text-center">
                <div class="animate-spin rounded-full h-12 w-12 border-b-2 border-laser-purple mx-auto mb-4"></div>
                <p class="text-gray-400">Loading...</p>
            </div>
        </div>

        <!-- 登录页面 -->
LiangLiu's avatar
LiangLiu committed
2463
        <div v-if="isLoggedIn === false || currentView === 'login'" class="login-container w-full">
LiangLiu's avatar
LiangLiu committed
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
            <!-- 浮动粒子背景 -->
            <div class="floating-particles">
                <div class="particle"></div>
                <div class="particle"></div>
                <div class="particle"></div>
                <div class="particle"></div>
                <div class="particle"></div>
                <div class="particle"></div>
                <div class="particle"></div>
                <div class="particle"></div>
                <div class="particle"></div>
                <div class="particle"></div>
                <div class="particle"></div>
                <div class="particle"></div>
                <div class="particle"></div>
                <div class="particle"></div>
                <div class="particle"></div>
                <div class="particle"></div>
                <div class="particle"></div>
                <div class="particle"></div>
                <div class="particle"></div>
                <div class="particle"></div>
            </div>

            <div class="login-card">
                <div class="card-body text-center p-8">
                    <!-- Logo和标题 -->
                    <div class="mb-8">
                        <div class="login-logo">
                            <i class="fas fa-film me-3"></i>
                            LightX2V
LiangLiu's avatar
LiangLiu committed
2495
                        </div>
LiangLiu's avatar
LiangLiu committed
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
                        <p class="login-subtitle">{{ t('loginSubtitle') }}</p>
                    </div>

                    <!-- 短信登录表单 -->
                    <div class="sms-login-form">
                        <div class="input-group">
                            <input v-model="phoneNumber"
                                type="tel"
                                class="form-control form-control-lg"
                                :placeholder="t('phoneNumber')"
                                :disabled="loginLoading"
                                maxlength="11"
                                @keyup.enter="handlePhoneEnter"
                            >
                            <div class="btn-placeholder"></div>
                        </div>
                        <div class="input-group">
                            <input
                                v-model="verifyCode"
                                type="text"
                                class="form-control form-control-lg"
                                :placeholder="t('verifyCode')"
                                :disabled="loginLoading"
                                maxlength="6"
                                @keyup.enter="handleVerifyCodeEnter"
                            >
                            <button
                                @click="sendSmsCode"
                                class="btn-sms-code"
                                :disabled="!phoneNumber || smsCountdown > 0 || loginLoading"
                            >
                                {{ smsCountdown > 0 ? `${smsCountdown}s` : t('sendSmsCode') }}
                            </button>
                        </div>
                    </div>

                    <!-- 确认登录按钮 -->
                    <div class="login-submit-section mb-4">
                        <button
                            @click="loginWithSms"
                            class="btn btn-submit text-white"
                            :disabled="!phoneNumber || !verifyCode || loginLoading"
                        >
                            {{ loginLoading ? t('loginLoading') : t('login') }}
                        </button>
                    </div>

                    <!-- 分隔线 -->
                    <div class="divider mb-4">
                        <span class="divider-text">{{ t('orLoginWith') }}</span>
                    </div>

                    <!-- 第三方登录按钮 -->
                    <div class="social-login-buttons">
                        <button @click="loginWithGitHub" class="btn btn-icon"
                            :disabled="loginLoading" :title="t('loginWithGitHub')">
                            <i class="fab fa-github"></i>
                        </button>

                        <button @click="loginWithGoogle" class="btn btn-icon"
                            :disabled="loginLoading" :title="t('loginWithGoogle')">
                            <i class="fab fa-google"></i>
                        </button>
                    </div>
                </div>
                                <!-- 功能特性 -->
                                <div class="login-features">
                                    <div class="feature-item">
                                        <div class="feature-icon">🎭</div>
                            <span>{{ t('feature1') }}</span>
                                    </div>
                                    <div class="feature-item">
                                        <div class="feature-icon"></div>
                            <span>{{ t('feature2') }}</span>
                                    </div>
                                    <div class="feature-item">
                                        <div class="feature-icon">💰</div>
                            <span>{{ t('feature3') }}</span>
                                    </div>
                                    <div class="feature-item">
                                        <div class="feature-icon">🎯</div>
                            <span>{{ t('feature4') }}</span>
                                    </div>
                                    <div class="feature-item">
                                        <div class="feature-icon">📱</div>
                            <span>{{ t('feature5') }}</span>
                                    </div>
                                    <div class="feature-item">
                                        <div class="feature-icon">🎨</div>
                            <span>{{ t('feature6') }}</span>
                                    </div>
                                </div>
                            </div>
LiangLiu's avatar
LiangLiu committed
2589
2590
        </div>

LiangLiu's avatar
LiangLiu committed
2591
        <!-- 主应用页面 -->
LiangLiu's avatar
LiangLiu committed
2592
        <div v-if="isLoggedIn === true && currentView !== 'login'" class="main-container">
LiangLiu's avatar
LiangLiu committed
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
        <!-- 浮动粒子背景 -->
        <div class="floating-particles">
            <div class="particle"></div>
            <div class="particle"></div>
            <div class="particle"></div>
            <div class="particle"></div>
            <div class="particle"></div>
            <div class="particle"></div>
            <div class="particle"></div>
            <div class="particle"></div>
            <div class="particle"></div>
            <div class="particle"></div>
            <div class="particle"></div>
            <div class="particle"></div>
            <div class="particle"></div>
            <div class="particle"></div>
            <div class="particle"></div>
            <div class="particle"></div>
            <div class="particle"></div>
            <div class="particle"></div>
            <div class="particle"></div>
            <div class="particle"></div>
        </div>

LiangLiu's avatar
LiangLiu committed
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
        <!-- 主内容区域 -->
        <div class="main-content-area flex flex-col relative h-full">
            <!-- 顶部栏 -->
            <div class="top-bar">
                <div class="top-bar-content">
                    <div class="top-bar-left">
                        <i class="fas fa-video text-gradient-icon mr-2 text-xl"></i>
                        <span class="text-lg">LightX2V</span>
                    </div>

                    <!-- 右侧用户信息 -->
                    <div class="top-bar-right">

                            <!-- 语言切换按钮 -->
                            <div class="language-switcher mr-6">
                                <button @click="toggleLanguage"
                                    class="w-10 h-10 bg-laser-purple/10 text-gradient-icon items-center px-1 py-1
                                           rounded-lg bg-dark-light border border-laser-purple/50 hover:border-laser-purple
                                           transition-all duration-200 text-sm hover:scale-105"
                                    :title="t('switchLanguage')">
                                    <span class="text-lg">{{ languageOptions.find(lang => lang.code ===
                                        (currentLanguage === 'zh' ? 'en' : 'zh'))?.flag }}</span>
                                </button>
                            </div>

                        <div class="user-info">
                            <div class="user-avatar text-gradient-icon">
                                    <img v-if="currentUser.avatar" :src="getUserAvatarUrl(currentUser)"
                                        :alt="currentUser.username" class="avatar-img">
                                <i v-else class="fas fa-user"></i>
                            </div>
                            <div class="user-details">
                                <span class="username">{{ currentUser.username }}</span>
                                <span class="user-email">{{ currentUser.email }}</span>
                            </div>
                                <button @click="logout" class="text-gradient-icon" :title="t('logout')">
                                <i class="fas fa-sign-out-alt"></i>
                            </button>
                        </div>
                    </div>
LiangLiu's avatar
LiangLiu committed
2657
2658
                </div>
            </div>
LiangLiu's avatar
LiangLiu committed
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678

                <!-- 下方区域 -->
                <div class="flex flex-row relative flex-1 min-h-0">
                    <!-- 左侧功能区 -->
                    <div
                        class="relative w-20 pl-5 flex flex-col z-10 mobile-bottom-nav">
                        <!-- 功能导航 -->
                <div class="p-2 flex flex-col justify-center h-full mobile-nav-buttons" style="margin-top: -10vh;">
                            <nav class="space-y-3">
                                <!-- 生成视频功能 -->
                                <div class="relative group">
                                    <button @click="switchToCreateView"
                                        class="w-12 h-12 flex items-center justify-center rounded-lg transition-all duration-300
                                               font-medium text-sm border border-transparent hover:scale-105 hover:shadow-lg
                                               hover:shadow-laser-purple/40 mobile-nav-btn"
                                        :class="currentView === 'create'
                                            ? 'bg-laser-purple/40 text-white border-laser-purple/40 shadow-lg shadow-laser-purple/20'
                                            : 'text-gray-400 hover:text-gradient-icon'"
                                        :title="t('generateVideo')">
                                        <i class="fas fa-plus text-lg transition-transform duration-300 group-hover:rotate-90"></i>
LiangLiu's avatar
LiangLiu committed
2679
2680
2681
                    </button>
                </div>

LiangLiu's avatar
LiangLiu committed
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
                                <!-- 我的项目功能 -->
                                <div class="relative group">
                                    <button @click="switchToProjectsView"
                                        class="w-12 h-12 flex items-center justify-center rounded-lg transition-all duration-300
                                               font-medium text-sm border border-transparent hover:scale-105 hover:shadow-lg
                                               hover:shadow-laser-purple/20 mobile-nav-btn"
                                        :class="currentView === 'projects'
                                            ? 'bg-laser-purple/40 text-white border-laser-purple/40 shadow-lg shadow-laser-purple/40'
                                            : 'text-gray-400 hover:text-white hover:bg-dark-light hover:border-laser-purple/30'"
                                        :title="t('myProjects')">
                                        <i class="fas fa-folder text-lg transition-transform duration-300 group-hover:scale-110"></i>
                                    </button>
                                </div>

                                <!-- 灵感广场功能 -->
                                <div class="relative group">
                                    <button @click="switchToInspirationView"
                                        class="w-12 h-12 flex items-center justify-center rounded-lg transition-all duration-300
                                               font-medium text-sm border border-transparent hover:scale-105 hover:shadow-lg
                                               hover:shadow-laser-purple/40 mobile-nav-btn"
                                        :class="currentView === 'inspiration'
                                            ? 'bg-laser-purple/40 text-white border-laser-purple/40 shadow-lg shadow-laser-purple/20'
                                            : 'text-gray-400 hover:text-white hover:bg-dark-light hover:border-laser-purple/30'"
                                        :title="t('inspiration')">
                                        <i class="fas fa-star text-lg transition-transform duration-300 group-hover:animate-pulse"></i>
                                    </button>
                                </div>
                            </nav>
                        </div>
LiangLiu's avatar
LiangLiu committed
2711
                    </div>
LiangLiu's avatar
LiangLiu committed
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765

                    <!-- 历史任务区域 -->
                    <div v-if="currentView === 'projects'" class="flex-1 flex flex-col min-h-0 mobile-content">
                        <!-- 内容区域 -->
                        <div class="flex-1 overflow-y-auto p-10 content-area main-scrollbar">
                            <!-- 历史任务功能区 -->
                            <div class="max-w-4xl mx-auto" id="task-creator">
                                <!-- 搜索和筛选区域 -->
                                <div class="flex flex-col md:flex-row gap-4 mb-6">
                            <!-- 搜索框 -->
                                    <div class="relative flex-1">
                                        <i
                                            class="fas fa-search absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none z-10"></i>
                                        <input v-model="taskSearchQuery"
                                            class="w-full bg-dark-light border border-laser-purple/30 rounded-lg py-3 pl-10 pr-4 text-sm focus:outline-none focus:ring-2 focus:ring-laser-purple/50 transition-all focus:border-laser focus:shadow-laser"
                                            :placeholder="t('searchTasks')" type="text" />
                        </div>

                                    <!-- 分类筛选 -->
                                    <div class="flex gap-2">
                                        <button @click="statusFilter = 'ALL'"
                                            :class="statusFilter === 'ALL'
                                                ? 'bg-laser-purple/20 text-white border-laser-purple/40'
                                                : 'bg-dark-light text-gray-400 hover:text-white hover:bg-dark-light/80'"
                                            class="px-4 py-2 rounded-lg border border-transparent transition-all duration-200 text-sm font-medium">
                                            {{ t('all') }}
                                </button>
                                        <button @click="statusFilter = 'SUCCEED'"
                                            :class="statusFilter === 'SUCCEED'
                                                ? 'bg-laser-purple/20 text-white border-laser-purple/40'
                                                : 'bg-dark-light text-gray-400 hover:text-white hover:bg-dark-light/80'"
                                            class="px-4 py-2 rounded-lg border border-transparent transition-all duration-200 text-sm font-medium">
                                            {{ t('success') }}
                                </button>
                                        <button @click="statusFilter = 'RUNNING'"
                                            :class="statusFilter === 'RUNNING'
                                                ? 'bg-laser-purple/20 text-white border-laser-purple/40'
                                                : 'bg-dark-light text-gray-400 hover:text-white hover:bg-dark-light/80'"
                                            class="px-4 py-2 rounded-lg border border-transparent transition-all duration-200 text-sm font-medium">
                                            {{ t('running') }}
                                </button>
                                        <button @click="statusFilter = 'FAILED'"
                                            :class="statusFilter === 'FAILED'
                                                ? 'bg-laser-purple/20 text-white border-laser-purple/40'
                                                : 'bg-dark-light text-gray-400 hover:text-white hover:bg-dark-light/80'"
                                            class="px-4 py-2 rounded-lg border border-transparent transition-all duration-200 text-sm font-medium">
                                            {{ t('failed') }}
                                </button>
                                        <button @click="() => refreshTasks(true)"
                                    class="text-gray-400 hover:text-gradient-icon transition-colors flex-shrink-0"
                                            :title="t('refreshTasks')">
                                    <i class="fas fa-sync-alt"></i>
                                </button>
                        </div>
LiangLiu's avatar
LiangLiu committed
2766
                    </div>
LiangLiu's avatar
LiangLiu committed
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807

                            <!-- 分页组件 -->
                            <div v-cloak>
                                            <div v-if="paginationInfo" :key="paginationKey" class="pagination-container mb-3">
                                    <div class="flex items-center justify-between text-xs text-gray-400">
                                        <div class="flex items-center space-x-1 text-gray-500">
                                                <span>{{ t('total') }} {{ paginationInfo.total }} {{ t('tasks') }}</span>
                        </div>
                                            <div v-if="paginationInfo.total_pages > 1"
                                                class="flex items-center space-x-2">
                                            <!-- 上一页按钮 -->
                                                <button @click="goToPage(currentTaskPage - 1)" :disabled="currentTaskPage <= 1"
                                                class="pagination-btn-compact"
                                                    :class="{ 'disabled': currentTaskPage <= 1 }" :title="t('previousPage')">
                                                <i class="fas fa-chevron-left text-xs"></i>
                                            </button>

                                            <!-- 页码输入框 -->
                                            <div class="flex items-center space-x-1">
                                                    <input v-model.number="pageInput" @keyup.enter="jumpToPage"
                                                        @blur="jumpToPage" type="number" :min="1"
                                                        :max="paginationInfo.total_pages" class="page-input"
                                                        :title="t('jumpToPage')" />
                                                <span class="text-gray-500">/</span>
                                                <span class="text-gray-500">{{ paginationInfo.total_pages }}</span>
                            </div>

                                            <!-- 下一页按钮 -->
                                                <button @click="goToPage(currentTaskPage + 1)"
                                                :disabled="currentTaskPage >= paginationInfo.total_pages"
                                                class="pagination-btn-compact"
                                                :class="{ 'disabled': currentTaskPage >= paginationInfo.total_pages }"
                                                    :title="t('nextPage')">
                                                <i class="fas fa-chevron-right text-xs"></i>
                                            </button>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- 可滚动的任务列表区域 -->
LiangLiu's avatar
LiangLiu committed
2808
                                <div class="flex-1 overflow-y-auto main-scrollbar min-h-0 p-4"
LiangLiu's avatar
LiangLiu committed
2809
2810
2811
2812
2813
2814
                                    style="overflow-x: visible;">
                            <div v-cloak>
                                        <div v-if="filteredTasks.length === 0"
                                            class="flex-col items-center justify-center py-12 text-center">
                                            <p class="text-gray-400 text-sm">{{ t('noHistoryTasks') }}</p>
                                            <p class="text-gray-500 text-xs mt-1">{{ t('startToCreateYourFirstAIVideo') }}</p>
LiangLiu's avatar
LiangLiu committed
2815
                                        </div>
LiangLiu's avatar
LiangLiu committed
2816
                                        <div v-else
LiangLiu's avatar
LiangLiu committed
2817
                                            class="columns-2 md:columns-3 lg:columns-4 xl:columns-5 gap-3">
LiangLiu's avatar
LiangLiu committed
2818
2819
                                                <!-- 任务卡片 -->
                                            <div v-for="task in filteredTasks" :key="task.task_id"
LiangLiu's avatar
LiangLiu committed
2820
2821
2822
                                                    class="break-inside-avoid mb-3 group relative bg-dark-light rounded-xl overflow-hidden border border-gray-700/50 hover:border-laser-purple/40 transition-all duration-300 hover:shadow-laser/20">
                                                <!-- 缩略图区域 -->
                                                <div class="cursor-pointer bg-gray-800 relative flex flex-col"
LiangLiu's avatar
LiangLiu committed
2823
                                                @click="openTaskDetailModal(task)"
LiangLiu's avatar
LiangLiu committed
2824
2825
2826
2827
2828
2829
2830
2831
                                                :title="t('viewTaskDetails')">
                                                    <!-- 视频预览 -->
                                                        <!-- 成功任务:显示视频动图 -->
                                                        <video v-if="task.status === 'SUCCEED' && task.outputs?.output_video"
                                                            :src="getTaskFileUrlSync(task.task_id, 'output_video')"
                                                            :poster="getTaskFileUrlSync(task.task_id, 'input_image')"
                                                                class="w-full h-auto object-contain group-hover:scale-105 transition-transform duration-300"
                                                            preload="auto" playsinline webkit-playsinline
LiangLiu's avatar
LiangLiu committed
2832
2833
2834
                                                                @mouseenter="playVideo($event)"
                                                                @mouseleave="pauseVideo($event)"
                                                                @loadeddata="onVideoLoaded($event)"
LiangLiu's avatar
LiangLiu committed
2835
                                                                @ended="onVideoEnded($event)"
LiangLiu's avatar
LiangLiu committed
2836
2837
                                                            @error="onVideoError($event)"></video>

LiangLiu's avatar
LiangLiu committed
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
                                                    <!-- 其他状态:显示输入图片或占位符 -->
                                                    <img v-else="task.inputs?.input_image"
                                                    :src="getTaskFileUrlSync(task.task_id, 'input_image')"
                                                    class="w-full h-auto object-contain group-hover:scale-105 transition-transform duration-300"
                                                    @error="handleThumbnailError" />

                                                    <!-- 移动端播放按钮 -->
                                                    <button v-if="task.status === 'SUCCEED'"
                                                    @click.stop="toggleVideoPlay($event)"
                                                    class="md:hidden absolute bottom-3 left-1/2 transform -translate-x-1/2 w-10 h-10 rounded-full bg-black/50 backdrop-blur-sm flex items-center justify-center text-white hover:bg-black/70 transition-colors z-20">
                                                    <i class="fas fa-play text-sm"></i>
                                                </button>
LiangLiu's avatar
LiangLiu committed
2850
2851
2852
2853
2854
2855
2856
2857
2858

                                                        <!-- 状态指示器 -->
                                                        <div class="absolute top-2 right-2">
                                                        <span :class="getTaskStatusColor(task.status)"
                                                            class="px-2 py-1 rounded-full text-xs font-medium bg-black/50 backdrop-blur-sm">
                                                                {{ getTaskStatusDisplay(task.status) }}
                                                            </span>
                                                        </div>

LiangLiu's avatar
LiangLiu committed
2859
                                                        <!-- 悬停时显示的操作按钮(桌面端) -->
LiangLiu's avatar
LiangLiu committed
2860
                                                    <div
LiangLiu's avatar
LiangLiu committed
2861
2862
                                                        class="hidden md:block absolute bottom-2 left-1/2 transform -translate-x-1/2 opacity-0 group-hover:opacity-100 transition-opacity duration-300 pointer-events-none">
                                                            <div class="flex space-x-2 sm:space-x-3 pointer-events-auto">
LiangLiu's avatar
LiangLiu committed
2863
2864
2865
                                                <button
                                                                    v-if="['CREATED', 'PENDING', 'RUNNING','SUCCEED', 'FAILED', 'CANCEL'].includes(task.status)"
                                                                    @click.stop="reuseTask(task)"
LiangLiu's avatar
LiangLiu committed
2866
                                                                    class="w-8 h-8 sm:w-10 sm:h-10 rounded-full bg-white/20 backdrop-blur-sm flex items-center justify-center text-white hover:bg-white/30 transition-colors"
LiangLiu's avatar
LiangLiu committed
2867
                                                                :title="t('reuseTask')">
LiangLiu's avatar
LiangLiu committed
2868
                                                            <i class="fas fa-copy text-sm sm:text-lg"></i>
LiangLiu's avatar
LiangLiu committed
2869
2870
2871
2872
2873
2874
                                                </button>
                                                        <button
                                                                v-if="['CREATED', 'PENDING', 'RUNNING'].includes(task.status)"
                                                                @click.stop="cancelTask(task.task_id)"
                                                                class="w-10 h-10 rounded-full bg-laser-purple/80 backdrop-blur-sm flex items-center justify-center text-white hover:bg-laser-purple transition-colors"
                                                                :title="t('cancelTask')">
LiangLiu's avatar
LiangLiu committed
2875
                                                            <i class="fas fa-times text-sm sm:text-lg"></i>
LiangLiu's avatar
LiangLiu committed
2876
2877
2878
2879
                                                        </button>
                                                        <button
                                                                    v-if="['SUCCEED', 'FAILED', 'CANCEL'].includes(task.status)"
                                                                    @click.stop="resumeTask(task.task_id)"
LiangLiu's avatar
LiangLiu committed
2880
                                                                    class="w-8 h-8 sm:w-10 sm:h-10 rounded-full bg-laser-purple/80 backdrop-blur-sm flex items-center justify-center text-white hover:bg-laser-purple transition-colors"
LiangLiu's avatar
LiangLiu committed
2881
                                                                :title="t('retryTask')">
LiangLiu's avatar
LiangLiu committed
2882
                                                                    <i class="fas fa-redo text-sm sm:text-lg"></i>
LiangLiu's avatar
LiangLiu committed
2883
2884
                                                        </button>
                                                            <button v-if="task.status === 'SUCCEED'"
LiangLiu's avatar
LiangLiu committed
2885
2886
                                                                    @click.stop="downloadFile(task.outputs?.output_video)"
                                                                    class="w-8 h-8 sm:w-10 sm:h-10 rounded-full bg-laser-purple/80 backdrop-blur-sm flex items-center justify-center text-white hover:bg-laser-purple transition-colors"
LiangLiu's avatar
LiangLiu committed
2887
                                                                :title="t('downloadTask')">
LiangLiu's avatar
LiangLiu committed
2888
                                                                    <i class="fas fa-download text-sm sm:text-lg"></i>
LiangLiu's avatar
LiangLiu committed
2889
2890
2891
2892
                                                        </button>
                                                        <button
                                                                    v-if="['SUCCEED', 'FAILED', 'CANCEL'].includes(task.status)"
                                                                    @click.stop="deleteTask(task.task_id)"
LiangLiu's avatar
LiangLiu committed
2893
                                                                    class="w-8 h-8 sm:w-10 sm:h-10 rounded-full bg-red-400/80 backdrop-blur-sm flex items-center justify-center text-white hover:bg-red-500 transition-colors"
LiangLiu's avatar
LiangLiu committed
2894
                                                                :title="t('deleteTask')">
LiangLiu's avatar
LiangLiu committed
2895
                                                                    <i class="fas fa-trash text-sm sm:text-lg"></i>
LiangLiu's avatar
LiangLiu committed
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
                                                        </button>
                                                </div>
                                            </div>
                                        </div>

                                                    <!-- 任务信息 -->
                                                    <div class="pl-4 pr-4 pb-4">
                                                    <h3 class="text-white font-medium text-sm mb-2 line-clamp-2">{{
                                                        task.params.prompt.length > 20 ? task.params.prompt.slice(0, 20)
                                                        + '···' : task.params.prompt }}</h3>
                                                    <div
                                                        class="flex items-center justify-between text-xs text-gray-500">
                                                            <span>{{ task.model_cls }}</span>
                                                            <span>{{ getRelativeTime(task.create_t) }}</span>
LiangLiu's avatar
LiangLiu committed
2910
                                    </div>
LiangLiu's avatar
LiangLiu committed
2911
2912
2913

                                </div>
                            </div>
LiangLiu's avatar
LiangLiu committed
2914
                                        </div>
LiangLiu's avatar
LiangLiu committed
2915
2916
2917
2918
2919
2920
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

LiangLiu's avatar
LiangLiu committed
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
                <!-- 生成视频区域 -->
                <div v-if="currentView === 'create'" class="flex-1 flex flex-col min-h-0 mobile-content">
                    <!-- 内容区域 -->
                    <div class="flex-1 overflow-y-auto p-6 content-area main-scrollbar">
                        <!-- 模板选择浮窗 -->
                        <div v-cloak>
                            <div v-if="showImageTemplates || showAudioTemplates"
                                class="fixed inset-0 bg-black/50 z-50 flex items-center justify-center"
                                @click="showImageTemplates = false; showAudioTemplates = false">
                                <div class="bg-secondary rounded-xl p-6 max-w-4xl w-full mx-4 h-[90vh] overflow-hidden"
                                    @click.stop>
                                    <!-- 浮窗头部 -->
                                    <div class="flex items-center justify-between mb-4">
                                        <h3 class="text-lg font-medium text-white">
                                                <i v-if="showImageTemplates"
                                                    class="fas fa-image text-gradient-icon mr-2"></i>
                                                <i v-if="showAudioTemplates"
                                                    class="fas fa-music text-gradient-icon mr-2"></i>
                                                {{ showImageTemplates ? t('imageTemplates') : t('audioTemplates') }}
                                        </h3>
                                        <button @click="showImageTemplates = false; showAudioTemplates = false"
                                                class="text-gray-400 hover:text-white transition-colors">
                                            <i class="fas fa-times text-xl"></i>
                                        </button>
                                    </div>
LiangLiu's avatar
LiangLiu committed
2946

LiangLiu's avatar
LiangLiu committed
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
                                    <!-- 标签页切换 -->
                                    <div class="flex border-b border-gray-700 mb-6">
                                            <button
                                                @click="mediaModalTab = 'history'; showImageTemplates && getImageHistory(); showAudioTemplates && getAudioHistory()"
                                                class="px-4 py-2 text-sm font-medium transition-colors" :class="mediaModalTab === 'history'
                                                    ? 'text-gradient-icon border-b-2 border-laser-purple'
                                                    : 'text-gray-400 hover:text-gray-300'">
                                            <i class="fas fa-history mr-2"></i>
                                                {{ t('history') }}
                                        </button>
                                        <button @click="mediaModalTab = 'templates'"
                                                class="px-4 py-2 text-sm font-medium transition-colors" :class="mediaModalTab === 'templates'
                                                    ? 'text-gradient-icon border-b-2 border-laser-purple'
                                                    : 'text-gray-400 hover:text-gray-300'">
                                            <i class="fas fa-layer-group mr-2"></i>
                                                {{ t('templates') }}
                                        </button>
                                    </div>
LiangLiu's avatar
LiangLiu committed
2965

LiangLiu's avatar
LiangLiu committed
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
                                    <!-- 图片历史记录 -->
                                          <div v-if="showImageTemplates && mediaModalTab === 'history'"
                                             class="overflow-y-auto flex-1 max-h-[60vh] main-scrollbar">
                                            <div v-if="imageHistory.length === 0"
                                                class="flex flex-col items-center justify-center py-12 text-center">
                                                <div
                                                    class="w-16 h-auto bg-laser-purple/20 rounded-full flex items-center justify-center mb-4">
                                                <i class="fas fa-history text-gradient-icon text-2xl"></i>
                                            </div>
                                                <p class="text-gray-400 text-lg mb-2">{{ t('noHistoryRecords') }}</p>
                                                <p class="text-gray-500 text-sm">{{ t('imageHistoryAutoSave') }}</p>
                                        </div>
                                        <div v-else class="space-y-3">
                                            <div class="flex items-center justify-between mb-4">
                                                    <span class="text-sm text-gray-400">{{ t('total') }} {{ imageHistory.length }}
                                                        {{ t('records') }}</span>
                                                <button @click="clearImageHistory"
                                                        class="text-xs text-red-400 hover:text-red-300 transition-colors flex items-center gap-1"
                                                        :title="t('clearHistory')">
                                                    <i class="fas fa-trash"></i>
                                                        {{ t('clear') }}
                                                </button>
                                            </div>
                                            <div class="columns-2 md:columns-3 lg:columns-4 xl:columns-5 gap-4">
                                                <div v-for="(history, index) in imageHistory" :key="index"
                                                    @click="selectImageHistory(history)"
                                                    class="break-inside-avoid mb-4 relative group cursor-pointer rounded-lg overflow-hidden border border-gray-700 hover:border-laser-purple/50 transition-all">
                                                        <img :src="getHistoryImageUrl(history)" :alt="history.filename"
                                                            class="w-full h-auto object-contain">
                                                        <div
                                                            class="absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center">
                                                        <i class="fas fa-check text-white text-xl"></i>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
LiangLiu's avatar
LiangLiu committed
3003

LiangLiu's avatar
LiangLiu committed
3004
3005
                                     <!-- 图片模板网格 -->
                                         <div v-if="showImageTemplates && mediaModalTab === 'templates'">
LiangLiu's avatar
LiangLiu committed
3006

LiangLiu's avatar
LiangLiu committed
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
                                            <!-- 图片模板分页组件 -->
                                            <div v-if="templatePaginationInfo" class="pagination-container mt-4">
                                                <div class="flex items-center justify-between text-xs text-gray-400">
                                                    <div class="flex items-center space-x-1 text-gray-500">
                                                        <span>{{ t('total') }} {{ templatePaginationInfo.total }} {{ t('records') }}</span>
                                                    </div>
                                                    <div v-if="templatePaginationInfo.total_pages > 1"
                                                        class="flex items-center space-x-2">
                                                        <!-- 上一页按钮 -->
                                                        <button @click="goToTemplatePage(templateCurrentPage - 1)"
                                                            :disabled="templateCurrentPage <= 1"
                                                            class="pagination-btn-compact"
                                                            :class="{ 'disabled': templateCurrentPage <= 1 }"
                                                            :title="t('previousPage')">
                                                            <i class="fas fa-chevron-left text-xs"></i>
                                                        </button>

                                                        <!-- 页码按钮 -->
                                                        <template v-for="page in getVisibleTemplatePages()" :key="page">
                                                            <button v-if="page !== '...'"
                                                                @click="goToTemplatePage(page)" :class="[
                                                                'pagination-btn-compact',
                                                                { 'active': page === templateCurrentPage }
                                                            ]">
                                                                {{ page }}
                                                            </button>
                                                            <span v-else class="text-gray-500">...</span>
                                                        </template>

                                                        <!-- 页码输入框 -->
                                                        <div class="flex items-center space-x-1">
                                                            <input v-model="templatePageInput"
                                                                @keyup.enter="jumpToTemplatePage"
                                                                @blur="jumpToTemplatePage" type="number" :min="1"
                                                                :max="templatePaginationInfo.total_pages"
                                                                class="page-input" :title="t('jumpToPage')" />
                                                            <span class="text-gray-500">/</span>
                                                            <span class="text-gray-500">{{
                                                                templatePaginationInfo.total_pages }}</span>
                                                        </div>

                                                        <!-- 下一页按钮 -->
                                                        <button @click="goToTemplatePage(templateCurrentPage + 1)"
                                                            :disabled="templateCurrentPage >= templatePaginationInfo.total_pages"
                                                            class="pagination-btn-compact"
                                                            :class="{ 'disabled': templateCurrentPage >= templatePaginationInfo.total_pages }"
                                                            :title="t('nextPage')">
                                                            <i class="fas fa-chevron-right text-xs"></i>
                                                        </button>
                                                    </div>
                                                </div>
                                            </div>
                                         <div class="overflow-y-auto flex-1 max-h-[60vh] main-scrollbar">
LiangLiu's avatar
LiangLiu committed
3060
                                         <div v-if="imageTemplates.length > 0" class="columns-2 sm:columns-2 md:columns-3 lg:columns-4 xl:columns-5 gap-4">
LiangLiu's avatar
LiangLiu committed
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
                                            <div v-for="template in imageTemplates" :key="template.filename"
                                                @click="selectImageTemplate(template)"
                                                class="break-inside-avoid mb-4 relative group cursor-pointer rounded-lg border border-gray-700 hover:border-laser-purple/50 transition-all">
                                                    <img :src="getTemplateFileUrl(template.filename,'images')" :alt="template.filename"
                                                    class="w-full h-auto object-contain" preload="metadata">
                                                    <div
                                                        class="absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center">
                                                    <i class="fas fa-check text-white text-2xl"></i>
                                                </div>
                                            </div>
LiangLiu's avatar
LiangLiu committed
3071
                                        </div>
LiangLiu's avatar
LiangLiu committed
3072
3073
3074
3075
3076
3077
3078
                                            <div v-else
                                                class="flex flex-col items-center justify-center py-12 text-center">
                                                <div
                                                    class="w-16 h-16 bg-laser-purple/20 rounded-full flex items-center justify-center mb-4">
                                                <i class="fas fa-image text-gradient-icon text-2xl"></i>
                                            </div>
                                                <p class="text-gray-400 text-lg mb-2">{{ t('noImageTemplates') }}</p>
LiangLiu's avatar
LiangLiu committed
3079
3080
                                        </div>
                                    </div>
LiangLiu's avatar
LiangLiu committed
3081

LiangLiu's avatar
LiangLiu committed
3082
3083
                                    </div>

LiangLiu's avatar
LiangLiu committed
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
                                    <!-- 音频历史记录 -->
                                          <div v-if="showAudioTemplates && mediaModalTab === 'history'"
                                             class="overflow-y-auto flex-1 max-h-[60vh] main-scrollbar">
                                            <div v-if="audioHistory.length === 0"
                                                class="flex flex-col items-center justify-center py-12 text-center">
                                                <div
                                                    class="w-16 h-16 bg-laser-purple/20 rounded-full flex items-center justify-center mb-4">
                                                <i class="fas fa-history text-gradient-icon text-2xl"></i>
                                            </div>
                                                <p class="text-gray-400 text-lg mb-2">{{ t('noHistoryRecords') }}</p>
                                                <p class="text-gray-500 text-sm">{{ t('audioHistoryAutoSave') }}</p>
LiangLiu's avatar
LiangLiu committed
3095
                                        </div>
LiangLiu's avatar
LiangLiu committed
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
                                        <div v-else class="space-y-3">
                                            <div class="flex items-center justify-between mb-4">
                                                    <span class="text-sm text-gray-400">共 {{ audioHistory.length }}
                                                        {{ t('records') }}</span>
                                                <button @click="clearAudioHistory"
                                                        class="text-xs text-red-400 hover:text-red-300 transition-colors flex items-center gap-1"
                                                        :title="t('clearHistory')">
                                                    <i class="fas fa-trash"></i>
                                                        {{ t('clear') }}
                                                </button>
                                            </div>
                                            <div class="space-y-3">
                                                <div v-for="(history, index) in audioHistory" :key="index"
                                                    @click="selectAudioHistory(history)"
                                                    class="flex items-center gap-4 p-4 rounded-lg border border-gray-700 hover:border-laser-purple/50 transition-all cursor-pointer bg-dark-light/50 group">
                                                        <div
                                                            class="w-12 h-12 bg-laser-purple/20 rounded-lg flex items-center justify-center">
                                                        <i class="fas fa-music text-gradient-icon text-xl"></i>
                                                    </div>
                                                    <div class="flex-1">
                                                            <div
                                                                class="text-white font-medium group-hover:text-gradient-icon transition-colors">
                                                                {{ history.filename }}</div>
                                                            <div class="text-gray-400 text-sm">{{ t('audioFile') }}</div>
                                                    </div>
                                                    <button @click.stop="previewAudioHistory(history)"
                                                            class="px-3 py-2 bg-laser-purple/20 hover:bg-laser-purple/30 text-gradient-icon rounded-lg transition-all">
                                                        <i class="fas fa-play mr-2"></i>
                                                            {{ t('preview') }}
                                                    </button>
                                                </div>
                                            </div>
LiangLiu's avatar
LiangLiu committed
3128
3129
                                        </div>
                                    </div>
LiangLiu's avatar
LiangLiu committed
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216

                                    <!-- 音频模板列表 -->
                                          <div v-if="showAudioTemplates && mediaModalTab === 'templates'">
                                                                                    <!-- 音频模板分页组件 -->
                                                                                    <div v-if="templatePaginationInfo" class="pagination-container mt-4">
                                                                                        <div class="flex items-center justify-between text-xs text-gray-400">
                                                                                            <div class="flex items-center space-x-1 text-gray-500">
                                                                                                <span>{{ templatePaginationInfo.total }} {{ t('records') }}</span>
                                                                            </div>
                                                                                            <div v-if="templatePaginationInfo.total_pages > 1"
                                                                                                class="flex items-center space-x-2">
                                                                                                <!-- 上一页按钮 -->
                                                                                                <button @click="goToTemplatePage(templateCurrentPage - 1)"
                                                                                                    :disabled="templateCurrentPage <= 1"
                                                                                                    class="pagination-btn-compact"
                                                                                                    :class="{ 'disabled': templateCurrentPage <= 1 }"
                                                                                                    :title="t('previousPage')">
                                                                                                    <i class="fas fa-chevron-left text-xs"></i>
                                                                                                </button>

                                                                                                <!-- 页码按钮 -->
                                                                                                <template v-for="page in getVisibleTemplatePages()" :key="page">
                                                                                                    <button v-if="page !== '...'"
                                                                                                        @click="goToTemplatePage(page)" :class="[
                                                                                                        'pagination-btn-compact',
                                                                                                        { 'active': page === templateCurrentPage }
                                                                                                    ]">
                                                                                                        {{ page }}
                                                                                                    </button>
                                                                                                    <span v-else class="text-gray-500">...</span>
                                                                                                </template>

                                                                                                <!-- 页码输入框 -->
                                                                                                <div class="flex items-center space-x-1">
                                                                                                    <input v-model="templatePageInput"
                                                                                                        @keyup.enter="jumpToTemplatePage"
                                                                                                        @blur="jumpToTemplatePage" type="number" :min="1"
                                                                                                        :max="templatePaginationInfo.total_pages"
                                                                                                        class="page-input" :title="t('jumpToPage')" />
                                                                                                    <span class="text-gray-500">/</span>
                                                                                                    <span class="text-gray-500">{{
                                                                                                        templatePaginationInfo.total_pages }}</span>
                                                                                                </div>

                                                                                                <!-- 下一页按钮 -->
                                                                                                <button @click="goToTemplatePage(templateCurrentPage + 1)"
                                                                                                    :disabled="templateCurrentPage >= templatePaginationInfo.total_pages"
                                                                                                    class="pagination-btn-compact"
                                                                                                    :class="{ 'disabled': templateCurrentPage >= templatePaginationInfo.total_pages }"
                                                                                                    :title="t('nextPage')">
                                                                                                    <i class="fas fa-chevron-right text-xs"></i>
                                                                                                </button>
                                                                                            </div>
                                                                                        </div>
                                                                                    </div>
                                        <div class="overflow-y-auto flex-1 max-h-[60vh] main-scrollbar">
                                        <div v-if="audioTemplates.length > 0" class="space-y-3">
                                            <div v-for="template in audioTemplates" :key="template.filename"
                                                @click="selectAudioTemplate(template)"
                                                class="flex items-center gap-4 p-4 rounded-lg border border-gray-700 hover:border-laser-purple/50 transition-all cursor-pointer bg-dark-light/50">
                                                    <div
                                                        class="w-12 h-12 bg-laser-purple/20 rounded-lg flex items-center justify-center">
                                                    <i class="fas fa-music text-gradient-icon text-xl"></i>
                                                </div>
                                                <div class="flex-1">
                                                        <div class="text-white font-medium">{{ template.filename }}
                                                        </div>
                                                        <div class="text-gray-400 text-sm">{{ t('audioTemplates') }}</div>
                                                </div>
                                                <button @click.stop="previewAudioTemplate(template)"
                                                        class="px-3 py-2 bg-laser-purple/20 hover:bg-laser-purple/30 text-gradient-icon rounded-lg transition-all">
                                                    <i class="fas fa-play mr-2"></i>
                                                        {{ t('preview') }}
                                                </button>
                                            </div>
                                        </div>
                                            <div v-else
                                                class="flex flex-col items-center justify-center py-12 text-center">
                                                <div
                                                    class="w-16 h-16 bg-laser-purple/20 rounded-full flex items-center justify-center mb-4">
                                                <i class="fas fa-music text-gradient-icon text-2xl"></i>
                                            </div>
                                            <p class="text-gray-400 text-lg mb-2">目前暂无音频模板</p>
                                        </div>
                                        </div>

                                        </div>
LiangLiu's avatar
LiangLiu committed
3217
3218
                                </div>
                        </div>
LiangLiu's avatar
LiangLiu committed
3219
3220
                    </div>

LiangLiu's avatar
LiangLiu committed
3221

LiangLiu's avatar
LiangLiu committed
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
                        <!-- 任务创建面板 -->
                        <div class="max-w-4xl mx-auto" id="task-creator">
                            <!-- 合并的创作区域 -->
                            <div class="creation-area-container">

                                <div class="default-state-container">
                                    <!-- 两个并列的下拉菜单 -->
                                    <div class="flex justify-center gap-10 mb-6">
                                        <!-- 任务类型下拉菜单 -->
                                        <div class="task-type-dropdown">
                                            <div class="relative">
                                                <button @click="showTaskTypeMenu = !showTaskTypeMenu"
                                                    class="flex items-center gap-3 px-4 py-3 text-white hover:text-gradient-icon transition-all duration-200 text-sm min-w-[120px]"
                                                    :title="t('selectTaskType')">
                                                    <span class="text-sm">{{ getTaskTypeName(selectedTaskId) }}</span>
                                                    <i class="fas fa-chevron-down text-xs transition-transform duration-200 ml-auto"
                                                        :class="{ 'rotate-180': showTaskTypeMenu }"></i>
                                                </button>

                                                <!-- 任务类型选择下拉菜单 -->
                                                <div v-if="showTaskTypeMenu"
                                                    class="absolute top-full left-0 mt-2 bg-dark-light border border-laser-purple/30 rounded-lg shadow-lg z-50 min-w-[150px]"
                                                    @click.stop>
                                                    <div v-for="taskType in availableTaskTypes" :key="taskType"
                                                        @click="selectTask(taskType); showTaskTypeMenu = false"
                                                        class="flex items-center gap-3 px-4 py-3 hover:bg-laser-purple/20 cursor-pointer transition-colors duration-200 first:rounded-t-lg last:rounded-b-lg"
                                                        :class="{ 'bg-laser-purple/20': selectedTaskId === taskType }">
                                                        <i :class="getTaskTypeIcon(taskType)" class="text-sm"></i>
                                                        <span class="text-white text-sm">{{ getTaskTypeName(taskType) }}</span>
                                                        <i v-if="selectedTaskId === taskType"
                                                            class="fas fa-check text-laser-purple ml-auto"></i>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
LiangLiu's avatar
LiangLiu committed
3257

LiangLiu's avatar
LiangLiu committed
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
                                        <!-- 模型选择下拉菜单 -->
                                        <div class="model-dropdown">
                                            <div class="relative">
                                                <button @click="showModelMenu = !showModelMenu"
                                                    class="flex items-center gap-3 px-4 py-3 text-white hover:text-gradient-icon transition-all duration-200 text-sm min-w-[120px]"
                                                    :title="t('selectModel')">
                                                    <span class="text-sm">{{ getCurrentForm().model_cls || t('selectModel') }}</span>
                                                    <i class="fas fa-chevron-down text-xs transition-transform duration-200 ml-auto"
                                                        :class="{ 'rotate-180': showModelMenu }"></i>
                                                </button>

                                                <!-- 模型选择下拉菜单 -->
                                                <div v-if="showModelMenu"
                                                    class="absolute top-full left-0 mt-2 bg-dark-light border border-laser-purple/30 rounded-lg shadow-lg z-50 min-w-[150px] max-h-48 overflow-y-auto"
                                                    @click.stop>
                                                    <div v-if="availableModelClasses.length > 0">
                                                        <div v-for="modelCls in availableModelClasses" :key="modelCls"
                                                            @click="selectModel(modelCls); showModelMenu = false"
                                                            class="flex items-center gap-3 px-4 py-3 hover:bg-laser-purple/20 cursor-pointer transition-colors duration-200 first:rounded-t-lg last:rounded-b-lg"
                                                            :class="{ 'bg-laser-purple/20': getCurrentForm().model_cls === modelCls }">
                                                            <span class="text-white text-sm">{{ modelCls }}</span>
                                                            <i v-if="getCurrentForm().model_cls === modelCls"
                                                                class="fas fa-check text-laser-purple ml-auto text-xs"></i>
                                                        </div>
                                                    </div>
                                                    <div v-else class="px-4 py-3 text-center text-gray-500 text-xs">
                                                        {{ t('selectTaskTypeFirst') }}
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
LiangLiu's avatar
LiangLiu committed
3290

LiangLiu's avatar
LiangLiu committed
3291
3292
3293
3294
3295
3296
                                 <!-- 默认状态:中心文字 -->
                                <div v-show="!isCreationAreaExpanded" class="flex flex-col items-center justify-center h-[60vh]">

                                    <div class="text-center">

                                        <h2 class="text-4xl font-bold text-white mb-6">{{ t('whatDoYouWantToDo') }}</h2>
LiangLiu's avatar
LiangLiu committed
3297

LiangLiu's avatar
LiangLiu committed
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
                                        <!-- 动态滚动提示 -->
                                        <div class="hint-container mb-8 pb-10">
                                            <div class="hint-text text-gray-400 text-lg min-h-[60px] flex items-center justify-center">
                                                <transition name="hint-fade" mode="out-in">
                                                    <p :key="currentHintIndex" class="text-center">
                                                        {{ currentTaskHints[currentHintIndex] }}
                                                    </p>
                                                </transition>
                                            </div>
                                            <!-- 提示指示器 -->
                                            <div class="flex justify-center mt-4 space-x-2">
                                                <div v-for="(hint, index) in currentTaskHints" :key="index"
                                                    class="w-2 h-2 rounded-full transition-all duration-300"
                                                    :class="index === currentHintIndex ? 'bg-laser-purple' : 'bg-gray-600'">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
LiangLiu's avatar
LiangLiu committed
3316

LiangLiu's avatar
LiangLiu committed
3317
3318
                                    <!-- 展开开关 -->
                                    <div class="relative group cursor-pointer max-w-3/5" @click="expandCreationArea">
LiangLiu's avatar
LiangLiu committed
3319
                                        <button
LiangLiu's avatar
LiangLiu committed
3320
3321
3322
3323
                                            class="relative w-full max-h-[75px] bg-dark-light/80 border border-laser-purple/30 rounded-full pl-10 pr-10 py-6 text-base hover:border-laser-purple transition-all duration-300 resize-none hover:shadow-2xl"
                                        >
                                        <i class="fas fa-mouse-pointer text-lg text-gradient-icon transition-all duration-300 pointer-events-none group-hover:drop-shadow-[0_0_8px_rgba(168,85,247,0.6)] group-hover:animate-pulse"></i>
                                        <span class="pl-2 text-base font-bold text-gradient-icon transition-all duration-300 pointer-events-none group-hover:drop-shadow-[0_0_8px_rgba(168,85,247,0.6)] group-hover:animate-pulse">{{ t('startCreatingVideo') }}</span>
LiangLiu's avatar
LiangLiu committed
3324
                                        </button>
LiangLiu's avatar
LiangLiu committed
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366

                                        <!-- 装饰性边框 -->
                                        <div class="absolute inset-0 rounded-full border border-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300 pointer-events-none"></div>
                                    </div>
                                </div>

                                <!-- 展开状态:素材区域 -->
                                <div v-show="isCreationAreaExpanded" class="mb-8 prompt-input-section">
                                    <!-- 中心文字 -->
                                    <div class="text-center">

                                        <h2 class="text-4xl font-bold text-white mb-6 animate-fade-in">{{ t('whatMaterialsDoYouNeed') }}</h2>

                                        <p class="text-gray-400 text-lg mb-8 transition-all duration-300">
                                            <span v-if="selectedTaskId === 't2v'"
                                                  class="inline-block animate-fade-in">{{ t('pleaseEnterTheMostDetailedVideoScript') }}</span>
                                            <span v-else-if="selectedTaskId === 'i2v'"
                                                  class="inline-block animate-fade-in">{{ t('pleaseUploadAnImageAsTheFirstFrameOfTheVideoAndTheMostDetailedVideoScript') }}</span>
                                            <span v-else-if="selectedTaskId === 's2v'"
                                                  class="inline-block animate-fade-in">{{ t('pleaseUploadARoleImageAnAudioAndTheGeneralVideoRequirements') }}</span>
                                            <span v-else
                                                  class="inline-block animate-fade-in">选择任务类型开始创作您的视频</span>
                                        </p>
                                    </div>

                                                                    <!-- 收缩开关 -->

                                <div
                                    class="creation-area transition-all duration-500 ease-out max-w-10xl mx-auto"
                                    @click.stop>
                                    <!-- 收起按钮 -->
                                    <div class="flex justify-center mb-4">
                                        <button @click="contractCreationArea"
                                                class="flex items-center gap-2 px-4 py-2 text-gray-400 hover:text-laser-purple transition-all duration-300 hover:bg-laser-purple/10 rounded-lg group"
                                                :class="{ 'animate-pulse': isContracting }">
                                            <i class="fas fa-compress-alt text-sm transition-transform duration-200 group-hover:scale-110"
                                               :class="{ 'animate-spin': isContracting }"></i>
                                            <span class="text-sm font-medium">
                                                {{ t('collapseCreationArea') }}
                                            </span>
                                            <i class="fas fa-chevron-up text-xs transition-transform duration-200 group-hover:translate-y-[-2px]"
                                               :class="{ 'animate-bounce': isContracting }"></i>
LiangLiu's avatar
LiangLiu committed
3367
3368
                                        </button>
                                    </div>
LiangLiu's avatar
LiangLiu committed
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380

                                    <div v-if="selectedTaskId === 'i2v' || selectedTaskId === 's2v'" class="upload-section">
                                    <!-- 上传图片 -->
                                    <div v-if="selectedTaskId === 'i2v' || selectedTaskId === 's2v'">
                                        <!-- 图片历史和素材库 -->
                                        <div class="flex justify-between items-center mb-2">
                                                <label class="block text-sm text-gray-400 flex items-center">
                                                                {{ t('image') }}
                                                </label>
                                        </div>
                                        <!-- 上传图片 -->
                                        <div class="upload-area"
LiangLiu's avatar
LiangLiu committed
3381
                                            >
LiangLiu's avatar
LiangLiu committed
3382
3383
                                            <!-- 默认上传界面 -->
                                            <div v-if="!getCurrentImagePreview()" class="upload-content">
LiangLiu's avatar
LiangLiu committed
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
                                            <p class="text-base text-white font-bold mb-4">{{ t('uploadImage') }}</p>
                                            <p class="text-xs text-gray-400 mb-4">{{ t('supportedImageFormats') }}</p>
                                            <div class="flex items-center justify-center space-x-6">
                                                        <div class="flex flex-col items-center space-y-2">
                                                            <button
                                                                class="w-12 h-12 flex items-center justify-center bg-white/15 text-white p-3 rounded-full transition-all duration-200 hover:scale-110 shadow-lg"
                                                                @click="triggerImageUpload"
                                                                :title="t('uploadImage')">
                                                                <i class="fas fa-upload text-lg"></i>
                                                            </button>
                                                            <span class="text-xs text-gray-300">{{ t('upload') }}</span>
                                                        </div>
                                                        <div class="flex flex-col items-center space-y-2">
                                                            <button
                                                                @click.stop="showImageTemplates = true; mediaModalTab = 'history'; getImageHistory()"
                                                                class="w-12 h-12 flex items-center justify-center bg-white/15 text-white p-3 rounded-full transition-all duration-200 hover:scale-110 shadow-lg"
                                                                :title="t('templates')">
                                                                <i class="fas fa-history text-lg"></i>
                                                            </button>
                                                            <span class="text-xs text-gray-300">{{ t('templates') }}</span>
                                                        </div>
LiangLiu's avatar
LiangLiu committed
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
                                            </div>
                                            </div>

                                            <!-- 图片预览 -->
                                            <div v-if="getCurrentImagePreview()" class="image-preview group">
                                                    <img :src="getCurrentImagePreviewUrl()" alt="t('previewImage')"
                                                        class="w-full h-full object-cover rounded-lg transition-all duration-300 group-hover:brightness-50">

                                                <!-- 悬停时显示的操作按钮,位置在中下方 -->
                                                    <div
LiangLiu's avatar
LiangLiu committed
3415
                                                        class="absolute inset-x-0 bottom-4 flex items-center justify-center opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-opacity duration-300">
LiangLiu's avatar
LiangLiu committed
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
                                                    <div class="flex space-x-3">
                                                            <button @click.stop="triggerImageUpload"
                                                            class="w-12 h-12 flex items-center justify-center bg-white/15 text-white p-3 rounded-full transition-all duration-200 hover:scale-110 shadow-lg"
                                                                :title="t('reupload')">
                                                            <i class="fas fa-upload text-lg"></i>
                                                        </button>
                                                            <button @click.stop="removeImage"
                                                            class="w-12 h-12 flex items-center justify-center bg-white/15 text-white p-3 rounded-full transition-all duration-200 hover:scale-110 shadow-lg"
                                                                :title="t('deleteImage')">
                                                            <i class="fas fa-trash text-lg"></i>
                                                        </button>
                                                    </div>
                                                </div>
                                            </div>
                                                <input type="file" ref="imageInput" @change="handleImageUpload" accept="image/*"
                                                style="display: none;">
                                            </div>
                                    </div>

                                    <!-- 上传音频 -->
                                    <div v-if="selectedTaskId === 's2v'">
                                        <!-- 音频历史和素材库 -->
                                        <div class="flex justify-between items-center mb-2">
                                                        <label class="block text-sm text-gray-400 flex items-center">
                                                                        {{ t('audio') }}
                                                        </label>
                                        </div>
                                        <!-- 上传音频 -->
                                        <div class="upload-area">
                                        <!-- 默认上传界面 -->
                                            <div v-if="!getCurrentAudioPreview()" class="upload-content"
LiangLiu's avatar
LiangLiu committed
3447
3448
                                                >
                                                <p class="text-base text-white font-bold mb-4">{{ t('uploadAudio') }}</p>
LiangLiu's avatar
LiangLiu committed
3449
                                                <p class="text-xs text-gray-400 mb-4">{{ t('supportedAudioFormats') }}</p>
LiangLiu's avatar
LiangLiu committed
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
                                            <div class="flex items-center justify-center space-x-6">
                                                    <div class="flex flex-col items-center space-y-2">
                                                        <button
                                                            @click.stop="showAudioTemplates = true; mediaModalTab = 'history'; getAudioHistory()"
                                                            class="w-12 h-12 flex items-center justify-center bg-white/15 text-white p-3 rounded-full transition-all duration-200 hover:scale-110 shadow-lg"
                                                            :title="t('templates')">
                                                            <i class="fas fa-history text-lg"></i>
                                                        </button>
                                                        <span class="text-xs text-gray-300">{{ t('templates') }}</span>
                                                    </div>
                                                    <div class="flex flex-col items-center space-y-2">
                                                        <button
                                                            class="w-12 h-12 flex items-center justify-center bg-white/15 text-white p-3 rounded-full transition-all duration-200 hover:scale-110 shadow-lg"
                                                            @click="triggerAudioUpload"
                                                            :title="t('uploadAudio')">
                                                            <i class="fas fa-upload text-lg"></i>
                                                        </button>
                                                        <span class="text-xs text-gray-300">{{ t('upload') }}</span>
                                                    </div>
                                                    <div class="flex flex-col items-center space-y-2">
                                                        <button
                                                            @click.stop="isRecording ? stopRecording() : startRecording()"
                                                            class="w-12 h-12 flex items-center justify-center bg-white/15 text-white p-3 rounded-full transition-all duration-200 hover:scale-110 shadow-lg"
                                                            :class="{ 'bg-red-500/80': isRecording }"
                                                            :title="isRecording ? t('stopRecording') : t('recordAudio')">
                                                            <i class="fas fa-microphone text-lg" :class="{ 'animate-pulse': isRecording }"></i>
                                                        </button>
                                                        <span class="text-xs text-gray-300">{{ t('recordAudio') }}</span>
                                                    </div>
                                                    <div v-if="isRecording && recordingDuration > 0" class="flex flex-col items-center space-y-2">
                                                        <div class="text-white text-xs font-medium bg-black/20 px-2 py-1 rounded-full">
                                                            {{ formatRecordingDuration(recordingDuration) }}
                                                        </div>
                                                        <span class="text-xs text-gray-300">{{ t('recording') }}</span>
                                                    </div>
LiangLiu's avatar
LiangLiu committed
3485
3486
3487
3488
3489
                                        </div>
                                            </div>

                                        <!-- 音频预览 -->
                                            <div v-if="getCurrentAudioPreview()" class="audio-preview group">
LiangLiu's avatar
LiangLiu committed
3490
                                            <audio controls class="w-full h-full" @error="handleAudioError" @loadstart="console.log('音频开始加载')" @canplay="console.log('音频可以播放')">
LiangLiu's avatar
LiangLiu committed
3491
3492
3493
3494
3495
                                                    <source :src="getCurrentAudioPreviewUrl()" :type="getAudioMimeType()" preload="metadata">
                                            </audio>

                                            <!-- 悬停时显示的操作按钮,位置在中下方 -->
                                                <div
LiangLiu's avatar
LiangLiu committed
3496
                                                    class="absolute inset-x-0 bottom-4 flex items-center justify-center opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-opacity duration-300">
LiangLiu's avatar
LiangLiu committed
3497
3498
3499
3500
3501
                                                <div class="flex space-x-3">
                                                        <button @click.stop="triggerAudioUpload"
                                                        class="w-12 h-12 flex items-center justify-center bg-white/15 text-white p-3 rounded-full transition-all duration-200 hover:scale-110 shadow-lg"
                                                            :title="t('reupload')">
                                                        <i class="fas fa-upload text-lg"></i>
LiangLiu's avatar
LiangLiu committed
3502
3503
3504
3505
3506
3507
                                                    </button>
                                                        <button @click.stop="isRecording ? stopRecording() : startRecording()"
                                                        class="w-12 h-12 flex items-center justify-center bg-white/15 text-white p-3 rounded-full transition-all duration-200 hover:scale-110 shadow-lg"
                                                            :title="isRecording ? t('stopRecording') : t('recordAudio')"
                                                            :class="{ 'bg-red-500/80': isRecording }">
                                                        <i class="fas fa-microphone text-lg" :class="{ 'animate-pulse': isRecording }"></i>
LiangLiu's avatar
LiangLiu committed
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
                                                    </button>
                                                        <button @click.stop="removeAudio"
                                                        class="w-12 h-12 flex items-center justify-center bg-white/15 text-white p-3 rounded-full transition-all duration-200 hover:scale-110 shadow-lg"
                                                            :title="t('deleteAudio')">
                                                        <i class="fas fa-trash text-lg"></i>
                                                    </button>
                                                </div>
                                            </div>
                                            </div>

                                            <input type="file" ref="audioInput" @change="handleAudioUpload" accept="audio/*"
                                            style="display: none;">
                                        </div>
                                    </div>
                                </div>

                                        <!-- 提示词输入区域 -->
                                        <div class="flex justify-between items-center mb-2">
                                            <label class="block text-sm text-gray-400 flex items-center">
                                                    {{ t('prompt') }}
                                                    <button @click="showPromptModal = true; promptModalTab = 'templates'"
                                                        class="text-xs text-gray-400 hover:text-gradient-icon transition-colors pl-3"
                                                        :title="t('promptTemplates')">
                                                    <i class="fas fa-lightbulb"></i>
                                                </button>
                                            </label>
                                            <div class="text-xs text-gray-400">
LiangLiu's avatar
LiangLiu committed
3535
                                                {{ getCurrentForm().prompt?.length || 0 }} / 1000
LiangLiu's avatar
LiangLiu committed
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
                                            </div>
                                        </div>
                                        <div class="relative group cursor-pointer">
                                            <textarea v-model="getCurrentForm().prompt"
                                                class="relative w-full bg-dark-light/80 border border-laser-purple/30 rounded-xl p-6 text-base min-h-[100px] focus:ring-1 transition-all duration-300 resize-none scrollbar-thin focus:shadow-2x placeholder-gray-500"
                                                :placeholder="getPromptPlaceholder()"
                                                rows="4"
                                                maxlength="500"
                                                required></textarea>

                                            <!-- 装饰性边框 -->
                                            <div class="absolute inset-0 rounded-xl border border-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300 pointer-events-none"></div>
                                        </div>

                                        <div class="flex justify-between items-center">
                                            <button @click="clearPrompt"
                                                class="flex items-center text-sm rounded-lg px-2 transition-all duration-200 text-gray-400 hover:text-laser-purple hover:bg-laser-purple/10 group">
                                                <i class="fas fa-sync-alt text-sm mr-2 group-hover:rotate-180 transition-transform duration-300"></i>
                                                {{ t('clear') }}
                                            </button>

                                        </div>
                                <!-- 提交按钮 -->
                                <div class="flex justify-center mt-2">
                                    <button @click="submitTask" :disabled="submitting"
                                        class="btn-primary flex items-center justify-center px-8 py-3 rounded-lg text-lg transition-all shadow-lg">
LiangLiu's avatar
LiangLiu committed
3562
3563
3564

                                        <i class="fas fa-spinner fa-spin text-xl mr-2" :class="{ 'hidden': !submitting }"></i>
                                        <i class="fas fa-play text-xl mr-2" :class="{ 'hidden': submitting }"></i>
LiangLiu's avatar
LiangLiu committed
3565
3566
3567
3568
3569
3570
                                        {{ submitting ? t('submitting') : t('generateVideo') }}
                                    </button>
                                </div>

                                </div>

LiangLiu's avatar
LiangLiu committed
3571
                                </div>
LiangLiu's avatar
LiangLiu committed
3572

LiangLiu's avatar
LiangLiu committed
3573
3574
                            </div>

LiangLiu's avatar
LiangLiu committed
3575
3576
                </div>

LiangLiu's avatar
LiangLiu committed
3577
                        </div>
LiangLiu's avatar
LiangLiu committed
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
                </div>
                </div>
                        <!-- 灵感广场区域 -->
                        <div v-if="currentView === 'inspiration'" class="flex-1 flex flex-col min-h-0 mobile-content">
                            <!-- 内容区域 -->
                            <div class="flex-1 overflow-y-auto p-6 content-area main-scrollbar">
                                <!-- 灵感广场功能区 -->
                                <div class="max-w-4xl mx-auto" id="inspiration-gallery">
                                    <!-- 固定功能区 -->
                                    <div class="flex-shrink-0 p-1">
                                        <!-- 标题区域 -->
                                        <div class="text-center mb-8">
                                                <h1 class="text-3xl font-bold text-white mb-2">{{ t('inspiration') }}</h1>
                                                <p class="text-gray-400">{{ t('discoverCreativity') }}</p>
                                        </div>
LiangLiu's avatar
LiangLiu committed
3593

LiangLiu's avatar
LiangLiu committed
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
                                        <!-- 搜索和筛选区域 -->
                                        <div class="flex flex-col md:flex-row gap-4 mb-6">
                                            <!-- 搜索框 -->
                                            <div class="relative flex-1">
                                                    <i
                                                        class="fas fa-search absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none z-10"></i>
                                                    <input v-model="inspirationSearchQuery"
                                                    @keyup.enter="handleInspirationSearch"
                                                    @input="handleInspirationSearch"
                                                    class="w-full bg-dark-light border border-laser-purple/30 rounded-lg py-3 pl-10 pr-4 text-sm focus:outline-none focus:ring-2 focus:ring-laser-purple/50 transition-all focus:border-laser focus:shadow-laser"
                                                        :placeholder="t('searchInspiration')" type="text" />
                                            </div>
LiangLiu's avatar
LiangLiu committed
3606

LiangLiu's avatar
LiangLiu committed
3607
3608
                                            <!-- 分类筛选 -->
                                                <div class="flex gap-2 flex-wrap">
LiangLiu's avatar
LiangLiu committed
3609
3610
3611
                                                    <button v-for="category in InspirationCategories" :key="category"
                                                    @click="selectInspirationCategory(category)"
                                                    :class="selectedInspirationCategory === category
LiangLiu's avatar
LiangLiu committed
3612
3613
3614
                                                        ? 'bg-laser-purple/20 text-white border-laser-purple/40'
                                                        : 'bg-dark-light text-gray-400 hover:text-white hover:bg-dark-light/80'"
                                                        class="px-4 py-2 rounded-lg border border-transparent transition-all duration-200 text-sm font-medium">
LiangLiu's avatar
LiangLiu committed
3615
                                                    {{ category }}
LiangLiu's avatar
LiangLiu committed
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
                                                </button>
                                            </div>
                                        </div>
                      <!-- 灵感广场分页组件 -->
                                        <div v-if="inspirationPaginationInfo" class="pagination-container mt-8">
                                                <div class="flex items-center justify-between text-xs text-gray-400">
                                                    <div class="flex items-center space-x-1 text-gray-500">
                                                        <span>{{ inspirationPaginationInfo.total }} {{ t('records') }}</span>
                                        </div>
                                                    <div v-if="inspirationPaginationInfo.total_pages > 1"
                                                        class="flex items-center space-x-2">
                                                        <!-- 上一页按钮 -->
                                                        <button @click="goToInspirationPage(inspirationCurrentPage - 1)"
                                                            :disabled="inspirationCurrentPage <= 1"
                                                            class="pagination-btn-compact"
                                                            :class="{ 'disabled': inspirationCurrentPage <= 1 }" :title="t('previousPage')">
                                                            <i class="fas fa-chevron-left text-xs"></i>
                                                        </button>

                                                        <!-- 页码按钮 -->
                                                        <template v-for="page in getVisibleInspirationPages()" :key="page">
                                                            <button v-if="page !== '...'" @click="goToInspirationPage(page)"
                                                                :class="[
                                                                'pagination-btn-compact',
                                                                { 'active': page === inspirationCurrentPage }
                                                            ]">
                                                                {{ page }}
                                                        </button>
                                                            <span v-else class="text-gray-500">...</span>
                                                        </template>

                                                        <!-- 页码输入框 -->
                                                        <div class="flex items-center space-x-1">
                                                            <input v-model="inspirationPageInput"
                                                                @keyup.enter="jumpToInspirationPage"
                                                                @blur="jumpToInspirationPage" type="number" :min="1"
                                                                :max="inspirationPaginationInfo.total_pages" class="page-input"
                                                                :title="t('jumpToPage')">
                                                            <span class="text-gray-500">/</span>
                                                            <span class="text-gray-500">{{ inspirationPaginationInfo.total_pages
                                                                }}</span>
                                                        </div>

                                                        <!-- 下一页按钮 -->
                                                        <button @click="goToInspirationPage(inspirationCurrentPage + 1)"
                                                            :disabled="inspirationCurrentPage >= inspirationPaginationInfo.total_pages"
                                                            class="pagination-btn-compact"
                                                            :class="{ 'disabled': inspirationCurrentPage >= inspirationPaginationInfo.total_pages }"
                                                            :title="t('nextPage')">
                                                            <i class="fas fa-chevron-right text-xs"></i>
                                                        </button>
                                                    </div>
                                                </div>
                                        </div>
                                        <!-- 灵感内容网格 -->
LiangLiu's avatar
LiangLiu committed
3671
                                        <div class="flex-1 overflow-y-auto main-scrollbar min-h-0 p-4"
LiangLiu's avatar
LiangLiu committed
3672
                                        style="overflow-x: visible;">
LiangLiu's avatar
LiangLiu committed
3673
                                        <div class="columns-2 md:columns-3 lg:columns-4 xl:columns-5 gap-3">
LiangLiu's avatar
LiangLiu committed
3674
                                            <!-- 灵感卡片 -->
LiangLiu's avatar
LiangLiu committed
3675
3676
                                            <div v-for="item in inspirationItems" :key="item.task_id"
                                                    class="break-inside-avoid mb-3 group relative bg-dark-light rounded-xl overflow-hidden border border-gray-700/50 hover:border-laser-purple/40 transition-all duration-300 hover:shadow-laser/20">
LiangLiu's avatar
LiangLiu committed
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
                                                <!-- 视频缩略图区域 -->
                                                <div class="cursor-pointer bg-gray-800 relative flex flex-col"
                                                @click="previewTemplateDetail(item)"
                                                :title="t('viewTemplateDetail')">
                                                        <!-- 视频预览 -->
                                                        <video v-if="item?.outputs?.output_video"
                                                            :src="getTemplateFileUrl(item.outputs.output_video,'videos')"
                                                            :poster="getTemplateFileUrl(item.inputs.input_image,'images')"
                                                            class="w-full h-auto object-contain group-hover:scale-105 transition-transform duration-300"
                                                            preload="auto" playsinline webkit-playsinline
                                                            @mouseenter="playVideo($event)" @mouseleave="pauseVideo($event)"
                                                            @loadeddata="onVideoLoaded($event)"
LiangLiu's avatar
LiangLiu committed
3689
                                                            @ended="onVideoEnded($event)"
LiangLiu's avatar
LiangLiu committed
3690
3691
                                                            @error="onVideoError($event)"></video>
                                                    <!-- 图片缩略图 -->
LiangLiu's avatar
LiangLiu committed
3692
                                                        <img v-else
LiangLiu's avatar
LiangLiu committed
3693
3694
3695
3696
                                                        :src="getTemplateFileUrl(item.inputs.input_image,'images')"
                                                        :alt="item.params?.prompt || '模板图片'"
                                                        class="w-full h-auto object-contain group-hover:scale-105 transition-transform duration-300"
                                                        @error="handleThumbnailError" />
LiangLiu's avatar
LiangLiu committed
3697
3698
3699
3700
3701
3702
3703
                                                        <!-- 移动端播放按钮 -->
                                                        <button v-if="item?.outputs?.output_video"
                                                            @click.stop="toggleVideoPlay($event)"
                                                            class="md:hidden absolute bottom-3 left-1/2 transform -translate-x-1/2 w-10 h-10 rounded-full bg-black/50 backdrop-blur-sm flex items-center justify-center text-white hover:bg-black/70 transition-colors z-20">
                                                            <i class="fas fa-play text-sm"></i>
                                                        </button>
                                                    <!-- 悬浮操作按钮(下方居中,仅桌面端) -->
LiangLiu's avatar
LiangLiu committed
3704
                                                    <div
LiangLiu's avatar
LiangLiu committed
3705
                                                        class="hidden md:flex absolute bottom-3 left-1/2 transform -translate-x-1/2 items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none z-10 w-full">
LiangLiu's avatar
LiangLiu committed
3706
                                                        <div class="flex space-x-3 pointer-events-auto">
LiangLiu's avatar
LiangLiu committed
3707
3708
                                                            <button @click.stop="applyTemplateImage(item)"
                                                                class="w-10 h-10 rounded-full bg-laser-purple backdrop-blur-sm flex items-center justify-center text-white hover:bg-laser-purple transition-colors"
LiangLiu's avatar
LiangLiu committed
3709
3710
3711
                                                                :title="t('applyImage')">
                                                                <i class="fas fa-image text-sm"></i>
                                                            </button>
LiangLiu's avatar
LiangLiu committed
3712
3713
                                                            <button @click.stop="applyTemplateAudio(item)"
                                                                class="w-10 h-10 rounded-full bg-laser-purple backdrop-blur-sm flex items-center justify-center text-white hover:bg-laser-purple transition-colors"
LiangLiu's avatar
LiangLiu committed
3714
3715
3716
                                                                :title="t('applyAudio')">
                                                                <i class="fas fa-music text-sm"></i>
                                                            </button>
LiangLiu's avatar
LiangLiu committed
3717
3718
                                                            <button @click.stop="useTemplate(item)"
                                                                class="w-10 h-10 rounded-full bg-laser-purple backdrop-blur-sm flex items-center justify-center text-white hover:bg-laser-purple transition-colors"
LiangLiu's avatar
LiangLiu committed
3719
3720
3721
3722
3723
3724
3725
                                                                :title="t('useTemplate')">
                                                                <i class="fas fa-clone text-sm"></i>
                                                            </button>
                                                        </div>
                                                    </div>

                                    </div>
LiangLiu's avatar
LiangLiu committed
3726
3727
3728
3729

                                    </div>
                                </div>
                            </div>
LiangLiu's avatar
LiangLiu committed
3730
3731
3732
3733
                        </div>
                        </div>
                </div>
        </div>
LiangLiu's avatar
LiangLiu committed
3734

LiangLiu's avatar
LiangLiu committed
3735
        </div>
LiangLiu's avatar
LiangLiu committed
3736

LiangLiu's avatar
LiangLiu committed
3737
3738
3739
3740
3741
3742

        <!-- 自定义确认对话框 -->
         <div v-cloak>
        <div v-if="confirmDialog.show" class="fixed inset-0 z-50 flex items-center justify-center p-4">
            <!-- 背景遮罩 -->
                    <div class="absolute inset-0 bg-black/60 backdrop-blur-sm" @click="confirmDialog.show = false">
LiangLiu's avatar
LiangLiu committed
3743
3744
                    </div>

LiangLiu's avatar
LiangLiu committed
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
            <!-- 对话框内容 -->
            <div class="relative bg-dark-light border border-laser-purple/30 rounded-xl shadow-2xl max-w-md w-full mx-4 transform transition-all duration-300 ease-out"
                 :class="confirmDialog.show ? 'scale-100 opacity-100' : 'scale-95 opacity-0'">
                <!-- 头部 -->
                <div class="flex items-center justify-between p-6 border-b border-gray-700">
                    <div class="flex items-center gap-3">
                        <div class="w-10 h-10 bg-red-500/20 rounded-full flex items-center justify-center">
                            <i class="fas fa-exclamation-triangle text-red-400 text-lg"></i>
                                            </div>
                        <h3 class="text-lg font-semibold text-white">{{ confirmDialog.title }}</h3>
                    </div>
                    <button @click="confirmDialog.show = false"
                            class="text-gray-400 hover:text-gray-300 transition-colors">
                        <i class="fas fa-times text-lg"></i>
                                                </button>
                                                </div>

                <!-- 内容 -->
                <div class="p-6">
                    <p class="text-gray-300 leading-relaxed mb-6">{{ confirmDialog.message }}</p>

                    <!-- 警告信息 -->
                            <div v-if="confirmDialog.warning"
                                class="bg-red-500/10 border border-red-500/30 rounded-lg p-4 mb-6">
                        <div class="flex items-start gap-3">
                            <i class="fas fa-info-circle text-red-400 mt-0.5"></i>
                            <div class="text-sm text-red-300">
                                <p class="font-medium mb-2">{{ confirmDialog.warning.title }}</p>
                                <ul class="space-y-1 text-xs">
                                            <li v-for="item in confirmDialog.warning.items" :key="item"
                                                class="flex items-center gap-2">
                                        <i class="fas fa-minus text-red-400 text-xs"></i>
                                        {{ item }}
                                    </li>
                                </ul>
                                            </div>
                                        </div>
                                    </div>
                </div>

                <!-- 底部按钮 -->
                <div class="flex gap-3 p-6 pt-0">
                    <button @click="confirmDialog.cancel()"
                            class="flex-1 px-4 py-2.5 bg-gray-600 hover:bg-gray-500 text-white rounded-lg transition-all duration-200 font-medium">
                                {{ t('cancel') }}
                    </button>
                    <button @click="confirmDialog.confirm()"
                            class="flex-1 px-4 py-2.5 bg-red-500 hover:bg-red-600 text-white rounded-lg transition-all duration-200 font-medium flex items-center justify-center gap-2">
                        <i class="fas fa-trash text-sm"></i>
                        {{ confirmDialog.confirmText }}
                    </button>
                </div>
            </div>
        </div>
        </div>

        <!-- 提示词模板和历史记录弹窗 -->
        <div v-cloak>
                <div v-if="showPromptModal" class="fixed inset-0 bg-black/50 z-50 flex items-center justify-center"
                @click="showPromptModal = false">
                <div class="bg-secondary rounded-xl p-6 max-w-4xl w-full mx-4 max-h-[80vh] overflow-hidden"
                    @click.stop>
                    <!-- 浮窗头部 -->
                    <div class="flex items-center justify-between mb-4">
                        <h3 class="text-lg font-medium text-white">
                            <i class="fas fa-lightbulb text-gradient-icon mr-2"></i>
                                {{ t('promptTemplates') }}
                        </h3>
                        <button @click="showPromptModal = false"
                                class="text-gray-400 hover:text-white transition-colors">
                            <i class="fas fa-times text-xl"></i>
                        </button>
                    </div>

                    <!-- 标签页切换 -->
                    <div class="flex border-b border-gray-700 mb-6">
                        <button @click="promptModalTab = 'templates'"
                                class="px-4 py-2 text-sm font-medium transition-colors" :class="promptModalTab === 'templates'
                                    ? 'text-gradient-icon border-b-2 border-laser-purple'
                                    : 'text-gray-400 hover:text-gray-300'">
                            <i class="fas fa-layer-group mr-2"></i>
                                {{ t('templates') }}
                        </button>
                        <button @click="promptModalTab = 'history'"
                                class="px-4 py-2 text-sm font-medium transition-colors" :class="promptModalTab === 'history'
                                    ? 'text-gradient-icon border-b-2 border-laser-purple'
                                    : 'text-gray-400 hover:text-gray-300'">
                            <i class="fas fa-history mr-2"></i>
                                {{ t('history') }}
                        </button>
                    </div>

                    <!-- 模板内容 -->
                    <div v-if="promptModalTab === 'templates'" class="overflow-y-auto max-h-[50vh]">
                            <div v-if="getPromptTemplates(selectedTaskId).length > 0"
                                class="grid grid-cols-1 md:grid-cols-2 gap-4 overflow-y-auto max-h-[50vh] main-scrollbar">
                                <button v-for="template in getPromptTemplates(selectedTaskId)" :key="template.id"
                                @click="selectPromptTemplate(template)"
                                    class="break-inside-avoid mb-4 p-4 text-left bg-dark-light rounded-lg hover:bg-laser-purple/20 transition-all border border-transparent hover:border-laser-purple/40 group">
                                    <div
                                        class="font-medium text-sm mb-2 text-white group-hover:text-gradient-icon transition-colors">
                                    {{ template.title }}
                                </div>
                                <div class="text-xs text-gray-400 line-clamp-3 leading-relaxed">
                                    {{ template.prompt }}
                                </div>
                                <div class="mt-3 flex items-center justify-between">
                                        <span class="text-xs text-laser-purple/60">{{ t('clickApply') }}</span>
                                        <i
                                            class="fas fa-arrow-right text-xs text-laser-purple/60 group-hover:translate-x-1 transition-transform"></i>
                                </div>
                            </button>
                        </div>
                        <div v-else class="flex flex-col items-center justify-center py-12 text-center">
                                <div
                                    class="w-16 h-16 bg-laser-purple/20 rounded-full flex items-center justify-center mb-4">
                                <i class="fas fa-layer-group text-gradient-icon text-2xl"></i>
LiangLiu's avatar
LiangLiu committed
3862
                            </div>
LiangLiu's avatar
LiangLiu committed
3863
3864
                                <p class="text-gray-400 text-lg mb-2">{{ t('noAvailableTemplates') }}</p>
                                <p class="text-gray-500 text-sm">{{ t('pleaseSelectTaskType') }}</p>
LiangLiu's avatar
LiangLiu committed
3865
                        </div>
LiangLiu's avatar
LiangLiu committed
3866
                    </div>
LiangLiu's avatar
LiangLiu committed
3867

LiangLiu's avatar
LiangLiu committed
3868
3869
3870
3871
3872
3873
3874
                    <!-- 历史记录内容 -->
                    <div v-if="promptModalTab === 'history'" class="overflow-y-auto max-h-[50vh]">
                            <div v-if="promptHistory.length === 0"
                                class="flex flex-col items-center justify-center py-12 text-center">
                                <div
                                    class="w-16 h-16 bg-laser-purple/20 rounded-full flex items-center justify-center mb-4">
                                <i class="fas fa-history text-gradient-icon text-2xl"></i>
LiangLiu's avatar
LiangLiu committed
3875
                            </div>
LiangLiu's avatar
LiangLiu committed
3876
3877
                                <p class="text-gray-400 text-lg mb-2">{{ t('noHistoryRecords') }}</p>
                                <p class="text-gray-500 text-sm">{{ t('promptHistoryAutoSave') }}</p>
LiangLiu's avatar
LiangLiu committed
3878
                        </div>
LiangLiu's avatar
LiangLiu committed
3879
3880
3881
3882
3883
3884
                        <div v-else class="space-y-3">
                            <div class="flex items-center justify-between mb-4">
                                    <span class="text-sm text-gray-400">{{ promptHistory.length }} {{ t('records') }}</span>
                                <button @click="clearPromptHistory"
                                        class="text-xs text-red-400 hover:text-red-300 transition-colors flex items-center gap-1"
                                        title="{{ t('clearHistory') }}">
LiangLiu's avatar
LiangLiu committed
3885
                                    <i class="fas fa-trash"></i>
LiangLiu's avatar
LiangLiu committed
3886
                                        {{ t('clear') }}
LiangLiu's avatar
LiangLiu committed
3887
3888
                                </button>
                            </div>
LiangLiu's avatar
LiangLiu committed
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
                                <button v-for="(history, index) in promptHistory" :key="index"
                                @click="selectPromptHistory(history)"
                                    class="w-full p-4 text-left bg-dark-light rounded-lg hover:bg-laser-purple/20 transition-all border border-transparent hover:border-laser-purple/40 group">
                                    <div
                                        class="text-sm text-gray-300 line-clamp-3 leading-relaxed group-hover:text-white transition-colors">
                                    {{ history }}
                                </div>
                                <div class="mt-2 flex items-center justify-between">
                                        <span class="text-xs text-laser-purple/60">{{ t('clickApply') }}</span>
                                        <i
                                            class="fas fa-arrow-right text-xs text-laser-purple/60 group-hover:translate-x-1 transition-transform"></i>
                                </div>
LiangLiu's avatar
LiangLiu committed
3901
3902
                            </button>
                        </div>
LiangLiu's avatar
LiangLiu committed
3903
3904
3905
3906
                    </div>
                </div>
            </div>
        </div>
LiangLiu's avatar
LiangLiu committed
3907

LiangLiu's avatar
LiangLiu committed
3908
3909
3910
3911
3912
            <!-- 模板详情弹窗 -->
            <div v-cloak>
                <div v-if="showTemplateDetailModal"
                    class="fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4"
                    @click="closeTemplateDetailModal">
LiangLiu's avatar
LiangLiu committed
3913
                    <div class="bg-secondary rounded-xl w-[95%] sm:w-[90%] md:w-[80%] h-[95vh] sm:h-[100vh]" @click.stop>
LiangLiu's avatar
LiangLiu committed
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
                        <!-- 弹窗头部 -->
                        <div class="flex items-center justify-between p-6 border-b border-gray-700">
                            <h3 class="text-xl font-medium text-white flex items-center">
                                <i class="fas fa-star text-laser-purple mr-3"></i>
                                {{ t('templateDetail') }}
                            </h3>
                            <!-- 右侧按钮组 -->
                            <div class="flex items-center space-x-3">
                                <!-- 使用模板按钮 -->
                                <button @click="useTemplate(selectedTemplate)"
                                    class="btn-primary px-4 py-3 bg-gradient-to-r from-laser-purple to-laser-blue text-white rounded-xl hover:from-laser-purple/80 hover:to-laser-blue/80 transition-all duration-200 font-medium">
                                    {{ t('useTemplate') }}
LiangLiu's avatar
LiangLiu committed
3926
                                </button>
LiangLiu's avatar
LiangLiu committed
3927
3928
3929
3930
                                <!-- 关闭按钮 -->
                                <button @click="closeTemplateDetailModal"
                                    class="text-gray-400 hover:text-white transition-colors">
                                    <i class="fas fa-times text-xl"></i>
LiangLiu's avatar
LiangLiu committed
3931
                                </button>
LiangLiu's avatar
LiangLiu committed
3932
                            </div>
LiangLiu's avatar
LiangLiu committed
3933
3934
                        </div>

LiangLiu's avatar
LiangLiu committed
3935
                        <!-- 弹窗内容 -->
LiangLiu's avatar
LiangLiu committed
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
                        <div class="flex flex-col lg:flex-row h-[calc(100vh-120px)] overflow-y-auto main-scrollbar">
                            <!-- 左侧视频播放区域 -->
                            <div class="flex-1 lg:flex-1">
                                <div class="p-4 lg:p-6 flex items-center justify-between">
                                    <label class="text-sm font-medium text-white">{{ t('outputVideo') }}</label>
                                </div>
                                <div class="w-full h-[50vh] sm:h-[60vh] lg:h-[calc(70vh)] bg-gray-900 rounded-lg overflow-hidden mx-4 lg:mx-6">
                                    <video
                                    :src="getTemplateFileUrl(selectedTemplate.outputs.output_video,'videos')"
                                    :poster="getTemplateFileUrl(selectedTemplate.inputs.input_image,'images')"
                                        class="w-full h-full object-contain" controls
                                        @loadeddata="onVideoLoaded($event)"></video>
                                </div>
                            </div>
                            <!-- 右侧输入素材区域 -->
                            <div class="w-full lg:w-2/5 lg:border-l border-gray-700 mt-4 lg:mt-0">
                                <div class="p-4 lg:p-6 space-y-4 lg:space-y-6">
LiangLiu's avatar
LiangLiu committed
3953
3954
3955
3956
3957
3958
3959
3960
3961
                                    <!-- 输入图片 -->
                                    <div v-if="selectedTemplate?.inputs?.input_image" class="space-y-3">
                                        <div class="flex items-center justify-between">
                                            <label class="text-sm font-medium text-white">{{ t('inputImage') }}</label>
                                            <button @click="applyTemplateImage(selectedTemplate)"
                                                class="px-3 py-1.5 bg-laser-purple/20 text-laser-purple border border-laser-purple/40 rounded-lg hover:bg-laser-purple/30 transition-all duration-200 text-xs">
                                                {{ t('applyImage') }}
                                            </button>
                                        </div>
LiangLiu's avatar
LiangLiu committed
3962
                                        <div class="relative w-full sm:w-3/4 lg:w-[50%] bg-gray-800 rounded-lg overflow-hidden cursor-pointer group"
LiangLiu's avatar
LiangLiu committed
3963
3964
3965
3966
3967
3968
3969
3970
                                            @click="showImageZoom(getTemplateFileUrl(selectedTemplate.inputs.input_image,'images'))">
                                            <img :src="getTemplateFileUrl(selectedTemplate.inputs.input_image,'images')" :alt="'输入图片'"
                                                class="w-full h-full object-cover transition-transform duration-300 group-hover:scale-105" />
                                            <div class="absolute inset-0 bg-black/0 group-hover:bg-black/20 transition-all duration-300 flex items-center justify-center">
                                                <i class="fas fa-search-plus text-white opacity-0 group-hover:opacity-100 transition-opacity duration-300 text-2xl"></i>
                                            </div>
                                        </div>
                                    </div>
LiangLiu's avatar
LiangLiu committed
3971

LiangLiu's avatar
LiangLiu committed
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
                                    <!-- 输入音频 -->
                                    <div v-if="selectedTemplate?.inputs?.input_audio" class="space-y-3">
                                        <div class="flex items-center justify-between">
                                            <label class="text-sm font-medium text-white">{{ t('inputAudio') }}</label>
                                            <button @click="applyTemplateAudio(selectedTemplate)"
                                                class="px-3 py-1.5 bg-laser-purple/20 text-laser-purple border border-laser-purple/40 rounded-lg hover:bg-laser-purple/30 transition-all duration-200 text-xs">
                                                {{ t('applyAudio') }}
                                            </button>
                                        </div>
                                        <div class="rounded-lg p-4">
                                            <audio :src="getTemplateFileUrl(selectedTemplate.inputs.input_audio,'audios')" controls
                                                class="w-full"></audio>
                                        </div>
LiangLiu's avatar
LiangLiu committed
3985
                                    </div>
LiangLiu's avatar
LiangLiu committed
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003

                                    <!-- 输入Prompt -->
                                    <div v-if="selectedTemplate?.params?.prompt" class="space-y-3">
                                        <div class="flex items-center justify-between">
                                            <label class="text-sm font-medium text-white">{{ t('prompt') }}</label>
                                            <div class="flex items-center space-x-2">
                                                <button @click="copyPrompt(selectedTemplate?.params?.prompt)"
                                                    class="px-3 py-1.5 bg-gray-600/20 text-gray-300 border border-gray-600/40 rounded-lg hover:bg-gray-600/30 transition-all duration-200 text-xs">
                                                    <i class="fas fa-copy mr-1"></i>{{ t('copy') }}
                                                </button>
                                                <button @click="applyTemplatePrompt(selectedTemplate)"
                                                    class="px-3 py-1.5 bg-laser-purple/20 text-laser-purple border border-laser-purple/40 rounded-lg hover:bg-laser-purple/30 transition-all duration-200 text-xs">
                                                    {{ t('applyPrompt') }}
                                                </button>
                                            </div>
                                        </div>
                                        <div class="bg-gray-800 rounded-lg p-4">
                                            <p class="text-sm text-gray-300 leading-relaxed">{{ selectedTemplate?.params?.prompt }}</p>
LiangLiu's avatar
LiangLiu committed
4004
4005
                                        </div>
                                    </div>
LiangLiu's avatar
LiangLiu committed
4006
4007
4008
4009

                                </div>
                            </div>
                        </div>
LiangLiu's avatar
LiangLiu committed
4010
4011
                    </div>
                </div>
LiangLiu's avatar
LiangLiu committed
4012
            </div>
LiangLiu's avatar
LiangLiu committed
4013

LiangLiu's avatar
LiangLiu committed
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
            <!-- 图片放大弹窗 -->
             <div v-cloak>
            <div v-if="showImageZoomModal" class="fixed inset-0 bg-black/80 z-60 flex items-center justify-center p-4"
                @click="closeImageZoomModal">
                <div class="relative max-w-4xl max-h-[90vh] bg-secondary rounded-xl overflow-hidden" @click.stop>
                    <div class="flex items-center justify-between p-4 border-b border-gray-700">
                        <h3 class="text-lg font-medium text-white">{{ t('imagePreview') }}</h3>
                        <button @click="closeImageZoomModal"
                            class="text-gray-400 hover:text-white transition-colors">
                            <i class="fas fa-times text-xl"></i>
                        </button>
                    </div>
                    <div class="p-4">
                        <img :src="zoomedImageUrl" :alt="'图片预览'"
                            class="w-full h-auto max-h-[70vh] object-contain rounded-lg" />
LiangLiu's avatar
LiangLiu committed
4029
4030
4031
                    </div>
                </div>
            </div>
LiangLiu's avatar
LiangLiu committed
4032
            </div>
LiangLiu's avatar
LiangLiu committed
4033

LiangLiu's avatar
LiangLiu committed
4034
4035
4036
4037
4038
4039
4040
            <!-- 任务详情弹窗 -->
            <div v-cloak>
                <div v-if="showTaskDetailModal"
                    class="fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4"
                    @click="closeTaskDetailModal">
                    <!-- 任务完成时的大弹窗 -->
                    <div v-if="modalTask?.status === 'SUCCEED'"
LiangLiu's avatar
LiangLiu committed
4041
                        class="bg-secondary rounded-xl w-[95%] sm:w-[90%] md:w-[80%] h-[95vh] sm:h-[100vh]" @click.stop>
LiangLiu's avatar
LiangLiu committed
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
                        <!-- 弹窗头部 -->
                        <div class="flex items-center justify-between p-6 border-b border-gray-700">
                            <h3 class="text-xl font-medium text-white flex items-center">
                                <i class="fas fa-info-circle text-gradient-icon mr-2"></i>
                                {{ t('taskDetails') }}
                            </h3>
                            <button @click="closeTaskDetailModal"
                                class="text-gray-400 hover:text-white transition-colors">
                                <i class="fas fa-times text-xl"></i>
                            </button>
LiangLiu's avatar
LiangLiu committed
4052
4053
                        </div>

LiangLiu's avatar
LiangLiu committed
4054
                        <!-- 左右布局内容 -->
LiangLiu's avatar
LiangLiu committed
4055
                        <div class="flex flex-col lg:flex-row h-[calc(100vh-120px)] main-scrollbar overflow-y-auto">
LiangLiu's avatar
LiangLiu committed
4056
                            <!-- 左侧视频播放器 -->
LiangLiu's avatar
LiangLiu committed
4057
4058
                            <div class="flex-1 p-6 order-1 lg:order-1">
                                <div class="h-64 lg:h-full bg-black rounded-xl border border-laser-purple/50 overflow-hidden">
LiangLiu's avatar
LiangLiu committed
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
                        <video
                            v-if="selectedTaskFiles.outputs.output_video && selectedTaskFiles.outputs.output_video.url"
                                        class="w-full h-full object-contain" controls preload="metadata"
                            :src="selectedTaskFiles.outputs.output_video.url">
                                        {{ t('browserNotSupported') }}
                        </video>
                        <div v-else-if="selectedTaskFiles.outputs.output_video && selectedTaskFiles.outputs.output_video.error"
                            class="w-full h-full flex items-center justify-center bg-red-900/20">
                            <div class="text-center">
                                <i class="fas fa-exclamation-triangle text-red-400 text-2xl mb-2"></i>
                                            <p class="text-red-400 text-sm">{{ t('videoLoadFailed') }}</p>
LiangLiu's avatar
LiangLiu committed
4070
4071
                            </div>
                        </div>
LiangLiu's avatar
LiangLiu committed
4072
4073
4074
4075
                                    <div v-else class="w-full h-full flex items-center justify-center bg-gray-700">
                            <div class="text-center">
                                <i class="fas fa-spinner fa-spin text-gray-400 text-2xl mb-2"></i>
                                            <p class="text-gray-400 text-sm">{{ t('loadingVideo') }}...</p>
LiangLiu's avatar
LiangLiu committed
4076
4077
                            </div>
                        </div>
LiangLiu's avatar
LiangLiu committed
4078
4079
                    </div>
                </div>
LiangLiu's avatar
LiangLiu committed
4080

LiangLiu's avatar
LiangLiu committed
4081
                            <!-- 右侧任务详情 -->
LiangLiu's avatar
LiangLiu committed
4082
                            <div class="w-full lg:w-[28rem] border-t lg:border-t-0 lg:border-l border-gray-700 order-2 lg:order-2">
LiangLiu's avatar
LiangLiu committed
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
                                <!-- 任务操作按钮 -->
                                <div class="flex flex-col space-y-3 items-center">
                                    <button v-if="['CREATED', 'PENDING', 'RUNNING'].includes(modalTask?.status)"
                                            @click="cancelTask(modalTask.task_id, true); closeTaskDetailModal()"
                                            class="w-3/4 px-4 py-3 bg-gray-700/50 hover:bg-gray-600/50 text-white border border-gray-600/30 rounded-xl text-sm transition-all duration-200 hover:border-gray-500/50">
                                        <i class="fas fa-times mr-2"></i>
                                        {{ t('cancelTask') }}
                                    </button>
                                    <button v-if="['SUCCEED', 'FAILED', 'CANCEL'].includes(modalTask?.status)"
                                            @click="reuseTask(modalTask); closeTaskDetailModal()"
                                            class="w-3/4 px-4 py-3 bg-laser-purple/20 hover:bg-laser-purple/30 text-white border border-laser-purple/40 rounded-xl text-sm transition-all duration-200 hover:border-laser-purple/60">
                                        <i class="fas fa-copy mr-2"></i>
                                        {{ t('reuseTask') }}
                                    </button>
                                    <button v-if="['SUCCEED', 'FAILED', 'CANCEL'].includes(modalTask?.status)"
                                            @click="resumeTask(modalTask.task_id, true); closeTaskDetailModal()"
                                            class="w-3/4 px-4 py-3 bg-gray-700/50 hover:bg-gray-600/50 text-white border border-gray-600/30 rounded-xl text-sm transition-all duration-200 hover:border-gray-500/50">
                                        <i class="fas fa-redo mr-2"></i>
                                        {{ t('regenerateTask') }}
                                    </button>
                                    <button
                                        v-if="selectedTaskFiles.outputs.output_video && selectedTaskFiles.outputs.output_video.url"
                                            @click="downloadFile(selectedTaskFiles.outputs.output_video)"
                                            class="w-3/4 px-4 py-3 bg-gray-700/50 hover:bg-gray-600/50 text-white border border-gray-600/30 rounded-xl text-sm transition-all duration-200 hover:border-gray-500/50">
                                        <i class="fas fa-download mr-2"></i>
                                        {{ t('downloadVideo') }}
                                    </button>
                                    <button v-if="['SUCCEED', 'FAILED', 'CANCEL'].includes(modalTask?.status)"
                                            @click="deleteTask(modalTask.task_id, true); closeTaskDetailModal()"
                                            class="w-3/4 px-4 py-3 bg-red-900/20 hover:bg-red-900/30 text-red-400 border border-red-500/30 rounded-xl text-sm transition-all duration-200 hover:border-red-500/50">
                                        <i class="fas fa-trash mr-2"></i>
                                        {{ t('deleteTask') }}
                                    </button>
            </div>
                                <div class="p-6 space-y-6">
                                    <!-- 任务状态显示 -->
                                    <div class="bg-secondary/30 rounded-xl p-4">
                                <h4 class="text-sm font-medium mb-3 flex items-center">
                                    <i class="fas fa-info-circle text-gradient-icon mr-2"></i>
                                            {{ t('taskInfo') }}
                                </h4>
                                <ul class="space-y-2 text-sm">
                                    <li class="flex justify-between">
                                                <span class="text-gray-400">{{ t('taskID') }}</span>
                                        <span class="text-xs">{{ modalTask?.task_id }}</span>
                                    </li>
                                    <li class="flex justify-between">
                                                <span class="text-gray-400">{{ t('taskType') }}</span>
                                        <span>{{ getTaskTypeName(modalTask) }}</span>
                                    </li>
                                    <li class="flex justify-between">
                                                <span class="text-gray-400">{{ t('modelName') }}</span>
                                        <span class="text-gradient-icon">{{ modalTask?.model_cls }}</span>
                                    </li>
                                    <li class="flex justify-between">
                                                <span class="text-gray-400">{{ t('createTime') }}</span>
                                        <span>{{ formatTime(modalTask?.create_t) }}</span>
                                    </li>
                                    <li class="flex justify-between">
                                                <span class="text-gray-400">{{ t('updateTime') }}</span>
                                        <span>{{ formatTime(modalTask?.update_t) }}</span>
                                    </li>
                                    <li class="flex justify-between">
                                                <span class="text-gray-400">{{ t('status') }}</span>
                                                <span :class="getStatusTextClass(modalTask?.status)">{{
                                                    getTaskStatusDisplay(modalTask?.status) }}</span>
                                    </li>
                                </ul>
        </div>

                                    <!-- 提示词 -->
                                    <div class="bg-secondary/30 rounded-xl p-4">
                                        <h4 class="text-sm font-medium mb-3 flex items-center">
                                            <i class="fas fa-file-alt text-gradient-icon mr-2"></i>
                                            {{ t('prompt') }}
                                        </h4>
                                        <div class="bg-dark-light rounded-lg p-3 text-sm text-gray-300">
                                            <p>{{ modalTask?.params?.prompt || t('noPrompt') }}</p>
                                </div>
LiangLiu's avatar
LiangLiu committed
4162
4163
                                </div>

LiangLiu's avatar
LiangLiu committed
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
                                    <!-- 上传素材 -->
                                    <div v-if="modalTask?.inputs && Object.keys(modalTask.inputs).length"
                                        class="bg-secondary/30 rounded-xl p-4">
                                <h4 class="text-sm font-medium mb-3 flex items-center">
                                    <i class="fas fa-upload text-gradient-icon mr-2"></i>
                                            {{ t('uploadMaterials') }}
                                            <span v-if="loadingTaskFiles"
                                                class="ml-2 text-xs text-gray-400">({{ t('loading') }}...)</span>
                                </h4>
                                <div class="space-y-3">
                                    <template v-for="(input, key) in modalTask.inputs" :key="key">
                                        <div class="flex items-center gap-3">
                                            <template v-if="key.includes('image')">
                                                <i class="fas fa-image text-gradient-icon text-lg"></i>
                                                <div class="flex items-center gap-2">
                                                            <span
                                                                v-if="!selectedTaskFiles.inputs[key] || !selectedTaskFiles.inputs[key].url"
                                                                class="text-gray-400 text-sm">{{ typeof input ===
                                                                'string' ? input : t('image') }}</span>
                                                    <div class="flex items-center gap-2 relative group">
                                                        <img v-if="selectedTaskFiles.inputs[key] && selectedTaskFiles.inputs[key].url"
                                                            :src="selectedTaskFiles.inputs[key].url"
                                                            :alt="input"

                                                            class="w-16 h-16 object-cover rounded bg-dark-light border border-gray-700">
                                                        <div v-else-if="selectedTaskFiles.inputs[key] && selectedTaskFiles.inputs[key].error"
                                                            class="w-16 h-16 rounded bg-red-900/20 border border-red-500/30 flex items-center justify-center">
                                                                    <i
                                                                        class="fas fa-exclamation-triangle text-red-400"></i>
                                                        </div>
                                                        <div v-else
                                                            class="w-16 h-16 rounded bg-gray-700 border border-gray-600 flex items-center justify-center">
                                                            <i class="fas fa-spinner fa-spin text-gray-400"></i>
                                                        </div>
                                                                <button
                                                                    v-if="selectedTaskFiles.inputs[key] && selectedTaskFiles.inputs[key].url"
                                                                @click="downloadFile(selectedTaskFiles.inputs[key])"
                                                                class="text-xs px-2 py-1 rounded">
                                                                    <i
                                                                        class="fas fa-download mr-1 text-white opacity-30 hover:opacity-100 transition-opacity"></i>
                                                        </button>
                                                    </div>
                                                </div>
                                            </template>
                                            <template v-else-if="key.includes('audio')">
                                                <i class="fas fa-microphone text-gradient-icon text-lg"></i>
                                                <div class="flex items-center gap-2">
                                                            <span
                                                                v-if="!selectedTaskFiles.inputs[key] || !selectedTaskFiles.inputs[key].url"
                                                                class="text-gray-400 text-sm">{{ typeof input ===
                                                                'string' ? input : t('audioFile') }}</span>
                                                    <div class="flex items-center gap-2">
                                                                <audio
                                                                    v-if="selectedTaskFiles.inputs[key] && selectedTaskFiles.inputs[key].url"
                                                                    :src="selectedTaskFiles.inputs[key].url" controls
                                                            class="h-8 text-gradient-icon"
                                                            preload="metadata">

                                                                    {{ t('browserNotSupported') }}
                                                        </audio>
                                                        <div v-else-if="selectedTaskFiles.inputs[key] && selectedTaskFiles.inputs[key].error"
                                                            class="h-8 px-3 rounded bg-red-900/20 border border-red-500/30 flex items-center">
                                                                    <i
                                                                        class="fas fa-exclamation-triangle text-red-400 text-xs"></i>
                                                        </div>
                                                        <div v-else
                                                            class="h-8 px-3 rounded bg-gray-700 border border-gray-600 flex items-center">
                                                                    <i
                                                                        class="fas fa-spinner fa-spin text-gray-400 text-xs"></i>
                                                        </div>
                                                                <button
                                                                    v-if="selectedTaskFiles.inputs[key] && selectedTaskFiles.inputs[key].url"
                                                                @click="downloadFile(selectedTaskFiles.inputs[key])"
                                                                class="text-xs px-2 py-1 rounded">
                                                                    <i
                                                                        class="fas fa-download mr-1 text-white opacity-30 hover:opacity-100 transition-opacity"></i>
                                                        </button>
                                                    </div>
                                                </div>
                                            </template>
                                        </div>
                                    </template>
                                </div>
                            </div>
                                </div>
                            </div>
LiangLiu's avatar
LiangLiu committed
4250
                        </div>
LiangLiu's avatar
LiangLiu committed
4251
                    </div>
LiangLiu's avatar
LiangLiu committed
4252

LiangLiu's avatar
LiangLiu committed
4253
                    <!-- 其他状态的小弹窗 -->
LiangLiu's avatar
LiangLiu committed
4254
                    <div v-else class="bg-secondary rounded-xl w-[95%] sm:w-[90%] md:w-[80%] h-[95vh] sm:h-[100vh]"
LiangLiu's avatar
LiangLiu committed
4255
4256
4257
4258
                        @click.stop>
                        <!-- 弹窗头部 -->
                        <div class="flex items-center justify-between p-6 border-b border-gray-700">
                            <h3 class="text-xl font-medium text-white flex items-center">
LiangLiu's avatar
LiangLiu committed
4259
                                <i class="fas fa-info-circle text-gradient-icon mr-2"></i>
LiangLiu's avatar
LiangLiu committed
4260
4261
4262
4263
4264
4265
                                {{ t('taskDetails') }}
                            </h3>
                            <button @click="closeTaskDetailModal"
                                class="text-gray-400 hover:text-white transition-colors">
                                <i class="fas fa-times text-xl"></i>
                            </button>
LiangLiu's avatar
LiangLiu committed
4266
4267
                        </div>

LiangLiu's avatar
LiangLiu committed
4268
                        <!-- 弹窗内容 -->
LiangLiu's avatar
LiangLiu committed
4269

LiangLiu's avatar
LiangLiu committed
4270
                        <div class="overflow-y-auto max-h-[calc(90vh-120px)] p-6 main-scrollbar">
LiangLiu's avatar
LiangLiu committed
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
                                <!-- 任务进行中信息 -->
                            <div v-if="['CREATED', 'PENDING', 'RUNNING'].includes(modalTask?.status)"
                                class="max-w-4xl mx-auto task-running-panel">
                                    <div class="text-center py-8">
                                    <div
                                        class="w-24 h-24 mx-auto bg-laser-purple/20 rounded-full flex items-center justify-center mb-6 animate-pulse-slow">
                                            <i class="fas fa-spinner fa-spin text-gradient-icon text-3xl"></i>
                                        </div>
                                    <h3 class="text-xl font-medium mb-2">{{ t('videoGenerating') }}</h3>
                                    <p class="text-gray-400 mb-6">{{ t('aiIsGeneratingYourVideo') }}...</p>

                                        <!-- 子任务进度显示 -->
                                    <div v-if="modalTask && modalTask.subtasks && modalTask.subtasks.length > 0"
                                        class="progress-container">
                                            <h4 class="text-sm font-medium mb-4 flex items-center">
                                            <i class="fas fa-chart-line text-gradient-icon mr-2"></i>
                                            {{ t('taskProgress') }}
                                            </h4>

                                            <!-- 总体进度条 -->
                                            <div class="mb-4">
                                                <div class="flex justify-between items-center mb-2">
                                                <span class="text-sm text-gray-300">{{
                                                    getProgressTitle(modalTask.subtasks || []) }}</span>
                                                <span class="text-sm text-gradient-icon">{{
                                                    getProgressInfo(modalTask.subtasks || []) }}</span>
                                                </div>
                                                <div class="progress-bar">
                                                <div class="progress-fill"
                                                    :style="{ width: getOverallProgress(modalTask.subtasks || []) + '%' }">
                                                </div>
LiangLiu's avatar
LiangLiu committed
4302
4303
                                                </div>
                                            </div>
LiangLiu's avatar
LiangLiu committed
4304
4305
4306
4307
4308
4309
4310

                                            <!-- 子任务列表 -->
                                            <div class="space-y-2">
                                            <div v-for="(subtask, index) in (modalTask.subtasks || [])" :key="index"
                                                class="subtask-item">
                                                    <div class="subtask-header">
                                                    <span class="text-sm font-medium">{{ t('subtask') }} {{ index + 1 }}</span>
LiangLiu's avatar
LiangLiu committed
4311
                                                        <span class="subtask-status">
LiangLiu's avatar
LiangLiu committed
4312
4313
                                                            {{ getSubtaskStatusText(subtask.status) }}
                                                        </span>
LiangLiu's avatar
LiangLiu committed
4314
                                                    </div>
LiangLiu's avatar
LiangLiu committed
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347

                                                    <!-- 子任务进度条 -->
                                                <div v-if="subtask.status === 'PENDING' || subtask.status === 'RUNNING'"
                                                    class="mt-2">
                                                        <div class="flex justify-between items-center mb-1">
                                                        <span class="text-xs text-gray-400">{{
                                                            getSubtaskStatusText(subtask.status) }}</span>
                                                        <span class="text-xs text-gradient-icon">{{
                                                            formatEstimatedTime(subtask) }}</span>
                                                        </div>
                                                        <div class="progress-bar">
                                                        <div class="progress-fill"
                                                            :style="{ width: getSubtaskProgress(subtask) + '%' }"></div>
                                                        </div>
                                                    </div>

                                                    <!-- 子任务详细信息 -->
                                                    <div class="subtask-info">
                                                    <div v-if="subtask.estimated_pending_order !== null"
                                                        class="flex items-center gap-2 mt-1">
                                                            <i class="fas fa-clock text-xs"></i>
                                                        <span>{{ t('queuePosition') }}: {{ subtask.estimated_pending_order }}</span>
                                                        </div>
                                                    <div v-if="subtask.ready_worker_count !== null"
                                                        class="flex items-center gap-2 mt-1">
                                                            <i class="fas fa-users text-xs"></i>
                                                        <span>{{ t('availableWorker') }}: {{ subtask.ready_worker_count }}</span>
                                                        </div>
                                                    <div v-if="subtask.fail_msg"
                                                        class="flex items-center gap-2 mt-1 text-red-400">
                                                            <i class="fas fa-exclamation-triangle text-xs"></i>
                                                            <span>{{ subtask.fail_msg }}</span>
                                                        </div>
LiangLiu's avatar
LiangLiu committed
4348
4349
4350
                                                    </div>
                                                </div>
                                            </div>
LiangLiu's avatar
LiangLiu committed
4351
4352
4353
                                        </div>
                                    </div>
                                </div>
LiangLiu's avatar
LiangLiu committed
4354

LiangLiu's avatar
LiangLiu committed
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
                                <!-- 任务失败信息 -->
                            <div v-if="modalTask?.status === 'FAILED'" class="max-w-4xl mx-auto task-failed-panel">
                                    <div class="text-center py-8">
                                    <div
                                        class="w-24 h-24 mx-auto bg-red-500/10 rounded-full flex items-center justify-center mb-6">
                                            <i class="fas fa-exclamation-triangle text-red-500 text-3xl"></i>
                                        </div>
                                    <h3 class="text-xl font-medium mb-2">{{ t('videoGeneratingFailed') }}</h3>
                                    <p
                                        class="text-gray-400 mb-4 max-w-md mx-auto flex items-center justify-center gap-2">
                                        {{ t('sorryYourVideoGenerationTaskFailed') }}
                                        <button v-if="getTaskFailureInfo(modalTask)"
                                                    @click="showErrorDetails = !showErrorDetails"
                                                    class="text-gray-400 hover:text-gray-100 transition-colors">
                                                <i class="fas fa-info-circle"></i>
                                            </button>
                                        </p>

                                        <!-- 可展开的错误详情 -->
                                    <div v-if="showErrorDetails && getTaskFailureInfo(modalTask)" class="mt-4">
                                            <span class="text-xs">{{ getTaskFailureInfo(modalTask) }}</span>
                                        </div>
                                    </div>
                                </div>
LiangLiu's avatar
LiangLiu committed
4379

LiangLiu's avatar
LiangLiu committed
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
                                <!-- 任务取消信息 -->
                            <div v-if="modalTask?.status === 'CANCEL'" class="max-w-4xl mx-auto task-cancelled-panel">
                                    <div class="text-center py-8">
                                    <div
                                        class="w-24 h-24 mx-auto bg-yellow-500/10 rounded-full flex items-center justify-center mb-6">
                                            <i class="fas fa-ban text-yellow-500 text-3xl"></i>
                                        </div>
                                    <h3 class="text-xl font-medium mb-2">{{ t('taskCancelled') }}</h3>
                                        <p class="text-gray-400 mb-4 max-w-md mx-auto">
                                        {{ t('thisTaskHasBeenCancelledYouCanRegenerateOrViewTheMaterialsYouUploadedBefore') }}
                                        </p>
                                    </div>
LiangLiu's avatar
LiangLiu committed
4392

LiangLiu's avatar
LiangLiu committed
4393
                                </div>
LiangLiu's avatar
LiangLiu committed
4394

LiangLiu's avatar
LiangLiu committed
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
                            <!-- 任务操作按钮 -->
                            <div class="flex justify-center space-x-3 p-4">
                            <button v-if="['CREATED', 'PENDING', 'RUNNING'].includes(modalTask?.status)"
                                    @click="cancelTask(modalTask.task_id, true); closeTaskDetailModal()"
                                            class="px-4 py-2 btn-primary rounded-lg text-sm transition-all">
                                        <i class="fas fa-times mr-2"></i>
                                    {{ t('cancelTask') }}
                                    </button>
                                <button
                                    v-if="['SUCCEED', 'FAILED', 'CANCEL','CREATED', 'PENDING', 'RUNNING'].includes(modalTask?.status)"
                                    @click="reuseTask(modalTask); closeTaskDetailModal()"
                                    class="px-4 py-3 bg-laser-purple/20 hover:bg-laser-purple/30 text-white border border-laser-purple/40 rounded-xl text-sm transition-all duration-200 hover:border-laser-purple/60">
                                <i class="fas fa-copy mr-2"></i>
                                    {{ t('reuseTask') }}
                                    </button>
                            <button v-if="['SUCCEED', 'FAILED', 'CANCEL'].includes(modalTask?.status)"
                                    @click="resumeTask(modalTask.task_id, true); closeTaskDetailModal()"
                                    class="px-4 py-3 bg-gray-700/50 hover:bg-gray-600/50 text-white border border-gray-600/30 rounded-xl text-sm transition-all duration-200 hover:border-gray-500/50">
                                        <i class="fas fa-redo mr-2"></i>
                                    {{ t('regenerateTask') }}
                                    </button>
                            <button v-if="['SUCCEED', 'FAILED', 'CANCEL'].includes(modalTask?.status)"
                                    @click="deleteTask(modalTask.task_id, true); closeTaskDetailModal()"
                                    class="px-4 py-3 bg-red-900/20 hover:bg-red-900/30 text-red-400 border border-red-500/30 rounded-xl text-sm transition-all duration-200 hover:border-red-500/50">
                                        <i class="fas fa-trash mr-2"></i>
                                    {{ t('deleteTask') }}
                                    </button>
                                </div>
LiangLiu's avatar
LiangLiu committed
4423

LiangLiu's avatar
LiangLiu committed
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
                                <!-- 任务状态显示 -->
                                <div class="bg-secondary/30 rounded-xl p-6 mb-6">
                                    <h4 class="text-sm font-medium mb-3 flex items-center">
                                        <i class="fas fa-info-circle text-gradient-icon mr-2"></i>
                                    {{ t('taskInfo') }}
                                    </h4>
                                    <ul class="space-y-2 text-sm">
                                        <li class="flex justify-between">
                                        <span class="text-gray-400">{{ t('taskID') }}</span>
                                        <span>{{ modalTask?.task_id }}</span>
                                        </li>
                                        <li class="flex justify-between">
                                        <span class="text-gray-400">{{ t('taskType') }}</span>
                                        <span>{{ getTaskTypeName(modalTask) }}</span>
                                        </li>
                                        <li class="flex justify-between">
                                        <span class="text-gray-400">{{ t('modelName') }}</span>
                                        <span class="text-gradient-icon">{{ modalTask?.model_cls }}</span>
                                        </li>
                                        <li class="flex justify-between">
                                        <span class="text-gray-400">{{ t('createTime') }}</span>
                                        <span>{{ formatTime(modalTask?.create_t) }}</span>
                                        </li>
                                        <li class="flex justify-between">
                                        <span class="text-gray-400">{{ t('updateTime') }}</span>
                                        <span>{{ formatTime(modalTask?.update_t) }}</span>
                                        </li>
                                        <li class="flex justify-between">
                                        <span class="text-gray-400">{{ t('status') }}</span>
                                        <div class="flex items-center gap-2">
                                            <span :class="getStatusTextClass(modalTask?.status)">{{
                                                getTaskStatusDisplay(modalTask?.status) }}</span>
                                            <button
                                                v-if="modalTask?.status === 'FAILED' && getTaskFailureInfo(modalTask)"
                                                    @click="showFailureDetails = !showFailureDetails"
                                                    class="text-red-400 hover:text-red-300 transition-colors"
                                                title="{{ t('viewFailureReason') }}">
                                                <i class="fas fa-exclamation-triangle text-xs"></i>
                                            </button>
                                        </div>
                                        </li>
                                    </ul>

                                <!-- 失败原因详情 -->
                                <div v-if="showFailureDetails && modalTask?.status === 'FAILED' && getTaskFailureInfo(modalTask)"
                                     class="mt-4 p-3 bg-red-900/20 border border-red-500/30 rounded-lg">
                                    <div class="flex items-start gap-2">
                                        <i class="fas fa-exclamation-triangle text-red-400 text-sm mt-0.5"></i>
                                        <div class="flex-1">
                                            <p class="text-xs text-red-300 font-medium mb-1">{{ t('failureReason') }}:</p>
                                            <p class="text-xs text-red-200 whitespace-pre-wrap">{{
                                                getTaskFailureInfo(modalTask) }}</p>
                                        </div>
                                    </div>
                                </div>
                                </div>
LiangLiu's avatar
LiangLiu committed
4480

LiangLiu's avatar
LiangLiu committed
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
                                <!-- 提示词 -->
                                <div class="bg-secondary/30 rounded-xl p-4 mb-6">
                                    <h4 class="text-sm font-medium mb-3 flex items-center">
                                        <i class="fas fa-file-alt text-gradient-icon mr-2"></i>
                                    {{ t('prompt') }}
                                    </h4>
                                    <div class="bg-dark-light rounded-lg p-4 text-sm text-gray-300">
                                    <p>{{ modalTask?.params?.prompt || t('noPrompt') }}</p>
                                    </div>
                                </div>
LiangLiu's avatar
LiangLiu committed
4491

LiangLiu's avatar
LiangLiu committed
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
                            <!-- 上传素材 -->
                            <div v-if="modalTask?.inputs && Object.keys(modalTask.inputs).length"
                                class="bg-secondary/30 rounded-xl p-4 mb-6">
                                    <h4 class="text-sm font-medium mb-3 flex items-center">
                                        <i class="fas fa-upload text-gradient-icon mr-2"></i>
                                    {{ t('uploadMaterials') }}
                                    <span v-if="loadingTaskFiles" class="ml-2 text-xs text-gray-400">({{ t('loading') }}...)</span>
                                    </h4>
                                    <div class="space-y-3">
                                    <template v-for="(input, key) in modalTask.inputs" :key="key">
                                            <div class="flex items-center gap-3">
                                                <template v-if="key.includes('image')">
                                                    <i class="fas fa-image text-gradient-icon text-xl"></i>
                                                    <div class="flex items-center gap-2">
                                                    <span
                                                        v-if="!selectedTaskFiles.inputs[key] || !selectedTaskFiles.inputs[key].url"
                                                        class="text-gray-400 text-sm">{{ typeof input === 'string' ?
                                                        input : t('image') }}</span>
                                                        <div class="flex items-center gap-2 relative group">
                                                            <img v-if="selectedTaskFiles.inputs[key] && selectedTaskFiles.inputs[key].url"
                                                            :src="selectedTaskFiles.inputs[key].url" :alt="input"
                                                                class="w-20 h-20 object-cover rounded bg-dark-light border border-gray-700"
                                                                >
                                                            <div v-else-if="selectedTaskFiles.inputs[key] && selectedTaskFiles.inputs[key].error"
                                                                class="w-20 h-20 rounded bg-red-900/20 border border-red-500/30 flex items-center justify-center">
                                                                <i class="fas fa-exclamation-triangle text-red-400"></i>
                                                            </div>
                                                            <div v-else
                                                                class="w-20 h-20 rounded bg-gray-700 border border-gray-600 flex items-center justify-center">
                                                                <i class="fas fa-spinner fa-spin text-gray-400"></i>
                                                            </div>
                                                        <button
                                                            v-if="selectedTaskFiles.inputs[key] && selectedTaskFiles.inputs[key].url"
                                                                    @click="downloadFile(selectedTaskFiles.inputs[key])"
                                                                    class="text-xs px-2 py-1 rounded">
                                                            <i
                                                                class="fas fa-download mr-1 text-white opacity-30 hover:opacity-100 transition-opacity"></i>
                                                            </button>
                                                        </div>
                                                    </div>
                                                </template>
                                                <template v-else-if="key.includes('audio')">
                                                    <i class="fas fa-microphone text-gradient-icon text-xl"></i>
                                                    <div class="flex items-center gap-2">
                                                    <span
                                                        v-if="!selectedTaskFiles.inputs[key] || !selectedTaskFiles.inputs[key].url"
                                                        class="text-gray-400 text-sm">{{ typeof input === 'string' ?
                                                        input : t('audioFile') }}</span>
                                                        <div class="flex items-center gap-2">
                                                        <audio
                                                            v-if="selectedTaskFiles.inputs[key] && selectedTaskFiles.inputs[key].url"
                                                            :src="selectedTaskFiles.inputs[key].url" controls
                                                                class="h-8 text-gradient-icon"
                                                                preload="metadata">
                                                            {{ t('browserNotSupported') }}
                                                            </audio>
                                                            <div v-else-if="selectedTaskFiles.inputs[key] && selectedTaskFiles.inputs[key].error"
                                                                class="h-8 px-3 rounded bg-red-900/20 border border-red-500/30 flex items-center">
                                                            <i
                                                                class="fas fa-exclamation-triangle text-red-400 text-xs"></i>
                                                            </div>
                                                            <div v-else
                                                                class="h-8 px-3 rounded bg-gray-700 border border-gray-600 flex items-center">
                                                                <i class="fas fa-spinner fa-spin text-gray-400 text-xs"></i>
                                                            </div>
                                                        <button
                                                            v-if="selectedTaskFiles.inputs[key] && selectedTaskFiles.inputs[key].url"
                                                                    @click="downloadFile(selectedTaskFiles.inputs[key])"
                                                                    class="text-xs px-2 py-1 rounded">
                                                            <i
                                                                class="fas fa-download mr-1 text-white opacity-30 hover:opacity-100 transition-opacity"></i>
                                                            </button>
                                                    </div>
                                </div>
                                                </template>
                                    </div>
                                        </template>
                                    </div>
                                </div>
LiangLiu's avatar
LiangLiu committed
4571

LiangLiu's avatar
LiangLiu committed
4572
4573
4574
4575
                </div>
            </div>
        </div>
    </div>
LiangLiu's avatar
LiangLiu committed
4576

LiangLiu's avatar
LiangLiu committed
4577
4578
        </div>
    </div>
LiangLiu's avatar
LiangLiu committed
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608

            <!-- 增强的提示消息系统 -->
            <div v-cloak>
                <div v-if="alert.show"
                    class="fixed top-4 left-1/2 transform -translate-x-1/2 z-[9999] max-w-xs w-full px-4"
                    :class="getAlertClass(alert.type)">
                        <div
                            class="bg-gray-800/95 backdrop-blur-sm border border-gray-700/50 rounded-lg shadow-lg transition-all duration-300 ease-out">
                        <div class="flex items-center p-3">
                            <div class="flex-shrink-0 mr-3">
                                <div class="w-6 h-6 rounded-full flex items-center justify-center"
                                    :class="getAlertIconBgClass(alert.type)">
                                    <i :class="getAlertIcon(alert.type)" class="text-xs"></i>
                                </div>
                            </div>
                            <div class="flex-1">
                                <p class="text-xs font-medium text-gray-200">
                                    {{ alert.message }}
                                </p>
                            </div>
                            <div class="flex-shrink-0 ml-2">
                                <button @click="alert.show = false"
                                        class="w-5 h-5 rounded-full flex items-center justify-center text-gray-400 hover:text-gray-200 hover:bg-gray-700/50 transition-all duration-200">
                                    <i class="fas fa-times text-xs"></i>
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
LiangLiu's avatar
LiangLiu committed
4609
4610
</div>
</div>
LiangLiu's avatar
LiangLiu committed
4611

LiangLiu's avatar
LiangLiu committed
4612
    <script src="https://unpkg.com/vue@3/dist/vue.global.js">
LiangLiu's avatar
LiangLiu committed
4613
4614
4615
    </script>

    <script>
LiangLiu's avatar
LiangLiu committed
4616
        const { createApp, ref, computed, onMounted, onUnmounted, watch, nextTick } = Vue;
LiangLiu's avatar
LiangLiu committed
4617
4618
4619
4620
4621

        createApp({
            setup() {
                // 响应式数据
                const loading = ref(false);
LiangLiu's avatar
LiangLiu committed
4622
4623
4624
                const loginLoading = ref(false);
                const initLoading = ref(false);
                const downloadLoading = ref(false);
LiangLiu's avatar
LiangLiu committed
4625
4626
4627
4628
4629
4630
4631

                // 录音相关状态
                const isRecording = ref(false);
                const mediaRecorder = ref(null);
                const audioChunks = ref([]);
                const recordingDuration = ref(0);
                const recordingTimer = ref(null);
LiangLiu's avatar
LiangLiu committed
4632
                const alert = ref({ show: false, message: '', type: 'info' });
LiangLiu's avatar
LiangLiu committed
4633

LiangLiu's avatar
LiangLiu committed
4634

LiangLiu's avatar
LiangLiu committed
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
                // 短信登录相关数据
                const phoneNumber = ref('');
                const verifyCode = ref('');
                const smsCountdown = ref(0);
                const showSmsForm = ref(false);
                const showErrorDetails = ref(false);
                const showFailureDetails = ref(false);

                // 语言切换相关
                const currentLanguage = ref('zh'); // 'zh' 或 'en'
                const showLanguageMenu = ref(false);
                const languageLoaded = ref(false); // 语言是否已加载完成

                // 任务类型下拉菜单
                const showTaskTypeMenu = ref(false);
                const showModelMenu = ref(false);
                const languageOptions = ref([
                    { code: 'zh', name: '中文', flag: 'ZH' },
                    { code: 'en', name: 'English', flag: 'EN' }
                ]);

                // 翻译函数
                const t = (key) => {
                    if (!languageLoaded.value) {
                        return '...'; // 语言未加载完成时返回占位符,避免显示原始key
                    }
                    return translations.value[currentLanguage.value]?.[key] || key;
                };
                // 多语言文本映射
                const translations = ref({
                    zh: {
                        // 通用
                        total: '',
                        tasks: '',
                        records: '',
                        imageTemplates: '图片素材',
                        audioTemplates: '音频素材',
                        noImageTemplates: '目前暂无图片素材',
                        noAudioTemplates: '目前暂无音频素材',
                        noHistoryTasks: '暂无历史任务',
                        templateDetail: '模板详情',
                        viewTemplateDetail: '查看模板详情',
LiangLiu's avatar
LiangLiu committed
4677
                        viewTaskDetails: '查看任务详情',
LiangLiu's avatar
LiangLiu committed
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
                        templateInfo: '模板信息',
                        useTemplate: '使用模板',
                        model: '模型',
                        type: '类型',
                        inputMaterials: '上传素材',
                        inputImage: '输入图片',
                        inputAudio: '输入音频',
                        applyImage: '只应用图片',
                        applyAudio: '只应用音频',
                        applyPrompt: '只应用提示词',
                        imageApplied: '图片已应用',
                        audioApplied: '音频已应用',
                        promptApplied: '提示词已应用',
                        copy: '复制',
                        promptCopied: '提示词已复制到剪贴板',
                        outputVideo: '输出视频',
                        audio: '音频',
LiangLiu's avatar
LiangLiu committed
4695
                        optional: '(选填)',
LiangLiu's avatar
LiangLiu committed
4696
4697
4698
4699
4700

                        // 页面标题
                        pageTitle: 'LightX2V服务',
                        pleaseEnterThePromptForVideoGeneration: '请输入视频生成提示词',
                        describeTheContentStyleSceneOfTheVideo: '描述视频内容、风格、场景等...',
LiangLiu's avatar
LiangLiu committed
4701
                        describeTheDigitalHumanImageBackgroundStyleActionRequirements: '描述数字人表情、语气、动作等...',
LiangLiu's avatar
LiangLiu committed
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
                        describeTheContentActionRequirementsBasedOnTheImage: '描述基于图片的视频内容、动作要求等...',
                        loginSubtitle: '一个强大的视频生成平台',

                        // 登录相关
                        loginWithGitHub: '使用GitHub登录',
                        loginWithGoogle: '使用Google登录',
                        loginWithSMS: '使用短信登录',
                        loggingIn: '登录中...',
                        logout: '退出登录',
                        loggedOut: '已退出登录',
                        loginFailed: '登录失败',
                        loginError: '登录过程中发生错误',
                        authFailed: '认证失败,请重新登录',
                        loginExpired: '登录已过期,请重新登录',
                        orLoginWith: '或使用以下方式登录',
                        login: '登录 / 注册',
                        loginLoading: '登录中...',
                        sendSmsCode: '发送验证码',
                        phoneNumber: '手机号',
                        verifyCode: '验证码',

                        // 功能特性
                        feature1: '电影级数字人视频',
                        feature2: '20倍生成提速',
                        feature3: '超低成本生成',
                        feature4: '精准口型对齐',
                        feature5: '分钟级视频时长',
                        feature6: '多场景应用',

                        // 导航和菜单
                        generateVideo: '生成视频',
                        history: '历史记录',
                        inspiration: '灵感广场',
                        myProjects: '我的项目',
                        discoverCreativity: '发现创意,激发灵感',
                        searchTasks: '搜索历史任务...',
                        searchInspiration: '搜索灵感...',
                        refresh: '刷新任务列表',
                        noHistoryTasks: '暂无历史任务',
                        startToCreateYourFirstAIVideo: '开始创建你的第一个AI视频吧',
                        switchLanguage: '切换语言',
                        selectTaskType: '选择任务类型',
                        selectTaskTypeFirst: '请先选择任务类型',
                        noHistoryRecords: '暂无历史记录',
                        imageHistoryAutoSave: '开始使用图片后,历史记录将自动保存',
                        audioHistoryAutoSave: '开始使用音频后,历史记录将自动保存',
                        clearHistory: '清空历史记录',
                        clear: '清空',
                        promptHistoryAutoSave: '开始创建任务后,提示词将自动保存',
                        searchTasks: '搜索任务',
                        initializationFailed: '初始化失败,请刷新页面重试',
                        browserNotSupported: '您的浏览器不支持播放',
                        videoLoadFailed: '视频加载失败',
                        loadingVideo: '加载视频中',
                        videoGenerating: '视频生成中',
                        taskProgress: '任务进度',
                        subtask: '子任务',
                        queuePosition: '队列位置',
                        availableWorker: '可用Worker',
                        whatDoYouWantToDo: '今天想做什么样的视频呢?',
                        whatMaterialsDoYouNeed: '创作视频需要什么素材呢?',
                        pleaseEnterTheMostDetailedVideoScript: '请输入尽可能详细的视频脚本',
                        pleaseUploadAnImageAsTheFirstFrameOfTheVideoAndTheMostDetailedVideoScript: '请上传一张图片作为视频的首帧图,以及尽可能详细的视频脚本',
                        pleaseUploadARoleImageAnAudioAndTheGeneralVideoRequirements: '请上传一张角色图片、一段音频、以及大致的视频要求',
                        collapseCreationArea: '收起创作区域',
                        startCreatingVideo: '开始创作视频···',
                        videoGeneratingFailed: '视频生成失败',
                        aiIsGeneratingYourVideo: 'AI正在生成您的视频...',

                        sorryYourVideoGenerationTaskFailed: '很抱歉,您的视频生成任务未能完成。',
                        thisTaskHasBeenCancelledYouCanRegenerateOrViewTheMaterialsYouUploadedBefore: '此任务已被取消,您可以重新生成或查看之前上传的素材。',
                        taskCancelled: '任务已取消',
                        taskDetails: '任务详情',
                        taskInfo: '任务信息',
                        taskID: '任务ID',
                        taskType: '任务类型',
                        modelName: '模型名称',
                        createTime: '创建时间',
                        updateTime: '更新时间',
                        status: '状态',
                        viewFailureReason: '查看失败原因',
                        failureReason: '失败原因',
                        noPrompt: '无提示词',
                        uploadMaterials: '上传素材',
                        loading: '加载中',
                        pending: '等待中',
                        remaining: '剩余',
                        image: '图片',
                        audioFile: '音频文件',
                        browserNotSupported: '您的浏览器不支持播放',
                        videoLoadFailed: '视频加载失败',
                        loadingVideo: '加载视频中',
                        videoGenerating: '视频生成中',
                        taskProgress: '任务进度',
                        subtask: '子任务',
                        queuePosition: '队列位置',
                        availableWorker: '可用Worker',
                        videoGeneratingFailed: '视频生成失败',
                        sorryYourVideoGenerationTaskFailed: '很抱歉,您的视频生成任务未能完成。',
                        thisTaskHasBeenCancelledYouCanRegenerateOrViewTheMaterialsYouUploadedBefore: '此任务已被取消,您可以重新生成或查看之前上传的素材。',
                        taskCancelled: '任务已取消',
                        taskInfo: '任务信息',
                        taskID: '任务ID',
                        taskType: '任务类型',
                        modelName: '模型名称',
                        createTime: '创建时间',
                        updateTime: '更新时间',
                        viewFailureReason: '查看失败原因',
                        failureReason: '失败原因',
                        noPrompt: '无提示词',
                        uploadMaterials: '上传素材',
                        loading: '加载中',
                        image: '图片',
                        audioFile: '音频文件',
                        status: '状态',
                        browserNotSupported: '您的浏览器不支持播放',
                        videoLoadFailed: '视频加载失败',
                        loadingVideo: '加载视频中',
                        videoGenerating: '视频生成中',

                        // 任务状态
                        succeed: '成功',
                        success: '成功',
                        failed: '失败',
                        running: '运行中',
                        pending: '等待中',
                        remaining: '剩余',
                        cancelled: '已取消',
                        all: '全部',

                        // 任务操作
LiangLiu's avatar
LiangLiu committed
4833
4834
4835
4836
                        reuseTask: '复用',
                        regenerateTask: '重试',
                        cancelTask: '取消',
                        retryTask: '重试',
LiangLiu's avatar
LiangLiu committed
4837
4838
                        downloadTask: '下载视频',
                        downloadVideo: '下载视频',
LiangLiu's avatar
LiangLiu committed
4839
                        deleteTask: '删除',
LiangLiu's avatar
LiangLiu committed
4840
4841
4842
4843
4844
4845

                        // 任务创建
                        createVideo: '创建视频',
                        selectTemplate: '选择模板',
                        uploadImage: '上传图片',
                        uploadAudio: '上传音频',
LiangLiu's avatar
LiangLiu committed
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
                        recordAudio: '录音',
                        recording: '录音中...',
                        takePhoto: '拍照',
                        retake: '重拍',
                        usePhoto: '使用照片',
                        upload: '上传',
                        stopRecording: '停止录音',
                        recordingStarted: '开始录音',
                        recordingStopped: '录音已停止',
                        recordingCompleted: '录音完成',
                        recordingFailed: '录音失败',
LiangLiu's avatar
LiangLiu committed
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
                        enterPrompt: '输入提示词',
                        selectModel: '选择模型',
                        startGeneration: '开始生成',
                        templates: '素材',

                        // 模型和任务类型
                        textToVideo: '文生视频',
                        imageToVideo: '图生视频',
                        speechToVideo: '数字人',

                        // 提示词相关
                        prompt: '提示词',
                        negativePrompt: '负面提示词',
                        promptTemplates: '提示词模板',
                        promptHistory: '提示词历史',

                        // 文件上传
                        uploadImageFile: '上传图片文件',
                        uploadAudioFile: '上传音频文件',
                        dragDropHere: '拖拽文件到此处或点击上传',
                        supportedImageFormats: '支持jpg、png、webp图片格式(10MB以内)',
                        supportedAudioFormats: '支持mp3、m4a、wav音频格式(120s以内)',
                        maxFileSize: '最大文件大小',

                        // 任务详情
                        taskDetails: '任务详情',
                        taskId: '任务ID',
                        taskType: '任务类型',
                        taskStatus: '任务状态',
                        createdAt: '创建时间',
                        completedAt: '完成时间',
                        duration: '持续时间',

                        // 通用操作
                        confirm: '确认',
                        cancel: '取消',
                        save: '保存',
                        edit: '编辑',
                        delete: '删除',
                        close: '关闭',
                        back: '返回',
                        next: '下一步',
                        previous: '上一步',
                        finish: '完成',
                        submitting: '提交中...',

                        // 任务类型提示信息
                        t2vHint1: '输入文字描述,AI将为您生成精彩的视频内容',
                        t2vHint2: '支持多种风格:写实、动画、艺术等',
                        t2vHint3: '可以描述场景、动作、情感等细节',
                        t2vHint4: '让您的创意通过文字变成生动的视频',
                        i2vHint1: '上传一张图片,AI将为您生成动态视频',
                        i2vHint2: '支持多种图片格式:JPG、PNG、WebP等',
                        i2vHint3: '可以生成各种风格的动态效果',
                        i2vHint4: '让静态图片动起来,创造无限可能',
                        s2vHint1: '上传一张角色图片+一段音频',
                        s2vHint2: 'AI将让角色根据音频内容说话和动作',
                        s2vHint3: '让您的角色栩栩如生地动起来',
                        s2vHint4: '来创造属于您的专属数字人吧',

                        // 消息提示
                        operationSuccess: '操作成功',
                        operationFailed: '操作失败',
                        pleaseWait: '请稍候...',
                        loading: '加载中...',
                        noData: '暂无数据',
                        errorOccurred: '发生错误',
                        networkError: '网络错误',
                        serverError: '服务器错误',
                        deleteTaskConfirm: '删除任务?',
                        deleteTaskConfirmMessage: '删除后无法恢复,包括任务记录、生成的文件、相关数据。此操作不可撤销!',
                        confirmDelete: '删除',
                        deletingTaskAlert: '正在删除任务...',
                        taskDeletedSuccessAlert: '任务删除成功',
                        deleteTaskFailedAlert: '删除任务失败',
                        getTaskDetailFailedAlert: '获取任务详情失败',
                        taskNotExistAlert: '任务不存在',
                        loadTaskFilesFailedAlert: '加载任务文件失败',
                        taskMaterialReuseSuccessAlert: '任务素材复用成功',
                        loadTaskDataFailedAlert: '加载任务数据失败',
                        fileUnavailableAlert: '文件不可用',
                        downloadFailedAlert: '下载失败',
                        taskSubmitSuccessAlert: '任务提交成功',
                        taskSubmitFailedAlert: '任务提交失败',
                        submitTaskFailedAlert: '提交任务失败',
                        fileDownloadSuccessAlert: '文件下载成功',
                        getTaskResultFailedAlert: '获取结果失败',
                        downloadTaskResultFailedAlert: '下载结果失败',
                        viewTaskResultFailedAlert: '查看结果失败',
                        cancelTaskConfirm: '取消任务?',
                        cancelTaskConfirmMessage: '取消任务后任务将停止执行,已生成的部分结果可能丢失,可以稍后重新生成。',
                        confirmCancel: '取消',
                        taskCancelSuccessAlert: '任务取消成功',
                        cancelTaskFailedAlert: '取消任务失败',
                        taskRetrySuccessAlert: '任务重试成功',
                        retryTaskFailedAlert: '重试任务失败',
                        seconds: '',
                        minutes: '分钟',
                        hours: '小时',
                        days: '',
                        weeks: '',
                        months: '',
                        years: '',
                        position: '位置',
                        remaining: '剩余',
                        calculating: '计算中',
                        completed: '已完成',
                        unknown: '未知',
                        queueing: '排队中',
                        overallProgress: '总体进度',
                        queueStatus: '排队状态',
                        templateApplied: '已应用模板',
                        promptHistoryApplied: '已应用历史提示词',
                        promptHistoryCleared: '提示词历史已清空',
                        getPromptHistoryFailed: '获取提示词历史失败',
                        saveTaskHistoryFailed: '保存任务历史失败',
                        parseTaskHistoryFailed: '解析任务历史失败',
                        getTaskHistoryFailed: '获取任务历史失败',
                        getImageHistoryFailed: '获取图片历史失败',
                        taskHistorySaved: '任务历史已保存',
                        taskHistoryCleared: '任务历史已清空',
                        clickToDownload: '点击下载',
                        clickApply: '点击应用',
                        loading: '加载中...',

                        // 时间相关
                        justNow: '刚刚',
                        minutesAgo: '分钟前',
                        hoursAgo: '小时前',
                        daysAgo: '天前',
                        weeksAgo: '周前',
                        monthsAgo: '月前',
                        yearsAgo: '年前',
                        oneMinuteAgo: '一分钟前',
                        oneHourAgo: '一小时前',
                        oneDayAgo: '一天前',
                        oneWeekAgo: '一周前',
                        oneMonthAgo: '一个月前',
                        oneYearAgo: '一年前',

                    },
                    en: {
                        // 通用
                        total: 'Total',
                        tasks: 'tasks',
                        records: 'records',
                        imageTemplates: 'Image Templates',
                        audioTemplates: 'Audio Templates',
                        noImageTemplates: 'No image templates',
                        noAudioTemplates: 'No audio templates',
                        noHistoryTasks: 'No history tasks',
                        templateDetail: 'Template detail',
                        viewTemplateDetail: 'View Template Detail',
LiangLiu's avatar
LiangLiu committed
5010
                        viewTaskDetails: 'View Task Details',
LiangLiu's avatar
LiangLiu committed
5011
5012
5013
5014
5015
5016
5017
                        templateInfo: 'Template Info',
                        useTemplate: 'Use Template',
                        model: 'Model',
                        type: 'Type',
                        inputMaterials: 'Input Materials',
                        inputImage: 'Input Image',
                        inputAudio: 'Input Audio',
LiangLiu's avatar
LiangLiu committed
5018
                        optional: '(Optional)',
LiangLiu's avatar
LiangLiu committed
5019
5020
5021
5022
5023

                        // 页面标题
                        pageTitle: 'LightX2V Service',
                        pleaseEnterThePromptForVideoGeneration: 'Please enter the prompt for video generation',
                        describeTheContentStyleSceneOfTheVideo: 'Describe the content, style, and scene of the video...',
LiangLiu's avatar
LiangLiu committed
5024
                        describeTheDigitalHumanImageBackgroundStyleActionRequirements: 'Describe the digital human expression, tone, and action...',
LiangLiu's avatar
LiangLiu committed
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
                        describeTheContentActionRequirementsBasedOnTheImage: 'Describe the content and action requirements based on the image...',
                        loginSubtitle: 'A powerful video generation platform',
                        whatDoYouWantToDo: 'What do you want to do today?',
                        whatMaterialsDoYouNeed: 'What materials do you need to create a video?',
                        pleaseEnterTheMostDetailedVideoScript: 'Please enter the most detailed video script',
                        pleaseUploadAnImageAsTheFirstFrameOfTheVideoAndTheMostDetailedVideoScript: 'Please upload an image as the first frame of the video and the most detailed video script',
                        pleaseUploadARoleImageAnAudioAndTheGeneralVideoRequirements: 'Please upload a role image, an audio, and the general video requirements',
                        collapseCreationArea: 'Collapse creation area',
                        startCreatingVideo: 'Start creating video···',

                        // 登录相关
                        loginWithGitHub: 'GitHub',
                        loginWithGoogle: 'Google',
                        loginWithSMS: 'SMS',
                        loggingIn: 'Logging in...',
                        logout: 'Logout',
                        loggedOut: 'Logged out',
                        loginFailed: 'Login failed',
                        loginError: 'Error occurred during login',
                        authFailed: 'Authentication failed, please login again',
                        loginExpired: 'Login expired, please login again',
                        orLoginWith: 'Or login with',
                        login: 'Login / Register',
                        loginLoading: 'Logging in...',
                        sendSmsCode: 'Send SMS',
                        phoneNumber: 'Phone Number',
                        verifyCode: 'Verify Code',

                        // 功能特性
                        feature1: 'Cinema-grade digital human videos',
                        feature2: '20x faster generation',
                        feature3: 'Ultra-low cost generation',
                        feature4: 'Precise lip-sync alignment',
                        feature5: 'Minute-level video duration',
                        feature6: 'Multi-scenario applications',

                        // 导航和菜单
                        generateVideo: 'Generate Video',
                        history: 'History',
                        inspiration: 'Inspiration',
                        discoverCreativity: 'Discover creativity, inspire ideas',
                        searchTasks: 'Search history tasks...',
                        searchInspiration: 'Search inspiration...',
                        refresh: 'Refresh task list',
                        noHistoryTasks: 'No history tasks',
                        startToCreateYourFirstAIVideo: 'Start creating your first AI video',
                        switchLanguage: 'Switch Language',
                        selectTaskType: 'Select Task Type',
                        selectTaskTypeFirst: 'Please select task type first',
                        noHistoryRecords: 'No history records',
                        imageHistoryAutoSave: 'Image history will be automatically saved when you start using images',
                        audioHistoryAutoSave: 'Audio history will be automatically saved when you start using audio',
                        clearHistory: 'Clear history',
                        clear: 'Clear',
                        promptHistoryAutoSave: 'Prompt history will be automatically saved when you start creating tasks',
                        promptTip: 'Describe the video content you want in detail',
                        viewFailureReason: 'View Failure Reason',
                        failureReason: 'Failure Reason',
                        noPrompt: 'No Prompt',
                        uploadMaterials: 'Upload Materials',
                        loading: 'Loading',
                        image: 'Image',
                        audioFile: 'Audio File',
                        myProjects: 'My Projects',
                        initializationFailed: 'Initialization Failed, Please Refresh The Page',
                        browserNotSupported: 'Browser Not Supported',
                        videoLoadFailed: 'Video Load Failed',
                        loadingVideo: 'Loading Video',
                        videoGenerating: 'Video Generating',
                        taskProgress: 'Task Progress',
                        subtask: 'Subtask',
                        queuePosition: 'Queue Position',
                        availableWorker: 'Available Worker',
                        videoGeneratingFailed: 'Video Generating Failed',
                        sorryYourVideoGenerationTaskFailed: 'Sorry Your Video Generation Task Failed',
                        thisTaskHasBeenCancelledYouCanRegenerateOrViewTheMaterialsYouUploadedBefore: 'This Task Has Been Cancelled You Can Regenerate Or View The Materials You Uploaded Before',
LiangLiu's avatar
LiangLiu committed
5101
5102
5103
5104
                        taskCancelled: 'Cancelled',
                        regenerateTask: 'Retry',
                        retryTask: 'Retry',
                        downloadTask: 'Download Video',
LiangLiu's avatar
LiangLiu committed
5105
                        downloadVideo: 'Download Video',
LiangLiu's avatar
LiangLiu committed
5106
                        deleteTask: 'Delete',
LiangLiu's avatar
LiangLiu committed
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
                        taskInfo: 'Task Info',
                        taskID: 'Task ID',
                        taskType: 'Task Type',
                        modelName: 'Model Name',
                        createTime: 'Create Time',
                        updateTime: 'Update Time',
                        aiIsGeneratingYourVideo: 'AI is generating your video...',
                        // 任务状态
                        success: 'Success',
                        failed: 'Failed',
                        running: 'Running',
                        pending: 'Pending',
                        cancelled: 'Cancelled',
                        all: 'All',
                        created: 'Created',
                        status: 'Status',

                        // 任务操作
LiangLiu's avatar
LiangLiu committed
5125
5126
5127
5128
                        reuseTask: 'Reuse',
                        regenerateTask: 'Retry',
                        retryTask: 'Retry',
                        downloadTask: 'Download Video',
LiangLiu's avatar
LiangLiu committed
5129
                        downloadVideo: 'Download Video',
LiangLiu's avatar
LiangLiu committed
5130
5131
                        deleteTask: 'Delete',
                        cancelTask: 'Cancel',
LiangLiu's avatar
LiangLiu committed
5132
5133
5134
5135
5136
5137
5138
5139
                        download: 'Download',
                        delete: 'Delete',

                        // 任务创建
                        createVideo: 'Create Video',
                        selectTemplate: 'Select Template',
                        uploadImage: 'Upload Image',
                        uploadAudio: 'Upload Audio',
LiangLiu's avatar
LiangLiu committed
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
                        recordAudio: 'Record Audio',
                        recording: 'Recording...',
                        takePhoto: 'Take Photo',
                        retake: 'Retake',
                        usePhoto: 'Use Photo',
                        upload: 'Upload',
                        stopRecording: 'Stop Recording',
                        recordingStarted: 'Recording started',
                        recordingStopped: 'Recording stopped',
                        recordingCompleted: 'Recording completed',
                        recordingFailed: 'Recording failed',
LiangLiu's avatar
LiangLiu committed
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
                        enterPrompt: 'Enter Prompt',
                        selectModel: 'Select Model',
                        startGeneration: 'Start Generation',
                        templates: 'Templates',
                        useTemplate: 'Use Template',
                        applyImage: 'Apply Image',
                        applyAudio: 'Apply Audio',
                        applyPrompt: 'Apply Prompt',
                        imageApplied: 'Image applied',
                        audioApplied: 'Audio applied',
                        promptApplied: 'Prompt applied',
                        copy: 'Copy',
                        promptCopied: 'Prompt copied to clipboard',
                        outputVideo: 'Output Video',

                        // 模型和任务类型
                        textToVideo: 'Text to Video',
                        imageToVideo: 'Image to Video',
                        speechToVideo: 'Speech to Video',

                        // 提示词相关
                        prompt: 'Prompt',
                        negativePrompt: 'Negative Prompt',
                        promptTemplates: 'Prompt Templates',
                        promptHistory: 'Prompt History',

                        // 任务类型提示信息
                        t2vHint1: 'Enter text description, AI will generate精彩的视频内容',
                        t2vHint2: 'Support multiple styles: realistic, animation, art, etc.',
                        t2vHint3: 'Can describe scenes, actions, emotions, etc.',
                        t2vHint4: 'Let your creativity become a vivid video',
                        i2vHint1: 'Upload an image, AI will generate dynamic video',
                        i2vHint2: 'Support multiple image formats: JPG, PNG, WebP, etc.',
                        i2vHint3: 'Can generate various dynamic effects.',
                        i2vHint4: 'Let static image become dynamic, create infinite possibilities',
                        s2vHint1: 'Upload a role image + an audio',
                        s2vHint2: 'AI will make the role speak and move according to the audio content.',
                        s2vHint3: 'Let your role become alive.',
                        s2vHint4: 'Create your own digital person.',

                        // 文件上传
                        uploadImageFile: 'Upload Image File',
                        uploadAudioFile: 'Upload Audio File',
                        dragDropHere: 'Drag and drop files here or click to upload',
                        supportedImageFormats: 'Supported jpg, png, webp image formats (< 10MB)',
LiangLiu's avatar
LiangLiu committed
5196
                        clearCharacterImageTip: 'Upload a clear character image',
LiangLiu's avatar
LiangLiu committed
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
                        maxFileSize: 'Max file size',

                        // 任务详情
                        taskDetails: 'Task Details',
                        taskId: 'Task ID',
                        taskType: 'Task Type',
                        taskStatus: 'Task Status',
                        createdAt: 'Created At',
                        completedAt: 'Completed At',
                        duration: 'Duration',

                        // 通用操作
                        confirm: 'Confirm',
                        cancel: 'Cancel',
                        save: 'Save',
                        edit: 'Edit',
                        delete: 'Delete',
                        close: 'Close',
                        back: 'Back',
                        next: 'Next',
                        previous: 'Previous',
                        finish: 'Finish',
                        submitting: 'Submitting...',

                        // 消息提示
                        operationSuccess: 'Operation successful',
                        operationFailed: 'Operation failed',
                        pleaseWait: 'Please wait...',
                        loading: 'Loading...',
                        noData: 'No data',
                        errorOccurred: 'Error occurred',
                        networkError: 'Network error',
                        serverError: 'Server error',
                        seconds: 'seconds',
                        deleteTaskConfirm: 'Delete Task?',
                        deleteTaskConfirmMessage: 'This action cannot be undone. It will delete the task record, generated files, and related data.',
                        confirmDelete: 'Delete',
                        deletingTaskAlert: 'Deleting task...',
                        taskDeletedSuccessAlert: 'Task deleted successfully',
                        deleteTaskFailedAlert: 'Delete task failed',
                        getTaskDetailFailedAlert: 'Get task detail failed',
                        taskNotExistAlert: 'Task not exist',
                        loadTaskFilesFailedAlert: 'Load task files failed',
                        taskMaterialReuseSuccessAlert: 'Task material reuse successfully',
                        loadTaskDataFailedAlert: 'Load task data failed',
                        fileUnavailableAlert: 'File unavailable',
                        downloadFailedAlert: 'Download failed',
                        taskSubmitSuccessAlert: 'Task submit successfully',
                        taskSubmitFailedAlert: 'Task submit failed',
                        submitTaskFailedAlert: 'Submit task failed',
                        fileDownloadSuccessAlert: 'File download successfully',
                        getTaskResultFailedAlert: 'Get task result failed',
                        downloadTaskResultFailedAlert: 'Download task result failed',
                        viewTaskResultFailedAlert: 'View task result failed',
                        cancelTaskConfirm: 'Cancel task?',
                        cancelTaskConfirmMessage: 'Cancel task will stop the task execution, and the generated part of the result may be lost, can be regenerated later.',
                        confirmCancel: 'Cancel',
                        taskCancelSuccessAlert: 'Task cancel successfully',
                        cancelTaskFailedAlert: 'Cancel task failed',
                        taskRetrySuccessAlert: 'Task retry successfully',
                        retryTaskFailedAlert: 'Retry task failed',
                        minutes: 'minutes',
                        hours: 'hours',
                        days: 'days',
                        weeks: 'weeks',
                        months: 'months',
                        years: 'years',
                        position: 'position',
                        remaining: 'remaining',
                        calculating: 'calculating',
                        completed: 'completed',
                        unknown: 'unknown',
                        queueing: 'queueing',
                        running: 'running',
                        overallProgress: 'overall progress',
                        queueStatus: 'queue status',
                        seconds: 'seconds',
                        minutes: 'minutes',
                        hours: 'hours',
                        days: 'days',
                        weeks: 'weeks',
                        months: 'months',
                        years: 'years',
                        position: 'position',
                        remaining: 'remaining',
                        calculating: 'calculating',
                        completed: 'completed',
                        unknown: 'unknown',
                        queueing: 'queueing',
                        running: 'running',
                        overallProgress: 'overall progress',
                        queueStatus: 'queue status',
                        templateApplied: 'Template applied',
                        promptHistoryApplied: 'Prompt history applied',
                        promptHistoryCleared: 'Prompt history cleared',
                        getPromptHistoryFailed: 'Get prompt history failed',
                        saveTaskHistoryFailed: 'Save task history failed',
                        parseTaskHistoryFailed: 'Parse task history failed',
                        getTaskHistoryFailed: 'Get task history failed',
                        getImageHistoryFailed: 'Get image history failed',
                        taskHistorySaved: 'Task history saved',
                        taskHistoryCleared: 'Task history cleared',
                        clickToDownload: 'Click to download',
                        clickApply: 'Click to apply',

                        // 时间相关
                        justNow: 'Just now',
                        minutesAgo: 'minutes ago',
                        hoursAgo: 'hours ago',
                        daysAgo: 'days ago',
                        weeksAgo: 'weeks ago',
                        monthsAgo: 'months ago',
                        yearsAgo: 'years ago',
                        oneMinuteAgo: 'one minute ago',
                        oneHourAgo: 'one hour ago',
                        oneDayAgo: 'one day ago',
                        oneWeekAgo: 'one week ago',
                        oneMonthAgo: 'one month ago',
                        oneYearAgo: 'one year ago',

                    }
                });

                // 任务状态轮询相关
                const pollingInterval = ref(null);
                const pollingTasks = ref(new Set()); // 正在轮询的任务ID集合
                const confirmDialog = ref({
                    show: false,
                    title: '',
                    message: '',
                    confirmText: '确认', // 使用静态文本,避免翻译依赖
                    warning: null,
                    confirm: () => { }
                });
LiangLiu's avatar
LiangLiu committed
5331
                const submitting = ref(false);
LiangLiu's avatar
LiangLiu committed
5332
                const taskSearchQuery = ref('');
LiangLiu's avatar
LiangLiu committed
5333
                const sidebarCollapsed = ref(false);
LiangLiu's avatar
LiangLiu committed
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
                const showExpandHint = ref(false);
                const showGlow = ref(false);
                const isDefaultStateHidden = ref(false);
                const isCreationAreaExpanded = ref(false);
                const hasUploadedContent = ref(false);
                const isContracting = ref(false);

                // 新增:视图切换相关状态
                const currentView = ref('create'); // 'create'、'projects' 或 'inspiration'
                const showTaskDetailModal = ref(false);
                const modalTask = ref(null);

LiangLiu's avatar
LiangLiu committed
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
                // 视频加载状态跟踪
                const videoLoadedStates = ref(new Map()); // 跟踪每个视频的加载状态

                // 检查视频是否已加载完成
                const isVideoLoaded = (videoSrc) => {
                    return videoLoadedStates.value.get(videoSrc) || false;
                };

                // 设置视频加载状态
                const setVideoLoaded = (videoSrc, loaded) => {
                    videoLoadedStates.value.set(videoSrc, loaded);
                };

LiangLiu's avatar
LiangLiu committed
5359
5360
5361
5362
                // 灵感广场相关数据
                const inspirationSearchQuery = ref('');
                const selectedInspirationCategory = ref('all');
                const inspirationItems = ref([]);
LiangLiu's avatar
LiangLiu committed
5363
                const InspirationCategories = ref([]);
LiangLiu's avatar
LiangLiu committed
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397

                // 灵感广场分页相关变量
                const inspirationPagination = ref(null);
                const inspirationCurrentPage = ref(1);
                const inspirationPageSize = ref(12);
                const inspirationPageInput = ref(1);
                const inspirationPaginationKey = ref(0);

                // 模板详情弹窗相关数据
                const showTemplateDetailModal = ref(false);
                const selectedTemplate = ref(null);

                // 图片放大弹窗相关数据
                const showImageZoomModal = ref(false);
                const zoomedImageUrl = ref('');

                // 任务文件缓存系统
                const taskFileCache = ref(new Map());
                const taskFileCacheLoaded = ref(false);

                // 模板文件缓存系统
                const templateFileCache = ref(new Map());
                const templateFileCacheLoaded = ref(false);

                // localStorage缓存相关常量
                const TASK_FILE_CACHE_KEY = 'lightx2v_task_files';
                const TEMPLATE_FILE_CACHE_KEY = 'lightx2v_template_files';
                const TASK_FILE_CACHE_EXPIRY = 24 * 60 * 60 * 1000; // 24小时过期
                const MODELS_CACHE_KEY = 'lightx2v_models';
                const MODELS_CACHE_EXPIRY = 60 * 60 * 1000; // 1小时过期
                const TEMPLATES_CACHE_KEY = 'lightx2v_templates';
                const TEMPLATES_CACHE_EXPIRY = 24 * 60 * 60 * 1000; // 24小时过期
                const TASKS_CACHE_KEY = 'lightx2v_tasks';
                const TASKS_CACHE_EXPIRY = 5 * 60 * 1000; // 5分钟过期
LiangLiu's avatar
LiangLiu committed
5398
5399
5400
5401
5402

                const imageTemplates = ref([]);
                const audioTemplates = ref([]);
                const showImageTemplates = ref(false);
                const showAudioTemplates = ref(false);
LiangLiu's avatar
LiangLiu committed
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
                const mediaModalTab = ref('history');

                // Template分页相关变量
                const templatePagination = ref(null);
                const templateCurrentPage = ref(1);
                const templatePageSize = ref(12); // 图片模板每页12个,音频模板每页10个
                const templatePageInput = ref(1);
                const templatePaginationKey = ref(0);
                const imageHistory = ref([]);
                const audioHistory = ref([]);

                // 模板文件缓存,避免重复下载
LiangLiu's avatar
LiangLiu committed
5415
5416
5417
                const currentUser = ref({});
                const models = ref([]);
                const tasks = ref([]);
LiangLiu's avatar
LiangLiu committed
5418
                const isLoggedIn = ref(null); // null表示未初始化,false表示未登录,true表示已登录
LiangLiu's avatar
LiangLiu committed
5419
5420
5421
5422
5423
5424
5425

                const selectedTaskId = ref(null);
                const selectedTask = ref(null);
                const selectedTaskFiles = ref({ inputs: {}, outputs: {} }); // 存储任务的输入输出文件
                const loadingTaskFiles = ref(false); // 加载任务文件的状态
                const statusFilter = ref('ALL');
                const pagination = ref(null);
LiangLiu's avatar
LiangLiu committed
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
                const currentTaskPage = ref(1);
                const taskPageSize = ref(12);
                const taskPageInput = ref(1);
                const paginationKey = ref(0); // 用于强制刷新分页组件
                const taskMenuVisible = ref({}); // 管理每个任务的菜单显示状态
                const nameMap = computed(() => ({
                    't2v': t('textToVideo'),
                    'i2v': t('imageToVideo'),
                    's2v': t('speechToVideo')
                }));

                // 任务类型提示信息
                const taskHints = computed(() => ({
                    't2v': [
                        t('t2vHint1'),
                        t('t2vHint2'),
                        t('t2vHint3'),
                        t('t2vHint4')
                    ],
                    'i2v': [
                        t('i2vHint1'),
                        t('i2vHint2'),
                        t('i2vHint3'),
                        t('i2vHint4')
                    ],
                    's2v': [
                        t('s2vHint1'),
                        t('s2vHint2'),
                        t('s2vHint3'),
                        t('s2vHint4')
                    ]
                }));

                // 当前任务类型的提示信息
                const currentTaskHints = computed(() => {
                    return taskHints.value[selectedTaskId.value] || taskHints.value['s2v'];
                });

                // 滚动提示相关
                const currentHintIndex = ref(0);
                const hintInterval = ref(null);

                // 开始滚动提示
                const startHintRotation = () => {
                    if (hintInterval.value) {
                        clearInterval(hintInterval.value);
                    }
                    hintInterval.value = setInterval(() => {
                        currentHintIndex.value = (currentHintIndex.value + 1) % currentTaskHints.value.length;
                    }, 3000); // 每3秒切换一次
                };

                // 停止滚动提示
                const stopHintRotation = () => {
                    if (hintInterval.value) {
                        clearInterval(hintInterval.value);
                        hintInterval.value = null;
                    }
                };
LiangLiu's avatar
LiangLiu committed
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503

                // 为三个任务类型分别创建独立的表单
                const t2vForm = ref({
                    task: 't2v',
                    model_cls: '',
                    stage: 'single_stage',
                    prompt: '',
                    seed: 42
                });

                const i2vForm = ref({
                    task: 'i2v',
                    model_cls: '',
                    stage: 'multi_stage',
                    imageFile: null,
                    prompt: '',
                    seed: 42
                });

LiangLiu's avatar
LiangLiu committed
5504
5505
                const s2vForm = ref({
                    task: 's2v',
LiangLiu's avatar
LiangLiu committed
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
                    model_cls: '',
                    stage: 'single_stage',
                    imageFile: null,
                    audioFile: null,
                    prompt: '',
                    seed: 42
                });

                // 根据当前选择的任务类型获取对应的表单
                const getCurrentForm = () => {
                    switch (selectedTaskId.value) {
                        case 't2v':
                            return t2vForm.value;
                        case 'i2v':
                            return i2vForm.value;
LiangLiu's avatar
LiangLiu committed
5521
5522
                        case 's2v':
                            return s2vForm.value;
LiangLiu's avatar
LiangLiu committed
5523
5524
5525
5526
5527
                        default:
                            return t2vForm.value;
                    }
                };

LiangLiu's avatar
LiangLiu committed
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
                // 控制默认状态显示/隐藏的方法
                const hideDefaultState = () => {
                    isDefaultStateHidden.value = true;
                };

                const showDefaultState = () => {
                    isDefaultStateHidden.value = false;
                };

                // 控制创作区域展开/收缩的方法
                const expandCreationArea = () => {
                    isCreationAreaExpanded.value = true;
                    // 添加show类来触发动画
                    setTimeout(() => {
                        const creationArea = document.querySelector('.creation-area');
                        if (creationArea) {
                            creationArea.classList.add('show');
                        }
                    }, 10);
                };

                const contractCreationArea = () => {
                    isContracting.value = true;
                    const creationArea = document.querySelector('.creation-area');
                    if (creationArea) {
                        // 添加hide类来触发收起动画
                        creationArea.classList.add('hide');
                        creationArea.classList.remove('show');
                    }
                    // 等待动画完成后更新状态
                    setTimeout(() => {
                        isCreationAreaExpanded.value = false;
                        isContracting.value = false;
                        if (creationArea) {
                            creationArea.classList.remove('hide');
                        }
                    }, 400);
                };

LiangLiu's avatar
LiangLiu committed
5567
5568
                // 为每个任务类型创建独立的预览变量
                const i2vImagePreview = ref(null);
LiangLiu's avatar
LiangLiu committed
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
                const s2vImagePreview = ref(null);
                const s2vAudioPreview = ref(null);

                // 监听上传内容变化
                const updateUploadedContentStatus = () => {
                    hasUploadedContent.value = !!(getCurrentImagePreview() || getCurrentAudioPreview() || getCurrentForm().prompt?.trim());
                };

                // 监听表单变化
                watch([i2vImagePreview, s2vImagePreview, s2vAudioPreview, () => getCurrentForm().prompt], () => {
                    updateUploadedContentStatus();
                }, { deep: true });

                // 监听任务类型变化,重置提示滚动
                watch(selectedTaskId, () => {
                    currentHintIndex.value = 0;
                    stopHintRotation();
                    startHintRotation();
                });
LiangLiu's avatar
LiangLiu committed
5588
5589
5590
5591
5592
5593
5594
5595

                // 根据当前任务类型获取对应的预览变量
                const getCurrentImagePreview = () => {
                    switch (selectedTaskId.value) {
                        case 't2v':
                            return null;
                        case 'i2v':
                            return i2vImagePreview.value;
LiangLiu's avatar
LiangLiu committed
5596
5597
                        case 's2v':
                            return s2vImagePreview.value;
LiangLiu's avatar
LiangLiu committed
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
                        default:
                            return null;
                    }
                };

                const getCurrentAudioPreview = () => {
                    switch (selectedTaskId.value) {
                        case 't2v':
                            return null
                        case 'i2v':
                            return null
LiangLiu's avatar
LiangLiu committed
5609
5610
                        case 's2v':
                            return s2vAudioPreview.value;
LiangLiu's avatar
LiangLiu committed
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
                        default:
                            return null;
                    }
                };

                const setCurrentImagePreview = (value) => {
                    switch (selectedTaskId.value) {
                        case 't2v':
                            break;
                        case 'i2v':
                            i2vImagePreview.value = value;
                            break;
LiangLiu's avatar
LiangLiu committed
5623
5624
                        case 's2v':
                            s2vImagePreview.value = value;
LiangLiu's avatar
LiangLiu committed
5625
5626
                            break;
                    }
LiangLiu's avatar
LiangLiu committed
5627
5628
                    // 清除图片预览缓存,确保新图片能正确显示
                    urlCache.value.delete('current_image_preview');
LiangLiu's avatar
LiangLiu committed
5629
5630
5631
5632
5633
5634
5635
5636
                };

                const setCurrentAudioPreview = (value) => {
                    switch (selectedTaskId.value) {
                        case 't2v':
                            break;
                        case 'i2v':
                            break;
LiangLiu's avatar
LiangLiu committed
5637
5638
                        case 's2v':
                            s2vAudioPreview.value = value;
LiangLiu's avatar
LiangLiu committed
5639
5640
5641
5642
5643
5644
5645
                            break;
                    }
                };

                // 提示词模板相关
                const showTemplates = ref(false);
                const showHistory = ref(false);
LiangLiu's avatar
LiangLiu committed
5646
5647
                const showPromptModal = ref(false);
                const promptModalTab = ref('templates');
LiangLiu's avatar
LiangLiu committed
5648
5649
5650
5651
5652
5653
5654

                // 计算属性
                const availableTaskTypes = computed(() => {
                    const types = [...new Set(models.value.map(m => m.task))];
                    // 重新排序,确保数字人在最左边
                    const orderedTypes = [];

LiangLiu's avatar
LiangLiu committed
5655
5656
5657
                    // 检查是否有s2v模型,如果有则添加s2v类型
                    const hasS2vModels = models.value.some(m =>
                        m.task === 's2v'
LiangLiu's avatar
LiangLiu committed
5658
5659
5660
                    );

                    // 优先添加数字人(如果存在相关模型)
LiangLiu's avatar
LiangLiu committed
5661
5662
                    if (hasS2vModels) {
                        orderedTypes.push('s2v');
LiangLiu's avatar
LiangLiu committed
5663
5664
5665
5666
                    }

                    // 然后添加其他类型
                    types.forEach(type => {
LiangLiu's avatar
LiangLiu committed
5667
                        if (type !== 's2v') {
LiangLiu's avatar
LiangLiu committed
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
                            orderedTypes.push(type);
                        }
                    });

                    return orderedTypes;
                });

                const availableModelClasses = computed(() => {
                    if (!selectedTaskId.value) return [];

                    // 其他任务类型正常处理
                    return [...new Set(models.value
                        .filter(m => m.task === selectedTaskId.value)
                        .map(m => m.model_cls))];
                });

                const filteredTasks = computed(() => {
                    let filtered = tasks.value;

                    // 状态过滤
                    if (statusFilter.value !== 'ALL') {
                        filtered = filtered.filter(task => task.status === statusFilter.value);
                    }

                    // 搜索过滤
LiangLiu's avatar
LiangLiu committed
5693
                    if (taskSearchQuery.value) {
LiangLiu's avatar
LiangLiu committed
5694
                        filtered = filtered.filter(task =>
LiangLiu's avatar
LiangLiu committed
5695
5696
5697
                        task.params.prompt?.toLowerCase().includes(taskSearchQuery.value.toLowerCase()) ||
                        task.task_id.toLowerCase().includes(taskSearchQuery.value.toLowerCase()) ||
                            nameMap.value[task.task_type].toLowerCase().includes(taskSearchQuery.value.toLowerCase())
LiangLiu's avatar
LiangLiu committed
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
                    );
                    }

                    // 按时间排序,最新的任务在前面
                    filtered = filtered.sort((a, b) => {
                        const timeA = parseInt(a.create_t) || 0;
                        const timeB = parseInt(b.create_t) || 0;
                        return timeB - timeA; // 降序排列,最新的在前
                    });

LiangLiu's avatar
LiangLiu committed
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
                    return filtered;
                });

                // 监听状态筛选变化,重置分页到第一页
                watch(statusFilter, (newStatus, oldStatus) => {
                    if (newStatus !== oldStatus) {
                        currentTaskPage.value = 1;
                        taskPageInput.value = 1;
                        refreshTasks(true); // 强制刷新
                    }
                });

                // 监听搜索查询变化,重置分页到第一页
                watch(taskSearchQuery, (newQuery, oldQuery) => {
                    if (newQuery !== oldQuery) {
                        currentTaskPage.value = 1;
                        taskPageInput.value = 1;
                        refreshTasks(true); // 强制刷新
                    }
                });

                // 分页信息计算属性,确保响应式更新
                const paginationInfo = computed(() => {
                    if (!pagination.value) return null;

                    return {
                        total: pagination.value.total || 0,
                        total_pages: pagination.value.total_pages || 0,
                        current_page: pagination.value.current_page || currentTaskPage.value,
                        page_size: pagination.value.page_size || taskPageSize.value
                    };
                });

                // Template分页信息计算属性
                const templatePaginationInfo = computed(() => {
                    if (!templatePagination.value) return null;

                    return {
                        total: templatePagination.value.total || 0,
                        total_pages: templatePagination.value.total_pages || 0,
                        current_page: templatePagination.value.current_page || templateCurrentPage.value,
                        page_size: templatePagination.value.page_size || templatePageSize.value
                    };
                });

                // 灵感广场分页信息计算属性
                const inspirationPaginationInfo = computed(() => {
                    if (!inspirationPagination.value) return null;

                    return {
                        total: inspirationPagination.value.total || 0,
                        total_pages: inspirationPagination.value.total_pages || 0,
                        current_page: inspirationPagination.value.current_page || inspirationCurrentPage.value,
                        page_size: inspirationPagination.value.page_size || inspirationPageSize.value
                    };
                });


                // 通用URL缓存
                const urlCache = ref(new Map());

                // 通用URL缓存函数
                const getCachedUrl = (key, urlGenerator) => {
                    if (urlCache.value.has(key)) {
                        return urlCache.value.get(key);
                    }

                    const url = urlGenerator();
                    urlCache.value.set(key, url);
                    return url;
                };

                // 获取历史图片URL(带缓存)
                const getHistoryImageUrl = (history) => {
                    if (!history || !history.thumbnail) return '';
                    return getCachedUrl(`history_image_${history.filename}`, () => history.thumbnail);
                };

                // 获取用户头像URL(带缓存)
                const getUserAvatarUrl = (user) => {
                    if (!user || !user.avatar) return '';
                    return getCachedUrl(`user_avatar_${user.username}`, () => user.avatar);
                };

                // 获取当前图片预览URL(带缓存)
                const getCurrentImagePreviewUrl = () => {
                    const preview = getCurrentImagePreview();
                    if (!preview) return '';
                    return getCachedUrl(`current_image_preview`, () => preview);
                };

                // 获取当前音频预览URL(带缓存)
                const getCurrentAudioPreviewUrl = () => {
                    const preview = getCurrentAudioPreview();
                    if (!preview) return '';
                    return getCachedUrl(`current_audio_preview`, () => preview);
                };
LiangLiu's avatar
LiangLiu committed
5805
5806
5807
5808
5809
5810
5811
5812
5813

                // 方法
                const showAlert = (message, type = 'info') => {
                    alert.value = { show: true, message, type };
                    setTimeout(() => {
                        alert.value.show = false;
                    }, 5000);
                };

LiangLiu's avatar
LiangLiu committed
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
                // 显示确认对话框
                const showConfirmDialog = (options) => {
                    return new Promise((resolve) => {
                        confirmDialog.value = {
                            show: true,
                            title: options.title || '确认操作',
                            message: options.message || '确定要执行此操作吗?',
                            confirmText: options.confirmText || '确认',
                            warning: options.warning || null,
                            confirm: () => {
                                confirmDialog.value.show = false;
                                resolve(true);
                            },
                            cancel: () => {
                                confirmDialog.value.show = false;
                                resolve(false);
                            }
                        };
                    });
                };

LiangLiu's avatar
LiangLiu committed
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
                const setLoading = (value) => {
                    loading.value = value;
                };

                const apiCall = async (endpoint, options = {}) => {
                    const url = `${endpoint}`;
                    const headers = {
                        'Content-Type': 'application/json',
                        ...options.headers
                    };

                    if (localStorage.getItem('accessToken')) {
                        headers['Authorization'] = `Bearer ${localStorage.getItem('accessToken')}`;
                    }

                    const response = await fetch(url, {
                        ...options,
                        headers
                    });

                    if (response.status === 401) {
                        logout();
LiangLiu's avatar
LiangLiu committed
5857
5858
                        throw new Error('认证失败,请重新登录');
                    }
LiangLiu's avatar
LiangLiu committed
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
                    if (response.status === 400) {
                        const error = await response.json();
                        showAlert(error.message, 'danger');
                        throw new Error(error.message);
                    }

                    // 添加50ms延迟,防止触发服务端频率限制
                    await new Promise(resolve => setTimeout(resolve, 50));

                    return response;
                };

LiangLiu's avatar
LiangLiu committed
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
                const beforeLogin = () => {
                    localStorage.removeItem('loginSource');
                    localStorage.removeItem('accessToken');
                    localStorage.removeItem('currentUser');
                    clearAllCache();
                    switchToLoginView();
                    currentUser.value = {};
                    isLoggedIn.value = false;
                    models.value = [];
                    tasks.value = [];
                };

LiangLiu's avatar
LiangLiu committed
5883
5884
                const loginWithGitHub = async () => {
                    try {
LiangLiu's avatar
LiangLiu committed
5885
                        beforeLogin();
LiangLiu's avatar
LiangLiu committed
5886
5887
                        console.log('starting login')
                        loginLoading.value = true;
LiangLiu's avatar
LiangLiu committed
5888
5889
                        const response = await fetch('./auth/login/github');
                        const data = await response.json();
LiangLiu's avatar
LiangLiu committed
5890
                        localStorage.setItem('loginSource', 'github');
LiangLiu's avatar
LiangLiu committed
5891
5892
5893
                        window.location.href = data.auth_url;
                    } catch (error) {
                        showAlert('获取GitHub认证URL失败', 'danger');
LiangLiu's avatar
LiangLiu committed
5894
5895
5896
5897
5898
                    }
                };

                const loginWithGoogle = async () => {
                    try {
LiangLiu's avatar
LiangLiu committed
5899
5900
5901
                        beforeLogin();
                        console.log('starting login')
                        loginLoading.value = true;
LiangLiu's avatar
LiangLiu committed
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
                        const response = await fetch('./auth/login/google');
                        const data = await response.json();
                        localStorage.setItem('loginSource', 'google');
                        window.location.href = data.auth_url;
                    } catch (error) {
                        showAlert('获取Google认证URL失败', 'danger');
                    }
                };

                // 发送短信验证码
                const sendSmsCode = async () => {
                    if (!phoneNumber.value) {
                        showAlert('手机号', 'warning');
                        return;
                    }

                    // 简单的手机号格式验证
                    const phoneRegex = /^1[3-9]\d{9}$/;
                    if (!phoneRegex.test(phoneNumber.value)) {
                        showAlert('请输入正确的手机号格式', 'warning');
                        return;
                    }

                    try {
LiangLiu's avatar
LiangLiu committed
5926
                        beforeLogin();
LiangLiu's avatar
LiangLiu committed
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
                        const response = await fetch(`./auth/login/sms?phone_number=${phoneNumber.value}`);
                        const data = await response.json();

                        if (response.ok) {
                            showAlert('验证码已发送,请查收短信', 'success');
                            // 开始倒计时
                            startSmsCountdown();
                        } else {
                            showAlert(data.message || '发送验证码失败', 'danger');
                        }
                    } catch (error) {
                        showAlert('发送验证码失败,请重试', 'danger');
                    } finally {
                        loginLoading.value = false;
                    }
                };

                // 短信验证码登录
                const loginWithSms = async () => {
                    if (!phoneNumber.value || !verifyCode.value) {
                        showAlert('请输入手机号和验证码', 'warning');
                        return;
                    }

                    try {
                        loginLoading.value = true;
                        const response = await fetch(`./auth/callback/sms?phone_number=${phoneNumber.value}&verify_code=${verifyCode.value}`);
                        const data = await response.json();

                        if (response.ok) {
                            localStorage.setItem('accessToken', data.access_token);
                            localStorage.setItem('currentUser', JSON.stringify(data.user_info));
                            currentUser.value = data.user_info;
                            isLoggedIn.value = true;

                            // 登录成功后初始化数据
                            await init();

LiangLiu's avatar
LiangLiu committed
5965
5966
5967
5968
5969
5970
5971
5972
                            // 登录成功后跳转到用户原本想访问的页面,如果没有则跳转到创建页面
                            if (currentView.value === 'login') {
                                currentView.value = 'create';
                                updateURL('create');
                            } else {
                                updateURL(currentView.value);
                            }

LiangLiu's avatar
LiangLiu committed
5973
5974
5975
5976
5977
5978
                            showAlert('登录成功', 'success');
                        } else {
                            showAlert(data.message || '验证码错误或已过期', 'danger');
                        }
                    } catch (error) {
                        showAlert('登录失败,请重试', 'danger');
LiangLiu's avatar
LiangLiu committed
5979
                    } finally {
LiangLiu's avatar
LiangLiu committed
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
                        loginLoading.value = false;
                    }
                };

                // 处理手机号输入框回车键
                const handlePhoneEnter = () => {
                    if (phoneNumber.value && !smsCountdown.value) {
                        sendSmsCode();
                    }
                };

                // 处理验证码输入框回车键
                const handleVerifyCodeEnter = () => {
                    if (phoneNumber.value && verifyCode.value) {
                        loginWithSms();
                    }
                };

                // 移动端检测和样式应用
                const applyMobileStyles = () => {
                    if (window.innerWidth <= 640) {
                        // 为左侧功能区添加移动端样式
                        const leftNav = document.querySelector('.relative.w-20.pl-5.flex.flex-col.z-10');
                        if (leftNav) {
                            leftNav.classList.add('mobile-bottom-nav');
                        }

                        // 为导航按钮容器添加移动端样式
                        const navContainer = document.querySelector('.p-2.flex.flex-col.justify-center.h-full');
                        if (navContainer) {
                            navContainer.classList.add('mobile-nav-buttons');
                        }

                        // 为所有导航按钮添加移动端样式
                        const navButtons = document.querySelectorAll('.relative.w-20.pl-5.flex.flex-col.z-10 button');
                        navButtons.forEach(btn => {
                            btn.classList.add('mobile-nav-btn');
                        });

                        // 为主内容区域添加移动端样式
                        const contentAreas = document.querySelectorAll('.flex-1.flex.flex-col.min-h-0');
                        contentAreas.forEach(area => {
                            area.classList.add('mobile-content');
                        });
                    }
                };

                // 页面加载时应用移动端样式
                onMounted(() => {
                    applyMobileStyles();
                    window.addEventListener('resize', applyMobileStyles);
                });

                // 组件卸载时移除事件监听器
                onUnmounted(() => {
                    window.removeEventListener('resize', applyMobileStyles);
                });

                // 短信验证码倒计时
                const startSmsCountdown = () => {
                    smsCountdown.value = 60;
                    const timer = setInterval(() => {
                        smsCountdown.value--;
                        if (smsCountdown.value <= 0) {
                            clearInterval(timer);
                        }
                    }, 1000);
                };

                // 切换短信登录表单显示
                const toggleSmsLogin = () => {
                    showSmsForm.value = !showSmsForm.value;
                    if (!showSmsForm.value) {
                        // 重置表单数据
                        phoneNumber.value = '';
                        verifyCode.value = '';
                        smsCountdown.value = 0;
LiangLiu's avatar
LiangLiu committed
6057
6058
6059
                    }
                };

LiangLiu's avatar
LiangLiu committed
6060
                const handleLoginCallback = async (code, source) => {
LiangLiu's avatar
LiangLiu committed
6061
                    try {
LiangLiu's avatar
LiangLiu committed
6062
                        const response = await fetch(`./auth/callback/${source}?code=${code}`);
LiangLiu's avatar
LiangLiu committed
6063
6064
6065
6066
6067
6068
6069
                        if (response.ok) {
                            const data = await response.json();
                            console.log(data);
                            localStorage.setItem('accessToken', data.access_token);
                            localStorage.setItem('currentUser', JSON.stringify(data.user_info));
                            currentUser.value = data.user_info;
                            isLoggedIn.value = true;
LiangLiu's avatar
LiangLiu committed
6070
6071
6072
6073

                            // 登录成功后初始化数据
                            await init();

LiangLiu's avatar
LiangLiu committed
6074
6075
6076
6077
6078
6079
6080
6081
                            // 登录成功后跳转到用户原本想访问的页面,如果没有则跳转到创建页面
                            if (currentView.value === 'login') {
                                currentView.value = 'create';
                                updateURL('create');
                            } else {
                                updateURL(currentView.value);
                            }

LiangLiu's avatar
LiangLiu committed
6082
6083
                            // 清除URL中的code参数
                            window.history.replaceState({}, document.title, window.location.pathname);
LiangLiu's avatar
LiangLiu committed
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
                        } else {
                            const error = await response.json();
                            showAlert(`登录失败: ${error.detail}`, 'danger');
                        }
                    } catch (error) {
                        showAlert('登录过程中发生错误', 'danger');
                        console.error(error);
                    }
                };

                const logout = () => {
                    localStorage.removeItem('accessToken');
                    localStorage.removeItem('currentUser');
LiangLiu's avatar
LiangLiu committed
6097
                    clearAllCache();
LiangLiu's avatar
LiangLiu committed
6098
                    switchToLoginView();
LiangLiu's avatar
LiangLiu committed
6099
6100
6101
6102
6103
6104
6105
                    currentUser.value = {};
                    isLoggedIn.value = false;
                    models.value = [];
                    tasks.value = [];
                    showAlert('已退出登录', 'info');
                };

LiangLiu's avatar
LiangLiu committed
6106
                const loadModels = async (forceRefresh = false) => {
LiangLiu's avatar
LiangLiu committed
6107
                    try {
LiangLiu's avatar
LiangLiu committed
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
                        // 如果不是强制更新,先尝试从缓存加载
                        if (!forceRefresh) {
                            const cachedModels = loadFromCache(MODELS_CACHE_KEY, MODELS_CACHE_EXPIRY);
                            if (cachedModels) {
                                console.log('成功从缓存加载模型列表');
                                models.value = cachedModels;
                                return;
                                }
                        }

LiangLiu's avatar
LiangLiu committed
6118
6119
6120
6121
6122
                        console.log('开始加载模型列表...');
                        const response = await apiRequest('./api/v1/model/list');
                        if (response && response.ok) {
                            const data = await response.json();
                            console.log('模型列表数据:', data);
LiangLiu's avatar
LiangLiu committed
6123
6124
6125
6126
6127
6128
                            const modelsData = data.models || [];
                            models.value = modelsData;

                            // 保存到缓存
                            saveToCache(MODELS_CACHE_KEY, modelsData);
                            console.log('模型列表已缓存');
LiangLiu's avatar
LiangLiu committed
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
                        } else if (response) {
                            console.error('模型列表API响应失败:', response);
                            showAlert('加载模型列表失败', 'danger');
                        }
                        // 如果response为null,说明是认证错误,apiRequest已经处理了
                    } catch (error) {
                        console.error('加载模型失败:', error);
                        showAlert(`加载模型失败: ${error.message}`, 'danger');
                    }
                };

LiangLiu's avatar
LiangLiu committed
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
                const refreshTemplateFileUrl = (templatesData) => {
                    for (const img of templatesData.images) {
                        console.log('刷新图片素材文件URL:', img.filename, img.url);
                        setTemplateFileToCache(img.filename, {url: img.url, timestamp: Date.now()});
                    }
                    for (const audio of templatesData.audios) {
                        console.log('刷新音频素材文件URL:', audio.filename, audio.url);
                        setTemplateFileToCache(audio.filename, {url: audio.url, timestamp: Date.now()});
                    }
                    for (const video of templatesData.videos) {
                        console.log('刷新视频素材文件URL:', video.filename, video.url);
                        setTemplateFileToCache(video.filename, {url: video.url, timestamp: Date.now()});
                    }
                }

LiangLiu's avatar
LiangLiu committed
6155
                // 加载模板文件
LiangLiu's avatar
LiangLiu committed
6156
                const loadImageAudioTemplates = async (forceRefresh = false) => {
LiangLiu's avatar
LiangLiu committed
6157
                    try {
LiangLiu's avatar
LiangLiu committed
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
                        // 如果不是强制刷新,先尝试从缓存加载
                        const cacheKey = `${TEMPLATES_CACHE_KEY}_IMAGE_AUDIO_${templateCurrentPage.value}_${templatePageSize.value}`;
                        if (!forceRefresh) {
                        // 构建缓存键,包含分页和过滤条件
                        const cachedTemplates = loadFromCache(cacheKey, TEMPLATES_CACHE_EXPIRY);
                            if (cachedTemplates && cachedTemplates.templates) {
                            console.log('成功从缓存加载模板列表');
                                imageTemplates.value = cachedTemplates.templates.images || [];
                                audioTemplates.value = cachedTemplates.templates.audios || [];
                                templatePagination.value = cachedTemplates.pagination || null;
                            return;
                            }
                        }

                        console.log('开始加载图片音乐素材库...');
                        const response = await apiCall(`./api/v1/template/list?page=${templateCurrentPage.value}&page_size=${templatePageSize.value}`);
LiangLiu's avatar
LiangLiu committed
6174
6175
                        if (response.ok) {
                            const data = await response.json();
LiangLiu's avatar
LiangLiu committed
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
                            console.log('图片音乐素材库数据:', data);

                            refreshTemplateFileUrl(data.templates);
                            const templatesData = {
                                images: data.templates.images || [],
                                audios: data.templates.audios || []
                            };

                            imageTemplates.value = templatesData.images;
                            audioTemplates.value = templatesData.audios;
                            templatePagination.value = data.pagination || null;

                            // 保存到缓存
                            saveToCache(cacheKey, {
                                templates: templatesData,
                                pagination: templatePagination.value
                            });
                            console.log('图片音乐素材库已缓存:', templatesData);

LiangLiu's avatar
LiangLiu committed
6195
                        } else {
LiangLiu's avatar
LiangLiu committed
6196
                            console.warn('加载素材库失败');
LiangLiu's avatar
LiangLiu committed
6197
6198
                        }
                    } catch (error) {
LiangLiu's avatar
LiangLiu committed
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
                        console.warn('加载素材库失败:', error);
                    }
                };

                // 获取素材文件的通用函数(带缓存)
                const getTemplateFile = async (template) => {
                    const cacheKey = template.url;

                    // 先检查内存缓存
                    if (templateFileCache.value.has(cacheKey)) {
                        console.log('从内存缓存获取素材文件:', template.filename);
                        return templateFileCache.value.get(cacheKey);
                    }

                    // 如果缓存中没有,则下载并缓存
                    console.log('下载素材文件:', template.filename);
                    const response = await fetch(template.url, {
                        cache: 'force-cache' // 强制使用浏览器缓存
                    });

                    if (response.ok) {
                        const blob = await response.blob();
LiangLiu's avatar
LiangLiu committed
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240

                        // 根据文件扩展名确定正确的MIME类型
                        let mimeType = blob.type;
                        const extension = template.filename.toLowerCase().split('.').pop();

                        if (extension === 'wav') {
                            mimeType = 'audio/wav';
                        } else if (extension === 'mp3') {
                            mimeType = 'audio/mpeg';
                        } else if (extension === 'm4a') {
                            mimeType = 'audio/mp4';
                        } else if (extension === 'ogg') {
                            mimeType = 'audio/ogg';
                        } else if (extension === 'webm') {
                            mimeType = 'audio/webm';
                        }

                        console.log('文件扩展名:', extension, 'MIME类型:', mimeType);

                        const file = new File([blob], template.filename, { type: mimeType });
LiangLiu's avatar
LiangLiu committed
6241
6242
6243

                        // 缓存文件对象
                        templateFileCache.value.set(cacheKey, file);
LiangLiu's avatar
LiangLiu committed
6244
                        console.log('下载素材文件完成:', template.filename);
LiangLiu's avatar
LiangLiu committed
6245
6246
6247
                        return file;
                    } else {
                        throw new Error('下载素材文件失败');
LiangLiu's avatar
LiangLiu committed
6248
6249
6250
                    }
                };

LiangLiu's avatar
LiangLiu committed
6251
                // 选择图片素材
LiangLiu's avatar
LiangLiu committed
6252
6253
                const selectImageTemplate = async (template) => {
                    try {
LiangLiu's avatar
LiangLiu committed
6254
                        const file = await getTemplateFile(template);
LiangLiu's avatar
LiangLiu committed
6255

LiangLiu's avatar
LiangLiu committed
6256
6257
6258
6259
6260
                        if (selectedTaskId.value === 'i2v') {
                            i2vForm.value.imageFile = file;
                        } else if (selectedTaskId.value === 's2v') {
                            s2vForm.value.imageFile = file;
                        }
LiangLiu's avatar
LiangLiu committed
6261

LiangLiu's avatar
LiangLiu committed
6262
6263
6264
6265
6266
6267
                        // 创建预览
                        const reader = new FileReader();
                        reader.onload = (e) => {
                            setCurrentImagePreview(e.target.result);
                        };
                        reader.readAsDataURL(file);
LiangLiu's avatar
LiangLiu committed
6268

LiangLiu's avatar
LiangLiu committed
6269
6270
                        showImageTemplates.value = false;
                        showAlert('图片素材已选择', 'success');
LiangLiu's avatar
LiangLiu committed
6271
                    } catch (error) {
LiangLiu's avatar
LiangLiu committed
6272
                        showAlert(`加载图片素材失败: ${error.message}`, 'danger');
LiangLiu's avatar
LiangLiu committed
6273
6274
6275
                    }
                };

LiangLiu's avatar
LiangLiu committed
6276
                // 选择音频素材
LiangLiu's avatar
LiangLiu committed
6277
6278
                const selectAudioTemplate = async (template) => {
                    try {
LiangLiu's avatar
LiangLiu committed
6279
                        const file = await getTemplateFile(template);
LiangLiu's avatar
LiangLiu committed
6280

LiangLiu's avatar
LiangLiu committed
6281
                        s2vForm.value.audioFile = file;
LiangLiu's avatar
LiangLiu committed
6282

LiangLiu's avatar
LiangLiu committed
6283
6284
6285
6286
                        // 创建预览
                        const reader = new FileReader();
                        reader.onload = (e) => {
                            setCurrentAudioPreview(e.target.result);
LiangLiu's avatar
LiangLiu committed
6287
                            updateUploadedContentStatus();
LiangLiu's avatar
LiangLiu committed
6288
6289
                        };
                        reader.readAsDataURL(file);
LiangLiu's avatar
LiangLiu committed
6290

LiangLiu's avatar
LiangLiu committed
6291
6292
                        showAudioTemplates.value = false;
                        showAlert('音频素材已选择', 'success');
LiangLiu's avatar
LiangLiu committed
6293
                    } catch (error) {
LiangLiu's avatar
LiangLiu committed
6294
                        showAlert(`加载音频素材失败: ${error.message}`, 'danger');
LiangLiu's avatar
LiangLiu committed
6295
6296
6297
                    }
                };

LiangLiu's avatar
LiangLiu committed
6298
                // 预览音频素材
LiangLiu's avatar
LiangLiu committed
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
                const previewAudioTemplate = (template) => {
                    const audio = new Audio(template.url);
                    audio.play().catch(error => {
                        console.error('音频播放失败:', error);
                        showAlert('音频播放失败', 'danger');
                    });
                };

                const handleImageUpload = (event) => {
                    const file = event.target.files[0];
                    if (file) {
                        if (selectedTaskId.value === 'i2v') {
                            i2vForm.value.imageFile = file;
LiangLiu's avatar
LiangLiu committed
6312
6313
                        } else if (selectedTaskId.value === 's2v') {
                            s2vForm.value.imageFile = file;
LiangLiu's avatar
LiangLiu committed
6314
6315
6316
6317
                        }
                        const reader = new FileReader();
                        reader.onload = (e) => {
                            setCurrentImagePreview(e.target.result);
LiangLiu's avatar
LiangLiu committed
6318
                            updateUploadedContentStatus();
LiangLiu's avatar
LiangLiu committed
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
                        };
                        reader.readAsDataURL(file);
                    } else {
                        // 用户取消了选择,保持原有图片不变
                        // 不做任何操作
                    }
                };

                const selectTask = (taskType) => {
                    selectedTaskId.value = taskType;

                    // 根据任务类型恢复对应的预览
                    if (taskType === 'i2v' && i2vForm.value.imageFile) {
                        // 恢复图片预览
                        const reader = new FileReader();
                        reader.onload = (e) => {
                            setCurrentImagePreview(e.target.result);
                        };
                        reader.readAsDataURL(i2vForm.value.imageFile);
LiangLiu's avatar
LiangLiu committed
6338
                    } else if (taskType === 's2v') {
LiangLiu's avatar
LiangLiu committed
6339
                        // 恢复数字人任务的图片和音频预览
LiangLiu's avatar
LiangLiu committed
6340
                        if (s2vForm.value.imageFile) {
LiangLiu's avatar
LiangLiu committed
6341
6342
6343
6344
                            const reader = new FileReader();
                            reader.onload = (e) => {
                                setCurrentImagePreview(e.target.result);
                            };
LiangLiu's avatar
LiangLiu committed
6345
                            reader.readAsDataURL(s2vForm.value.imageFile);
LiangLiu's avatar
LiangLiu committed
6346
                        }
LiangLiu's avatar
LiangLiu committed
6347
                        if (s2vForm.value.audioFile) {
LiangLiu's avatar
LiangLiu committed
6348
6349
6350
6351
                            const reader = new FileReader();
                            reader.onload = (e) => {
                                setCurrentAudioPreview(e.target.result);
                            };
LiangLiu's avatar
LiangLiu committed
6352
                            reader.readAsDataURL(s2vForm.value.audioFile);
LiangLiu's avatar
LiangLiu committed
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
                        }
                    }

                    // 如果当前表单没有选择模型,自动选择第一个可用的模型
                    const currentForm = getCurrentForm();
                    if (!currentForm.model_cls) {
                    const availableModels = models.value.filter(m => m.task === taskType);
                    if (availableModels.length > 0) {
                        const firstModel = availableModels[0];
                            currentForm.model_cls = firstModel.model_cls;
                            currentForm.stage = firstModel.stage;
                        }
                    }
                };

                const selectModel = (model) => {
                    getCurrentForm().model_cls = model;
                };

                const triggerImageUpload = () => {
                    document.querySelector('input[type="file"][accept="image/*"]').click();
                };

                const triggerAudioUpload = () => {
                    document.querySelector('input[type="file"][accept="audio/*"]').click();
                };

                const removeImage = () => {
                    setCurrentImagePreview(null);
                    if (selectedTaskId.value === 'i2v') {
                        i2vForm.value.imageFile = null;
LiangLiu's avatar
LiangLiu committed
6384
6385
                    } else if (selectedTaskId.value === 's2v') {
                        s2vForm.value.imageFile = null;
LiangLiu's avatar
LiangLiu committed
6386
                    }
LiangLiu's avatar
LiangLiu committed
6387
                    updateUploadedContentStatus();
LiangLiu's avatar
LiangLiu committed
6388
6389
6390
6391
6392
6393
6394
6395
6396
                    // 重置文件输入框,确保可以重新选择相同文件
                    const imageInput = document.querySelector('input[type="file"][accept="image/*"]');
                    if (imageInput) {
                        imageInput.value = '';
                    }
                };

                const removeAudio = () => {
                    setCurrentAudioPreview(null);
LiangLiu's avatar
LiangLiu committed
6397
6398
                    s2vForm.value.audioFile = null;
                    updateUploadedContentStatus();
LiangLiu's avatar
LiangLiu committed
6399
6400
6401
6402
6403
6404
6405
6406
6407
                    console.log('音频已移除');
                    // 重置音频文件输入框,确保可以重新选择相同文件
                    const audioInput = document.querySelector('input[type="file"][accept="audio/*"]');
                    if (audioInput) {
                        audioInput.value = '';
                    }
                };

                const getAudioMimeType = () => {
LiangLiu's avatar
LiangLiu committed
6408
6409
                    if (s2vForm.value.audioFile) {
                        return s2vForm.value.audioFile.type;
LiangLiu's avatar
LiangLiu committed
6410
6411
6412
6413
6414
6415
6416
6417
                    }
                    return 'audio/mpeg'; // 默认类型
                };

                const handleAudioUpload = (event) => {
                    const file = event.target.files[0];

                    if (file) {
LiangLiu's avatar
LiangLiu committed
6418
                        s2vForm.value.audioFile = file;
LiangLiu's avatar
LiangLiu committed
6419
6420
6421
                        const reader = new FileReader();
                        reader.onload = (e) => {
                            setCurrentAudioPreview(e.target.result);
LiangLiu's avatar
LiangLiu committed
6422
                            updateUploadedContentStatus();
LiangLiu's avatar
LiangLiu committed
6423
6424
6425
6426
6427
                            console.log('音频预览已设置:', e.target.result);
                        };
                        reader.readAsDataURL(file);
                    } else {
                        setCurrentAudioPreview(null);
LiangLiu's avatar
LiangLiu committed
6428
                        updateUploadedContentStatus();
LiangLiu's avatar
LiangLiu committed
6429
6430
6431
                    }
                };

LiangLiu's avatar
LiangLiu committed
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
                // 开始录音
                const startRecording = async () => {
                    try {
                        // 请求麦克风权限
                        const stream = await navigator.mediaDevices.getUserMedia({
                            audio: {
                                echoCancellation: true,
                                noiseSuppression: true,
                                sampleRate: 44100
                            }
                        });

                        // 创建MediaRecorder
                        mediaRecorder.value = new MediaRecorder(stream, {
                            mimeType: 'audio/webm;codecs=opus'
                        });

                        audioChunks.value = [];

                        // 监听数据可用事件
                        mediaRecorder.value.ondataavailable = (event) => {
                            if (event.data.size > 0) {
                                audioChunks.value.push(event.data);
                            }
                        };

                        // 监听录音停止事件
                        mediaRecorder.value.onstop = () => {
                            const audioBlob = new Blob(audioChunks.value, { type: 'audio/webm' });
                            const audioFile = new File([audioBlob], 'recording.webm', { type: 'audio/webm' });

                            // 设置到表单
                            s2vForm.value.audioFile = audioFile;

                            // 创建预览URL
                            const audioUrl = URL.createObjectURL(audioBlob);
                            setCurrentAudioPreview(audioUrl);
                            updateUploadedContentStatus();

                            // 停止所有音频轨道
                            stream.getTracks().forEach(track => track.stop());

                            showAlert(t('recordingCompleted'), 'success');
                        };

                        // 开始录音
                        mediaRecorder.value.start(1000); // 每秒收集一次数据
                        isRecording.value = true;
                        recordingDuration.value = 0;

                        // 开始计时
                        recordingTimer.value = setInterval(() => {
                            recordingDuration.value++;
                        }, 1000);

                        showAlert(t('recordingStarted'), 'info');

                    } catch (error) {
                        console.error('录音失败:', error);
                        showAlert(t('recordingFailed'), 'danger');
                    }
                };

                // 停止录音
                const stopRecording = () => {
                    if (mediaRecorder.value && isRecording.value) {
                        mediaRecorder.value.stop();
                        isRecording.value = false;

                        if (recordingTimer.value) {
                            clearInterval(recordingTimer.value);
                            recordingTimer.value = null;
                        }

                        showAlert(t('recordingStopped'), 'info');
                    }
                };

                // 格式化录音时长
                const formatRecordingDuration = (seconds) => {
                    const mins = Math.floor(seconds / 60);
                    const secs = seconds % 60;
                    return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
                };

LiangLiu's avatar
LiangLiu committed
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
                const submitTask = async () => {
                    try {
                        const currentForm = getCurrentForm();

                        // 表单验证
                        if (!selectedTaskId.value) {
                            showAlert('请选择任务类型', 'warning');
                            return;
                        }

                        if (!currentForm.model_cls) {
                            showAlert('请选择模型', 'warning');
                            return;
                        }

                        if (!currentForm.prompt || currentForm.prompt.trim().length === 0) {
LiangLiu's avatar
LiangLiu committed
6533
6534
6535
6536
6537
6538
                            if (selectedTaskId.value === 's2v') {
                                currentForm.prompt = 'Make the character speak in a natural way according to the audio.';
                            } else {
                                showAlert('请输入提示词', 'warning');
                                return;
                            }
LiangLiu's avatar
LiangLiu committed
6539
6540
                        }

LiangLiu's avatar
LiangLiu committed
6541
6542
                        if (currentForm.prompt.length > 1000) {
                            showAlert('提示词长度不能超过1000个字符', 'warning');
LiangLiu's avatar
LiangLiu committed
6543
6544
6545
6546
6547
6548
6549
6550
                            return;
                        }

                        if (selectedTaskId.value === 'i2v' && !currentForm.imageFile) {
                            showAlert('图生视频任务需要上传参考图片', 'warning');
                            return;
                        }

LiangLiu's avatar
LiangLiu committed
6551
                        if (selectedTaskId.value === 's2v' && !currentForm.imageFile) {
LiangLiu's avatar
LiangLiu committed
6552
6553
6554
6555
                            showAlert('数字人任务需要上传参考图片', 'warning');
                            return;
                        }

LiangLiu's avatar
LiangLiu committed
6556
                        if (selectedTaskId.value === 's2v' && !currentForm.audioFile) {
LiangLiu's avatar
LiangLiu committed
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
                            showAlert('数字人任务需要上传音频文件', 'warning');
                            return;
                        }
                        submitting.value = true;

                        // 确定实际提交的任务类型
                        let actualTaskType = selectedTaskId.value;

                        var formData = {
                            task: actualTaskType,
                            model_cls: currentForm.model_cls,
                            stage: currentForm.stage,
                            prompt: currentForm.prompt.trim(),
                            seed: currentForm.seed || Math.floor(Math.random() * 1000000)
                        };

                        if (currentForm.model_cls.startsWith('wan2.1')) {
                            formData.negative_prompt = "镜头晃动,色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走"
                        }

                        if (selectedTaskId.value === 'i2v' && currentForm.imageFile) {
                            const base64 = await fileToBase64(currentForm.imageFile);
                            formData.input_image = {
                                type: 'base64',
                                data: base64
                            };
                        }

LiangLiu's avatar
LiangLiu committed
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
                        if (selectedTaskId.value === 's2v') {
                            if (currentForm.imageFile) {
                                const base64 = await fileToBase64(currentForm.imageFile);
                                formData.input_image = {
                                    type: 'base64',
                                    data: base64
                                };
                            }
                            if (currentForm.audioFile) {
                                const base64 = await fileToBase64(currentForm.audioFile);
                                formData.input_audio = {
                                    type: 'base64',
                                    data: base64
                                };
                                formData.negative_prompt = "色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走"
                            }
                        }

                        const response = await apiRequest('./api/v1/task/submit', {
                            method: 'POST',
                            body: JSON.stringify(formData)
                        });

                        if (response && response.ok) {
                            const result = await response.json();
                            showAlert(t('taskSubmitSuccessAlert'), 'success');

                            refreshTasks(true); // 强制刷新
                            switchToProjectsView();
                            // 开始轮询新提交的任务状态
                            startPollingTask(result.task_id);

                            // 保存完整的任务历史(包括提示词、图片和音频)
                            await addTaskToHistory(selectedTaskId.value, currentForm);
                            resetForm(selectedTaskId.value);
                            // 重置当前任务类型的表单(保留模型选择,清空图片、音频和提示词)
                            selectedTaskId.value = selectedTaskId.value;
                            selectModel(currentForm.model_cls);

                        } else {
                            const error = await response.json();
                            showAlert(`${t('taskSubmitFailedAlert')}: ${error.message},${error.detail}`, 'danger');
                        }
                    } catch (error) {
                        showAlert(`${t('submitTaskFailedAlert')}: ${error.message}`, 'danger');
                    } finally {
                        submitting.value = false;
                    }
                };

                const fileToBase64 = (file) => {
                    return new Promise((resolve, reject) => {
                        const reader = new FileReader();
                        reader.readAsDataURL(file);
                        reader.onload = () => {
                            const base64 = reader.result.split(',')[1];
                            resolve(base64);
                        };
                        reader.onerror = error => reject(error);
                    });
                };

                const formatTime = (timestamp) => {
                    if (!timestamp) return '';
                    const date = new Date(timestamp * 1000);
                    return date.toLocaleString('zh-CN');
                };

                // 通用缓存管理函数
                const loadFromCache = (cacheKey, expiryKey) => {
                    try {
                        const cached = localStorage.getItem(cacheKey);
                        if (cached) {
                            const data = JSON.parse(cached);
                            if (Date.now() - data.timestamp < expiryKey) {
                                console.log(`成功从缓存加载数据${cacheKey}:`, data.data);
                                return data.data;
                            } else {
                                // 缓存过期,清除
                                localStorage.removeItem(cacheKey);
                                console.log(`缓存过期,清除 ${cacheKey}`);
                            }
                        }
                    } catch (error) {
                        console.warn(`加载缓存失败 ${cacheKey}:`, error);
                        localStorage.removeItem(cacheKey);
                    }
                    return null;
                };

                const saveToCache = (cacheKey, data) => {
                    try {
                        const cacheData = {
                            data: data,
                            timestamp: Date.now()
                        };
                        console.log(`成功保存缓存数据 ${cacheKey}:`, cacheData);
                        localStorage.setItem(cacheKey, JSON.stringify(cacheData));
                    } catch (error) {
                        console.warn(`保存缓存失败 ${cacheKey}:`, error);
                    }
                };

                // 清除所有应用缓存
                const clearAllCache = () => {
                    try {
                        const cacheKeys = [
                            TASK_FILE_CACHE_KEY,
                            TEMPLATE_FILE_CACHE_KEY,
                            MODELS_CACHE_KEY,
                            TEMPLATES_CACHE_KEY
                        ];

                        // 清除所有任务缓存(使用通配符匹配)
                        for (let i = 0; i < localStorage.length; i++) {
                            const key = localStorage.key(i);
                            if (key && key.startsWith(TASKS_CACHE_KEY)) {
                                localStorage.removeItem(key);
                            }
                        }

                        // 清除所有模板缓存(使用通配符匹配)
                        for (let i = 0; i < localStorage.length; i++) {
                            const key = localStorage.key(i);
                            if (key && key.startsWith(TEMPLATES_CACHE_KEY)) {
                                localStorage.removeItem(key);
                            }
                        }
                        // 清除其他缓存
                        cacheKeys.forEach(key => {
                            localStorage.removeItem(key);
                        });

                        // 清除内存中的任务文件缓存
                        taskFileCache.value.clear();
                        taskFileCacheLoaded.value = false;

                        // 清除内存中的模板文件缓存
                        templateFileCache.value.clear();
                        templateFileCacheLoaded.value = false;

                        console.log('所有缓存已清除');
                    } catch (error) {
                        console.warn('清除缓存失败:', error);
                    }
                };

                // 模板文件缓存管理函数
                const loadTemplateFilesFromCache = () => {
                    try {
                        const cached = localStorage.getItem(TEMPLATE_FILE_CACHE_KEY);
                        if (cached) {
                            const data = JSON.parse(cached);
                            if (data.files) {
                                for (const [cacheKey, fileData] of Object.entries(data.files)) {
                                    templateFileCache.value.set(cacheKey, fileData);
                                }
                                return true;
                            } else {
                                console.warn('模板文件缓存数据格式错误');
                                return false;
                            }
                        }
                    } catch (error) {
                        console.warn('加载模板文件缓存失败:', error);
                    }
                    return false;
                };

                const saveTemplateFilesToCache = () => {
                    try {
                        const files = {};
                        for (const [cacheKey, fileData] of templateFileCache.value.entries()) {
                            files[cacheKey] = fileData;
                        }
                        const data = {
                            files: files,
                            timestamp: Date.now()
                        };
                        localStorage.setItem(TEMPLATE_FILE_CACHE_KEY, JSON.stringify(data));
                    } catch (error) {
                        console.warn('保存模板文件缓存失败:', error);
                    }
                };

                const getTemplateFileCacheKey = (templateId, fileKey) => {
                    return `template_${templateId}_${fileKey}`;
                };

                const getTemplateFileFromCache = (cacheKey) => {
                    return templateFileCache.value.get(cacheKey) || null;
                };

                const setTemplateFileToCache = (fileKey, fileData) => {
                    templateFileCache.value.set(fileKey, fileData);
                    // 异步保存到localStorage
                    setTimeout(() => {
                        saveTemplateFilesToCache();
                    }, 100);
                };

                const getTemplateFileUrlFromApi = async (fileKey, fileType) => {
                    const apiUrl = `./api/v1/template/asset_url/${fileType}/${fileKey}`;
                    const response = await apiRequest(apiUrl);
                    if (response && response.ok) {
                        const data = await response.json();
                        let assertUrl = data.url;
                        if (assertUrl.startsWith('./assets/')) {
                            const token = localStorage.getItem('accessToken');
                            if (token) {
                                assertUrl = `${assertUrl}&token=${encodeURIComponent(token)}`;
LiangLiu's avatar
LiangLiu committed
6796
6797
                            }
                        }
LiangLiu's avatar
LiangLiu committed
6798
6799
6800
                        setTemplateFileToCache(fileKey, {
                            url: assertUrl,
                            timestamp: Date.now()
LiangLiu's avatar
LiangLiu committed
6801
                        });
LiangLiu's avatar
LiangLiu committed
6802
6803
6804
6805
                        return assertUrl;
                    }
                    return null;
                };
LiangLiu's avatar
LiangLiu committed
6806

LiangLiu's avatar
LiangLiu committed
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
                // 获取模板文件URL(优先从缓存,缓存没有则生成URL)- 同步版本
                const getTemplateFileUrl = (fileKey, fileType) => {
                    // 先从缓存获取
                    const cachedFile = getTemplateFileFromCache(fileKey);
                    if (cachedFile) {
                        console.log('从缓存获取模板文件url', { fileKey});
                        return cachedFile.url;
                    }
                    getTemplateFileUrlFromApi(fileKey, fileType);
                };
LiangLiu's avatar
LiangLiu committed
6817

LiangLiu's avatar
LiangLiu committed
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
                // 获取模板文件URL(异步版本,用于预加载等场景)
                const getTemplateFileUrlAsync = async (fileKey, fileType) => {
                    // 先从缓存获取
                    const cachedFile = getTemplateFileFromCache(fileKey);
                    if (cachedFile) {
                        console.log('getTemplateFileUrlAsync: 从缓存获取', { fileKey, url: cachedFile.url });
                        return cachedFile.url;
                    }
                    return await getTemplateFileUrlFromApi(fileKey, fileType);
                };
LiangLiu's avatar
LiangLiu committed
6828

LiangLiu's avatar
LiangLiu committed
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
                // 任务文件缓存管理函数
                const loadTaskFilesFromCache = () => {
                    try {
                        const cached = localStorage.getItem(TASK_FILE_CACHE_KEY);
                        if (cached) {
                            const data = JSON.parse(cached);
                            // 检查是否过期
                            if (Date.now() - data.timestamp < TASK_FILE_CACHE_EXPIRY) {
                                // 将缓存数据加载到内存缓存中
                                for (const [cacheKey, fileData] of Object.entries(data.files)) {
                                    taskFileCache.value.set(cacheKey, fileData);
                                }
                                return true;
                            } else {
                                // 缓存过期,清除
                                localStorage.removeItem(TASK_FILE_CACHE_KEY);
LiangLiu's avatar
LiangLiu committed
6845
6846
6847
                            }
                        }
                    } catch (error) {
LiangLiu's avatar
LiangLiu committed
6848
6849
                        console.warn('加载任务文件缓存失败:', error);
                        localStorage.removeItem(TASK_FILE_CACHE_KEY);
LiangLiu's avatar
LiangLiu committed
6850
                    }
LiangLiu's avatar
LiangLiu committed
6851
                    return false;
LiangLiu's avatar
LiangLiu committed
6852
6853
                };

LiangLiu's avatar
LiangLiu committed
6854
6855
6856
6857
6858
6859
6860
6861
6862
                const saveTaskFilesToCache = () => {
                    try {
                        const files = {};
                        for (const [cacheKey, fileData] of taskFileCache.value.entries()) {
                            files[cacheKey] = fileData;
                        }
                        const data = {
                            files,
                            timestamp: Date.now()
LiangLiu's avatar
LiangLiu committed
6863
                        };
LiangLiu's avatar
LiangLiu committed
6864
6865
6866
6867
                        localStorage.setItem(TASK_FILE_CACHE_KEY, JSON.stringify(data));
                    } catch (error) {
                        console.warn('保存任务文件缓存失败:', error);
                    }
LiangLiu's avatar
LiangLiu committed
6868
6869
                };

LiangLiu's avatar
LiangLiu committed
6870
6871
6872
                // 生成缓存键
                const getTaskFileCacheKey = (taskId, fileKey) => {
                    return `${taskId}_${fileKey}`;
LiangLiu's avatar
LiangLiu committed
6873
6874
                };

LiangLiu's avatar
LiangLiu committed
6875
6876
6877
6878
6879
                // 从缓存获取任务文件
                const getTaskFileFromCache = (taskId, fileKey) => {
                    const cacheKey = getTaskFileCacheKey(taskId, fileKey);
                    return taskFileCache.value.get(cacheKey) || null;
                };
LiangLiu's avatar
LiangLiu committed
6880

LiangLiu's avatar
LiangLiu committed
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
                // 设置任务文件到缓存
                const setTaskFileToCache = (taskId, fileKey, fileData) => {
                    const cacheKey = getTaskFileCacheKey(taskId, fileKey);
                    taskFileCache.value.set(cacheKey, fileData);
                    // 异步保存到localStorage
                    setTimeout(() => {
                        saveTaskFilesToCache();
                    }, 100);
                };

                const getTaskFileUrlFromApi = async (taskId, fileKey) => {
                    let apiUrl = `./api/v1/task/input_url?task_id=${taskId}&name=${fileKey}`;
                    if (fileKey.includes('output')) {
                        apiUrl = `./api/v1/task/result_url?task_id=${taskId}&name=${fileKey}`;
                    }
                    const response = await apiRequest(apiUrl);
                    if (response && response.ok) {
                        const data = await response.json();
                        let assertUrl = data.url;
                        if (assertUrl.startsWith('./assets/')) {
                            const token = localStorage.getItem('accessToken');
                            if (token) {
                                assertUrl = `${assertUrl}&token=${encodeURIComponent(token)}`;
LiangLiu's avatar
LiangLiu committed
6904
6905
                            }
                        }
LiangLiu's avatar
LiangLiu committed
6906
6907
6908
6909
6910
                        setTaskFileToCache(taskId, fileKey, {
                            url: assertUrl,
                            timestamp: Date.now()
                        });
                        return assertUrl;
LiangLiu's avatar
LiangLiu committed
6911
                    }
LiangLiu's avatar
LiangLiu committed
6912
                    return null;
LiangLiu's avatar
LiangLiu committed
6913
6914
                };

LiangLiu's avatar
LiangLiu committed
6915
6916
6917
6918
6919
6920
6921
6922
6923
                // 获取任务文件URL(优先从缓存,缓存没有则调用后端)
                const getTaskFileUrl = async (taskId, fileKey) => {
                    // 先从缓存获取
                    const cachedFile = getTaskFileFromCache(taskId, fileKey);
                    if (cachedFile) {
                        return cachedFile.url;
                    }
                    return await getTaskFileUrlFromApi(taskId, fileKey);
                };
LiangLiu's avatar
LiangLiu committed
6924

LiangLiu's avatar
LiangLiu committed
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
                // 同步获取任务文件URL(仅从缓存获取,用于模板显示)
                const getTaskFileUrlSync = (taskId, fileKey) => {
                    const cachedFile = getTaskFileFromCache(taskId, fileKey);
                    if (cachedFile) {
                        console.log('getTaskFileUrlSync: 从缓存获取', { taskId, fileKey, url: cachedFile.url, type: typeof cachedFile.url });
                        return cachedFile.url;
                    }
                    console.log('getTaskFileUrlSync: 缓存中没有找到', { taskId, fileKey });
                    return null;
                };
LiangLiu's avatar
LiangLiu committed
6935

LiangLiu's avatar
LiangLiu committed
6936
6937
6938
                // 预加载任务文件
                const preloadTaskFilesUrl = async (tasks) => {
                    if (!tasks || tasks.length === 0) return;
LiangLiu's avatar
LiangLiu committed
6939

LiangLiu's avatar
LiangLiu committed
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
                    // 先尝试从localStorage加载缓存
                    if (taskFileCache.value.size === 0) {
                        loadTaskFilesFromCache();
                    }

                    console.log(`开始获取 ${tasks.length} 个任务的文件url`);

                    // 分批预加载,避免过多并发请求
                    const batchSize = 5;
                    for (let i = 0; i < tasks.length; i += batchSize) {
                        const batch = tasks.slice(i, i + batchSize);

                        const promises = batch.map(async (task) => {
                            if (!task.task_id) return;

                            // 预加载输入图片
                            if (task.inputs) {
                                const imageInputs = Object.keys(task.inputs).filter(key =>
                                    key.includes('image') ||
                                    task.inputs[key].toString().toLowerCase().match(/\.(jpg|jpeg|png|gif|bmp|webp)$/)
                                );

                                for (const imageKey of imageInputs) {
                                    await getTaskFileUrl(task.task_id, imageKey);
LiangLiu's avatar
LiangLiu committed
6964
6965
6966
                                }
                            }

LiangLiu's avatar
LiangLiu committed
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
                            // 预加载输出视频
                            if (task.outputs && task.outputs.output_video && task.status === 'SUCCEED') {
                                await getTaskFileUrl(task.task_id, 'output_video');
                            }
                        });

                        await Promise.all(promises);

                        // 批次间添加延迟
                        if (i + batchSize < tasks.length) {
                            await new Promise(resolve => setTimeout(resolve, 200));
LiangLiu's avatar
LiangLiu committed
6978
6979
                        }
                    }
LiangLiu's avatar
LiangLiu committed
6980
6981

                    console.log('任务文件url预加载完成');
LiangLiu's avatar
LiangLiu committed
6982
6983
                };

LiangLiu's avatar
LiangLiu committed
6984
6985
6986
                // 预加载模板文件
                const preloadTemplateFilesUrl = async (templates) => {
                    if (!templates || templates.length === 0) return;
LiangLiu's avatar
LiangLiu committed
6987

LiangLiu's avatar
LiangLiu committed
6988
6989
6990
6991
                    // 先尝试从localStorage加载缓存
                    if (templateFileCache.value.size === 0) {
                        loadTemplateFilesFromCache();
                    }
LiangLiu's avatar
LiangLiu committed
6992

LiangLiu's avatar
LiangLiu committed
6993
                    console.log(`开始获取 ${templates.length} 个模板的文件url`);
LiangLiu's avatar
LiangLiu committed
6994

LiangLiu's avatar
LiangLiu committed
6995
6996
6997
6998
                    // 分批预加载,避免过多并发请求
                    const batchSize = 5;
                    for (let i = 0; i < templates.length; i += batchSize) {
                        const batch = templates.slice(i, i + batchSize);
LiangLiu's avatar
LiangLiu committed
6999

LiangLiu's avatar
LiangLiu committed
7000
7001
                        const promises = batch.map(async (template) => {
                            if (!template.task_id) return;
LiangLiu's avatar
LiangLiu committed
7002

LiangLiu's avatar
LiangLiu committed
7003
7004
7005
7006
7007
7008
7009
7010
                            // 预加载视频文件
                            if (template.outputs?.output_video) {
                                await getTemplateFileUrlAsync(template.outputs.output_video, 'videos');
                            }

                            // 预加载图片文件
                            if (template.inputs?.input_image) {
                                await getTemplateFileUrlAsync(template.inputs.input_image, 'images');
LiangLiu's avatar
LiangLiu committed
7011
                            }
LiangLiu's avatar
LiangLiu committed
7012
7013
7014
7015

                            // 预加载音频文件
                            if (template.inputs?.input_audio) {
                                await getTemplateFileUrlAsync(template.inputs.input_audio, 'audios');
LiangLiu's avatar
LiangLiu committed
7016
                            }
LiangLiu's avatar
LiangLiu committed
7017
7018
7019
7020
7021
7022
7023
                        });

                        await Promise.all(promises);

                        // 批次间添加延迟
                        if (i + batchSize < templates.length) {
                            await new Promise(resolve => setTimeout(resolve, 200));
LiangLiu's avatar
LiangLiu committed
7024
7025
                        }
                    }
LiangLiu's avatar
LiangLiu committed
7026
7027

                    console.log('模板文件url预加载完成');
LiangLiu's avatar
LiangLiu committed
7028
7029
                };

LiangLiu's avatar
LiangLiu committed
7030
                const refreshTasks = async (forceRefresh = false) => {
LiangLiu's avatar
LiangLiu committed
7031
                    try {
LiangLiu's avatar
LiangLiu committed
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
                        console.log('开始刷新任务列表, forceRefresh:', forceRefresh, 'currentPage:', currentTaskPage.value);

                        // 构建缓存键,包含分页和过滤条件
                        const cacheKey = `${TASKS_CACHE_KEY}_${currentTaskPage.value}_${taskPageSize.value}_${statusFilter.value}_${taskSearchQuery.value}`;

                        // 如果不是强制刷新,先尝试从缓存加载
                        if (!forceRefresh) {
                            const cachedTasks = loadFromCache(cacheKey, TASKS_CACHE_EXPIRY);
                            if (cachedTasks) {
                                console.log('从缓存加载任务列表');
                                tasks.value = cachedTasks.tasks || [];
                                pagination.value = cachedTasks.pagination || null;
                                // 强制触发响应式更新
                                await nextTick();
                                // 强制刷新分页组件
                                paginationKey.value++;
                                // 使用新的任务文件预加载逻辑
                                await preloadTaskFilesUrl(tasks.value);
                                return;
                            }
                        }

LiangLiu's avatar
LiangLiu committed
7054
                        const params = new URLSearchParams({
LiangLiu's avatar
LiangLiu committed
7055
7056
                            page: currentTaskPage.value.toString(),
                            page_size: taskPageSize.value.toString()
LiangLiu's avatar
LiangLiu committed
7057
7058
7059
7060
7061
7062
                        });

                        if (statusFilter.value !== 'ALL') {
                            params.append('status', statusFilter.value);
                        }

LiangLiu's avatar
LiangLiu committed
7063
                        console.log('请求任务列表API:', `./api/v1/task/list?${params.toString()}`);
LiangLiu's avatar
LiangLiu committed
7064
7065
7066
                        const response = await apiRequest(`./api/v1/task/list?${params.toString()}`);
                        if (response && response.ok) {
                            const data = await response.json();
LiangLiu's avatar
LiangLiu committed
7067
7068
7069
7070
7071
7072
7073
                            console.log('任务列表API响应:', data);

                            // 强制清空并重新赋值,确保Vue检测到变化
                            tasks.value = [];
                            pagination.value = null;
                            await nextTick();

LiangLiu's avatar
LiangLiu committed
7074
7075
7076
                            tasks.value = data.tasks || [];
                            pagination.value = data.pagination || null;

LiangLiu's avatar
LiangLiu committed
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
                            // 缓存任务数据
                            saveToCache(cacheKey, {
                                tasks: data.tasks || [],
                                pagination: data.pagination || null
                            });
                            console.log('缓存任务列表数据成功');

                            // 强制触发响应式更新
                            await nextTick();

                            // 强制刷新分页组件
                            paginationKey.value++;

                            // 使用新的任务文件预加载逻辑
                            await preloadTaskFilesUrl(tasks.value);
LiangLiu's avatar
LiangLiu committed
7092
7093
7094
7095
7096
                        } else if (response) {
                            showAlert('刷新任务列表失败', 'danger');
                        }
                        // 如果response为null,说明是认证错误,apiRequest已经处理了
                    } catch (error) {
LiangLiu's avatar
LiangLiu committed
7097
                        console.error('刷新任务列表失败:', error);
LiangLiu's avatar
LiangLiu committed
7098
7099
7100
7101
                        showAlert(`刷新任务列表失败: ${error.message}`, 'danger');
                    }
                };

LiangLiu's avatar
LiangLiu committed
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
                // 分页相关函数
                const goToPage = async (page) => {
                    if (page < 1 || page > pagination.value?.total_pages || page === currentTaskPage.value) {
                        return;
                    }
                    currentTaskPage.value = page;
                    taskPageInput.value = page; // 同步更新输入框
                    await refreshTasks();
                };

                const jumpToPage = async () => {
                    const page = parseInt(taskPageInput.value);
                    if (page && page >= 1 && page <= pagination.value?.total_pages && page !== currentTaskPage.value) {
                        await goToPage(page);
                    } else {
                        // 如果输入无效,恢复到当前页
                        taskPageInput.value = currentTaskPage.value;
                    }
                };

                // Template分页相关函数
                const goToTemplatePage = async (page) => {
                    if (page < 1 || page > templatePagination.value?.total_pages || page === templateCurrentPage.value) {
                        return;
                    }
                    templateCurrentPage.value = page;
                    templatePageInput.value = page; // 同步更新输入框
                    await loadImageAudioTemplates();
                };

                const jumpToTemplatePage = async () => {
                    const page = parseInt(templatePageInput.value);
                    if (page && page >= 1 && page <= templatePagination.value?.total_pages && page !== templateCurrentPage.value) {
                        await goToTemplatePage(page);
                    } else {
                        // 如果输入无效,恢复到当前页
                        templatePageInput.value = templateCurrentPage.value;
                    }
                };

                const getVisiblePages = () => {
                    if (!pagination.value) return [];

                    const totalPages = pagination.value.total_pages;
                    const current = currentTaskPage.value;
                    const pages = [];

                    // 总是显示第一页
                    pages.push(1);

                    if (totalPages <= 5) {
                        // 如果总页数少于等于7页,显示所有页码
                        for (let i = 2; i <= totalPages - 1; i++) {
                            pages.push(i);
                        }
                    } else {
                        // 如果总页数大于7页,使用省略号
                        if (current <= 3) {
                            // 当前页在前4页
                            for (let i = 2; i <= 3; i++) {
                                pages.push(i);
                            }
                            pages.push('...');
                        } else if (current >= totalPages - 2) {
                            // 当前页在后4页
                            pages.push('...');
                            for (let i = totalPages - 2; i <= totalPages - 1; i++) {
                                pages.push(i);
                            }
                        } else {
                            // 当前页在中间
                            pages.push('...');
                            for (let i = current - 1; i <= current + 1; i++) {
                                pages.push(i);
                            }
                            pages.push('...');
                        }
                    }

                    // 总是显示最后一页(如果不是第一页)
                    if (totalPages > 1) {
                        pages.push(totalPages);
                    }

                    return pages;
                };

                const getVisibleTemplatePages = () => {
                    if (!templatePagination.value) return [];

                    const totalPages = templatePagination.value.total_pages;
                    const current = templateCurrentPage.value;
                    const pages = [];

                    // 总是显示第一页
                    pages.push(1);

                    if (totalPages <= 5) {
                        // 如果总页数少于等于7页,显示所有页码
                        for (let i = 2; i <= totalPages - 1; i++) {
                            pages.push(i);
                        }
                    } else {
                        // 显示当前页附近的页码
                        const start = Math.max(2, current - 1);
                        const end = Math.min(totalPages - 1, current + 1);

                        if (start > 2) {
                            pages.push('...');
                        }

                        for (let i = start; i <= end; i++) {
                            if (i !== 1 && i !== totalPages) {
                                pages.push(i);
                            }
                        }

                        if (end < totalPages - 1) {
                            pages.push('...');
                        }
                    }

                    // 总是显示最后一页
                    if (totalPages > 1) {
                        pages.push(totalPages);
                    }

                    return pages;
                };

                // 灵感广场分页相关函数
                const goToInspirationPage = async (page) => {
                    if (page < 1 || page > inspirationPagination.value?.total_pages || page === inspirationCurrentPage.value) {
                        return;
                    }
                    inspirationCurrentPage.value = page;
                    inspirationPageInput.value = page; // 同步更新输入框
                    await loadInspirationData();
                };

                const jumpToInspirationPage = async () => {
                    const page = parseInt(inspirationPageInput.value);
                    if (page && page >= 1 && page <= inspirationPagination.value?.total_pages && page !== inspirationCurrentPage.value) {
                        await goToInspirationPage(page);
                    } else {
                        // 如果输入无效,恢复到当前页
                        inspirationPageInput.value = inspirationCurrentPage.value;
                    }
                };

                const getVisibleInspirationPages = () => {
                    if (!inspirationPagination.value) return [];

                    const totalPages = inspirationPagination.value.total_pages;
                    const current = inspirationCurrentPage.value;
                    const pages = [];

                    // 总是显示第一页
                    pages.push(1);

                    if (totalPages <= 5) {
                        // 如果总页数少于等于7页,显示所有页码
                        for (let i = 2; i <= totalPages - 1; i++) {
                            pages.push(i);
                        }
                    } else {
                        // 显示当前页附近的页码
                        const start = Math.max(2, current - 1);
                        const end = Math.min(totalPages - 1, current + 1);

                        if (start > 2) {
                            pages.push('...');
                        }

                        for (let i = start; i <= end; i++) {
                            if (i !== 1 && i !== totalPages) {
                                pages.push(i);
                            }
                        }

                        if (end < totalPages - 1) {
                            pages.push('...');
                        }
                    }

                    // 总是显示最后一页
                    if (totalPages > 1) {
                        pages.push(totalPages);
                    }

                    return pages;
                };

LiangLiu's avatar
LiangLiu committed
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
                const getStatusBadgeClass = (status) => {
                    const statusMap = {
                        'SUCCEED': 'bg-success',
                        'FAILED': 'bg-danger',
                        'RUNNING': 'bg-warning',
                        'PENDING': 'bg-secondary',
                        'CREATED': 'bg-secondary'
                    };
                    return statusMap[status] || 'bg-secondary';
                };

                const viewSingleResult = async (taskId, key) => {
                    try {
LiangLiu's avatar
LiangLiu committed
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
                        downloadLoading.value = true;
                        const url = await getTaskFileUrl(taskId, key);
                        if (url) {
                            const response = await fetch(url);
                            if (response.ok) {
                                const blob = await response.blob();
                                const videoBlob = new Blob([blob], { type: 'video/mp4' });
                                const url = window.URL.createObjectURL(videoBlob);
                                window.open(url, '_blank');
                            } else {
                                showAlert('获取结果失败', 'danger');
                            }
LiangLiu's avatar
LiangLiu committed
7320
                        } else {
LiangLiu's avatar
LiangLiu committed
7321
                            showAlert(t('getTaskResultFailedAlert'), 'danger');
LiangLiu's avatar
LiangLiu committed
7322
7323
                        }
                    } catch (error) {
LiangLiu's avatar
LiangLiu committed
7324
                        showAlert(`${t('viewTaskResultFailedAlert')}: ${error.message}`, 'danger');
LiangLiu's avatar
LiangLiu committed
7325
                    } finally {
LiangLiu's avatar
LiangLiu committed
7326
                        downloadLoading.value = false;
LiangLiu's avatar
LiangLiu committed
7327
7328
7329
                    }
                };

LiangLiu's avatar
LiangLiu committed
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
                const cancelTask = async (taskId, fromDetailPage = false) => {
                    try {
                        // 显示确认对话框
                        const confirmed = await showConfirmDialog({
                            title: t('cancelTaskConfirm'),
                            message: t('cancelTaskConfirmMessage'),
                            confirmText: t('confirmCancel'),
                        });

                        if (!confirmed) {
                            return;
                        }

                        const response = await apiRequest(`./api/v1/task/cancel?task_id=${taskId}`);
                        if (response && response.ok) {
                            showAlert(t('taskCancelSuccessAlert'), 'success');

                            // 如果当前在任务详情界面,先刷新任务列表,然后重新获取任务信息
                            if (fromDetailPage) {
                                refreshTasks(true); // 强制刷新
                                const updatedTask = tasks.value.find(t => t.task_id === taskId);
                                if (updatedTask) {
                                    selectedTask.value = updatedTask;
                                }
                                await nextTick();
                            } else {
                                refreshTasks(true); // 强制刷新
                            }

                        } else if (response) {
                            const error = await response.json();
                            showAlert(`${t('cancelTaskFailedAlert')}: ${error.message}`, 'danger');
                        }
                        // 如果response为null,说明是认证错误,apiRequest已经处理了
                    } catch (error) {
                        showAlert(`${t('cancelTaskFailedAlert')}: ${error.message}`, 'danger');
LiangLiu's avatar
LiangLiu committed
7366
7367
7368
                    }
                };

LiangLiu's avatar
LiangLiu committed
7369
                const resumeTask = async (taskId, fromDetailPage = false) => {
LiangLiu's avatar
LiangLiu committed
7370
                    try {
LiangLiu's avatar
LiangLiu committed
7371
                        const response = await apiRequest(`./api/v1/task/resume?task_id=${taskId}`);
LiangLiu's avatar
LiangLiu committed
7372
                        if (response && response.ok) {
LiangLiu's avatar
LiangLiu committed
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
                            showAlert(t('taskRetrySuccessAlert'), 'success');

                            // 如果当前在任务详情界面,先刷新任务列表,然后重新获取任务信息
                            if (fromDetailPage) {
                                refreshTasks(true); // 强制刷新
                                const updatedTask = tasks.value.find(t => t.task_id === taskId);
                                if (updatedTask) {
                                    selectedTask.value = updatedTask;
                                }
                                startPollingTask(taskId);
                                await nextTick();
                            } else {
                                refreshTasks(true); // 强制刷新

                                // 开始轮询新提交的任务状态
                                startPollingTask(taskId);
                            }
LiangLiu's avatar
LiangLiu committed
7390
7391
                        } else if (response) {
                            const error = await response.json();
LiangLiu's avatar
LiangLiu committed
7392
                            showAlert(`${t('retryTaskFailedAlert')}: ${error.message}`, 'danger');
LiangLiu's avatar
LiangLiu committed
7393
7394
7395
                        }
                        // 如果response为null,说明是认证错误,apiRequest已经处理了
                    } catch (error) {
LiangLiu's avatar
LiangLiu committed
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
                        showAlert(`${t('retryTaskFailedAlert')}: ${error.message}`, 'danger');
                    }
                };

                // 切换任务菜单显示状态
                const toggleTaskMenu = (taskId) => {
                    // 先关闭所有其他菜单
                    closeAllTaskMenus();
                    // 然后打开当前菜单
                    taskMenuVisible.value[taskId] = true;
                };

                // 关闭所有任务菜单
                const closeAllTaskMenus = () => {
                    taskMenuVisible.value = {};
                };

                // 点击外部关闭菜单
                const handleClickOutside = (event) => {
                    if (!event.target.closest('.task-menu-container')) {
                        closeAllTaskMenus();
                    }
                    if (!event.target.closest('.language-switcher')) {
                        showLanguageMenu.value = false;
                    }
                    if (!event.target.closest('.task-type-dropdown')) {
                        showTaskTypeMenu.value = false;
                    }
                    if (!event.target.closest('.model-dropdown')) {
                        showModelMenu.value = false;
LiangLiu's avatar
LiangLiu committed
7426
7427
7428
                    }
                };

LiangLiu's avatar
LiangLiu committed
7429
                const deleteTask = async (taskId, fromDetailPage = false) => {
LiangLiu's avatar
LiangLiu committed
7430
                    try {
LiangLiu's avatar
LiangLiu committed
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
                        // 显示确认对话框
                        const confirmed = await showConfirmDialog({
                            title: t('deleteTaskConfirm'),
                            message: t('deleteTaskConfirmMessage'),
                            confirmText: t('confirmDelete')
                        });

                        if (!confirmed) {
                            return;
                        }

                        // 显示删除中的提示
                        showAlert(t('deletingTaskAlert'), 'info');

                        const response = await apiRequest(`./api/v1/task/delete?task_id=${taskId}`, {
                            method: 'DELETE'
                        });

LiangLiu's avatar
LiangLiu committed
7449
                        if (response && response.ok) {
LiangLiu's avatar
LiangLiu committed
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
                            showAlert(t('taskDeletedSuccessAlert'), 'success');
                            refreshTasks(true); // 强制刷新

                            // 如果是从任务详情页删除,则跳转回主页
                            if (fromDetailPage) {
                                if (!selectedTaskId.value) {
                                    if (availableTaskTypes.value.includes('s2v')) {
                                        selectTask('s2v');
                                    }
                                }
                            }
LiangLiu's avatar
LiangLiu committed
7461
7462
                        } else if (response) {
                            const error = await response.json();
LiangLiu's avatar
LiangLiu committed
7463
                            showAlert(`${t('deleteTaskFailedAlert')}: ${error.message}`, 'danger');
LiangLiu's avatar
LiangLiu committed
7464
7465
7466
                        }
                        // 如果response为null,说明是认证错误,apiRequest已经处理了
                    } catch (error) {
LiangLiu's avatar
LiangLiu committed
7467
                        showAlert(`${t('deleteTaskFailedAlert')}: ${error.message}`, 'danger');
LiangLiu's avatar
LiangLiu committed
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
                    }
                };

                const loadTaskFiles = async (taskId) => {
                    try {
                        loadingTaskFiles.value = true;

                        // 通过API获取任务详情
                        const response = await apiRequest(`./api/v1/task/query?task_id=${taskId}`);
                        if (!response || !response.ok) {
LiangLiu's avatar
LiangLiu committed
7478
                            showAlert(t('getTaskDetailFailedAlert'), 'danger');
LiangLiu's avatar
LiangLiu committed
7479
7480
7481
7482
7483
                            return;
                        }

                        const task = await response.json();
                        if (!task) {
LiangLiu's avatar
LiangLiu committed
7484
                            showAlert(t('taskNotExistAlert'), 'danger');
LiangLiu's avatar
LiangLiu committed
7485
7486
7487
7488
7489
7490
7491
7492
7493
                            return;
                        }

                        const files = { inputs: {}, outputs: {} };

                        // 获取输入文件(所有状态的任务都需要)
                        if (task.inputs) {
                            for (const [key, inputPath] of Object.entries(task.inputs)) {
                                try {
LiangLiu's avatar
LiangLiu committed
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
                                    const url = await getTaskFileUrl(taskId, key);
                                    if (url) {
                                        const response = await fetch(url);
                                        if (response && response.ok) {
                                            const blob = await response.blob()
                                            files.inputs[key] = {
                                                name: inputPath, // 使用原始文件名而不是key
                                                path: inputPath,
                                                blob: blob,
                                                url: URL.createObjectURL(blob)
                                            }
                                        }
LiangLiu's avatar
LiangLiu committed
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
                                    }
                                } catch (error) {
                                    console.error(`Failed to load input ${key}:`, error);
                                    files.inputs[key] = {
                                        name: inputPath, // 使用原始文件名而不是key
                                        path: inputPath,
                                        error: true
                                    };
                                }
                            }
                        }

                        // 只对成功完成的任务获取输出文件
                        if (task.status === 'SUCCEED' && task.outputs) {
                            for (const [key, outputPath] of Object.entries(task.outputs)) {
                                try {
LiangLiu's avatar
LiangLiu committed
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
                                    const url = await getTaskFileUrl(taskId, key);
                                    if (url) {
                                        const response = await fetch(url);
                                        if (response && response.ok) {
                                            const blob = await response.blob()
                                            files.outputs[key] = {
                                                name: outputPath, // 使用原始文件名而不是key
                                                path: outputPath,
                                                blob: blob,
                                                url: URL.createObjectURL(blob)
                                            }
LiangLiu's avatar
LiangLiu committed
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
                                        };
                                    }
                                } catch (error) {
                                    console.error(`Failed to load output ${key}:`, error);
                                    files.outputs[key] = {
                                        name: outputPath, // 使用原始文件名而不是key
                                        path: outputPath,
                                        error: true
                                    };
                                }
                            }
                        }

                        selectedTaskFiles.value = files;

                    } catch (error) {
                        console.error('Failed to load task files:', error);
LiangLiu's avatar
LiangLiu committed
7550
                        showAlert(t('loadTaskFilesFailedAlert'), 'danger');
LiangLiu's avatar
LiangLiu committed
7551
7552
7553
7554
7555
7556
7557
7558
                    } finally {
                        loadingTaskFiles.value = false;
                    }
                };

                const viewTaskDetail = async (task) => {
                    selectedTask.value = task;
                    selectedTaskId.value = task.task_type;
LiangLiu's avatar
LiangLiu committed
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575

                    try {
                    const response = await apiRequest(`./api/v1/task/query?task_id=${task.task_id}`);
                        if (response && response.ok) {
                            const updatedTask = await response.json();
                            selectedTask.value = updatedTask;
                            console.log('updated task data:', updatedTask);
                            await nextTick();
                        }
                    } catch (error) {
                        console.warn('Failed to fetch updated task data:', error);
                    }
                    // 如果任务还在进行中,开始轮询状态
                    if (['CREATED', 'PENDING', 'RUNNING'].includes(task.status)) {

                        startPollingTask(task.task_id);
                    }
LiangLiu's avatar
LiangLiu committed
7576
7577
7578
7579
7580

                    // 一次性加载所有任务文件
                    await loadTaskFiles(task.task_id);
                };

LiangLiu's avatar
LiangLiu committed
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
                const reuseTask = async (task) => {
                    try {
                        // 跳转到任务创建界面
                        isCreationAreaExpanded.value=true
                        switchToCreateView();

                        // 设置任务类型
                        selectedTaskId.value = task.task_type;
                        console.log('selectedTaskId.value', selectedTaskId.value);

                        // 获取当前表单
                        const currentForm = getCurrentForm();

                        // 设置模型
                        if (task.params && task.params.model_cls) {
                            currentForm.model_cls = task.params.model_cls;
                        }

                        // 设置prompt
                        if (task.params && task.params.prompt) {
                            currentForm.prompt = task.params.prompt;
                        }

                        // 尝试从localStorage获取任务历史数据
                        const taskHistory = JSON.parse(localStorage.getItem('taskHistory') || '[]');
                        const historyItem = taskHistory.find(item => item.task_id === task.task_id);

                        if (historyItem) {
                            // 从localStorage恢复图片和音频
                            if (historyItem.imageFile && historyItem.imageFile.blob) {
                                // 重新创建File对象
                                const imageFile = new File([historyItem.imageFile.blob], historyItem.imageFile.name, { type: historyItem.imageFile.type });
                                currentForm.imageFile = imageFile;
                                setCurrentImagePreview(URL.createObjectURL(imageFile));
                            }

                            if (historyItem.audioFile && historyItem.audioFile.blob) {
                                // 重新创建File对象
                                let mimeType = historyItem.audioFile.type;
                                if (!mimeType || mimeType === 'application/octet-stream') {
                                    const filename = historyItem.audioFile.name || 'audio.wav';
                                    const ext = filename.toLowerCase().split('.').pop();
                                    const mimeTypes = {
                                        'mp3': 'audio/mpeg',
                                        'wav': 'audio/wav',
                                        'mp4': 'audio/mp4',
                                        'aac': 'audio/aac',
                                        'ogg': 'audio/ogg',
LiangLiu's avatar
LiangLiu committed
7629
7630
                                        'm4a': 'audio/mp4',
                                        'webm': 'audio/webm'
LiangLiu's avatar
LiangLiu committed
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
                                    };
                                    mimeType = mimeTypes[ext] || 'audio/mpeg';
                                }
                                const audioFile = new File([historyItem.audioFile.blob], historyItem.audioFile.name, { type: mimeType });
                                currentForm.audioFile = audioFile;
                                console.log('复用任务 - 从localStorage恢复音频文件:', {
                                    name: audioFile.name,
                                    type: audioFile.type,
                                    size: audioFile.size
                                });
                                // 使用FileReader生成data URL,与正常上传保持一致
                                const reader = new FileReader();
                                reader.onload = (e) => {
                                    setCurrentAudioPreview(e.target.result);
                                    console.log('复用任务 - 音频预览已设置:', e.target.result.substring(0, 50) + '...');
                                };
                                reader.readAsDataURL(audioFile);
                            }
                        } else {
                            // 如果localStorage中没有,尝试从后端获取任务文件
                            try {
                                // 使用现有的函数获取图片和音频URL
                                const imageUrl = await getTaskInputImage(task);
                                const audioUrl = await getTaskInputAudio(task);

                                // 加载图片文件
                                if (imageUrl) {
                                    try {
                                        const imageResponse = await fetch(imageUrl);
                                        if (imageResponse && imageResponse.ok) {
                                            const blob = await imageResponse.blob();
                                            const filename = task.inputs[Object.keys(task.inputs).find(key =>
                                                key.includes('image') ||
                                                task.inputs[key].toString().toLowerCase().match(/\.(jpg|jpeg|png|gif|bmp|webp)$/)
                                            )] || 'image.jpg';
                                            const file = new File([blob], filename, { type: blob.type });
                                            currentForm.imageFile = file;
                                            setCurrentImagePreview(URL.createObjectURL(file));
                                        }
                                    } catch (error) {
                                        console.warn('Failed to load image file:', error);
                                    }
                                }

                                // 加载音频文件
                                if (audioUrl) {
                                    try {
                                        const audioResponse = await fetch(audioUrl);
                                        if (audioResponse && audioResponse.ok) {
                                            const blob = await audioResponse.blob();
                                            const filename = task.inputs[Object.keys(task.inputs).find(key =>
                                                key.includes('audio') ||
                                                task.inputs[key].toString().toLowerCase().match(/\.(mp3|wav|mp4|aac|ogg|m4a)$/)
                                            )] || 'audio.wav';

                                            // 根据文件扩展名确定正确的MIME类型
                                            let mimeType = blob.type;
                                            if (!mimeType || mimeType === 'application/octet-stream') {
                                                const ext = filename.toLowerCase().split('.').pop();
                                                const mimeTypes = {
                                                    'mp3': 'audio/mpeg',
                                                    'wav': 'audio/wav',
                                                    'mp4': 'audio/mp4',
                                                    'aac': 'audio/aac',
                                                    'ogg': 'audio/ogg',
                                                    'm4a': 'audio/mp4'
                                                };
                                                mimeType = mimeTypes[ext] || 'audio/mpeg';
                                            }

                                            const file = new File([blob], filename, { type: mimeType });
                                            currentForm.audioFile = file;
                                            console.log('复用任务 - 从后端加载音频文件:', {
                                                name: file.name,
                                                type: file.type,
                                                size: file.size,
                                                originalBlobType: blob.type
                                            });
                                            // 使用FileReader生成data URL,与正常上传保持一致
                                            const reader = new FileReader();
                                            reader.onload = (e) => {
                                                setCurrentAudioPreview(e.target.result);
                                                console.log('复用任务 - 音频预览已设置:', e.target.result.substring(0, 50) + '...');
                                            };
                                            reader.readAsDataURL(file);
                                        }

                                    } catch (error) {
                                        console.warn('Failed to load audio file:', error);
                                    }
                                }
                            } catch (error) {
                                console.warn('Failed to load task data from backend:', error);
                            }
                        }

                        showAlert(t('taskMaterialReuseSuccessAlert'), 'success');

                    } catch (error) {
                        console.error('Failed to reuse task:', error);
                        showAlert(t('loadTaskDataFailedAlert'), 'danger');
                    }
                };

LiangLiu's avatar
LiangLiu committed
7735
7736
                const downloadFile = (fileInfo) => {
                    if (!fileInfo || !fileInfo.blob) {
LiangLiu's avatar
LiangLiu committed
7737
                        showAlert(t('fileUnavailableAlert'), 'danger');
LiangLiu's avatar
LiangLiu committed
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
                        return;
                    }

                    try {
                        const url = URL.createObjectURL(fileInfo.blob);
                        const a = document.createElement('a');
                        a.href = url;
                        a.download = fileInfo.name || 'download';
                        document.body.appendChild(a);
                        a.click();
                        document.body.removeChild(a);
                        URL.revokeObjectURL(url);
                    } catch (error) {
                        console.error('Download failed:', error);
LiangLiu's avatar
LiangLiu committed
7752
                        showAlert(t('downloadFailedAlert'), 'danger');
LiangLiu's avatar
LiangLiu committed
7753
7754
7755
7756
7757
                    }
                };

                const viewFile = (fileInfo) => {
                    if (!fileInfo || !fileInfo.url) {
LiangLiu's avatar
LiangLiu committed
7758
                        showAlert(t('fileUnavailableAlert'), 'danger');
LiangLiu's avatar
LiangLiu committed
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
                        return;
                    }

                    // 在新窗口中打开文件
                    window.open(fileInfo.url, '_blank');
                };

                const clearTaskFiles = () => {
                    // 清理 URL 对象,释放内存
                    Object.values(selectedTaskFiles.value.inputs).forEach(file => {
                        if (file.url) {
                            URL.revokeObjectURL(file.url);
                        }
                    });
                    Object.values(selectedTaskFiles.value.outputs).forEach(file => {
                        if (file.url) {
                            URL.revokeObjectURL(file.url);
                        }
                    });
                    selectedTaskFiles.value = { inputs: {}, outputs: {} };
                };

                const showTaskCreator = () => {
                    selectedTask.value = null;
                    // clearTaskFiles(); // 清空文件缓存
LiangLiu's avatar
LiangLiu committed
7784
7785
7786
7787
7788
7789
7790
7791
                    selectedTaskId.value = 's2v'; // 默认选择数字人任务

                    // 停止所有任务状态轮询
                    pollingTasks.value.clear();
                    if (pollingInterval.value) {
                        clearInterval(pollingInterval.value);
                        pollingInterval.value = null;
                    }
LiangLiu's avatar
LiangLiu committed
7792
7793
7794
7795
                };

                const toggleSidebar = () => {
                    sidebarCollapsed.value = !sidebarCollapsed.value;
LiangLiu's avatar
LiangLiu committed
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810

                    if (sidebarCollapsed.value) {
                        // 收起时,将历史任务栏隐藏到屏幕左侧
                        if (sidebar.value) {
                            sidebar.value.style.transform = 'translateX(-100%)';
                        }
                    } else {
                        // 展开时,恢复历史任务栏位置
                        if (sidebar.value) {
                            sidebar.value.style.transform = 'translateX(0)';
                        }
                    }

                    // 更新悬浮按钮位置
                    updateFloatingButtonPosition(sidebarWidth.value);
LiangLiu's avatar
LiangLiu committed
7811
7812
7813
7814
                };

                const clearPrompt = () => {
                    getCurrentForm().prompt = '';
LiangLiu's avatar
LiangLiu committed
7815
                    updateUploadedContentStatus();
LiangLiu's avatar
LiangLiu committed
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
                };

                const getTaskItemClass = (status) => {
                    if (status === 'SUCCEED') return 'bg-laser-purple/15 border border-laser-purple/30';
                    if (status === 'RUNNING') return 'bg-laser-purple/15 border border-laser-purple/30';
                    if (status === 'FAILED') return 'bg-red-500/15 border border-red-500/30';
                    return 'bg-dark-light border border-gray-700';
                };

                const getStatusIndicatorClass = (status) => {
                const base = 'inline-block w-2 aspect-square rounded-full shrink-0 align-middle';
                    if (status === 'SUCCEED')
                        return `${base} bg-gradient-to-r from-emerald-200 to-green-300 shadow-md shadow-emerald-300/30`;
                    if (status === 'RUNNING')
                        return `${base} bg-gradient-to-r from-amber-200 to-yellow-300 shadow-md shadow-amber-300/30 animate-pulse`;
                    if (status === 'FAILED')
                        return `${base} bg-gradient-to-r from-red-200 to-pink-300 shadow-md shadow-red-300/30`;
                    return `${base} bg-gradient-to-r from-gray-200 to-gray-300 shadow-md shadow-gray-300/30`;
                    };

                const getTaskTypeBtnClass = (taskType) => {
                    if (selectedTaskId.value === taskType) {
                        return 'text-gradient-icon border-b-2 border-laser-purple';
                    }
                    return 'text-gray-400 hover:text-gradient-icon';
                };

                const getModelBtnClass = (model) => {
                    if (getCurrentForm().model_cls === model) {
LiangLiu's avatar
LiangLiu committed
7845
                        return 'bg-laser-purple/20 border border-laser-purple/40 active shadow-laser';
LiangLiu's avatar
LiangLiu committed
7846
7847
7848
7849
7850
7851
7852
7853
                    }
                    return 'bg-dark-light border border-gray-700 hover:bg-laser-purple/15 hover:border-laser-purple/40 transition-all hover:shadow-laser';
                };

                const getTaskTypeIcon = (taskType) => {
                    const iconMap = {
                        't2v': 'fas fa-font',
                        'i2v': 'fas fa-image',
LiangLiu's avatar
LiangLiu committed
7854
                        's2v': 'fas fa-user'
LiangLiu's avatar
LiangLiu committed
7855
7856
7857
7858
7859
7860
                    };
                    return iconMap[taskType] || 'fas fa-video';
                };

                const getTaskTypeName = (task) => {
                    // 如果传入的是字符串,直接返回映射
LiangLiu's avatar
LiangLiu committed
7861
7862
7863
                    if (!task) {
                        return '未知';
                    }
LiangLiu's avatar
LiangLiu committed
7864
                    if (typeof task === 'string') {
LiangLiu's avatar
LiangLiu committed
7865
                        return nameMap.value[task] || task;
LiangLiu's avatar
LiangLiu committed
7866
7867
7868
7869
7870
7871
                    }

                    // 如果传入的是任务对象,根据模型类型判断
                    if (task && task.model_cls) {
                        const modelCls = task.model_cls.toLowerCase();

LiangLiu's avatar
LiangLiu committed
7872
                        return nameMap.value[task.task_type] || task.task_type;
LiangLiu's avatar
LiangLiu committed
7873
7874
7875
7876
7877
7878
7879
7880
                    }

                    // 默认返回task_type
                    return task.task_type || '未知';
                };

                const getPromptPlaceholder = () => {
                    if (selectedTaskId.value === 't2v') {
LiangLiu's avatar
LiangLiu committed
7881
                        return t('pleaseEnterThePromptForVideoGeneration') + ''+ t('describeTheContentStyleSceneOfTheVideo');
LiangLiu's avatar
LiangLiu committed
7882
                    } else if (selectedTaskId.value === 'i2v') {
LiangLiu's avatar
LiangLiu committed
7883
7884
                        return t('pleaseEnterThePromptForVideoGeneration') + ''+ t('describeTheContentActionRequirementsBasedOnTheImage');
                    } else if (selectedTaskId.value === 's2v') {
LiangLiu's avatar
LiangLiu committed
7885
                        return t('optional') + ' '+ t('pleaseEnterThePromptForVideoGeneration') + ''+ t('describeTheDigitalHumanImageBackgroundStyleActionRequirements');
LiangLiu's avatar
LiangLiu committed
7886
                    }
LiangLiu's avatar
LiangLiu committed
7887
                    return t('pleaseEnterThePromptForVideoGeneration') + '...';
LiangLiu's avatar
LiangLiu committed
7888
7889
7890
7891
                };

                const getStatusTextClass = (status) => {
                    if (status === 'SUCCEED') return 'text-emerald-400';
LiangLiu's avatar
LiangLiu committed
7892
7893
                    if (status === 'CREATED') return 'text-blue-400';
                    if (status === 'PENDING') return 'text-yellow-400';
LiangLiu's avatar
LiangLiu committed
7894
7895
                    if (status === 'RUNNING') return 'text-amber-400';
                    if (status === 'FAILED') return 'text-red-400';
LiangLiu's avatar
LiangLiu committed
7896
                    if (status === 'CANCEL') return 'text-gray-400';
LiangLiu's avatar
LiangLiu committed
7897
7898
7899
7900
7901
7902
7903
7904
                    return 'text-gray-400';
                };

                const getImagePreview = (base64Data) => {
                    if (!base64Data) return '';
                    return `data:image/jpeg;base64,${base64Data}`;
                };

LiangLiu's avatar
LiangLiu committed
7905
7906
7907
7908
7909
7910
                const getTaskInputUrl = async (taskId, key) => {
                    // 优先从缓存获取
                    const cachedUrl = getTaskFileUrlSync(taskId, key);
                    if (cachedUrl) {
                        console.log('getTaskInputUrl: 从缓存获取', { taskId, key, url: cachedUrl });
                        return cachedUrl;
LiangLiu's avatar
LiangLiu committed
7911
                    }
LiangLiu's avatar
LiangLiu committed
7912
                    return await getTaskFileUrlFromApi(taskId, key);
LiangLiu's avatar
LiangLiu committed
7913
7914
                };

LiangLiu's avatar
LiangLiu committed
7915
7916
7917
7918
7919
7920
7921
                const getTaskInputImage = async (task) => {

                    if (!task || !task.inputs) {
                        console.log('getTaskInputImage: 任务或输入为空', { task: task?.task_id, inputs: task?.inputs });
                        return null;
                    }

LiangLiu's avatar
LiangLiu committed
7922
7923
7924
7925
7926
7927
7928
                    const imageInputs = Object.keys(task.inputs).filter(key =>
                        key.includes('image') ||
                        task.inputs[key].toString().toLowerCase().match(/\.(jpg|jpeg|png|gif|bmp|webp)$/)
                    );

                    if (imageInputs.length > 0) {
                        const firstImageKey = imageInputs[0];
LiangLiu's avatar
LiangLiu committed
7929
7930
7931
7932
7933
                        // 优先从缓存获取
                        const cachedUrl = getTaskFileUrlSync(task.task_id, firstImageKey);
                        if (cachedUrl) {
                            console.log('getTaskInputImage: 从缓存获取', { taskId: task.task_id, key: firstImageKey, url: cachedUrl });
                            return cachedUrl;
LiangLiu's avatar
LiangLiu committed
7934
                        }
LiangLiu's avatar
LiangLiu committed
7935
7936
7937
7938
                        // 缓存没有则生成URL
                        const url = await getTaskInputUrl(task.task_id, firstImageKey);
                        console.log('getTaskInputImage: 生成URL', { taskId: task.task_id, key: firstImageKey, url });
                        return url;
LiangLiu's avatar
LiangLiu committed
7939
7940
                    }

LiangLiu's avatar
LiangLiu committed
7941
7942
                    console.log('getTaskInputImage: 没有找到图片输入');
                    return null;
LiangLiu's avatar
LiangLiu committed
7943
7944
                };

LiangLiu's avatar
LiangLiu committed
7945
7946
7947
7948
7949
                const getTaskInputAudio = async (task) => {
                    if (!task || !task.inputs) return null;
                    const audioInputs = Object.keys(task.inputs).filter(key =>
                        key.includes('audio') ||
                        task.inputs[key].toString().toLowerCase().match(/\.(mp3|wav|mp4|aac|ogg|m4a)$/)
LiangLiu's avatar
LiangLiu committed
7950
7951
                    );

LiangLiu's avatar
LiangLiu committed
7952
7953
7954
                    if (audioInputs.length > 0) {
                        const firstAudioKey = audioInputs[0];
                        return await getTaskInputUrl(task.task_id, firstAudioKey);
LiangLiu's avatar
LiangLiu committed
7955
                    }
LiangLiu's avatar
LiangLiu committed
7956
7957

                    return null;
LiangLiu's avatar
LiangLiu committed
7958
7959
7960
7961
7962
7963
                };

                const handleThumbnailError = (event) => {
                    // 当输入图片加载失败时,显示默认图标
                    const img = event.target;
                    const parent = img.parentElement;
LiangLiu's avatar
LiangLiu committed
7964
                    parent.innerHTML = '<div class="w-full h-44 bg-laser-purple/20 flex items-center justify-center"><i class="fas fa-video text-gradient-icon text-xl"></i></div>';
LiangLiu's avatar
LiangLiu committed
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
                };

                const handleImageError = (event) => {
                    // 当图片加载失败时,隐藏图片,显示文件名
                    const img = event.target;
                    img.style.display = 'none';
                    // 文件名已经显示,不需要额外处理
                };

                const handleImageLoad = (event) => {
                    // 当图片加载成功时,显示图片和下载按钮,隐藏文件名
                    const img = event.target;
                    img.style.display = 'block';
                    // 显示下载按钮
                    const downloadBtn = img.parentElement.querySelector('button');
                    if (downloadBtn) {
                        downloadBtn.style.display = 'block';
                    }
                    // 隐藏文件名span
                    const span = img.parentElement.parentElement.querySelector('span');
                    if (span) {
                        span.style.display = 'none';
                    }
                };

                const handleAudioError = (event) => {
                    // 当音频加载失败时,隐藏音频控件和下载按钮,显示文件名
                    const audio = event.target;
                    audio.style.display = 'none';
                    // 隐藏下载按钮
                    const downloadBtn = audio.parentElement.querySelector('button');
                    if (downloadBtn) {
                        downloadBtn.style.display = 'none';
                    }
                    // 文件名已经显示,不需要额外处理
                };

                const handleAudioLoad = (event) => {
                    // 当音频加载成功时,显示音频控件和下载按钮,隐藏文件名
                    const audio = event.target;
                    audio.style.display = 'block';
                    // 显示下载按钮
                    const downloadBtn = audio.parentElement.querySelector('button');
                    if (downloadBtn) {
                        downloadBtn.style.display = 'block';
                    }
                    // 隐藏文件名span
                    const span = audio.parentElement.parentElement.querySelector('span');
                    if (span) {
                        span.style.display = 'none';
                    }
                };

LiangLiu's avatar
LiangLiu committed
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
                // 监听currentPage变化,同步更新pageInput
                watch(currentTaskPage, (newPage) => {
                    taskPageInput.value = newPage;
                });

                // 监听pagination变化,确保分页组件更新
                watch(pagination, (newPagination) => {
                    console.log('pagination变化:', newPagination);
                    if (newPagination && newPagination.total_pages) {
                        // 确保当前页不超过总页数
                        if (currentTaskPage.value > newPagination.total_pages) {
                            currentTaskPage.value = newPagination.total_pages;
                        }
                    }
                }, { deep: true });

                // 监听templateCurrentPage变化,同步更新templatePageInput
                watch(templateCurrentPage, (newPage) => {
                    templatePageInput.value = newPage;
                });

                // 监听templatePagination变化,确保分页组件更新
                watch(templatePagination, (newPagination) => {
                    console.log('templatePagination变化:', newPagination);
                    if (newPagination && newPagination.total_pages) {
                        // 确保当前页不超过总页数
                        if (templateCurrentPage.value > newPagination.total_pages) {
                            templateCurrentPage.value = newPagination.total_pages;
                        }
                    }
                }, { deep: true });

                // 监听inspirationCurrentPage变化,同步更新inspirationPageInput
                watch(inspirationCurrentPage, (newPage) => {
                    inspirationPageInput.value = newPage;
                });

                // 监听inspirationPagination变化,确保分页组件更新
                watch(inspirationPagination, (newPagination) => {
                    console.log('inspirationPagination变化:', newPagination);
                    if (newPagination && newPagination.total_pages) {
                        // 确保当前页不超过总页数
                        if (inspirationCurrentPage.value > newPagination.total_pages) {
                            inspirationCurrentPage.value = newPagination.total_pages;
                        }
                    }
                }, { deep: true });

                // 统一的初始化函数
                const init = async () => {
                    try {
                        // 1. 加载模型和任务数据
                        await loadModels();

                        // 3. 选择任务类型(优先选择数字人任务)
                        let selectedTaskType = null;
                        if (availableTaskTypes.value.includes('s2v')) {
                            selectedTaskType = 's2v';
                        } else if (availableTaskTypes.value.length > 0) {
                            selectedTaskType = availableTaskTypes.value[0];
                        }

                        if (selectedTaskType) {
                            selectTask(selectedTaskType);

                            // 4. 为选中的任务类型选择第一个模型
                            const currentForm = getCurrentForm();
                            if (!currentForm.model_cls && availableModelClasses.value.length > 0) {
                                selectModel(availableModelClasses.value[0]);
                            }
                        }

                        // 2. 加载历史记录和素材库
                        refreshTasks(true);
                        loadInspirationData(true);

                        // 3. 加载历史记录和素材库文件
                        getPromptHistory();
                        loadTaskFilesFromCache();
                        loadTemplateFilesFromCache();
                        loadImageAudioTemplates(true);

LiangLiu's avatar
LiangLiu committed
8100
8101
8102
                        // 4. 初始化路由(在数据加载完成后)
                        initRoute();

LiangLiu's avatar
LiangLiu committed
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
                        console.log('初始化完成:', {
                            currentUser: currentUser.value,
                            availableModels: models.value,
                            tasks: tasks.value,
                            inspirationItems: inspirationItems.value,
                            selectedTaskType: selectedTaskType,
                            selectedModel: getCurrentForm().model_cls
                        });

                    } catch (error) {
                        console.error('初始化失败:', error);
                        showAlert('初始化失败,请刷新页面重试', 'danger');
                    }
                };

                // 重置表单函数(保留模型选择,清空图片、音频和提示词)
                const resetForm = async (taskType) => {
                    const currentForm = getCurrentForm();
                    const currentModel = currentForm.model_cls;
                    const currentStage = currentForm.stage;

                    // 重置表单但保留模型和阶段
                    switch (taskType) {
                        case 't2v':
                            t2vForm.value = {
                                task: 't2v',
                                model_cls: currentModel || '',
                                stage: currentStage || 'single_stage',
                                prompt: '',
                                seed: Math.floor(Math.random() * 1000000)
                            };
                            break;
                        case 'i2v':
                            i2vForm.value = {
                                task: 'i2v',
                                model_cls: currentModel || '',
                                stage: currentStage || 'multi_stage',
                                imageFile: null,
                                prompt: '',
                                seed: Math.floor(Math.random() * 1000000)
                            };
                            // 直接清空i2v图片预览
                            i2vImagePreview.value = null;
                            // 清理图片文件输入框
                            const imageInput = document.querySelector('input[type="file"][accept="image/*"]');
                            if (imageInput) {
                                imageInput.value = '';
                            }
                            break;
                        case 's2v':
                            s2vForm.value = {
                                task: 's2v',
                                model_cls: currentModel || '',
                                stage: currentStage || 'single_stage',
                                imageFile: null,
                                audioFile: null,
LiangLiu's avatar
LiangLiu committed
8159
                                prompt: 'Make the character speak in a natural way according to the audio.',
LiangLiu's avatar
LiangLiu committed
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
                                seed: Math.floor(Math.random() * 1000000)
                            };
                            break;
                    }

                    // 强制触发Vue响应式更新
                    setCurrentImagePreview(null);
                    setCurrentAudioPreview(null);
                    await nextTick();
                };

                // 开始轮询任务状态
                const startPollingTask = (taskId) => {
                    if (!pollingTasks.value.has(taskId)) {
                        pollingTasks.value.add(taskId);
                        console.log(`开始轮询任务状态: ${taskId}`);

                        // 如果还没有轮询定时器,启动一个
                        if (!pollingInterval.value) {
                            pollingInterval.value = setInterval(async () => {
                                await pollTaskStatuses();
                            }, 1000); // 每1秒轮询一次
                        }
                    }
                };

                // 停止轮询任务状态
                const stopPollingTask = (taskId) => {
                    pollingTasks.value.delete(taskId);
                    console.log(`停止轮询任务状态: ${taskId}`);

                    // 如果没有任务需要轮询了,清除定时器
                    if (pollingTasks.value.size === 0 && pollingInterval.value) {
                        clearInterval(pollingInterval.value);
                        pollingInterval.value = null;
                        console.log('停止所有任务状态轮询');
                    }
                };

                const refreshTaskFiles = (task) => {
                    for (const [key, inputPath] of Object.entries(task.inputs)) {
                        getTaskFileUrlFromApi(task.task_id, key).then(url => {
                            console.log('refreshTaskFiles: input', task.task_id, key, url);
                        });
                    }
                    for (const [key, outputPath] of Object.entries(task.outputs)) {
                        getTaskFileUrlFromApi(task.task_id, key).then(url => {
                            console.log('refreshTaskFiles: output', task.task_id, key, url);
                        });
                    }
                };

                // 轮询任务状态
                const pollTaskStatuses = async () => {
                    if (pollingTasks.value.size === 0) return;

                    try {
                        const taskIds = Array.from(pollingTasks.value);
                        const response = await apiRequest(`./api/v1/task/query?task_ids=${taskIds.join(',')}`);

                        if (response && response.ok) {
                            const tasksData = await response.json();
                            const updatedTasks = tasksData.tasks || [];

                            // 更新任务列表中的任务状态
                            let hasUpdates = false;
                            updatedTasks.forEach(updatedTask => {
                                const existingTaskIndex = tasks.value.findIndex(t => t.task_id === updatedTask.task_id);
                                if (existingTaskIndex !== -1) {
                                    const oldTask = tasks.value[existingTaskIndex];
                                    tasks.value[existingTaskIndex] = updatedTask;
                                    console.log('updatedTask', updatedTask);
                                    console.log('oldTask', oldTask);

                                    // 如果状态发生变化,记录日志
                                    if (oldTask !== updatedTask) {
                                        hasUpdates = true; // 这里基本都会变,因为任务有进度条

                                        // 如果当前在查看这个任务的详情,更新selectedTask
                                        if (modalTask.value && modalTask.value.task_id === updatedTask.task_id) {
                                            modalTask.value = updatedTask;
                                            if (updatedTask.status === 'SUCCEED') {
                                                console.log('refresh viewing task: output files');
                                                loadTaskFiles(updatedTask.task_id);
                                            }
                                        }

                                        // 如果当前在projects页面且变化的是状态,更新tasks
                                        if (currentView.value === 'projects' && oldTask.status !== updatedTask.status) {
                                            refreshTasks(true);
                                        }

                                        // 如果任务完成或失败,停止轮询并显示提示
                                        if (['SUCCEED', 'FAILED', 'CANCEL'].includes(updatedTask.status)) {
                                            stopPollingTask(updatedTask.task_id);
                                            refreshTaskFiles(updatedTask);
                                            refreshTasks(true);

                                            // 显示任务完成提示
                                            if (updatedTask.status === 'SUCCEED') {
                                                showAlert('视频生成完成!', 'success');
                                            } else if (updatedTask.status === 'FAILED') {
                                                showAlert('视频生成失败,请查看详情', 'danger');
                                            } else if (updatedTask.status === 'CANCEL') {
                                                showAlert('任务已取消', 'warning');
                                            }
                                        }
                                    }
                                }
                            });

                            // 如果有更新,触发界面刷新
                            if (hasUpdates) {
                                await nextTick();
                            }
                        }
                    } catch (error) {
                        console.error('轮询任务状态失败:', error);
                    }
LiangLiu's avatar
LiangLiu committed
8279
8280
8281
8282
8283
                };

                // 任务状态管理
                const getTaskStatusDisplay = (status) => {
                    const statusMap = {
LiangLiu's avatar
LiangLiu committed
8284
8285
8286
8287
8288
8289
                        'CREATED': t('created'),
                        'PENDING': t('pending'),
                        'RUNNING': t('running'),
                        'SUCCEED': t('succeed'),
                        'FAILED': t('failed'),
                        'CANCEL': t('cancelled')
LiangLiu's avatar
LiangLiu committed
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
                    };
                    return statusMap[status] || status;
                };

                const getTaskStatusColor = (status) => {
                    const colorMap = {
                        'CREATED': 'text-blue-400',
                        'PENDING': 'text-yellow-400',
                        'RUNNING': 'text-amber-400',
                        'SUCCEED': 'text-emerald-400',
                        'FAILED': 'text-red-400',
                        'CANCEL': 'text-gray-400'
                    };
                    return colorMap[status] || 'text-gray-400';
                };

                const getTaskStatusIcon = (status) => {
                    const iconMap = {
                        'CREATED': 'fas fa-clock',
                        'PENDING': 'fas fa-hourglass-half',
                        'RUNNING': 'fas fa-spinner fa-spin',
                        'SUCCEED': 'fas fa-check-circle',
                        'FAILED': 'fas fa-exclamation-triangle',
                        'CANCEL': 'fas fa-ban'
                    };
                    return iconMap[status] || 'fas fa-question-circle';
                };

                // 任务时间格式化
                const getTaskDuration = (startTime, endTime) => {
                    if (!startTime || !endTime) return '未知';
                    const start = new Date(startTime * 1000);
                    const end = new Date(endTime * 1000);
                    const diff = end - start;
                    const minutes = Math.floor(diff / 60000);
                    const seconds = Math.floor((diff % 60000) / 1000);
                    return `${minutes}${seconds}秒`;
                };

                // 相对时间格式化
                const getRelativeTime = (timestamp) => {
                    if (!timestamp) return '未知';
                    const now = new Date();
                    const time = new Date(timestamp * 1000);
                    const diff = now - time;

                    const minutes = Math.floor(diff / 60000);
                    const hours = Math.floor(diff / 3600000);
                    const days = Math.floor(diff / 86400000);
                    const months = Math.floor(diff / 2592000000); // 30天
                    const years = Math.floor(diff / 31536000000);

                    if (years > 0) {
LiangLiu's avatar
LiangLiu committed
8343
                        return years === 1 ? t('oneYearAgo') : `${years}t('yearsAgo')`;
LiangLiu's avatar
LiangLiu committed
8344
                    } else if (months > 0) {
LiangLiu's avatar
LiangLiu committed
8345
                        return months === 1 ? t('oneMonthAgo') : `${months}${t('monthsAgo')}`;
LiangLiu's avatar
LiangLiu committed
8346
                    } else if (days > 0) {
LiangLiu's avatar
LiangLiu committed
8347
                        return days === 1 ? t('oneDayAgo') : `${days}${t('daysAgo')}`;
LiangLiu's avatar
LiangLiu committed
8348
                    } else if (hours > 0) {
LiangLiu's avatar
LiangLiu committed
8349
                        return hours === 1 ? t('oneHourAgo') : `${hours}${t('hoursAgo')}`;
LiangLiu's avatar
LiangLiu committed
8350
                    } else if (minutes > 0) {
LiangLiu's avatar
LiangLiu committed
8351
                        return minutes === 1 ? t('oneMinuteAgo') : `${minutes}${t('minutesAgo')}`;
LiangLiu's avatar
LiangLiu committed
8352
                    } else {
LiangLiu's avatar
LiangLiu committed
8353
                        return t('justNow');
LiangLiu's avatar
LiangLiu committed
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
                    }
                };

                // 任务历史记录管理
                const getTaskHistory = () => {
                    return tasks.value.filter(task =>
                        ['SUCCEED', 'FAILED', 'CANCEL'].includes(task.status)
                    );
                };

LiangLiu's avatar
LiangLiu committed
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
                // 子任务进度相关函数
                const getOverallProgress = (subtasks) => {
                    if (!subtasks || subtasks.length === 0) return 0;

                    let completedCount = 0;
                    subtasks.forEach(subtask => {
                        if (subtask.status === 'SUCCEED') {
                            completedCount++;
                        }
                    });

                    return Math.round((completedCount / subtasks.length) * 100);
                };

                // 获取进度条标题
                const getProgressTitle = (subtasks) => {
                    if (!subtasks || subtasks.length === 0) return t('overallProgress');

                    const pendingSubtasks = subtasks.filter(subtask => subtask.status === 'PENDING');
                    const runningSubtasks = subtasks.filter(subtask => subtask.status === 'RUNNING');

                    if (pendingSubtasks.length > 0) {
                        return t('queueStatus');
                    } else if (runningSubtasks.length > 0) {
                        return t('running');
                    } else {
                        return t('overallProgress');
                    }
                };

                // 获取进度信息
                const getProgressInfo = (subtasks) => {
                    if (!subtasks || subtasks.length === 0) return '0%';

                    const pendingSubtasks = subtasks.filter(subtask => subtask.status === 'PENDING');
                    const runningSubtasks = subtasks.filter(subtask => subtask.status === 'RUNNING');

                    if (pendingSubtasks.length > 0) {
                        // 显示排队信息
                        const firstPending = pendingSubtasks[0];
                        const queuePosition = firstPending.estimated_pending_order;
                        const estimatedTime = firstPending.estimated_pending_secs;

                        let info = t('queueing');
                        if (queuePosition !== null && queuePosition !== undefined) {
                            info += ` (${t('position')}: ${queuePosition})`;
                        }
                        if (estimatedTime !== null && estimatedTime !== undefined) {
                            info += ` - ${formatDuration(estimatedTime)}`;
                        }
                        return info;
                    } else if (runningSubtasks.length > 0) {
                        // 显示运行信息
                        const firstRunning = runningSubtasks[0];
                        const workerName = firstRunning.worker_name || t('unknown');
                        const estimatedTime = firstRunning.estimated_running_secs;

                        let info = `${t('subtask')} ${workerName}`;
                        if (estimatedTime !== null && estimatedTime !== undefined) {
                            const elapses = firstRunning.elapses || {};
                            const runningTime = elapses['RUNNING-'] || 0;
                            const remaining = Math.max(0, estimatedTime - runningTime);
                            info += ` - ${t('remaining')} ${formatDuration(remaining)}`;
                        }
                        return info;
                    } else {
                        // 显示总体进度
                        return getOverallProgress(subtasks) + '%';
                    }
                };

                const getSubtaskProgress = (subtask) => {
                    if (subtask.status === 'SUCCEED') return 100;
                    if (subtask.status === 'FAILED' || subtask.status === 'CANCEL') return 0;

                    // 对于PENDING和RUNNING状态,基于时间估算进度
                    if (subtask.status === 'PENDING') {
                        // 排队中的任务,进度为0
                        return 0;
                    }

                    if (subtask.status === 'RUNNING') {
                        // 运行中的任务,基于已运行时间估算进度
                        const elapses = subtask.elapses || {};
                        const runningTime = elapses['RUNNING-'] || 0;
                        const estimatedTotal = subtask.estimated_running_secs || 0;

                        if (estimatedTotal > 0) {
                            const progress = Math.min((runningTime / estimatedTotal) * 100, 95); // 最多95%,避免显示100%但未完成
                            return Math.round(progress);
                        }
                    }

                    return 0;
                };

                const getSubtaskStatusText = (status) => {
                    const statusMap = {
                        'PENDING': t('pending'),
                        'RUNNING': t('running'),
                        'SUCCEED': t('completed'),
                        'FAILED': t('failed'),
                        'CANCEL': t('cancelled')
                    };
                    return statusMap[status] || status;
                };

                const formatEstimatedTime = (subtask) => {
                    if (subtask.status === 'PENDING') {
                        const pendingSecs = subtask.estimated_pending_secs;
                        const queuePosition = subtask.estimated_pending_order;

                        if (pendingSecs !== null && pendingSecs !== undefined) {
                            let info = formatDuration(pendingSecs);
                            if (queuePosition !== null && queuePosition !== undefined) {
                                info += ` (${t('position')}: ${queuePosition})`;
                            }
                            return info;
                        }
                        return t('calculating');
                    }

                    if (subtask.status === 'RUNNING') {
                        const elapses = subtask.elapses || {};
                        const runningTime = elapses['RUNNING-'] || 0;
                        const estimatedTotal = subtask.estimated_running_secs || 0;

                        if (estimatedTotal > 0) {
                            const remaining = Math.max(0, estimatedTotal - runningTime);
                            return `${t('remaining')} ${formatDuration(remaining)}`;
                        }
                        return t('calculating');
                    }

                    return t('completed');
                };

                const formatDuration = (seconds) => {
                    if (seconds < 60) {
                        return `${Math.round(seconds)}${t('seconds')}`;
                    } else if (seconds < 3600) {
                        const minutes = Math.round(seconds / 60);
                        return `${minutes}${t('minutes')}`;
                    } else {
                        const hours = Math.floor(seconds / 3600);
                        const minutes = Math.round((seconds % 3600) / 60);
                        return `${hours}${t('hours')}${minutes}${t('minutes')}`;
                    }
                };

                const getTaskFailureInfo = (task) => {
                    if (!task) return null;

                    // 检查任务级别的失败信息
                    if (task.fail_msg) {
                        return task.fail_msg;
                    }

                    // 检查子任务的失败信息
                    if (task.subtasks && task.subtasks.length > 0) {
                        const failedSubtasks = task.subtasks.filter(subtask =>
                            (subtask.extra_info && subtask.extra_info.fail_msg) || subtask.fail_msg
                        );
                        if (failedSubtasks.length > 0) {
                            const msg = failedSubtasks.map(subtask =>
                                (subtask.extra_info && subtask.extra_info.fail_msg) || subtask.fail_msg
                            ).join('\n');
                            return msg;
                        }
                    }

                    return null;
                };

LiangLiu's avatar
LiangLiu committed
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
                const getActiveTasks = () => {
                    return tasks.value.filter(task =>
                        ['CREATED', 'PENDING', 'RUNNING'].includes(task.status)
                    );
                };

                // 任务搜索和过滤增强
                const searchTasks = (query) => {
                    if (!query) return tasks.value;
                    return tasks.value.filter(task => {
                        const searchText = [
                            task.task_id,
                            task.task_type,
                            task.model_cls,
                            task.params?.prompt || '',
                            getTaskStatusDisplay(task.status)
                        ].join(' ').toLowerCase();
                        return searchText.includes(query.toLowerCase());
                    });
                };

                const filterTasksByStatus = (status) => {
                    if (status === 'ALL') return tasks.value;
                    return tasks.value.filter(task => task.status === status);
                };

                const filterTasksByType = (type) => {
                    if (!type) return tasks.value;
                    return tasks.value.filter(task => task.task_type === type);
                };

                // 提示消息样式管理
                const getAlertClass = (type) => {
                    const classMap = {
                        'success': 'animate-slide-down',
                        'warning': 'animate-slide-down',
                        'danger': 'animate-slide-down',
                        'info': 'animate-slide-down'
                    };
                    return classMap[type] || 'animate-slide-down';
                };

                const getAlertBorderClass = (type) => {
                    const borderMap = {
                        'success': 'border-green-500',
                        'warning': 'border-yellow-500',
                        'danger': 'border-red-500',
                        'info': 'border-blue-500'
                    };
                    return borderMap[type] || 'border-gray-500';
                };

                const getAlertTextClass = (type) => {
LiangLiu's avatar
LiangLiu committed
8591
8592
                    // 统一使用白色文字
                    return 'text-white';
LiangLiu's avatar
LiangLiu committed
8593
8594
8595
8596
                };

                const getAlertIcon = (type) => {
                    const iconMap = {
LiangLiu's avatar
LiangLiu committed
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
                        'success': 'fas fa-check text-white',
                        'warning': 'fas fa-exclamation text-white',
                        'danger': 'fas fa-times text-white',
                        'info': 'fas fa-info text-white'
                    };
                    return iconMap[type] || 'fas fa-info text-white';
                };

                const getAlertIconBgClass = (type) => {
                    const bgMap = {
                        'success': 'bg-green-500/30',
                        'warning': 'bg-yellow-500/30',
                        'danger': 'bg-red-500/30',
                        'info': 'bg-laser-purple/30'
LiangLiu's avatar
LiangLiu committed
8611
                    };
LiangLiu's avatar
LiangLiu committed
8612
                    return bgMap[type] || 'bg-laser-purple/30';
LiangLiu's avatar
LiangLiu committed
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
                };

                // 监听器 - 监听任务类型变化
                watch(() => selectedTaskId.value, () => {
                    const currentForm = getCurrentForm();

                    // 只有当当前表单没有选择模型时,才自动选择第一个可用的模型
                    if (!currentForm.model_cls) {
                        let availableModels;

LiangLiu's avatar
LiangLiu committed
8623
                        availableModels = models.value.filter(m => m.task === selectedTaskId.value);
LiangLiu's avatar
LiangLiu committed
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642

                        if (availableModels.length > 0) {
                            const firstModel = availableModels[0];
                            currentForm.model_cls = firstModel.model_cls;
                            currentForm.stage = firstModel.stage;
                        }
                    }

                    // 注意:这里不需要重置预览,因为我们要保持每个任务的独立性
                    // 预览会在 selectTask 函数中根据文件状态恢复
                });

                watch(() => getCurrentForm().model_cls, () => {
                    const currentForm = getCurrentForm();

                    // 只有当当前表单没有选择阶段时,才自动选择第一个可用的阶段
                    if (!currentForm.stage) {
                        let availableStages;

LiangLiu's avatar
LiangLiu committed
8643
                        availableStages = models.value
LiangLiu's avatar
LiangLiu committed
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
                                .filter(m => m.task === selectedTaskId.value && m.model_cls === currentForm.model_cls)
                                .map(m => m.stage);

                        if (availableStages.length > 0) {
                            currentForm.stage = availableStages[0];
                        }
                    }
                });

                // 生命周期
                onMounted(async () => {
LiangLiu's avatar
LiangLiu committed
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
                    // 必须先初始化语言
                    await initLanguage();
                    console.log('initLanguage');
                    // 设置初始化loading状态
                    initLoading.value = true;
                    console.log('initLoading');
                    // 启动提示滚动
                    startHintRotation();
                    // 添加全局点击事件监听器
                    document.addEventListener('click', handleClickOutside);
LiangLiu's avatar
LiangLiu committed
8665

LiangLiu's avatar
LiangLiu committed
8666
8667
8668
8669
                    try {
                        // 检查是否已登录
                        const savedToken = localStorage.getItem('accessToken');
                        const savedUser = localStorage.getItem('currentUser');
LiangLiu's avatar
LiangLiu committed
8670

LiangLiu's avatar
LiangLiu committed
8671
                        if (savedToken && savedUser) {
LiangLiu's avatar
LiangLiu committed
8672
8673
                            currentUser.value = JSON.parse(savedUser);
                            isLoggedIn.value = true;
LiangLiu's avatar
LiangLiu committed
8674
                            await init();
LiangLiu's avatar
LiangLiu committed
8675
                        } else {
LiangLiu's avatar
LiangLiu committed
8676
8677
8678
8679
8680
8681
8682
8683
                            // 检查是否是GitHub回调
                            const urlParams = new URLSearchParams(window.location.search);
                            const code = urlParams.get('code');
                            if (code) {
                                source = localStorage.getItem('loginSource');
                                await handleLoginCallback(code, source);
                                // handleGitHubCallback内部会设置isLoggedIn.value = true
                            } else {
LiangLiu's avatar
LiangLiu committed
8684
                                // 没有token且不是回调,默认显示登录界面
LiangLiu's avatar
LiangLiu committed
8685
                                isLoggedIn.value = false;
LiangLiu's avatar
LiangLiu committed
8686
8687
8688
8689
8690
8691
8692
8693
8694
                                const urlParams = new URLSearchParams(window.location.search);
                                const view = urlParams.get('view');
                                if (view && ['create', 'projects', 'inspiration'].includes(view)) {
                                    // 如果URL中指定了其他页面,仍然显示登录界面,但设置currentView用于登录后跳转
                                    currentView.value = view;
                                } else {
                                    // 默认显示登录界面
                                    currentView.value = 'login';
                                }
LiangLiu's avatar
LiangLiu committed
8695
                            }
LiangLiu's avatar
LiangLiu committed
8696
                        }
LiangLiu's avatar
LiangLiu committed
8697
8698
8699
8700
8701
8702
8703
8704
                    } catch (error) {
                        console.error(t('initializationFailed'), error);
                        showAlert(t('initializationFailed'), 'danger');
                        // 出错时显示登录页面
                        isLoggedIn.value = false;
                    } finally {
                        loginLoading.value = false;
                        initLoading.value = false;
LiangLiu's avatar
LiangLiu committed
8705
                    }
LiangLiu's avatar
LiangLiu committed
8706
8707
8708

                    // 监听浏览器前进后退
                    window.addEventListener('popstate', handlePopState);
LiangLiu's avatar
LiangLiu committed
8709
                });
LiangLiu's avatar
LiangLiu committed
8710

LiangLiu's avatar
LiangLiu committed
8711
8712
8713
8714
8715
                // 页面卸载时清理轮询
                onUnmounted(() => {
                    if (pollingInterval.value) {
                        clearInterval(pollingInterval.value);
                        pollingInterval.value = null;
LiangLiu's avatar
LiangLiu committed
8716
                    }
LiangLiu's avatar
LiangLiu committed
8717
8718
8719
8720
                    pollingTasks.value.clear();

                    // 清理提示滚动
                    stopHintRotation();
LiangLiu's avatar
LiangLiu committed
8721
8722
8723

                    // 清理路由事件监听器
                    window.removeEventListener('popstate', handlePopState);
LiangLiu's avatar
LiangLiu committed
8724
8725
8726
8727
                });

                // 提示词模板管理
                const promptTemplates = {
LiangLiu's avatar
LiangLiu committed
8728
                    's2v': [
LiangLiu's avatar
LiangLiu committed
8729
                        {
LiangLiu's avatar
LiangLiu committed
8730
                            id: 's2v_1',
LiangLiu's avatar
LiangLiu committed
8731
8732
                            title: '情绪表达',
                            prompt: '根据音频,人物进行情绪化表达,表情丰富,能体现音频中的情绪,手势根据情绪适当调整。'
LiangLiu's avatar
LiangLiu committed
8733
8734
                        },
                        {
LiangLiu's avatar
LiangLiu committed
8735
                            id: 's2v_2',
LiangLiu's avatar
LiangLiu committed
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
                            title: '故事讲述',
                            prompt: '根据音频,人物进行故事讲述,表情丰富,能体现音频中的情绪,手势根据故事情节适当调整。'
                        },
                        {
                            id: 's2v_3',
                            title: '知识讲解',
                            prompt: '根据音频,人物进行知识讲解,表情严肃,整体风格专业得体,手势根据知识内容适当调整。'
                        },
                        {
                            id: 's2v_4',
                            title: '浮夸表演',
                            prompt: '根据音频,人物进行浮夸表演,表情夸张,动作浮夸,整体风格夸张搞笑。'
                        },
                        {
                            id: 's2v_5',
                            title: '商务演讲',
                            prompt: '根据音频,人物进行商务演讲,表情严肃,手势得体,整体风格专业商务。'
                        },
                        {
                            id: 's2v_6',
LiangLiu's avatar
LiangLiu committed
8756
                            title: '产品介绍',
LiangLiu's avatar
LiangLiu committed
8757
                            prompt: '数字人介绍产品特点,语气亲切热情,表情丰富,动作自然,能体现产品特点。'
LiangLiu's avatar
LiangLiu committed
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
                        }
                    ],
                    't2v': [
                        {
                            id: 't2v_1',
                            title: '自然风景',
                            prompt: '一个宁静的山谷,阳光透过云层洒在绿色的草地上,远处有雪山,近处有清澈的溪流,画面温暖自然,充满生机。'
                        },
                        {
                            id: 't2v_2',
                            title: '城市夜景',
                            prompt: '繁华的城市夜景,霓虹灯闪烁,高楼大厦林立,车流如织,天空中有星星点缀,营造出都市的繁华氛围。'
                        },
                        {
                            id: 't2v_3',
                            title: '科技未来',
                            prompt: '未来科技城市,飞行汽车穿梭,全息投影随处可见,建筑具有流线型设计,充满科技感和未来感。'
                        }
                    ],
                    'i2v': [
                        {
                            id: 'i2v_1',
                            title: '人物动作',
                            prompt: '基于参考图片,让角色做出自然的行走动作,保持原有的服装和风格,背景可以适当变化。'
                        },
                        {
                            id: 'i2v_2',
                            title: '场景转换',
                            prompt: '保持参考图片中的人物形象,将背景转换为不同的季节或环境,如从室内到户外,从白天到夜晚。'
                        }
                    ]
                };

                const getPromptTemplates = (taskType) => {
                    return promptTemplates[taskType] || [];
                };

                const selectPromptTemplate = (template) => {
                    getCurrentForm().prompt = template.prompt;
LiangLiu's avatar
LiangLiu committed
8797
8798
                    showPromptModal.value = false;
                    showAlert(`${t('templateApplied')} ${template.title}`, 'success');
LiangLiu's avatar
LiangLiu committed
8799
8800
                };

LiangLiu's avatar
LiangLiu committed
8801
                // 提示词历史记录管理 - 现在直接从taskHistory中获取
LiangLiu's avatar
LiangLiu committed
8802
8803
                const promptHistory = ref([]);

LiangLiu's avatar
LiangLiu committed
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
                const getPromptHistory = async () => {
                    try {
                        // 从taskHistory中获取prompt历史,去重并按时间排序
                        const taskHistory = await getLocalTaskHistory();
                        const uniquePrompts = [];
                        const seenPrompts = new Set();

                        // 遍历taskHistory,提取唯一的prompt
                        for (const task of taskHistory) {
                            if (task.prompt && task.prompt.trim() && !seenPrompts.has(task.prompt.trim())) {
                                uniquePrompts.push(task.prompt.trim());
                                seenPrompts.add(task.prompt.trim());
                            }
                        }

                        const result = uniquePrompts.slice(0, 10); // 只显示最近10条
                        promptHistory.value = result; // 更新响应式数据
                        return result;
                    } catch (error) {
                        console.error(t('getPromptHistoryFailed'), error);
                        promptHistory.value = []; // 更新响应式数据
                        return [];
                    }
LiangLiu's avatar
LiangLiu committed
8827
8828
                };

LiangLiu's avatar
LiangLiu committed
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
                // addPromptToHistory函数已删除,现在prompt历史直接从taskHistory中获取

                // 保存完整的任务历史(包括提示词、图片、音频)
                const addTaskToHistory = (taskType, formData) => {
                    const historyItem = {
                        id: Date.now(),
                        timestamp: new Date().toISOString(),
                        taskType: taskType,
                        prompt: formData.prompt || '',
                        imageFile: null,
                        audioFile: null
                    };

                    // 保存图片文件
                    if (formData.imageFile) {
                        const reader = new FileReader();
                        reader.onload = function (e) {
                            historyItem.imageFile = {
                                name: formData.imageFile.name,
                                type: formData.imageFile.type,
                                size: formData.imageFile.size,
                                data: e.target.result
                            };
                            saveTaskHistoryItem(historyItem);
                        };
                        reader.readAsDataURL(formData.imageFile);
                    } else {
                        // 没有图片文件,直接保存
                        saveTaskHistoryItem(historyItem);
                    }
LiangLiu's avatar
LiangLiu committed
8859

LiangLiu's avatar
LiangLiu committed
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
                    // 保存音频文件
                    if (formData.audioFile) {
                        const reader = new FileReader();
                        reader.onload = function (e) {
                            historyItem.audioFile = {
                                name: formData.audioFile.name,
                                type: formData.audioFile.type,
                                size: formData.audioFile.size,
                                data: e.target.result
                            };
                            saveTaskHistoryItem(historyItem);
                        };
                        reader.readAsDataURL(formData.audioFile);
LiangLiu's avatar
LiangLiu committed
8873
                    }
LiangLiu's avatar
LiangLiu committed
8874
                };
LiangLiu's avatar
LiangLiu committed
8875

LiangLiu's avatar
LiangLiu committed
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
                // 保存任务历史项到localStorage
                const saveTaskHistoryItem = (historyItem) => {
                    try {
                        const existingHistory = JSON.parse(localStorage.getItem('taskHistory') || '[]');

                        // 避免重复添加(基于提示词和任务类型)
                        const isDuplicate = existingHistory.some(item =>
                            item.prompt === historyItem.prompt &&
                            item.taskType === historyItem.taskType
                        );

                        if (!isDuplicate) {
                            // 按时间戳排序,确保最新的记录在最后
                            existingHistory.push(historyItem);
                            existingHistory.sort((a, b) => new Date(a.timestamp) - new Date(b.timestamp));

                            // 限制历史记录数量,删除最旧的记录(最晚的记录)
                            if (existingHistory.length > 20) {
                                // 删除最前面的记录(最旧的)
                                existingHistory.splice(0, existingHistory.length - 20);
                            }
LiangLiu's avatar
LiangLiu committed
8897

LiangLiu's avatar
LiangLiu committed
8898
8899
8900
8901
8902
                            localStorage.setItem('taskHistory', JSON.stringify(existingHistory));
                            console.log(t('taskHistorySaved'), historyItem);
                        }
                    } catch (error) {
                        console.error(t('saveTaskHistoryFailed'), error);
LiangLiu's avatar
LiangLiu committed
8903
                    }
LiangLiu's avatar
LiangLiu committed
8904
                };
LiangLiu's avatar
LiangLiu committed
8905

LiangLiu's avatar
LiangLiu committed
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
                // 获取本地存储的任务历史
                const getLocalTaskHistory = async () => {
                    try {
                        // 使用Promise模拟异步操作,避免阻塞UI
                        return await new Promise((resolve) => {
                            setTimeout(() => {
                                try {
                                    const history = JSON.parse(localStorage.getItem('taskHistory') || '[]');
                                    // 按时间戳排序,最新的记录在前
                                    const sortedHistory = history.sort((a, b) => new Date(b.timestamp) - new Date(a.timestamp));
                                    resolve(sortedHistory);
                                } catch (error) {
                                    console.error(t('parseTaskHistoryFailed'), error);
                                    resolve([]);
                                }
                            }, 0);
                        });
                    } catch (error) {
                        console.error(t('getTaskHistoryFailed'), error);
                        return [];
                    }
LiangLiu's avatar
LiangLiu committed
8927
8928
8929
8930
                };

                const selectPromptHistory = (prompt) => {
                    getCurrentForm().prompt = prompt;
LiangLiu's avatar
LiangLiu committed
8931
8932
                    showPromptModal.value = false;
                    showAlert(t('promptHistoryApplied'), 'success');
LiangLiu's avatar
LiangLiu committed
8933
8934
8935
                };

                const clearPromptHistory = () => {
LiangLiu's avatar
LiangLiu committed
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
                    // 清空taskHistory中的prompt相关数据
                    localStorage.removeItem('taskHistory');
                    showAlert(t('promptHistoryCleared'), 'info');
                };

                // 图片历史记录管理
                const getImageHistory = async () => {
                    try {
                        const taskHistory = await getLocalTaskHistory();
                        const uniqueImages = [];
                        const seenImages = new Set();

                        // 遍历taskHistory,提取唯一的图片
                        for (const task of taskHistory) {
                            if (task.imageFile && task.imageFile.name && !seenImages.has(task.imageFile.name)) {
                                uniqueImages.push({
                                    filename: task.imageFile.name,
                                    thumbnail: task.imageFile.data,
                                    data: task.imageFile.data,
                                    timestamp: task.timestamp
                                });
                                seenImages.add(task.imageFile.name);
                            }
                        }

                        const result = uniqueImages.slice(0, 20); // 只显示最近20条
                        imageHistory.value = result;
                        return result;
                    } catch (error) {
                        console.error(t('getImageHistoryFailed'), error);
                        imageHistory.value = [];
                        return [];
                    }
LiangLiu's avatar
LiangLiu committed
8969
8970
                };

LiangLiu's avatar
LiangLiu committed
8971
8972
                // 音频历史记录管理
                const getAudioHistory = async () => {
LiangLiu's avatar
LiangLiu committed
8973
                    try {
LiangLiu's avatar
LiangLiu committed
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
                        const taskHistory = await getLocalTaskHistory();
                        const uniqueAudios = [];
                        const seenAudios = new Set();

                        // 遍历taskHistory,提取唯一的音频
                        for (const task of taskHistory) {
                            if (task.audioFile && task.audioFile.name && !seenAudios.has(task.audioFile.name)) {
                                uniqueAudios.push({
                                    filename: task.audioFile.name,
                                    data: task.audioFile.data,
                                    timestamp: task.timestamp
                                });
                                seenAudios.add(task.audioFile.name);
                            }
LiangLiu's avatar
LiangLiu committed
8988
                        }
LiangLiu's avatar
LiangLiu committed
8989
8990
8991
8992

                        const result = uniqueAudios.slice(0, 20); // 只显示最近20条
                        audioHistory.value = result;
                        return result;
LiangLiu's avatar
LiangLiu committed
8993
                    } catch (error) {
LiangLiu's avatar
LiangLiu committed
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
                        console.error('获取音频历史失败:', error);
                        audioHistory.value = [];
                        return [];
                    }
                };

                // 选择图片历史记录
                const selectImageHistory = (history) => {
                    // 创建File对象
                    const byteCharacters = atob(history.data.split(',')[1]);
                    const byteNumbers = new Array(byteCharacters.length);
                    for (let i = 0; i < byteCharacters.length; i++) {
                        byteNumbers[i] = byteCharacters.charCodeAt(i);
                    }
                    const byteArray = new Uint8Array(byteNumbers);
                    const file = new File([byteArray], history.filename, { type: 'image/jpeg' });

                    // 设置图片预览
                    setCurrentImagePreview(history.data);

                    // 更新表单
                    const currentForm = getCurrentForm();
                    currentForm.imageFile = file;

                    showImageTemplates.value = false;
                    showAlert('已应用历史图片', 'success');
                };

                // 选择音频历史记录
                const selectAudioHistory = (history) => {
                    // 创建File对象
                    const byteCharacters = atob(history.data.split(',')[1]);
                    const byteNumbers = new Array(byteCharacters.length);
                    for (let i = 0; i < byteCharacters.length; i++) {
                        byteNumbers[i] = byteCharacters.charCodeAt(i);
LiangLiu's avatar
LiangLiu committed
9029
                    }
LiangLiu's avatar
LiangLiu committed
9030
9031
9032
9033
9034
                    const byteArray = new Uint8Array(byteNumbers);
                    const file = new File([byteArray], history.filename, { type: 'audio/mpeg' });

                    // 设置音频预览
                    setCurrentAudioPreview(history.data);
LiangLiu's avatar
LiangLiu committed
9035
                    updateUploadedContentStatus();
LiangLiu's avatar
LiangLiu committed
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063

                    // 更新表单
                    const currentForm = getCurrentForm();
                    currentForm.audioFile = file;

                    showAudioTemplates.value = false;
                    showAlert('已应用历史音频', 'success');
                };

                // 预览音频历史记录
                const previewAudioHistory = (history) => {
                    const audio = new Audio(history.data);
                    audio.play().catch(error => {
                        console.error('音频播放失败:', error);
                        showAlert('音频播放失败', 'danger');
                    });
                };

                // 清空图片历史记录
                const clearImageHistory = () => {
                    imageHistory.value = [];
                    showAlert('图片历史已清空', 'info');
                };

                // 清空音频历史记录
                const clearAudioHistory = () => {
                    audioHistory.value = [];
                    showAlert('音频历史已清空', 'info');
LiangLiu's avatar
LiangLiu committed
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
                };

                const getAuthHeaders = () => {
                    const headers = {
                        'Content-Type': 'application/json'
                    };

                    const token = localStorage.getItem('accessToken');
                    if (token) {
                        headers['Authorization'] = `Bearer ${token}`;
                        console.log('使用Token进行认证:', token.substring(0, 20) + '...');
                    } else {
                        console.warn('没有找到accessToken');
                    }
                    return headers;
                };

                // 验证token是否有效
                const validateToken = async (token) => {
                    try {
                        const response = await fetch('./api/v1/model/list', {
                            method: 'GET',
                            headers: {
                                'Authorization': `Bearer ${token}`,
                                'Content-Type': 'application/json'
                            }
                        });
LiangLiu's avatar
LiangLiu committed
9091
                        await new Promise(resolve => setTimeout(resolve, 100));
LiangLiu's avatar
LiangLiu committed
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
                        return response.ok;
                    } catch (error) {
                        console.error('Token validation failed:', error);
                        return false;
                    }
                };

                // 增强的API请求函数,自动处理认证错误
                const apiRequest = async (url, options = {}) => {
                    const headers = getAuthHeaders();

                    try {
                        const response = await fetch(url, {
                            ...options,
                            headers: {
                                ...headers,
                                ...options.headers
                            }
                        });
LiangLiu's avatar
LiangLiu committed
9111
                        await new Promise(resolve => setTimeout(resolve, 100));
LiangLiu's avatar
LiangLiu committed
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
                        // 检查是否是认证错误
                        if (response.status === 401 || response.status === 403) {
                            // Token无效,清除本地存储并跳转到登录页
                            logout();
                            showAlert('登录已过期,请重新登录', 'warning');
                            return null;
                        }
                        return response;
                    } catch (error) {
                        console.error('API request failed:', error);
                        showAlert('网络请求失败', 'danger');
                        return null;
                    }
                };

                // 侧边栏拖拽调整功能
                const sidebar = ref(null);
LiangLiu's avatar
LiangLiu committed
9129
                const sidebarWidth = ref(256); // 默认宽度 256px (w-64)
LiangLiu's avatar
LiangLiu committed
9130
9131
9132
9133
                let isResizing = false;
                let startX = 0;
                let startWidth = 0;

LiangLiu's avatar
LiangLiu committed
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
                // 更新悬浮按钮位置
                const updateFloatingButtonPosition = (width) => {
                    const floatingBtn = document.querySelector('.floating-toggle-btn');
                    if (floatingBtn) {
                        if (sidebarCollapsed.value) {
                            // 收起状态时,按钮位于屏幕左侧
                            floatingBtn.style.left = '0px';
                            floatingBtn.style.right = 'auto';
                        } else {
                            // 展开状态时,按钮位于历史任务栏右侧
                            floatingBtn.style.left = width + 'px';
                            floatingBtn.style.right = 'auto';
                        }
                    }
                };

LiangLiu's avatar
LiangLiu committed
9150
9151
                const startResize = (e) => {
                    e.preventDefault();
LiangLiu's avatar
LiangLiu committed
9152
                    console.log('startResize called');
LiangLiu's avatar
LiangLiu committed
9153
9154
9155
9156

                    isResizing = true;
                    startX = e.clientX;
                    startWidth = sidebar.value.offsetWidth;
LiangLiu's avatar
LiangLiu committed
9157
                    console.log('Resize started, width:', startWidth);
LiangLiu's avatar
LiangLiu committed
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172

                    document.body.classList.add('resizing');
                    document.addEventListener('mousemove', handleResize);
                    document.addEventListener('mouseup', stopResize);
                };

                const handleResize = (e) => {
                    if (!isResizing) return;

                    const deltaX = e.clientX - startX;
                    const newWidth = startWidth + deltaX;
                    const minWidth = 200;
                    const maxWidth = 500;

                    if (newWidth >= minWidth && newWidth <= maxWidth) {
LiangLiu's avatar
LiangLiu committed
9173
9174
9175
9176
9177
9178
9179
9180
9181
                        // 立即更新悬浮按钮位置,不等待其他更新
                        const floatingBtn = document.querySelector('.floating-toggle-btn');
                        if (floatingBtn && !sidebarCollapsed.value) {
                            floatingBtn.style.left = newWidth + 'px';
                        }

                        sidebarWidth.value = newWidth; // 更新响应式变量
                        sidebar.value.style.setProperty('width', newWidth + 'px', 'important');

LiangLiu's avatar
LiangLiu committed
9182
                        // 同时调整主内容区域宽度
LiangLiu's avatar
LiangLiu committed
9183
                        const mainContent = document.querySelector('.main-container main');
LiangLiu's avatar
LiangLiu committed
9184
                        if (mainContent) {
LiangLiu's avatar
LiangLiu committed
9185
9186
9187
9188
9189
9190
                            mainContent.style.setProperty('width', `calc(100% - ${newWidth}px)`, 'important');
                        } else {
                            const altMain = document.querySelector('main');
                            if (altMain) {
                                altMain.style.setProperty('width', `calc(100% - ${newWidth}px)`, 'important');
                            }
LiangLiu's avatar
LiangLiu committed
9191
                        }
LiangLiu's avatar
LiangLiu committed
9192
9193
                    } else {
                        console.log('Width out of range:', newWidth);
LiangLiu's avatar
LiangLiu committed
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
                    }
                };

                const stopResize = () => {
                    isResizing = false;
                    document.body.classList.remove('resizing');
                    document.removeEventListener('mousemove', handleResize);
                    document.removeEventListener('mouseup', stopResize);

                    // 保存当前宽度到localStorage
                    if (sidebar.value) {
                        localStorage.setItem('sidebarWidth', sidebar.value.offsetWidth);
                    }
                };

                // 应用响应式侧边栏宽度
                const applyResponsiveWidth = () => {
                    if (!sidebar.value) return;

                    const windowWidth = window.innerWidth;
LiangLiu's avatar
LiangLiu committed
9214
                    let sidebarWidthPx;
LiangLiu's avatar
LiangLiu committed
9215
9216

                    if (windowWidth <= 768) {
LiangLiu's avatar
LiangLiu committed
9217
                        sidebarWidthPx = 200;
LiangLiu's avatar
LiangLiu committed
9218
                    } else if (windowWidth <= 1200) {
LiangLiu's avatar
LiangLiu committed
9219
                        sidebarWidthPx = 250;
LiangLiu's avatar
LiangLiu committed
9220
9221
9222
9223
9224
9225
                    } else {
                        // 大屏幕时使用保存的宽度或默认宽度
                        const savedWidth = localStorage.getItem('sidebarWidth');
                        if (savedWidth) {
                            const width = parseInt(savedWidth);
                            if (width >= 200 && width <= 500) {
LiangLiu's avatar
LiangLiu committed
9226
                                sidebarWidthPx = width;
LiangLiu's avatar
LiangLiu committed
9227
                            } else {
LiangLiu's avatar
LiangLiu committed
9228
                                sidebarWidthPx = 256; // 默认 w-64
LiangLiu's avatar
LiangLiu committed
9229
9230
                            }
                        } else {
LiangLiu's avatar
LiangLiu committed
9231
                            sidebarWidthPx = 256; // 默认 w-64
LiangLiu's avatar
LiangLiu committed
9232
9233
9234
                        }
                    }

LiangLiu's avatar
LiangLiu committed
9235
9236
9237
9238
9239
9240
                    sidebarWidth.value = sidebarWidthPx; // 更新响应式变量
                    sidebar.value.style.width = sidebarWidthPx + 'px';

                    // 更新悬浮按钮位置
                    updateFloatingButtonPosition(sidebarWidthPx);

LiangLiu's avatar
LiangLiu committed
9241
9242
                    const mainContent = document.querySelector('main');
                    if (mainContent) {
LiangLiu's avatar
LiangLiu committed
9243
9244
9245
9246
9247
9248
9249
                        mainContent.style.width = `calc(100% - ${sidebarWidthPx}px)`;
                    }
                };

                // 新增:视图切换方法
                const switchToCreateView = () => {
                    currentView.value = 'create';
LiangLiu's avatar
LiangLiu committed
9250
                    updateURL('create');
LiangLiu's avatar
LiangLiu committed
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
                    // 如果之前有展开过创作区域,保持展开状态
                    if (isCreationAreaExpanded.value) {
                        // 延迟一点时间确保DOM更新完成
                        setTimeout(() => {
                            const creationArea = document.querySelector('.creation-area');
                            if (creationArea) {
                                creationArea.classList.add('show');
                            }
                        }, 50);
                    }
                };

                const switchToProjectsView = () => {
                    currentView.value = 'projects';
LiangLiu's avatar
LiangLiu committed
9265
                    updateURL('projects');
LiangLiu's avatar
LiangLiu committed
9266
9267
9268
9269
9270
9271
                    // 刷新任务列表
                    refreshTasks();
                };

                const switchToInspirationView = () => {
                    currentView.value = 'inspiration';
LiangLiu's avatar
LiangLiu committed
9272
                    updateURL('inspiration');
LiangLiu's avatar
LiangLiu committed
9273
9274
9275
9276
                    // 加载灵感数据
                    loadInspirationData();
                };

LiangLiu's avatar
LiangLiu committed
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
                const switchToLoginView = () => {
                    currentView.value = 'login';
                    updateURL('login');
                };

                // URL路由管理
                const updateURL = (view) => {
                    const url = new URL(window.location);
                    url.searchParams.set('view', view);
                    window.history.pushState({ view }, '', url);
                };

                const initRoute = () => {
                    const urlParams = new URLSearchParams(window.location.search);
                    const view = urlParams.get('view');

                    if (view && ['create', 'projects', 'inspiration', 'login'].includes(view)) {
                        currentView.value = view;
                        // 注意:数据已经在init()中加载过了,这里不需要重复加载
                        // 只需要设置当前视图即可
                    } else {
                        // 默认显示登录界面
                        currentView.value = 'login';
                        updateURL('login');
                    }
                };

                // 监听浏览器前进后退
                const handlePopState = (event) => {
                    if (event.state && event.state.view) {
                        currentView.value = event.state.view;
                        // 根据页面加载相应的数据
                        if (event.state.view === 'projects') {
                            refreshTasks();
                        } else if (event.state.view === 'inspiration') {
                            loadInspirationData();
                        }
                        // login页面不需要额外数据加载
                    } else {
                        // 处理直接访问URL的情况
                        initRoute();
                    }
                };

LiangLiu's avatar
LiangLiu committed
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
                // 日期格式化函数
                const formatDate = (date) => {
                    if (!date) return '';
                    const d = new Date(date);
                    return d.toLocaleDateString('zh-CN', {
                        year: 'numeric',
                        month: '2-digit',
                        day: '2-digit'
                    });
                };

                // 灵感广场相关方法
                const loadInspirationData = async (forceRefresh = false) => {
                    try {
                        // 如果不是强制刷新,先尝试从缓存加载
                        // 构建缓存键,包含分页和过滤条件
                        const cacheKey = `${TEMPLATES_CACHE_KEY}_${inspirationCurrentPage.value}_${inspirationPageSize.value}_${selectedInspirationCategory.value}_${inspirationSearchQuery.value}`;

                        if (!forceRefresh) {
                        const cachedData = loadFromCache(cacheKey, TEMPLATES_CACHE_EXPIRY);
                        if (cachedData && cachedData.templates) {
                            console.log(`成功从缓存加载灵感模板数据${cacheKey}:`, cachedData.templates);
                            inspirationItems.value = cachedData.templates;
LiangLiu's avatar
LiangLiu committed
9344
                            InspirationCategories.value = cachedData.categories;
LiangLiu's avatar
LiangLiu committed
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
                                // 如果有分页信息也加载
                                if (cachedData.pagination) {
                                    inspirationPagination.value = cachedData.pagination;
                                }
                            preloadTemplateFilesUrl(inspirationItems.value);
                            return;
                            }
                        }

                        // 缓存中没有或强制刷新,从API加载
                        const response = await apiCall(`./api/v1/template/tasks?category=${selectedInspirationCategory.value}&search=${inspirationSearchQuery.value}&page=${inspirationCurrentPage.value}&page_size=${inspirationPageSize.value}`);
                        if (response.ok) {
                            const data = await response.json();
                            const templates = data.templates || [];

                            inspirationItems.value = data.templates || [];
LiangLiu's avatar
LiangLiu committed
9361
                            InspirationCategories.value = data.categories || [];
LiangLiu's avatar
LiangLiu committed
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
                            inspirationPagination.value = data.pagination || null;

                            // 缓存模板数据
                            saveToCache(cacheKey, {
                                templates: inspirationItems.value,
                                pagination: inspirationPagination.value,
                                category: selectedInspirationCategory.value,
                            });

                            console.log('缓存灵感模板数据成功:', inspirationItems.value.length, '个模板');
                            // 强制触发响应式更新
                            await nextTick();

                            // 强制刷新分页组件
                            inspirationPaginationKey.value++;

                            // 使用新的模板文件预加载逻辑
                            preloadTemplateFilesUrl(inspirationItems.value);
                        } else {
                            console.warn('加载模板数据失败');
                        }
                    } catch (error) {
                        console.warn('加载模板数据失败:', error);
                    }
                };
LiangLiu's avatar
LiangLiu committed
9387

LiangLiu's avatar
LiangLiu committed
9388
9389

                // 选择分类
LiangLiu's avatar
LiangLiu committed
9390
                const selectInspirationCategory = async (category) => {
LiangLiu's avatar
LiangLiu committed
9391
                    // 如果点击的是当前分类,不重复请求
LiangLiu's avatar
LiangLiu committed
9392
                    if (selectedInspirationCategory.value === category) {
LiangLiu's avatar
LiangLiu committed
9393
9394
9395
9396
                        return;
                    }

                    // 更新分类
LiangLiu's avatar
LiangLiu committed
9397
                    selectedInspirationCategory.value = category;
LiangLiu's avatar
LiangLiu committed
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435

                    // 重置页码为1
                    inspirationCurrentPage.value = 1;
                    inspirationPageInput.value = 1;

                    // 清空当前数据,显示加载状态
                    inspirationItems.value = [];
                    inspirationPagination.value = null;

                    // 重新加载数据
                    await loadInspirationData(); // 强制刷新,不使用缓存
                };

                // 搜索防抖定时器
                let searchTimeout = null;

                // 处理搜索
                const handleInspirationSearch = async () => {
                    // 清除之前的定时器
                    if (searchTimeout) {
                        clearTimeout(searchTimeout);
                    }

                    // 设置防抖延迟
                    searchTimeout = setTimeout(async () => {
                        // 重置页码为1
                        inspirationCurrentPage.value = 1;
                        inspirationPageInput.value = 1;

                        // 清空当前数据,显示加载状态
                        inspirationItems.value = [];
                        inspirationPagination.value = null;

                        // 重新加载数据
                        await loadInspirationData(); // 强制刷新,不使用缓存
                    }, 500); // 500ms 防抖延迟
                };

LiangLiu's avatar
LiangLiu committed
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
                // 全局视频播放管理
                let currentPlayingVideo = null;
                let currentLoadingVideo = null; // 跟踪正在等待加载的视频

                // 更新视频播放按钮图标
                const updateVideoIcon = (video, isPlaying) => {
                    // 查找视频容器中的播放按钮
                    const container = video.closest('.relative');
                    if (!container) return;

                    // 查找移动端播放按钮
                    const playButton = container.querySelector('button[class*="absolute"][class*="bottom-3"]');
                    if (playButton) {
                        const icon = playButton.querySelector('i');
                        if (icon) {
                            icon.className = isPlaying ? 'fas fa-pause text-sm' : 'fas fa-play text-sm';
                        }
                    }
                };

                // 处理视频播放结束
                const onVideoEnded = (event) => {
                    const video = event.target;
                    console.log('视频播放完毕:', video.src);

                    // 重置视频到开始位置
                    video.currentTime = 0;

                    // 更新播放按钮图标为播放状态
                    updateVideoIcon(video, false);

                    // 如果播放完毕的是当前播放的视频,清除引用
                    if (currentPlayingVideo === video) {
                        currentPlayingVideo = null;
                        console.log('当前播放视频播放完毕');
                    }
                };

LiangLiu's avatar
LiangLiu committed
9474
9475
9476
                // 视频播放控制
                const playVideo = (event) => {
                    const video = event.target;
LiangLiu's avatar
LiangLiu committed
9477
9478
9479
9480
9481

                    // 检查视频是否已加载完成
                    if (video.readyState < 2) { // HAVE_CURRENT_DATA
                        console.log('视频还没加载完成,忽略鼠标悬停播放');
                        return;
LiangLiu's avatar
LiangLiu committed
9482
                    }
LiangLiu's avatar
LiangLiu committed
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504

                    // 如果当前有视频在播放,先暂停它
                    if (currentPlayingVideo && currentPlayingVideo !== video) {
                        currentPlayingVideo.pause();
                        currentPlayingVideo.currentTime = 0;
                        // 更新上一个视频的图标
                        updateVideoIcon(currentPlayingVideo, false);
                        console.log('暂停上一个视频');
                    }

                    // 视频已加载完成,可以播放
                    video.currentTime = 0; // 从头开始播放
                    video.play().then(() => {
                        // 播放成功,更新当前播放视频
                        currentPlayingVideo = video;
                        console.log('开始播放新视频');
                    }).catch(e => {
                        console.log('视频播放失败:', e);
                        currentPlayingVideo = null;
                        video.pause();
                        video.currentTime = 0;
                    });
LiangLiu's avatar
LiangLiu committed
9505
9506
9507
9508
                };

                const pauseVideo = (event) => {
                    const video = event.target;
LiangLiu's avatar
LiangLiu committed
9509
9510
9511
9512
9513
9514
9515

                    // 检查视频是否已加载完成
                    if (video.readyState < 2) { // HAVE_CURRENT_DATA
                        console.log('视频还没加载完成,忽略鼠标离开暂停');
                        return;
                    }

LiangLiu's avatar
LiangLiu committed
9516
9517
                    video.pause();
                    video.currentTime = 0;
LiangLiu's avatar
LiangLiu committed
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637

                    // 更新视频图标
                    updateVideoIcon(video, false);

                    // 如果暂停的是当前播放的视频,清除引用
                    if (currentPlayingVideo === video) {
                        currentPlayingVideo = null;
                        console.log('暂停当前播放视频');
                    }
                };

                // 移动端视频播放切换
                const toggleVideoPlay = (event) => {
                    const button = event.target.closest('button');
                    const video = button.parentElement.querySelector('video');
                    const icon = button.querySelector('i');

                    if (video.paused) {
                        // 如果当前有视频在播放,先暂停它
                        if (currentPlayingVideo && currentPlayingVideo !== video) {
                            currentPlayingVideo.pause();
                            currentPlayingVideo.currentTime = 0;
                            // 更新上一个视频的图标
                            updateVideoIcon(currentPlayingVideo, false);
                            console.log('暂停上一个视频(移动端)');
                        }

                        // 如果当前有视频在等待加载,取消它的等待状态
                        if (currentLoadingVideo && currentLoadingVideo !== video) {
                            currentLoadingVideo = null;
                            console.log('取消上一个视频的加载等待(移动端)');
                        }

                        // 检查视频是否已加载完成
                        if (video.readyState >= 2) { // HAVE_CURRENT_DATA
                            // 视频已加载完成,直接播放
                            video.currentTime = 0;
                            video.play().then(() => {
                                icon.className = 'fas fa-pause text-sm';
                                currentPlayingVideo = video;
                                console.log('开始播放新视频(移动端)');
                            }).catch(e => {
                                console.log('视频播放失败:', e);
                                icon.className = 'fas fa-play text-sm';
                                currentPlayingVideo = null;
                            });
                        } else {
                            // 视频未加载完成,显示loading并等待
                            console.log('视频还没加载完成,等待加载(移动端)');
                            icon.className = 'fas fa-spinner fa-spin text-sm';
                            currentLoadingVideo = video;

                            // 等待视频加载完成
                            video.addEventListener('loadeddata', () => {
                                // 检查这个视频是否仍然是当前等待加载的视频
                                if (currentLoadingVideo === video) {
                                    currentLoadingVideo = null;
                                    video.currentTime = 0;
                                    video.play().then(() => {
                                        icon.className = 'fas fa-pause text-sm';
                                        currentPlayingVideo = video;
                                        console.log('开始播放新视频(移动端-延迟加载)');
                                    }).catch(e => {
                                        console.log('视频播放失败:', e);
                                        icon.className = 'fas fa-play text-sm';
                                        currentPlayingVideo = null;
                                    });
                                } else {
                                    // 这个视频的加载等待已被取消,重置图标
                                    icon.className = 'fas fa-play text-sm';
                                    console.log('视频加载完成但等待已被取消(移动端)');
                                }
                            }, { once: true });
                    };
                 } else {
                        video.pause();
                        video.currentTime = 0;
                        icon.className = 'fas fa-play text-sm';

                        // 如果暂停的是当前播放的视频,清除引用
                        if (currentPlayingVideo === video) {
                            currentPlayingVideo = null;
                            console.log('暂停当前播放视频(移动端)');
                        }

                        // 如果暂停的是当前等待加载的视频,清除引用
                        if (currentLoadingVideo === video) {
                            currentLoadingVideo = null;
                            console.log('取消当前等待加载的视频(移动端)');
                        }
                    }
                };

                // 暂停所有视频
                const pauseAllVideos = () => {
                    if (currentPlayingVideo) {
                        currentPlayingVideo.pause();
                        currentPlayingVideo.currentTime = 0;
                        // 更新视频图标
                        updateVideoIcon(currentPlayingVideo, false);
                        currentPlayingVideo = null;
                        console.log('暂停所有视频');
                    }

                    // 清理等待加载的视频状态
                    if (currentLoadingVideo) {
                        // 重置等待加载的视频图标
                        const loadingContainer = currentLoadingVideo.closest('.relative');
                        if (loadingContainer) {
                            const loadingButton = loadingContainer.querySelector('button[class*="absolute"][class*="bottom-3"]');
                            if (loadingButton) {
                                const loadingIcon = loadingButton.querySelector('i');
                                if (loadingIcon) {
                                    loadingIcon.className = 'fas fa-play text-sm';
                                }
                            }
                        }
                        currentLoadingVideo = null;
                        console.log('取消所有等待加载的视频');
                    }
LiangLiu's avatar
LiangLiu committed
9638
9639
9640
9641
9642
9643
                };

                const onVideoLoaded = (event) => {
                    const video = event.target;
                    // 视频加载完成,准备播放
                    console.log('视频加载完成:', video.src);
LiangLiu's avatar
LiangLiu committed
9644
9645
9646
9647
9648
9649

                    // 更新视频加载状态(使用视频的实际src)
                    setVideoLoaded(video.src, true);

                    // 触发Vue的响应式更新
                    videoLoadedStates.value = new Map(videoLoadedStates.value);
LiangLiu's avatar
LiangLiu committed
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
                };

                const onVideoError = (event) => {
                    const video = event.target;
                    console.error('视频加载失败:', video.src, event);
                    const img = event.target;
                    const parent = img.parentElement;
                    parent.innerHTML = '<div class="w-full h-44 bg-laser-purple/20 flex items-center justify-center"><i class="fas fa-video text-gradient-icon text-xl"></i></div>';
                    // 回退到图片
                };

                // 预览模板详情
                const previewTemplateDetail = (item) => {
                    selectedTemplate.value = item;
                    showTemplateDetailModal.value = true;
                };

                // 关闭模板详情弹窗
                const closeTemplateDetailModal = () => {
                    showTemplateDetailModal.value = false;
                    selectedTemplate.value = null;
                };

                // 显示图片放大
                const showImageZoom = (imageUrl) => {
                    zoomedImageUrl.value = imageUrl;
                    showImageZoomModal.value = true;
                };

                // 关闭图片放大弹窗
                const closeImageZoomModal = () => {
                    showImageZoomModal.value = false;
                    zoomedImageUrl.value = '';
                };

                // 应用模板图片
                const applyTemplateImage = (template) => {
                    if (template?.inputs?.input_image) {
                        const imageUrl = getTemplateFileUrl(template.inputs.input_image, 'images');
                        // 这里需要根据当前任务类型设置图片
                        if (selectedTaskId.value === 'i2v' || selectedTaskId.value === 's2v') {
                            // 模拟文件上传,将图片URL转换为File对象
                            fetch(imageUrl)
                                .then(response => response.blob())
                                .then(blob => {
                                    const file = new File([blob], 'template_image.jpg', { type: blob.type });
                                    if (selectedTaskId.value === 'i2v') {
                                        i2vForm.value.imageFile = file;
                                    } else if (selectedTaskId.value === 's2v') {
                                        s2vForm.value.imageFile = file;
                                    }
                                    setCurrentImagePreview(imageUrl);
                                    updateUploadedContentStatus();
                                    showAlert(t('imageApplied'), 'success');
                                })
                                .catch(error => {
                                    console.error('应用图片失败:', error);
                                    showAlert(t('applyImageFailed'), 'danger');
                                });
                        }
                    }
                };

                // 应用模板音频
                const applyTemplateAudio = (template) => {
                    if (template?.inputs?.input_audio && selectedTaskId.value === 's2v') {
                        const audioUrl = getTemplateFileUrl(template.inputs.input_audio, 'audios');
                        // 模拟文件上传,将音频URL转换为File对象
                        fetch(audioUrl)
                            .then(response => response.blob())
                            .then(blob => {
                                const file = new File([blob], 'template_audio.mp3', { type: blob.type });
                                s2vForm.value.audioFile = file;
                                setCurrentAudioPreview(audioUrl);
                                updateUploadedContentStatus();
                                showAlert(t('audioApplied'), 'success');
                            })
                            .catch(error => {
                                console.error('应用音频失败:', error);
                                showAlert(t('applyAudioFailed'), 'danger');
                            });
LiangLiu's avatar
LiangLiu committed
9731
9732
9733
                    }
                };

LiangLiu's avatar
LiangLiu committed
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
                // 应用模板Prompt
                const applyTemplatePrompt = (template) => {
                    if (template?.params?.prompt) {
                        const currentForm = getCurrentForm();
                        if (currentForm) {
                            currentForm.prompt = template.params.prompt;
                            updateUploadedContentStatus();
                            showAlert(t('promptApplied'), 'success');
                        }
                    }
                };

                // 复制Prompt到剪贴板
                const copyPrompt = async (promptText) => {
                    if (!promptText) return;

                    try {
                        await navigator.clipboard.writeText(promptText);
                        showAlert(t('promptCopied'), 'success');
                    } catch (error) {
                        // 降级方案:使用传统方法
                        const textArea = document.createElement('textarea');
                        textArea.value = promptText;
                        document.body.appendChild(textArea);
                        textArea.select();
                        document.execCommand('copy');
                        document.body.removeChild(textArea);
                        showAlert(t('promptCopied'), 'success');
                    }
                };

                // 使用模板
                const useTemplate = async (item) => {
                    if (!item) {
                        showAlert('模板数据不完整', 'danger');
                        return;
                    }
                    console.log('使用模板:', item);

                    try {
                        // 先设置任务类型
                        selectedTaskId.value = item.task_type;

                        // 获取当前表单
                        const currentForm = getCurrentForm();

                        // 设置表单数据
                        currentForm.prompt = item.params?.prompt || '';
                        currentForm.negative_prompt = item.params?.negative_prompt || '';
                        currentForm.seed = item.params?.seed || 42;
                        currentForm.model_cls = item.model_cls || '';
                        currentForm.stage = item.stage || 'single_stage';

                        // 如果有输入图片,先设置URL,延迟加载文件
                        if (item.inputs && item.inputs.input_image) {
                            getTemplateFileUrl(item.inputs.input_image,'images')
                            imageUrl = getTemplateFileUrl(item.inputs.input_image,'images')
                            currentForm.imageUrl = imageUrl;
                            setCurrentImagePreview(imageUrl); // 直接使用URL作为预览
                            console.log('模板输入图片:', imageUrl);

                            // 异步加载图片文件(不阻塞UI)
                            setTimeout(async () => {
                                try {
                                    const imageResponse = await fetch(imageUrl);
                                    if (imageResponse.ok) {
                                        const blob = await imageResponse.blob();
                                        const filename = item.inputs.input_image;
                                        const file = new File([blob], filename, { type: blob.type });
                                        currentForm.imageFile = file;
                                        console.log('模板图片文件已加载');
                                    }
                                } catch (error) {
                                    console.warn('Failed to load template image file:', error);
                                }
                            }, 100);
                        }

                        // 如果有输入音频,先设置URL,延迟加载文件
                        if (item.inputs && item.inputs.input_audio) {
                            getTemplateFileUrl(item.inputs.input_audio,'audios')
                            audioUrl = getTemplateFileUrl(item.inputs.input_audio,'audios')
                            currentForm.audioUrl = audioUrl;
                            setCurrentAudioPreview(audioUrl); // 直接使用URL作为预览
                            console.log('模板输入音频:', audioUrl);

                            // 异步加载音频文件(不阻塞UI)
                            setTimeout(async () => {
                                try {
                                    const audioResponse = await fetch(audioUrl);
                                    if (audioResponse.ok) {
                                        const blob = await audioResponse.blob();
                                        const filename = item.inputs.input_audio;

                                        // 根据文件扩展名确定正确的MIME类型
                                        let mimeType = blob.type;
                                        if (!mimeType || mimeType === 'application/octet-stream') {
                                            const ext = filename.toLowerCase().split('.').pop();
                                            const mimeTypes = {
                                                'mp3': 'audio/mpeg',
                                                'wav': 'audio/wav',
                                                'mp4': 'audio/mp4',
                                                'aac': 'audio/aac',
                                                'ogg': 'audio/ogg',
                                                'm4a': 'audio/mp4'
                                            };
                                            mimeType = mimeTypes[ext] || 'audio/mpeg';
                                        }

                                        const file = new File([blob], filename, { type: mimeType });
                                        currentForm.audioFile = file;
                                        console.log('模板音频文件已加载');
                                        // 使用FileReader生成data URL,与正常上传保持一致
                                        const reader = new FileReader();
                                        reader.onload = (e) => {
                                            setCurrentAudioPreview(e.target.result);
                                            console.log('模板音频预览已设置:', e.target.result.substring(0, 50) + '...');
                                        };
                                        reader.readAsDataURL(file);
                                    }
                                } catch (error) {
                                    console.warn('Failed to load template audio file:', error);
                                }
                            }, 100);
                        }

                        // 关闭模板详情弹窗
                        closeTemplateDetailModal();

                        // 切换到创建视图
                        isCreationAreaExpanded.value=true;
                        switchToCreateView();

                        showAlert(`已应用模板`, 'success');
                    } catch (error) {
                        console.error('应用模板失败:', error);
                        showAlert(`应用模板失败: ${error.message}`, 'danger');
                    }
                };

                // 加载更多灵感
                const loadMoreInspiration = () => {
                    showAlert('加载更多灵感功能开发中...', 'info');
                };

                // 新增:任务详情弹窗方法
                const openTaskDetailModal = (task) => {
                    modalTask.value = task;
                    showTaskDetailModal.value = true;
                    // 加载任务详情
                    viewTaskDetail(task);
                };

                const closeTaskDetailModal = () => {
                    showTaskDetailModal.value = false;
                    modalTask.value = null;
                    selectedTask.value = null;
                };

LiangLiu's avatar
LiangLiu committed
9893
9894
9895
9896
9897
9898
                // 恢复保存的侧边栏宽度
                onMounted(() => {
                    applyResponsiveWidth();

                    // 监听窗口大小变化
                    window.addEventListener('resize', applyResponsiveWidth);
LiangLiu's avatar
LiangLiu committed
9899
9900
9901
9902
9903

                    // 确保悬浮按钮初始位置正确
                    setTimeout(() => {
                        updateFloatingButtonPosition(sidebarWidth.value);
                    }, 100);
LiangLiu's avatar
LiangLiu committed
9904
9905
                });

LiangLiu's avatar
LiangLiu committed
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
                // 语言切换功能
                const switchLanguage = (langCode) => {
                    currentLanguage.value = langCode;
                    localStorage.setItem('preferredLanguage', langCode);

                    // 更新页面标题
                    document.title = t('pageTitle');

                    // 更新HTML lang属性
                    document.documentElement.lang = langCode === 'zh' ? 'zh-CN' : 'en';
                };

                // 简单语言切换功能(中英文切换)
                const toggleLanguage = () => {
                    const newLang = currentLanguage.value === 'zh' ? 'en' : 'zh';
                    switchLanguage(newLang);
                };

                // 初始化语言设置
                const initLanguage = () => {
                    const savedLanguage = localStorage.getItem('preferredLanguage');
                    if (savedLanguage && ['zh', 'en'].includes(savedLanguage)) {
                        currentLanguage.value = savedLanguage;
                    } else {
                        // 根据浏览器语言自动选择
                        const browserLang = navigator.language || navigator.userLanguage;
                        if (browserLang.startsWith('zh')) {
                            currentLanguage.value = 'zh';
                        } else {
                            currentLanguage.value = 'en';
                        }
                    }

                    // 标记语言已加载完成
                    languageLoaded.value = true;

                    // 应用语言设置
                    document.title = t('pageTitle');
                    document.documentElement.lang = currentLanguage.value === 'zh' ? 'zh-CN' : 'en';
                };

LiangLiu's avatar
LiangLiu committed
9947
                return {
LiangLiu's avatar
LiangLiu committed
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
                    // 语言相关
                    currentLanguage,
                    showLanguageMenu,
                    languageLoaded,
                    languageOptions,
                    translations,
                    t,
                    switchLanguage,
                    toggleLanguage,
                    initLanguage,

                    // 任务类型下拉菜单
                    showTaskTypeMenu,
                    showModelMenu,

LiangLiu's avatar
LiangLiu committed
9963
9964
                    isLoggedIn,
                    loading,
LiangLiu's avatar
LiangLiu committed
9965
9966
9967
                    loginLoading,
                    initLoading,
                    downloadLoading,
LiangLiu's avatar
LiangLiu committed
9968
9969
9970
9971
9972
9973
9974
9975

                    // 录音相关
                    isRecording,
                    recordingDuration,
                    startRecording,
                    stopRecording,
                    formatRecordingDuration,

LiangLiu's avatar
LiangLiu committed
9976
                    loginWithGitHub,
LiangLiu's avatar
LiangLiu committed
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
                    loginWithGoogle,
                    // 短信登录相关
                    phoneNumber,
                    verifyCode,
                    smsCountdown,
                    showSmsForm,
                    sendSmsCode,
                    loginWithSms,
                    handlePhoneEnter,
                    handleVerifyCodeEnter,
                    toggleSmsLogin,
LiangLiu's avatar
LiangLiu committed
9988
                    submitting,
LiangLiu's avatar
LiangLiu committed
9989
                    taskSearchQuery,
LiangLiu's avatar
LiangLiu committed
9990
9991
9992
9993
                    currentUser,
                    models,
                    tasks,
                    alert,
LiangLiu's avatar
LiangLiu committed
9994
9995
9996
9997
9998
9999
10000
10001
                    showErrorDetails,
                    showFailureDetails,
                    confirmDialog,
                    showConfirmDialog,
                    // 新增:视图切换相关状态
                    currentView,
                    showTaskDetailModal,
                    modalTask,
LiangLiu's avatar
LiangLiu committed
10002
10003
                    t2vForm,
                    i2vForm,
LiangLiu's avatar
LiangLiu committed
10004
                    s2vForm,
LiangLiu's avatar
LiangLiu committed
10005
10006
                    getCurrentForm,
                    i2vImagePreview,
LiangLiu's avatar
LiangLiu committed
10007
10008
                    s2vImagePreview,
                    s2vAudioPreview,
LiangLiu's avatar
LiangLiu committed
10009
10010
                    getCurrentImagePreview,
                    getCurrentAudioPreview,
LiangLiu's avatar
LiangLiu committed
10011
10012
10013
                    setCurrentImagePreview,
                    setCurrentAudioPreview,
                    updateUploadedContentStatus,
LiangLiu's avatar
LiangLiu committed
10014
10015
                    availableTaskTypes,
                    availableModelClasses,
LiangLiu's avatar
LiangLiu committed
10016
10017
10018
10019
                    currentTaskHints,
                    currentHintIndex,
                    startHintRotation,
                    stopHintRotation,
LiangLiu's avatar
LiangLiu committed
10020
10021
10022
10023
10024
10025
10026
                    filteredTasks,
                    selectedTaskId,
                    selectedTask,
                    selectedTaskFiles,
                    loadingTaskFiles,
                    statusFilter,
                    pagination,
LiangLiu's avatar
LiangLiu committed
10027
10028
10029
10030
10031
10032
10033
10034
10035
                    paginationInfo,
                    currentTaskPage,
                    taskPageSize,
                    taskPageInput,
                    paginationKey,
                    taskMenuVisible,
                    toggleTaskMenu,
                    closeAllTaskMenus,
                    handleClickOutside,
LiangLiu's avatar
LiangLiu committed
10036
10037
10038
10039
10040
10041
                    showAlert,
                    setLoading,
                    apiCall,
                    logout,
                    loadModels,
                    sidebarCollapsed,
LiangLiu's avatar
LiangLiu committed
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
                    sidebarWidth,
                    showExpandHint,
                    showGlow,
                    isDefaultStateHidden,
                    hideDefaultState,
                    showDefaultState,
                    isCreationAreaExpanded,
                    hasUploadedContent,
                    isContracting,
                    expandCreationArea,
                    contractCreationArea,
                    taskFileCache,
                    taskFileCacheLoaded,
                    templateFileCache,
                    templateFileCacheLoaded,
LiangLiu's avatar
LiangLiu committed
10057
10058
10059
10060
10061
10062
                    loadTaskFiles,
                    downloadFile,
                    viewFile,
                    handleImageUpload,
                    selectTask,
                    selectModel,
LiangLiu's avatar
LiangLiu committed
10063
                    resetForm,
LiangLiu's avatar
LiangLiu committed
10064
10065
10066
10067
10068
                    triggerImageUpload,
                    triggerAudioUpload,
                    removeImage,
                    removeAudio,
                    handleAudioUpload,
LiangLiu's avatar
LiangLiu committed
10069
                    loadImageAudioTemplates,
LiangLiu's avatar
LiangLiu committed
10070
10071
10072
                    selectImageTemplate,
                    selectAudioTemplate,
                    previewAudioTemplate,
LiangLiu's avatar
LiangLiu committed
10073
                    getTemplateFile,
LiangLiu's avatar
LiangLiu committed
10074
10075
10076
10077
                    imageTemplates,
                    audioTemplates,
                    showImageTemplates,
                    showAudioTemplates,
LiangLiu's avatar
LiangLiu committed
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
                    mediaModalTab,
                    templatePagination,
                    templatePaginationInfo,
                    templateCurrentPage,
                    templatePageSize,
                    templatePageInput,
                    templatePaginationKey,
                    imageHistory,
                    audioHistory,
                    templateFileCache,
LiangLiu's avatar
LiangLiu committed
10088
10089
                    showTemplates,
                    showHistory,
LiangLiu's avatar
LiangLiu committed
10090
10091
                    showPromptModal,
                    promptModalTab,
LiangLiu's avatar
LiangLiu committed
10092
10093
10094
10095
                    submitTask,
                    fileToBase64,
                    formatTime,
                    refreshTasks,
LiangLiu's avatar
LiangLiu committed
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
                    goToPage,
                    jumpToPage,
                    getVisiblePages,
                    goToTemplatePage,
                    jumpToTemplatePage,
                    getVisibleTemplatePages,
                    goToInspirationPage,
                    jumpToInspirationPage,
                    getVisibleInspirationPages,
                    preloadTaskFilesUrl,
                    preloadTemplateFilesUrl,
                    loadTaskFilesFromCache,
                    saveTaskFilesToCache,
                    getTaskFileFromCache,
                    setTaskFileToCache,
                    getTaskFileUrlFromApi,
                    getTaskFileUrl,
                    getTaskFileUrlSync,
                    getTemplateFileUrlFromApi,
                    getTemplateFileUrl,
                    getTemplateFileUrlAsync,
                    loadTemplateFilesFromCache,
                    saveTemplateFilesToCache,
                    loadFromCache,
                    saveToCache,
                    clearAllCache,
LiangLiu's avatar
LiangLiu committed
10122
10123
10124
10125
                    getStatusBadgeClass,
                    viewSingleResult,
                    cancelTask,
                    resumeTask,
LiangLiu's avatar
LiangLiu committed
10126
10127
10128
                    deleteTask,
                    startPollingTask,
                    stopPollingTask,
LiangLiu's avatar
LiangLiu committed
10129
                    viewTaskDetail,
LiangLiu's avatar
LiangLiu committed
10130
                    reuseTask,
LiangLiu's avatar
LiangLiu committed
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
                    showTaskCreator,
                    toggleSidebar,
                    clearPrompt,
                    getTaskItemClass,
                    getStatusIndicatorClass,
                    getTaskTypeBtnClass,
                    getModelBtnClass,
                    getTaskTypeIcon,
                    getTaskTypeName,
                    getPromptPlaceholder,
                    getStatusTextClass,
                    getImagePreview,
                    getTaskInputUrl,
LiangLiu's avatar
LiangLiu committed
10144
10145
                    getTaskInputImage,
                    getTaskInputAudio,
LiangLiu's avatar
LiangLiu committed
10146
                    getTaskFileUrl,
LiangLiu's avatar
LiangLiu committed
10147
10148
10149
10150
                    getHistoryImageUrl,
                    getUserAvatarUrl,
                    getCurrentImagePreviewUrl,
                    getCurrentAudioPreviewUrl,
LiangLiu's avatar
LiangLiu committed
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
                    handleThumbnailError,
                    handleImageError,
                    handleImageLoad,
                    handleAudioError,
                    handleAudioLoad,
                    getTaskStatusDisplay,
                    getTaskStatusColor,
                    getTaskStatusIcon,
                    getTaskDuration,
                    getRelativeTime,
                    getTaskHistory,
                    getActiveTasks,
LiangLiu's avatar
LiangLiu committed
10163
10164
10165
10166
10167
10168
10169
10170
                    getOverallProgress,
                    getProgressTitle,
                    getProgressInfo,
                    getSubtaskProgress,
                    getSubtaskStatusText,
                    formatEstimatedTime,
                    formatDuration,
                    getTaskFailureInfo,
LiangLiu's avatar
LiangLiu committed
10171
10172
10173
10174
10175
10176
10177
                    searchTasks,
                    filterTasksByStatus,
                    filterTasksByType,
                    getAlertClass,
                    getAlertBorderClass,
                    getAlertTextClass,
                    getAlertIcon,
LiangLiu's avatar
LiangLiu committed
10178
                    getAlertIconBgClass,
LiangLiu's avatar
LiangLiu committed
10179
10180
10181
10182
                    getPromptTemplates,
                    selectPromptTemplate,
                    promptHistory,
                    getPromptHistory,
LiangLiu's avatar
LiangLiu committed
10183
10184
                    addTaskToHistory,
                    getLocalTaskHistory,
LiangLiu's avatar
LiangLiu committed
10185
10186
                    selectPromptHistory,
                    clearPromptHistory,
LiangLiu's avatar
LiangLiu committed
10187
10188
10189
10190
10191
10192
10193
                    getImageHistory,
                    getAudioHistory,
                    selectImageHistory,
                    selectAudioHistory,
                    previewAudioHistory,
                    clearImageHistory,
                    clearAudioHistory,
LiangLiu's avatar
LiangLiu committed
10194
10195
                    getAudioMimeType,
                    getAuthHeaders,
LiangLiu's avatar
LiangLiu committed
10196
                    startResize,
LiangLiu's avatar
LiangLiu committed
10197
                    sidebar,
LiangLiu's avatar
LiangLiu committed
10198
10199
10200
                    switchToCreateView,
                    switchToProjectsView,
                    switchToInspirationView,
LiangLiu's avatar
LiangLiu committed
10201
10202
10203
10204
                    switchToLoginView,
                    updateURL,
                    initRoute,
                    handlePopState,
LiangLiu's avatar
LiangLiu committed
10205
10206
10207
10208
10209
10210
                    openTaskDetailModal,
                    closeTaskDetailModal,
                    // 灵感广场相关
                    inspirationSearchQuery,
                    selectedInspirationCategory,
                    inspirationItems,
LiangLiu's avatar
LiangLiu committed
10211
                    InspirationCategories,
LiangLiu's avatar
LiangLiu committed
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
                    loadInspirationData,
                    selectInspirationCategory,
                    handleInspirationSearch,
                    loadMoreInspiration,
                    inspirationPagination,
                    inspirationPaginationInfo,
                    inspirationCurrentPage,
                    inspirationPageSize,
                    inspirationPageInput,
                    inspirationPaginationKey,
                    // 工具函数
                    formatDate,
                    // 模板详情弹窗相关
                    showTemplateDetailModal,
                    selectedTemplate,
                    previewTemplateDetail,
                    closeTemplateDetailModal,
                    useTemplate,
                    // 图片放大弹窗相关
                    showImageZoomModal,
                    zoomedImageUrl,
                    showImageZoom,
                    closeImageZoomModal,
                    // 模板素材应用相关
                    applyTemplateImage,
                    applyTemplateAudio,
                    applyTemplatePrompt,
                    copyPrompt,
                    // 视频播放控制
                    playVideo,
                    pauseVideo,
LiangLiu's avatar
LiangLiu committed
10243
10244
10245
                    toggleVideoPlay,
                    pauseAllVideos,
                    updateVideoIcon,
LiangLiu's avatar
LiangLiu committed
10246
                    onVideoLoaded,
LiangLiu's avatar
LiangLiu committed
10247
10248
                    onVideoError,
                    onVideoEnded
LiangLiu's avatar
LiangLiu committed
10249
10250
10251
                };
            }
        }).mount('#app');
LiangLiu's avatar
LiangLiu committed
10252

LiangLiu's avatar
LiangLiu committed
10253
10254
    </script>
</body>
LiangLiu's avatar
LiangLiu committed
10255

LiangLiu's avatar
LiangLiu committed
10256
</html>