-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathindex.html
More file actions
5948 lines (5169 loc) · 348 KB
/
index.html
File metadata and controls
5948 lines (5169 loc) · 348 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-4D36DBYDJX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-4D36DBYDJX');
</script>
<title>unitale ai工具</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script src="https://unpkg.com/mp4-muxer/build/mp4-muxer.js"></script>
<script src="./vendor/ffmpeg/ffmpeg.js"></script>
<script src="./vendor/ffmpeg/util.js"></script>
<style>
.thinking {
color: #6b7280;
font-style: italic;
background: #f3f4f6;
padding: 12px;
border-radius: 8px;
margin-bottom: 12px;
border-left: 4px solid #d1d5db;
font-size: 0.9rem;
}
.result-box {
line-height: 1.6;
font-size: 1rem;
color: #1f2937;
}
/* 随机背景与毛玻璃特效 */
body {
background-color: #f1f5f9;
/* Fallback color */
background-image: url('https://picsum.photos/1920/1080');
background-size: cover;
background-position: center;
background-attachment: fixed;
}
#app {
background-color: rgba(255, 255, 255, 0.58) !important;
backdrop-filter: blur(6px);
-webkit-backdrop-filter: blur(6px);
border: 1px solid rgba(255, 255, 255, 0.28);
}
/* 内部组件半透明化,增强层次感 */
#app .bg-white,
#app .bg-slate-50,
#app .bg-slate-100 {
background-color: rgba(255, 255, 255, 0.34) !important;
}
input,
textarea,
select {
background-color: rgba(255, 255, 255, 0.8) !important;
}
</style>
</head>
<body class="p-4 md:p-8">
<div id="app" class="w-full max-w-[96%] mx-auto p-6 rounded-2xl shadow-2xl">
<div v-if="previewImageUrl" @click="closeImagePreview"
class="fixed inset-0 z-[10000] bg-slate-950/78 backdrop-blur-sm flex items-center justify-center p-4">
<button @click.stop="closeImagePreview"
class="absolute top-4 right-4 px-3 py-1.5 rounded-lg bg-white/15 text-white text-sm font-bold hover:bg-white/25 transition-all">
关闭
</button>
<img :src="previewImageUrl" alt="背景图片大图预览" @click.stop
class="max-w-[95vw] max-h-[92vh] object-contain rounded-xl shadow-2xl bg-white">
</div>
<header class="mb-6 flex justify-between items-end">
<div>
<h1 class="text-2xl font-bold text-slate-800">Unitale AI <span class="text-blue-600">1.5</span></h1>
<p style="color: rgb(39, 92, 120);" class="text-slate-400 text-xs mt-1">多角色音效合成有声书生成工具</p>
</div>
<div class="text-[10px] text-slate-300">v1.5</div>
</header>
<!-- 标签页导航 -->
<div class="flex flex-wrap items-center justify-between border-b border-slate-200 mb-6 gap-4">
<div class="flex overflow-x-auto">
<button @click="activeTab = 'config'"
:class="['px-6 py-3 text-sm font-bold transition-colors whitespace-nowrap', activeTab === 'config' ? 'text-blue-600 border-b-2 border-blue-600' : 'text-slate-500 hover:text-slate-700']">
模型配置
</button>
<button @click="activeTab = 'timbres'"
:class="['px-6 py-3 text-sm font-bold transition-colors whitespace-nowrap', activeTab === 'timbres' ? 'text-blue-600 border-b-2 border-blue-600' : 'text-slate-500 hover:text-slate-700']">
音色资源库
</button>
<button @click="activeTab = 'sfx'"
:class="['px-6 py-3 text-sm font-bold transition-colors whitespace-nowrap', activeTab === 'sfx' ? 'text-blue-600 border-b-2 border-blue-600' : 'text-slate-500 hover:text-slate-700']">
音效与滤波器
</button>
<button @click="activeTab = 'script'"
:class="['px-6 py-3 text-sm font-bold transition-colors whitespace-nowrap', activeTab === 'script' ? 'text-blue-600 border-b-2 border-blue-600' : 'text-slate-500 hover:text-slate-700']">
脚本制作
</button>
<button @click="activeTab = 'prompt'"
:class="['px-6 py-3 text-sm font-bold transition-colors whitespace-nowrap', activeTab === 'prompt' ? 'text-blue-600 border-b-2 border-blue-600' : 'text-slate-500 hover:text-slate-700']">
Prompt 管理
</button>
</div>
<!-- 全局功能栏 (导出/导入) -->
<div class="flex flex-wrap items-center gap-2 py-2">
<button @click="exportScriptState" :disabled="isExportingProject"
class="px-3 py-1.5 bg-amber-100 text-amber-700 rounded-lg text-xs font-bold hover:bg-amber-200 transition-all flex items-center gap-1 disabled:opacity-50 disabled:cursor-wait">
{{ isExportingProject ? exportStatus : '导出完整工程' }}
</button>
<button @click="triggerImport" :disabled="isExportingProject"
class="px-3 py-1.5 bg-amber-100 text-amber-700 rounded-lg text-xs font-bold hover:bg-amber-200 transition-all flex items-center gap-1 disabled:opacity-50">
{{ isExportingProject ? '请等待...' : '导入完整工程' }}
</button>
<button @click="triggerImportTxt" :disabled="isExportingProject"
class="px-3 py-1.5 bg-slate-100 text-slate-700 rounded-lg text-xs font-bold hover:bg-slate-200 transition-all flex items-center gap-1 disabled:opacity-50">
导入TXT
</button>
<button @click="exportSRT" :disabled="isExportingAudio"
class="px-3 py-1.5 bg-teal-100 text-teal-700 rounded-lg text-xs font-bold hover:bg-teal-200 transition-all flex items-center gap-1 disabled:opacity-50 disabled:cursor-wait">
导出SRT字幕
</button>
<button @click="exportAudio" :disabled="isExportingAudio"
class="px-3 py-1.5 bg-purple-100 text-purple-700 rounded-lg text-xs font-bold hover:bg-purple-200 transition-all flex items-center gap-1 disabled:opacity-50 disabled:cursor-wait">
{{ isExportingAudio ? (exportStatus || '⏳ 处理中...') : '导出音频' }}
</button>
<select v-model="videoResolution" class="px-2 py-1.5 bg-white border border-slate-300 text-slate-700 rounded-lg text-xs font-bold outline-none focus:ring-2 focus:ring-sky-500">
<option value="1920x1080">横屏 16:9</option>
<option value="1080x1920">竖屏 9:16</option>
<option value="1280x960">横屏 4:3</option>
<option value="960x1280">竖屏 3:4</option>
</select>
<button @click="generateVideo" :disabled="isExportingAudio || isSequencePlaying || isGeneratingVideo"
class="px-3 py-1.5 bg-sky-100 text-sky-700 rounded-lg text-xs font-bold hover:bg-sky-200 transition-all flex items-center gap-1 disabled:opacity-50 disabled:cursor-wait">
{{ isGeneratingVideo ? (exportStatus || '⏳ 生成视频...') : '生成视频' }}
</button>
<input type="file" ref="importFileRef" @change="handleImportFile" accept=".json" class="hidden">
<input type="file" ref="importTxtRef" @change="handleImportTxt" accept=".txt" class="hidden">
<input type="file" ref="bgImagePickerRef" @change="handleBgImageFileChange" accept="image/*" class="hidden">
</div>
</div>
<!-- 页面 1: 模型配置 (LLM & TTS) -->
<div v-if="activeTab === 'config'" class="space-y-6">
<h2 class="text-lg font-bold text-slate-800 border-b pb-2">LLM 模型配置(OpenAI通用接口)</h2>
<!-- 添加/编辑表单 -->
<div class="bg-slate-50 p-5 rounded-xl border border-slate-200">
<h3 class="text-sm font-bold text-slate-700 mb-4">{{ isEditing ? '编辑配置' : '添加新配置' }}</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
<div>
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">配置名称</label>
<input v-model="form.name"
class="w-full px-3 py-2 border rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none"
placeholder="例如: Google Gemini">
</div>
<div>
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">模型名称</label>
<input v-model="form.model"
class="w-full px-3 py-2 border rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none"
placeholder="gemini-2.5-flash">
</div>
<div class="md:col-span-2">
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">Base URL</label>
<input v-model="form.baseUrl"
class="w-full px-3 py-2 border rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none"
placeholder="https://generativelanguage.googleapis.com/v1beta/openai">
</div>
<div class="md:col-span-2">
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">API Key</label>
<input v-model="form.key" type="password"
class="w-full px-3 py-2 border rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none"
placeholder="sk-...">
</div>
<div class="md:col-span-2">
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">额外参数
(JSON格式,可选)</label>
<input v-model="form.params"
class="w-full px-3 py-2 border rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none"
placeholder='例如: {"temperature": 0.7, "max_tokens": 2000}'>
</div>
</div>
<div class="flex gap-2">
<button type="button" @click.prevent="saveConfig"
class="px-4 py-2 bg-blue-600 text-white rounded-lg text-xs font-bold hover:bg-blue-700 transition-all">保存配置</button>
<button type="button" v-if="isEditing" @click="resetForm"
class="px-4 py-2 bg-slate-200 text-slate-600 rounded-lg text-xs font-bold hover:bg-slate-300 transition-all">取消</button>
</div>
</div>
<!-- 配置列表 -->
<div class="grid gap-3">
<div v-for="conf in llmConfigs" :key="conf.id"
class="flex items-center justify-between p-4 bg-white border border-slate-200 rounded-xl hover:shadow-sm transition-shadow">
<div>
<div class="font-bold text-slate-800 text-sm">{{ conf.name }}</div>
<div class="text-xs text-slate-400 mt-1">{{ conf.model }} | {{ conf.baseUrl }}</div>
</div>
<div class="flex gap-2">
<button @click="editConfig(conf)"
class="text-xs text-blue-600 hover:underline font-medium">编辑</button>
<button @click="deleteConfig(conf.id)"
class="text-xs text-red-500 hover:underline font-medium">删除</button>
</div>
</div>
<div v-if="llmConfigs.length === 0" class="text-center py-8 text-slate-400 text-sm">
暂无配置,请在上方添加
</div>
</div>
<h2 class="text-lg font-bold text-slate-800 border-b pb-2 pt-6">TTS 语音合成配置</h2>
<!-- 添加/编辑表单 -->
<div class="bg-slate-50 p-5 rounded-xl border border-slate-200">
<h3 class="text-sm font-bold text-slate-700 mb-4">{{ isEditingTts ? '编辑 TTS 配置' : '添加新 TTS 配置' }}</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
<div>
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">配置名称</label>
<input v-model="ttsForm.name"
class="w-full px-3 py-2 border rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none"
placeholder="例如: IndexTTS 2">
</div>
<div>
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">Base URL</label>
<input v-model="ttsForm.baseUrl"
class="w-full px-3 py-2 border rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none"
placeholder="http://127.0.0.1:8300">
</div>
</div>
<div class="flex gap-2">
<button type="button" @click.prevent="saveTtsConfig"
class="px-4 py-2 bg-blue-600 text-white rounded-lg text-xs font-bold hover:bg-blue-700 transition-all">保存配置</button>
<button type="button" v-if="isEditingTts" @click="resetTtsForm"
class="px-4 py-2 bg-slate-200 text-slate-600 rounded-lg text-xs font-bold hover:bg-slate-300 transition-all">取消</button>
</div>
</div>
<!-- 配置列表 -->
<div class="grid gap-3">
<div v-for="conf in ttsConfigs" :key="conf.id"
class="flex items-center justify-between p-4 bg-white border border-slate-200 rounded-xl hover:shadow-sm transition-shadow">
<div>
<div class="font-bold text-slate-800 text-sm">{{ conf.name }}</div>
<div class="text-xs text-slate-400 mt-1">{{ conf.baseUrl }}</div>
</div>
<div class="flex gap-2">
<button @click="editTtsConfig(conf)"
class="text-xs text-blue-600 hover:underline font-medium">编辑</button>
<button @click="deleteTtsConfig(conf.id)"
class="text-xs text-red-500 hover:underline font-medium">删除</button>
</div>
</div>
<div v-if="ttsConfigs.length === 0" class="text-center py-8 text-slate-400 text-sm">
暂无 TTS 配置,请在上方添加
</div>
</div>
</div>
<!-- 页面 4: 音色资源库 -->
<div v-if="activeTab === 'timbres'" class="space-y-8">
<!-- 音色管理区域 -->
<section class="space-y-6">
<h2 class="text-lg font-bold text-slate-800 border-b pb-2">音色管理</h2>
<!-- 添加/编辑表单 -->
<div class="bg-slate-50 p-5 rounded-xl border border-slate-200">
<h3 class="text-sm font-bold text-slate-700 mb-4">{{ isEditingTimbre ? '编辑音色' : '添加新音色' }}</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
<div>
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">音色名称</label>
<input v-model="timbreForm.name"
class="w-full px-3 py-2 border rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none"
placeholder="例如: 旁白 / 少年音">
</div>
<div>
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">音色描述 (用于 AI
自动匹配)</label>
<input v-model="timbreForm.description"
class="w-full px-3 py-2 border rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none"
placeholder="例如: 声音低沉,适合反派或中年男性">
</div>
<div class="md:col-span-2">
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">参考音频文件</label>
<div class="flex gap-2 items-center">
<input type="file" ref="timbreFileRef" @change="handleTimbreFileUpload"
accept=".wav,.mp3" class="hidden">
<button type="button" @click="$refs.timbreFileRef.click()"
class="whitespace-nowrap px-3 py-2 bg-slate-100 border border-slate-300 text-slate-600 rounded-lg text-xs hover:bg-slate-200 transition-colors">选择文件</button>
<input v-model="timbreForm.refPath"
class="w-full px-3 py-2 border rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none"
placeholder="选择一个音频文件作为音色参考">
</div>
<p class="text-[10px] text-slate-400 mt-1">提示:选择的音频文件将保存在本地,生成音频时会自动上传。</p>
</div>
</div>
<div class="flex gap-2">
<button type="button" @click.prevent="saveTimbre"
class="px-4 py-2 bg-blue-600 text-white rounded-lg text-xs font-bold hover:bg-blue-700 transition-all">保存音色</button>
<button type="button" v-if="isEditingTimbre" @click="resetTimbreForm"
class="px-4 py-2 bg-slate-200 text-slate-600 rounded-lg text-xs font-bold hover:bg-slate-300 transition-all">取消</button>
</div>
</div>
<!-- 音色列表 -->
<div class="grid gap-3">
<div v-for="timbre in timbres" :key="timbre.id"
class="flex items-center justify-between p-4 bg-white border border-slate-200 rounded-xl hover:shadow-sm transition-shadow">
<div class="flex items-center gap-3">
<div
class="w-10 h-10 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center font-bold text-lg">
{{ timbre.name.charAt(0) }}
</div>
<div>
<div class="font-bold text-slate-800 text-sm">{{ timbre.name }}</div>
<div v-if="timbre.description" class="text-xs text-slate-500 mt-0.5">{{
timbre.description }}</div>
<div class="text-xs text-slate-400 mt-1">{{ timbre.refPath }}</div>
</div>
</div>
<div class="flex gap-2">
<button @click="playPreview(timbre.refPath)"
class="text-xs text-slate-400 hover:text-green-600 mr-1" title="试听">
<svg v-if="previewPlayingFile === timbre.refPath" class="h-4 w-4 text-green-600"
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd"
d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zM7 8a1 1 0 012 0v4a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v4a1 1 0 102 0V8a1 1 0 00-1-1z"
clip-rule="evenodd" />
</svg>
<svg v-else class="h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"
fill="currentColor">
<path fill-rule="evenodd"
d="M10 18a8 8 0 100-16 8 8 0 000 16zM9.555 7.168A1 1 0 008 8v4a1 1 0 001.555.832l3-2a1 1 0 000-1.664l-3-2z"
clip-rule="evenodd" />
</svg>
</button>
<button @click="editTimbre(timbre)"
class="text-xs text-blue-600 hover:underline font-medium">编辑</button>
<button @click="deleteTimbre(timbre.id)"
class="text-xs text-red-500 hover:underline font-medium">删除</button>
</div>
</div>
<div v-if="timbres.length === 0" class="text-center py-8 text-slate-400 text-sm">
暂无音色,请在上方添加
</div>
</div>
</section>
<!-- 情绪向量预设区域 -->
<section class="space-y-6">
<h2 class="text-lg font-bold text-slate-800 border-b pb-2">情绪描述预设</h2>
<!-- 添加/编辑情绪表单 -->
<div class="bg-slate-50 p-5 rounded-xl border border-slate-200">
<h3 class="text-sm font-bold text-slate-700 mb-4">{{ isEditingEmotion ? '编辑情绪预设' : '添加新情绪预设' }}</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
<div>
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">情绪名称</label>
<input v-model="emotionForm.name"
class="w-full px-3 py-2 border rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none"
placeholder="例如: 开心 / 愤怒">
</div>
<div class="md:col-span-2">
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-2">8维情感向量 (对应: 高兴, 生气,
伤心, 害怕, 厌恶, 低落, 惊喜, 平静) <span
class="text-slate-400 font-normal ml-2 normal-case">提示:所有值必须在 0.0 到 1.0
之间</span></label>
<div class="grid grid-cols-4 md:grid-cols-8 gap-2">
<div v-for="(val, idx) in 8" :key="idx" class="flex flex-col items-center">
<span class="text-[8px] text-slate-400 mb-1">{{
['高兴','生气','伤心','害怕','厌恶','低落','惊喜','平静'][idx] }}</span>
<input type="number" step="0.1" min="0" max="1"
v-model.number="emotionForm.vector[idx]"
class="w-full px-1 py-1 border rounded text-xs text-center focus:ring-1 focus:ring-blue-500"
placeholder="0">
</div>
</div>
</div>
</div>
<div class="flex gap-2">
<button type="button" @click.prevent="saveEmotion"
class="px-4 py-2 bg-green-600 text-white rounded-lg text-xs font-bold hover:bg-green-700 transition-all">保存情绪</button>
<button type="button" v-if="isEditingEmotion" @click="resetEmotionForm"
class="px-4 py-2 bg-slate-200 text-slate-600 rounded-lg text-xs font-bold hover:bg-slate-300 transition-all">取消</button>
</div>
</div>
<!-- 情绪列表 -->
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3">
<div v-for="emo in emotionPresets.filter(e => !isSystemEmotion(e.name))" :key="emo.id"
class="p-3 bg-white border border-slate-200 rounded-xl hover:shadow-sm transition-shadow flex justify-between items-center">
<div class="flex items-center gap-3">
<input type="checkbox" v-model="emo.enabled"
class="w-4 h-4 text-blue-600 rounded focus:ring-blue-500 cursor-pointer"
title="启用/禁用此情绪">
<div>
<div class="font-bold text-slate-800 text-sm">{{ emo.name }}</div>
<div class="text-[8px] text-slate-400 mt-1 font-mono tracking-tighter"
v-if="emo.vector">[{{ emo.vector.join(',') }}]</div>
</div>
</div>
<div class="flex gap-2">
<button @click="editEmotion(emo)" class="text-xs text-blue-600 hover:underline">编辑</button>
<button @click="deleteEmotion(emo.id)"
class="text-xs text-red-500 hover:underline">删除</button>
</div>
</div>
</div>
</section>
</div>
<!-- 页面 6: 音效素材库 -->
<div v-if="activeTab === 'sfx'" class="space-y-8">
<section class="space-y-6">
<h2 class="text-lg font-bold text-slate-800 border-b pb-2">音效素材管理</h2>
<p>音效和背景音乐可以自行使用其他的AI模型生成,或者前往在线免费音效网站下载:<a style="color: blue;" href="https://pixabay.com/zh/sound-effects">Pixabay在线音效库</a></p>
<div class="bg-slate-50 p-5 rounded-xl border border-slate-200">
<h3 class="text-sm font-bold text-slate-700 mb-4">{{ isEditingSfx ? '编辑音效' : '添加新音效' }}</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
<div>
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">音效名称</label>
<input v-model="sfxForm.name"
class="w-full px-3 py-2 border rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none"
placeholder="例如: 开门声 / 雷声">
</div>
<div>
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">音效描述 (用于 AI
判断插入)</label>
<input v-model="sfxForm.description"
class="w-full px-3 py-2 border rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none"
placeholder="例如: 沉重的木门被用力关上">
</div>
<div class="md:col-span-2">
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">音频文件名 / 路径</label>
<div class="flex gap-2 items-center">
<input type="file" ref="sfxFileRef" @change="handleSfxFileUpload" accept=".wav,.mp3"
class="hidden">
<button type="button" @click="$refs.sfxFileRef.click()"
class="whitespace-nowrap px-3 py-2 bg-slate-100 border border-slate-300 text-slate-600 rounded-lg text-xs hover:bg-slate-200 transition-colors">选择文件</button>
<input v-model="sfxForm.filename"
class="w-full px-3 py-2 border rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none"
placeholder="例如: door_slam.wav">
</div>
<p class="text-[10px] text-slate-400 mt-1"></p>
</div>
<div class="md:col-span-2 border-t border-slate-200 pt-4 mt-2">
<div class="flex items-center gap-4 mb-4">
<span class="text-[10px] font-bold text-slate-500 uppercase w-16">默认音量</span>
<input type="range" v-model.number="sfxForm.volume" min="0" max="2" step="0.05" class="flex-1 h-1.5 bg-slate-200 rounded-lg appearance-none cursor-pointer accent-blue-600">
<span class="text-xs text-slate-500 font-mono w-10 text-right">{{ Math.round((sfxForm.volume ?? 1) * 100) }}%</span>
<button type="button" @click="playPreview(sfxForm)" :disabled="!sfxForm.filename" class="text-xs text-slate-400 hover:text-green-600 ml-2 disabled:opacity-30 disabled:cursor-not-allowed" title="试听">
<svg v-if="previewPlayingFile === sfxForm.filename" class="h-5 w-5 text-green-600" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zM7 8a1 1 0 012 0v4a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v4a1 1 0 102 0V8a1 1 0 00-1-1z" clip-rule="evenodd" />
</svg>
<svg v-else class="h-5 w-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM9.555 7.168A1 1 0 008 8v4a1 1 0 001.555.832l3-2a1 1 0 000-1.664l-3-2z" clip-rule="evenodd" />
</svg>
</button>
</div>
<div v-if="sfxForm.filename">
<div class="flex justify-between items-center px-0.5 mb-1">
<span class="text-[10px] font-bold text-slate-500 uppercase">音频剪辑 (预览)</span>
<span class="text-[10px] text-slate-400 font-mono">{{ Math.round(((sfxForm.trimEnd ?? 1) - (sfxForm.trimStart ?? 0)) * 100) }}%</span>
</div>
<div :key="sfxForm.filename" class="relative w-full bg-slate-100 rounded border border-slate-200 overflow-hidden select-none group/wave" style="height: 40px;">
<canvas :ref="(el) => drawWaveform(el, sfxForm)" width="300" height="40" class="w-full h-full block opacity-60"></canvas>
<div class="absolute inset-0 pointer-events-none">
<div class="absolute top-0 bottom-0 left-0 bg-slate-500/30 border-r border-blue-500" :style="{ width: (sfxForm.trimStart ?? 0) * 100 + '%' }"></div>
<div class="absolute top-0 bottom-0 right-0 bg-slate-500/30 border-l border-red-500" :style="{ width: (1 - (sfxForm.trimEnd ?? 1)) * 100 + '%' }"></div>
<div class="absolute top-0 bottom-0 w-4 -ml-2 cursor-ew-resize pointer-events-auto hover:bg-blue-500/10 transition-colors flex justify-center group/handle" :style="{ left: (sfxForm.trimStart ?? 0) * 100 + '%' }" @mousedown.stop="startDragTrim($event, sfxForm, 'start')">
<div class="w-0.5 h-full bg-blue-500 group-hover/handle:w-1 transition-all"></div>
</div>
<div class="absolute top-0 bottom-0 w-4 -ml-2 cursor-ew-resize pointer-events-auto hover:bg-red-500/10 transition-colors flex justify-center group/handle" :style="{ left: (sfxForm.trimEnd ?? 1) * 100 + '%' }" @mousedown.stop="startDragTrim($event, sfxForm, 'end')">
<div class="w-0.5 h-full bg-red-500 group-hover/handle:w-1 transition-all"></div>
</div>
<div v-if="previewPlayingFile === sfxForm.filename" class="absolute top-0 bottom-0 w-0.5 bg-green-500 z-20 pointer-events-none shadow-[0_0_4px_rgba(34,197,94,0.8)]" :style="{ left: (playbackProgress * 100) + '%' }"></div>
</div>
</div>
<div class="text-[10px] text-slate-400 mt-1 text-right">提示:拖动红蓝线条裁剪音频,点击保存后生效</div>
</div>
</div>
</div>
<div class="flex gap-2">
<button type="button" @click.prevent="saveSfx"
class="px-4 py-2 bg-blue-600 text-white rounded-lg text-xs font-bold hover:bg-blue-700 transition-all">保存音效</button>
<button type="button" v-if="isEditingSfx" @click="resetSfxForm"
class="px-4 py-2 bg-slate-200 text-slate-600 rounded-lg text-xs font-bold hover:bg-slate-300 transition-all">取消</button>
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-3 max-h-[600px] overflow-y-auto pr-1">
<div v-for="sfx in sfxLibrary" :key="sfx.id" class="bg-white border border-slate-200 rounded-xl hover:shadow-sm transition-shadow flex flex-col">
<div class="flex items-start justify-between p-4">
<div class="flex items-start gap-3">
<input type="checkbox" v-model="sfx.enabled" class="w-4 h-4 text-blue-600 rounded focus:ring-blue-500 cursor-pointer mt-1 flex-shrink-0" title="启用/禁用此资源">
<div>
<div class="font-bold text-slate-800 text-sm">{{ sfx.name }}</div>
<div class="text-xs text-slate-500 mt-0.5">{{ sfx.description }}</div>
<div class="text-xs text-slate-400 mt-1">{{ sfx.filename }}</div>
</div>
</div>
<div class="flex gap-2 flex-shrink-0 ml-2">
<button @click="playPreview(sfx)" class="text-xs text-slate-400 hover:text-green-600 mr-1" title="试听">
<svg v-if="previewPlayingFile === sfx.filename" class="h-4 w-4 text-green-600" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zM7 8a1 1 0 012 0v4a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v4a1 1 0 102 0V8a1 1 0 00-1-1z" clip-rule="evenodd" />
</svg>
<svg v-else class="h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM9.555 7.168A1 1 0 008 8v4a1 1 0 001.555.832l3-2a1 1 0 000-1.664l-3-2z" clip-rule="evenodd" />
</svg>
</button>
<button @click="editSfx(sfx)" class="text-xs text-blue-600 hover:underline font-medium">编辑</button>
<button @click="deleteSfx(sfx.id)" class="text-xs text-red-500 hover:underline font-medium">删除</button>
</div>
</div>
</div>
<div v-if="sfxLibrary.length === 0" class="col-span-full text-center py-8 text-slate-400 text-sm">暂无音效素材</div>
</div>
</section>
<section class="space-y-6 border-t border-slate-200 pt-6">
<h2 class="text-lg font-bold text-slate-800 border-b pb-2">背景音乐管理 (BGM)</h2>
<div class="bg-slate-50 p-5 rounded-xl border border-slate-200">
<h3 class="text-sm font-bold text-slate-700 mb-4">{{ isEditingBgm ? '编辑 BGM' : '添加新 BGM' }}</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
<div>
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">BGM 名称</label>
<input v-model="bgmForm.name"
class="w-full px-3 py-2 border rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none"
placeholder="例如: 悲伤钢琴 / 战斗激昂">
</div>
<div>
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">BGM 描述 (用于 AI
判断)</label>
<input v-model="bgmForm.description"
class="w-full px-3 py-2 border rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none"
placeholder="例如: 适合悲伤场景的钢琴曲">
</div>
<div class="md:col-span-2">
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">音频文件名 / 路径</label>
<div class="flex gap-2 items-center">
<input type="file" ref="bgmFileRef" @change="handleBgmFileUpload" accept=".wav,.mp3"
class="hidden">
<button type="button" @click="$refs.bgmFileRef.click()"
class="whitespace-nowrap px-3 py-2 bg-slate-100 border border-slate-300 text-slate-600 rounded-lg text-xs hover:bg-slate-200 transition-colors">选择文件</button>
<input v-model="bgmForm.filename"
class="w-full px-3 py-2 border rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none"
placeholder="例如: sad_piano.mp3">
</div>
<p class="text-[10px] text-slate-400 mt-1"></p>
</div>
<div class="md:col-span-2 border-t border-slate-200 pt-4 mt-2">
<div class="flex items-center gap-4 mb-4">
<span class="text-[10px] font-bold text-slate-500 uppercase w-16">默认音量</span>
<input type="range" v-model.number="bgmForm.volume" min="0" max="2" step="0.05" class="flex-1 h-1.5 bg-slate-200 rounded-lg appearance-none cursor-pointer accent-blue-600">
<span class="text-xs text-slate-500 font-mono w-10 text-right">{{ Math.round((bgmForm.volume ?? 1) * 100) }}%</span>
<button type="button" @click="playPreview(bgmForm)" :disabled="!bgmForm.filename" class="text-xs text-slate-400 hover:text-green-600 ml-2 disabled:opacity-30 disabled:cursor-not-allowed" title="试听">
<svg v-if="previewPlayingFile === bgmForm.filename" class="h-5 w-5 text-green-600" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zM7 8a1 1 0 012 0v4a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v4a1 1 0 102 0V8a1 1 0 00-1-1z" clip-rule="evenodd" />
</svg>
<svg v-else class="h-5 w-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM9.555 7.168A1 1 0 008 8v4a1 1 0 001.555.832l3-2a1 1 0 000-1.664l-3-2z" clip-rule="evenodd" />
</svg>
</button>
</div>
<div v-if="bgmForm.filename">
<div class="flex justify-between items-center px-0.5 mb-1">
<span class="text-[10px] font-bold text-slate-500 uppercase">音频剪辑 (预览)</span>
<span class="text-[10px] text-slate-400 font-mono">{{ Math.round(((bgmForm.trimEnd ?? 1) - (bgmForm.trimStart ?? 0)) * 100) }}%</span>
</div>
<div :key="bgmForm.filename" class="relative w-full bg-slate-100 rounded border border-slate-200 overflow-hidden select-none group/wave" style="height: 40px;">
<canvas :ref="(el) => drawWaveform(el, bgmForm)" width="300" height="40" class="w-full h-full block opacity-60"></canvas>
<div class="absolute inset-0 pointer-events-none">
<div class="absolute top-0 bottom-0 left-0 bg-slate-500/30 border-r border-blue-500" :style="{ width: (bgmForm.trimStart ?? 0) * 100 + '%' }"></div>
<div class="absolute top-0 bottom-0 right-0 bg-slate-500/30 border-l border-red-500" :style="{ width: (1 - (bgmForm.trimEnd ?? 1)) * 100 + '%' }"></div>
<div class="absolute top-0 bottom-0 w-4 -ml-2 cursor-ew-resize pointer-events-auto hover:bg-blue-500/10 transition-colors flex justify-center group/handle" :style="{ left: (bgmForm.trimStart ?? 0) * 100 + '%' }" @mousedown.stop="startDragTrim($event, bgmForm, 'start')">
<div class="w-0.5 h-full bg-blue-500 group-hover/handle:w-1 transition-all"></div>
</div>
<div class="absolute top-0 bottom-0 w-4 -ml-2 cursor-ew-resize pointer-events-auto hover:bg-red-500/10 transition-colors flex justify-center group/handle" :style="{ left: (bgmForm.trimEnd ?? 1) * 100 + '%' }" @mousedown.stop="startDragTrim($event, bgmForm, 'end')">
<div class="w-0.5 h-full bg-red-500 group-hover/handle:w-1 transition-all"></div>
</div>
<div v-if="previewPlayingFile === bgmForm.filename" class="absolute top-0 bottom-0 w-0.5 bg-green-500 z-20 pointer-events-none shadow-[0_0_4px_rgba(34,197,94,0.8)]" :style="{ left: (playbackProgress * 100) + '%' }"></div>
</div>
</div>
<div class="text-[10px] text-slate-400 mt-1 text-right">提示:拖动红蓝线条裁剪音频,点击保存后生效</div>
</div>
</div>
</div>
<div class="flex gap-2">
<button type="button" @click.prevent="saveBgm"
class="px-4 py-2 bg-blue-600 text-white rounded-lg text-xs font-bold hover:bg-blue-700 transition-all">保存
BGM</button>
<button type="button" v-if="isEditingBgm" @click="resetBgmForm"
class="px-4 py-2 bg-slate-200 text-slate-600 rounded-lg text-xs font-bold hover:bg-slate-300 transition-all">取消</button>
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-3 max-h-[600px] overflow-y-auto pr-1">
<div v-for="bgm in bgmLibrary" :key="bgm.id" class="bg-white border border-slate-200 rounded-xl hover:shadow-sm transition-shadow flex flex-col">
<div class="flex items-start justify-between p-4">
<div class="flex items-start gap-3">
<input type="checkbox" v-model="bgm.enabled" class="w-4 h-4 text-blue-600 rounded focus:ring-blue-500 cursor-pointer mt-1 flex-shrink-0" title="启用/禁用此资源">
<div>
<div class="font-bold text-slate-800 text-sm">{{ bgm.name }}</div>
<div class="text-xs text-slate-500 mt-0.5">{{ bgm.description }}</div>
<div class="text-xs text-slate-400 mt-1">{{ bgm.filename }}</div>
</div>
</div>
<div class="flex gap-2 flex-shrink-0 ml-2">
<button @click="playPreview(bgm)" class="text-xs text-slate-400 hover:text-green-600 mr-1" title="试听">
<svg v-if="previewPlayingFile === bgm.filename" class="h-4 w-4 text-green-600" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zM7 8a1 1 0 012 0v4a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v4a1 1 0 102 0V8a1 1 0 00-1-1z" clip-rule="evenodd" />
</svg>
<svg v-else class="h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM9.555 7.168A1 1 0 008 8v4a1 1 0 001.555.832l3-2a1 1 0 000-1.664l-3-2z" clip-rule="evenodd" />
</svg>
</button>
<button @click="editBgm(bgm)" class="text-xs text-blue-600 hover:underline font-medium">编辑</button>
<button @click="deleteBgm(bgm.id)" class="text-xs text-red-500 hover:underline font-medium">删除</button>
</div>
</div>
</div>
<div v-if="bgmLibrary.length === 0" class="col-span-full text-center py-8 text-slate-400 text-sm">暂无 BGM 素材</div>
</div>
</section>
<section class="space-y-6 border-t border-slate-200 pt-6">
<h2 class="text-lg font-bold text-slate-800 border-b pb-2">音频滤波器管理</h2>
<div class="bg-slate-50 p-5 rounded-xl border border-slate-200">
<h3 class="text-sm font-bold text-slate-700 mb-4">{{ isEditingFilter ? '编辑滤波器' : '添加新滤波器' }}</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
<div>
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">滤波器名称</label>
<input v-model="filterForm.name"
class="w-full px-3 py-2 border rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none"
placeholder="例如: 电话音 / 水下">
</div>
<div>
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">滤波器描述 (用于 AI
判断)</label>
<input v-model="filterForm.description"
class="w-full px-3 py-2 border rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none"
placeholder="例如: 声音通过电话传输,频段变窄">
</div>
<div>
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">滤波器类型</label>
<select v-model="filterForm.type"
class="w-full px-3 py-2 border rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none bg-white">
<option value="lowpass">低通 (Lowpass) - 适合水下/闷声</option>
<option value="highpass">高通 (Highpass) - 适合收音机/尖锐</option>
<option value="bandpass">带通 (Bandpass) - 适合电话/对讲机</option>
<option value="distortion">失真 (Distortion) - 适合机器人/损坏设备</option>
</select>
</div>
<div v-if="filterForm.type !== 'distortion'">
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">频率 (Hz): {{
filterForm.frequency }}</label>
<input type="range" v-model.number="filterForm.frequency" min="20" max="20000" step="10"
class="w-full h-2 bg-slate-200 rounded-lg appearance-none cursor-pointer accent-blue-600">
</div>
<div v-if="filterForm.type !== 'distortion'">
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">Q 值 (共振峰): {{
filterForm.Q }}</label>
<input type="range" v-model.number="filterForm.Q" min="0.1" max="20" step="0.1"
class="w-full h-2 bg-slate-200 rounded-lg appearance-none cursor-pointer accent-blue-600">
</div>
<div v-if="filterForm.type === 'distortion'">
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">失真度 (Amount): {{
filterForm.gain }}</label>
<input type="range" v-model.number="filterForm.gain" min="0" max="1000" step="10"
class="w-full h-2 bg-slate-200 rounded-lg appearance-none cursor-pointer accent-red-600">
</div>
</div>
<div class="flex gap-2">
<button type="button" @click.prevent="saveFilter"
class="px-4 py-2 bg-blue-600 text-white rounded-lg text-xs font-bold hover:bg-blue-700 transition-all">保存滤波器</button>
<button type="button" v-if="isEditingFilter" @click="resetFilterForm"
class="px-4 py-2 bg-slate-200 text-slate-600 rounded-lg text-xs font-bold hover:bg-slate-300 transition-all">取消</button>
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3">
<div v-for="filter in filterLibrary" :key="filter.id"
class="p-4 bg-white border border-slate-200 rounded-xl hover:shadow-sm transition-shadow flex justify-between items-center">
<div class="flex items-center gap-3">
<input type="checkbox" v-model="filter.enabled"
class="w-4 h-4 text-blue-600 rounded focus:ring-blue-500 cursor-pointer"
title="启用/禁用此资源">
<div>
<div class="font-bold text-slate-800 text-sm">{{ filter.name }}</div>
<div class="text-xs text-slate-500 mt-0.5">{{ filter.description }}</div>
<div class="text-[10px] text-slate-400 mt-1 font-mono">{{ filter.type }} | {{
filter.type === 'distortion' ? `Amt:${filter.gain}` : `Freq:${filter.frequency}Hz`
}}</div>
</div>
</div>
<div class="flex gap-2">
<button @click="editFilter(filter)"
class="text-xs text-blue-600 hover:underline font-medium">编辑</button>
<button @click="deleteFilter(filter.id)"
class="text-xs text-red-500 hover:underline font-medium">删除</button>
</div>
</div>
<div v-if="filterLibrary.length === 0"
class="col-span-full text-center py-8 text-slate-400 text-sm">暂无滤波器,请添加</div>
</div>
</section>
</div>
<!-- 页面 5: 脚本制作 (重构:左右分栏) -->
<div v-if="activeTab === 'script'">
<!-- 脚本多标签页管理 -->
<div class="flex items-center gap-2 overflow-x-auto pb-2 mb-6">
<div v-for="script in scriptList" :key="script.id"
@click="switchScript(script.id)"
@dblclick="startEditingScript(script.id)"
:class="['flex items-center gap-2 px-3 py-2 rounded-lg cursor-pointer text-xs font-bold transition-colors min-w-[100px] flex-shrink-0 justify-between group', currentScriptId === script.id ? 'bg-white border border-slate-200 text-blue-600' : 'bg-slate-100 border-transparent text-slate-500 hover:bg-slate-200']">
<span v-if="editingScriptId !== script.id" class="whitespace-nowrap">{{ script.name }}</span>
<input v-else v-model="script.name" @click.stop @blur="stopEditingScript" @keyup.enter="stopEditingScript" :ref="el => { if(el) scriptNameInputRefs[script.id] = el }" class="bg-transparent outline-none w-full" />
<button @click.stop="deleteScriptTab(script.id)" class="opacity-0 group-hover:opacity-100 text-slate-400 hover:text-red-500">×</button>
</div>
<button @click="addScript" class="px-3 py-2 rounded-lg bg-slate-100 hover:bg-slate-200 text-slate-500 font-bold text-xs">+</button>
</div>
<div class="flex flex-col lg:flex-row gap-6 items-start">
<!-- 左侧:角色与音色绑定栏 -->
<div class="w-full lg:w-60 flex-shrink-0 space-y-4">
<div class="bg-slate-100 p-4 rounded-xl border border-slate-200">
<h3 class="text-sm font-bold text-slate-700 mb-3 flex justify-between items-center">
角色列表
<button @click="addCharacter"
class="text-xs bg-blue-600 text-white px-2 py-1 rounded hover:bg-blue-700">+ 新增</button>
</h3>
<div class="space-y-3 pr-1">
<div v-for="char in characters" :key="char.id"
class="bg-white p-3 rounded-lg border border-slate-200 shadow-sm text-sm space-y-2">
<div class="flex justify-between items-center">
<input v-model="char.name"
class="font-bold text-slate-800 w-2/3 bg-transparent border-b border-transparent focus:border-blue-500 outline-none px-1"
placeholder="角色名">
<button @click="deleteCharacter(char.id)"
class="text-slate-400 hover:text-red-500">×</button>
</div>
<div>
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">音色选择</label>
<div class="flex gap-1">
<select v-model="char.voiceFile"
class="flex-1 px-2 py-1.5 border rounded-md text-xs bg-white outline-none focus:ring-1 focus:ring-blue-500">
<option value="">-- 请选择音色 --</option>
<option v-for="timbre in timbres" :key="timbre.id" :value="timbre.refPath">
{{ timbre.name }}
</option>
</select>
<button @click="playPreview(char.voiceFile)" :disabled="!char.voiceFile"
class="px-2 bg-slate-100 border border-slate-200 rounded text-slate-500 hover:text-green-600 disabled:opacity-50"
title="试听当前音色">
<svg v-if="previewPlayingFile === char.voiceFile" class="h-4 w-4 text-green-600"
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd"
d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zM7 8a1 1 0 012 0v4a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v4a1 1 0 102 0V8a1 1 0 00-1-1z"
clip-rule="evenodd" />
</svg>
<svg v-else class="h-4 w-4" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd"
d="M10 18a8 8 0 100-16 8 8 0 000 16zM9.555 7.168A1 1 0 008 8v4a1 1 0 001.555.832l3-2a1 1 0 000-1.664l-3-2z"
clip-rule="evenodd" />
</svg>
</button>
</div>
</div>
<div class="mt-2 pt-2 border-t border-slate-100">
<div class="flex justify-between items-center mb-1">
<span class="text-[10px] font-bold text-slate-500 uppercase">角色音量</span>
<span class="text-[10px] text-slate-500 font-mono">{{ Math.round((char.volume ?? 1) * 100) }}%</span>
</div>
<input type="range" v-model.number="char.volume" min="0" max="2" step="0.05" class="w-full h-1.5 bg-slate-200 rounded-lg appearance-none cursor-pointer accent-blue-600 block">
</div>
<div class="mt-2 pt-2 border-t border-slate-100 space-y-2">
<textarea v-model="char.voiceDescription" rows="2"
class="w-full px-2 py-1.5 text-[10px] border rounded bg-slate-50 focus:ring-1 focus:ring-blue-500 outline-none resize-none text-slate-600"
placeholder="音色描述 (例如: 甜美少女音)"></textarea>
<div class="flex gap-1">
<button @click="analyzeCharacterVoice(char)"
:class="['flex-1 px-2 py-1.5 border rounded text-[10px] font-bold transition-colors flex justify-center items-center gap-1', char.isAnalyzing ? 'bg-red-50 text-red-600 border-red-100 hover:bg-red-100' : 'bg-indigo-50 text-indigo-600 border-indigo-100 hover:bg-indigo-100']">
<span v-if="char.isAnalyzing" class="animate-spin">⏳</span>{{ char.isAnalyzing ? '停止分析' : 'AI分析音色' }}
</button>
<button @click="generateQwenVoice(char)"
:class="['flex-1 px-2 py-1.5 border rounded text-[10px] font-bold transition-colors flex justify-center items-center gap-1', char.isGeneratingVoice ? 'bg-red-50 text-red-600 border-red-100 hover:bg-red-100' : 'bg-pink-50 text-pink-600 border-pink-100 hover:bg-pink-100']">
<span v-if="char.isGeneratingVoice" class="animate-spin">⏳</span>{{ char.isGeneratingVoice ? '停止生成' : 'Qwen生成音色' }}
</button>
</div>
</div>
</div>
<div v-if="characters.length === 0" class="text-center text-xs text-slate-400 py-4">暂无角色,请点击新增
</div>
</div>
</div>
</div>
<!-- 原文输入区域 -->
<div class="flex-1 w-full space-y-6 min-w-0">
<div class="bg-white p-5 rounded-xl border border-slate-200 shadow-sm">
<div class="flex justify-between items-center mb-4">
<h3 class="text-sm font-bold text-slate-700">1. 输入原文 / 小说片段</h3>
</div>
<textarea v-model="rawScript"
class="w-full p-4 border rounded-xl h-48 mb-4 focus:ring-2 focus:ring-blue-500 outline-none resize-none bg-slate-50 text-sm leading-relaxed"
placeholder="请粘贴小说内容或剧本原文..."></textarea>
<div class="grid grid-cols-1 md:grid-cols-3 gap-3">
<!-- AI 拆分/分析 -->
<div class="bg-white p-3 rounded-xl border border-slate-200 shadow-sm space-y-2">
<div class="font-bold text-xs text-slate-700">AI 深度分析</div>
<select v-model="currentConfigId"
class="px-3 py-2 border rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none bg-white w-full"
title="选择用于分析的 LLM 模型">
<option value="" disabled>-- 选择LLM模型 --</option>
<option v-for="conf in llmConfigs" :key="conf.id" :value="conf.id">
{{ conf.name }}
</option>
</select>
<button @click="analyzeScript"
:class="['w-full px-3 py-2 text-white rounded-lg text-sm font-bold transition-all flex items-center justify-center', isAnalyzingScript ? 'bg-red-500 hover:bg-red-600' : 'bg-indigo-600 hover:bg-indigo-700 disabled:opacity-50']">
<span v-if="isAnalyzingScript" class="animate-spin mr-2">⏳</span>
{{ isAnalyzingScript ? '停止分析' : 'AI 深度分析' }}
</button>
</div>
<!-- 插入控制块 -->
<div class="bg-white p-3 rounded-xl border border-slate-200 shadow-sm space-y-2">
<div class="font-bold text-xs text-slate-700">插入控制块</div>
<div class="flex flex-wrap gap-2">
<button @click="addDialogueBlock"
class="px-2 py-2 bg-blue-100 text-blue-600 rounded-lg text-sm font-bold hover:bg-blue-200 transition-all">
➕ 插入台词
</button>
<button @click="addBgmBlock"
class="px-2 py-2 bg-purple-100 text-purple-600 rounded-lg text-sm font-bold hover:bg-purple-200 transition-all">
➕ 插入BGM
</button>
<button @click="addBgImageBlock"
class="px-2 py-2 bg-emerald-100 text-emerald-700 rounded-lg text-sm font-bold hover:bg-emerald-200 transition-all">
➕ 插入背景图片
</button>
</div>
<div class="flex flex-wrap items-center gap-2 px-2 py-2 bg-white border border-slate-200 rounded-lg">
<label class="text-[10px] font-bold text-slate-500 uppercase whitespace-nowrap">背景图片数量</label>
<input type="number" v-model.number="bgImageCount" min="0" max="100"
class="w-20 px-2 py-1 border rounded-lg text-xs focus:ring-2 focus:ring-emerald-500 outline-none bg-white"
title="LLM 将严格插入的 bgImage 块数量" />
<span class="text-[10px] text-slate-400 whitespace-nowrap">张</span>
<span class="text-[10px] text-slate-400 ml-2">(若需关闭,可从Prompt管理中删除背景图片块相关提示词)</span>
</div>
</div>
<!-- 配音/生成/播放 -->
<div class="bg-white p-3 rounded-xl border border-slate-200 shadow-sm space-y-2">
<div class="font-bold text-xs text-slate-700">配音与播放</div>
<select v-model="currentTtsConfigId"
class="px-3 py-2 border rounded-lg text-sm focus:ring-2 focus:ring-blue-500 outline-none bg-white w-full"
title="选择用于生成的 TTS 服务">
<option value="" disabled>-- 选择 TTS 模型 --</option>
<option v-for="conf in ttsConfigs" :key="conf.id" :value="conf.id">
{{ conf.name }}
</option>
</select>
<div class="flex flex-wrap gap-2">
<button @click="generateAllLines" :disabled="isSequencePlaying"
:class="['flex-1 px-2 py-2 text-white rounded-lg text-sm font-bold transition-all flex items-center justify-center', isGeneratingAll ? 'bg-red-500 hover:bg-red-600' : 'bg-green-600 hover:bg-green-700 disabled:opacity-50']">
<span v-if="isGeneratingAll" class="animate-spin mr-2">⏳</span>
{{ isGeneratingAll ? '停止生成' : (selectedLineIndex !== -1 ? '从选中行开始生成' : '一键生成配音(跳过已生成)') }}
</button>
<button @click="clearAllGeneratedAudio" :disabled="isSequencePlaying || isGeneratingAll"
class="px-2 py-2 bg-red-600 text-white rounded-lg text-sm font-bold hover:bg-red-700 disabled:opacity-50 transition-all flex items-center justify-center">
清空配音
</button>
</div>
<div class="flex flex-wrap gap-2">
<button v-if="!isSequencePlaying" @click="playScriptSequentially"
class="flex-1 px-2 py-2 bg-blue-600 text-white rounded-lg text-sm font-bold hover:bg-blue-700 disabled:opacity-50 transition-all">
{{ selectedLineIndex !== -1 ? '▶️ 从选中位置播放' : '▶️ 顺序播放' }}
</button>
<button v-else @click="stopScriptSequentially"
class="flex-1 px-2 py-2 bg-red-500 text-white rounded-lg text-sm font-bold hover:bg-red-600 transition-all">
停止播放
</button>
</div>
</div>
</div>
</div>
<!-- 拆分结果列表 -->
<div v-if="scriptLines.length > 0"
class="bg-white p-5 rounded-xl border border-slate-200 shadow-sm"
:style="stageBgUrl ? {
backgroundImage: `linear-gradient(to bottom, rgba(255,255,255,0.76), rgba(255,255,255,0.58)), url(${stageBgUrl})`,
backgroundRepeat: 'no-repeat, no-repeat',
backgroundPosition: 'center center, center center',
backgroundSize: '100% 100%, contain'
} : {}">
<div class="flex justify-between items-center mb-4">
<h3 class="text-sm font-bold text-slate-700">2. 脚本台词列表 ({{ scriptLines.length }} 行)</h3>
</div>
<div ref="scriptListContainer" class="space-y-3 max-h-[600px] overflow-y-auto px-2 pb-10">
<div v-for="(line, index) in scriptLines" :key="line.id" @click="toggleLineSelection(index, $event)"
:ref="el => { if (el) lineRefs[index] = el }"
class="transition-all duration-200">
<!-- BGM 控制块 -->
<div v-if="line.type === 'bgm'"
:class="['flex flex-wrap items-center gap-3 p-3 rounded-lg border mb-2 transition-all', selectedLineIndex === index ? 'border-purple-500 bg-purple-50 shadow-md' : 'bg-purple-50/50 border-purple-200', currentSequenceIndex === index ? 'ring-2 ring-green-500' : '']">
<div
class="flex flex-col items-center justify-center gap-1 w-8 flex-shrink-0 border-r border-purple-200 pr-2">
<button @click.stop="moveLineUp(index)"
class="text-purple-400 hover:text-purple-700 p-0.5 hover:bg-purple-100 rounded"
title="上移">▲</button>
<div class="text-xs font-bold text-purple-500 select-none">{{ index + 1 }}</div>
<button @click.stop="moveLineDown(index)"
class="text-purple-400 hover:text-purple-700 p-0.5 hover:bg-purple-100 rounded"
title="下移">▼</button>
</div>
<div
class="w-24 flex-shrink-0 font-bold text-xs text-purple-600 uppercase tracking-wider flex items-center justify-center border-r border-purple-200 pr-3">
BGM 控制
</div>
<select v-model="line.action"
class="w-24 px-2 py-1.5 text-xs border rounded bg-white focus:ring-1 focus:ring-purple-500 outline-none font-bold text-purple-700">
<option value="play">▶ 播放</option>
<option value="stop">停止</option>
</select>
<div class="flex-1 min-w-[220px] flex items-center gap-2">
<select v-if="line.action === 'play'" v-model="line.bgmName"
class="flex-1 px-2 py-1.5 text-xs border rounded bg-white focus:ring-1 focus:ring-purple-500 outline-none font-bold text-purple-700">
<option value="" disabled>-- 选择背景音乐 --</option>
<option v-for="s in bgmLibrary" :key="s.id" :value="s.name">{{ s.name }}</option>
</select>
<div v-else class="flex-1 text-xs text-slate-400 italic py-1.5 px-2">
停止当前播放的所有背景音乐
</div>
</div>
<div v-if="line.action === 'play'" class="w-28 flex-shrink-0 space-y-1">
<div class="text-[10px] font-bold text-slate-400 uppercase text-center leading-tight">
BGM音量
</div>
<input type="range" v-model="line.volume" min="0" max="2" step="0.05"
class="w-full h-2 bg-slate-200 rounded-lg appearance-none cursor-pointer accent-purple-600">
</div>
<button @click="removeScriptLine(index)"
class="text-slate-300 hover:text-red-500 p-2">
<svg class="h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd"
d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z"
clip-rule="evenodd" />
</svg>
</button>
</div>
<!-- 背景图片块 -->
<div v-else-if="line.type === 'bgImage'"
:class="['flex flex-col gap-2 p-3 rounded-lg mb-2 transition-all group cursor-pointer border', selectedLineIndex === index ? 'bg-emerald-50 border-emerald-300 shadow-md' : 'bg-emerald-50/50 border-emerald-200', currentSequenceIndex === index ? 'ring-2 ring-green-500' : '']">
<div class="flex flex-wrap items-start gap-3">
<div
class="flex flex-col items-center justify-center gap-1 w-8 flex-shrink-0 border-r border-emerald-200 pr-2">
<button @click.stop="moveLineUp(index)"
class="text-emerald-400 hover:text-emerald-700 p-0.5 hover:bg-emerald-100 rounded"
title="上移">▲</button>
<div class="text-xs font-bold text-emerald-500 select-none">{{ index + 1 }}</div>
<button @click.stop="moveLineDown(index)"
class="text-emerald-400 hover:text-emerald-700 p-0.5 hover:bg-emerald-100 rounded"
title="下移">▼</button>
</div>
<div class="flex-1 min-w-[260px]">
<div class="flex items-center justify-between gap-2 mb-2">
<div class="font-bold text-xs text-emerald-700 uppercase tracking-wider">
背景图片块
</div>
<button @click="removeScriptLine(index)"
class="text-slate-300 hover:text-red-500 p-2"
title="删除"><svg class="h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd"
d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z"
clip-rule="evenodd" />
</svg></button>
</div>
<div class="grid grid-cols-1 md:grid-cols-[160px_1fr] gap-3">
<!-- 图片展示 -->