-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathindex_en.html
More file actions
5948 lines (5169 loc) · 349 KB
/
Copy pathindex_en.html
File metadata and controls
5948 lines (5169 loc) · 349 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="en">
<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 Tool</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">
Close
</button>
<img :src="previewImageUrl" alt="Large background image preview" @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">Multi-character sound-effect audiobook generator</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']">
Model Settings
</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']">
Voice Library
</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']">
Sound Effects & Filters
</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']">
Script Studio
</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 Manager
</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 : 'Export Full Project' }}
</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 ? 'Please wait...' : 'Import Full Project' }}
</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">
Import 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">
Export SRT Subtitles
</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 || '⏳ Processing...') : 'Export Audio' }}
</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">Landscape 16:9</option>
<option value="1080x1920">Portrait 9:16</option>
<option value="1280x960">Landscape 4:3</option>
<option value="960x1280">Portrait 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 || '⏳ Generating video...') : 'Generate Video' }}
</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: Model Settings (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 Model Settings (OpenAI-Compatible API)</h2>
<!-- 添加/Edit表单 -->
<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 ? 'Edit Configuration' : 'Add New Configuration' }}</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">Configuration Name</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="Example: Google Gemini">
</div>
<div>
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">Model Name</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">Extra Parameters
(JSON format, optional)</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='Example: {"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">Save Configuration</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">Cancel</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">Edit</button>
<button @click="deleteConfig(conf.id)"
class="text-xs text-red-500 hover:underline font-medium">Delete</button>
</div>
</div>
<div v-if="llmConfigs.length === 0" class="text-center py-8 text-slate-400 text-sm">
No configurations yet. Add one above.
</div>
</div>
<h2 class="text-lg font-bold text-slate-800 border-b pb-2 pt-6">TTS Speech Synthesis Settings</h2>
<!-- 添加/Edit表单 -->
<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 ? 'Edit TTS Configuration' : 'Add New TTS Configuration' }}</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">Configuration Name</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="Example: 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">Save Configuration</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">Cancel</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">Edit</button>
<button @click="deleteTtsConfig(conf.id)"
class="text-xs text-red-500 hover:underline font-medium">Delete</button>
</div>
</div>
<div v-if="ttsConfigs.length === 0" class="text-center py-8 text-slate-400 text-sm">
No TTS configurations yet. Add one above.
</div>
</div>
</div>
<!-- 页面 4: Voice Library -->
<div v-if="activeTab === 'timbres'" class="space-y-8">
<!-- Voice Management区域 -->
<section class="space-y-6">
<h2 class="text-lg font-bold text-slate-800 border-b pb-2">Voice Management</h2>
<!-- 添加/Edit表单 -->
<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 ? 'Edit Voice' : 'Add New Voice' }}</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">Voice Name</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="Example: Narrator / Young male voice">
</div>
<div>
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">Voice Description (for AI
auto matching)</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="Example: Deep voice, suitable for a villain or middle-aged man">
</div>
<div class="md:col-span-2">
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">Reference Audio File</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">Choose File</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="Choose an audio file as the voice reference">
</div>
<p class="text-[10px] text-slate-400 mt-1">Tip: The selected audio file will be saved locally and uploaded automatically when audio is generated.</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">Save Voice</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">Cancel</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="Preview">
<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">Edit</button>
<button @click="deleteTimbre(timbre.id)"
class="text-xs text-red-500 hover:underline font-medium">Delete</button>
</div>
</div>
<div v-if="timbres.length === 0" class="text-center py-8 text-slate-400 text-sm">
No voices yet. Add one above.
</div>
</div>
</section>
<!-- 情绪向量预设区域 -->
<section class="space-y-6">
<h2 class="text-lg font-bold text-slate-800 border-b pb-2">Emotion Presets</h2>
<!-- 添加/Edit情绪表单 -->
<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 ? 'Edit Emotion Preset' : 'Add New Emotion Preset' }}</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">Emotion Name</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="Example: Happy / Angry">
</div>
<div class="md:col-span-2">
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-2">8-D emotion vector (order: Happy, Angry,
Sad, Fearful, Disgusted, Down, Surprised, Calm) <span
class="text-slate-400 font-normal ml-2 normal-case">Tip: All values must be between 0.0 and 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">{{
['Happy','Angry','Sad','Fearful','Disgusted','Down','Surprised','Calm'][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">Save Emotion</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">Cancel</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="Enable/disable this emotion">
<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">Edit</button>
<button @click="deleteEmotion(emo.id)"
class="text-xs text-red-500 hover:underline">Delete</button>
</div>
</div>
</div>
</section>
</div>
<!-- 页面 6: SFX素材库 -->
<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">Sound Effect Asset Management</h2>
<p>You can generate sound effects and background music with other AI models, or download them from free online sound-effect sites: <a style="color: blue;" href="https://pixabay.com/zh/sound-effects">Pixabay Sound Effects Library</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 ? 'EditSFX' : 'Add New Sound Effect' }}</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">Sound Effect Name</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="Example: Door opening / Thunder">
</div>
<div>
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">Sound Effect Description (for AI
placement decisions)</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="Example: A heavy wooden door slams shut">
</div>
<div class="md:col-span-2">
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">Audio Filename / Path</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">Choose File</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">Default Volume</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="Preview">
<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">Audio Trim (Preview)</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">Tip: Drag the red and blue lines to trim the audio. Changes apply after saving.</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">Save Sound Effect</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">Cancel</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="Enable/disable this asset">
<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="Preview">
<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">Edit</button>
<button @click="deleteSfx(sfx.id)" class="text-xs text-red-500 hover:underline font-medium">Delete</button>
</div>
</div>
</div>
<div v-if="sfxLibrary.length === 0" class="col-span-full text-center py-8 text-slate-400 text-sm">No sound-effect assets yet</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">Background Music Management (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 ? 'Edit BGM' : 'Add New 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 Name</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="Example: Sad piano / Intense battle">
</div>
<div>
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">BGM Description (for AI
decisions)</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="Example: Piano music suitable for sad scenes">
</div>
<div class="md:col-span-2">
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">Audio Filename / Path</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">Choose File</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">Default Volume</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="Preview">
<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">Audio Trim (Preview)</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">Tip: Drag the red and blue lines to trim the audio. Changes apply after saving.</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">Save 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">Cancel</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="Enable/disable this asset">
<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="Preview">
<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">Edit</button>
<button @click="deleteBgm(bgm.id)" class="text-xs text-red-500 hover:underline font-medium">Delete</button>
</div>
</div>
</div>
<div v-if="bgmLibrary.length === 0" class="col-span-full text-center py-8 text-slate-400 text-sm">No BGM assets yet</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">Audio Filter Management</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 ? 'Edit Filter' : 'Add New Filter' }}</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">Filter Name</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="Example: Telephone / Underwater">
</div>
<div>
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">Filter Description (for AI
decisions)</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="Example: Voice transmitted by phone with a narrowed frequency band">
</div>
<div>
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">Filter Type</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 - suitable for underwater/muffled sound</option>
<option value="highpass">Highpass - suitable for radio/sharp sound</option>
<option value="bandpass">Bandpass - suitable for telephone/walkie-talkie sound</option>
<option value="distortion">Distortion - suitable for robots/damaged devices</option>
</select>
</div>
<div v-if="filterForm.type !== 'distortion'">
<label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">Frequency (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 Value (Resonance): {{
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">Distortion 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">Save Filter</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">Cancel</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="Enable/disable this asset">
<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">Edit</button>
<button @click="deleteFilter(filter.id)"
class="text-xs text-red-500 hover:underline font-medium">Delete</button>
</div>
</div>
<div v-if="filterLibrary.length === 0"
class="col-span-full text-center py-8 text-slate-400 text-sm">No filters yet. Add one.</div>
</div>
</section>
</div>
<!-- 页面 5: Script Studio (重构:左右分栏) -->
<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">
Characters
<button @click="addCharacter"
class="text-xs bg-blue-600 text-white px-2 py-1 rounded hover:bg-blue-700">+ Add</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="Character name">
<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">Voice Selection</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="">-- Select a voice --</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="Preview current voice">
<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">Character Volume</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="Voice description (example: sweet young female voice)"></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 ? 'Stop Analysis' : 'Analyze Voice with 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 ? 'Stop Generation' : 'Generate Voice with Qwen' }}
</button>
</div>
</div>
</div>
<div v-if="characters.length === 0" class="text-center text-xs text-slate-400 py-4">No characters yet. Click Add.
</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. Enter Source Text / Novel Excerpt</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="Paste novel content or the original script text..."></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 Deep Analysis</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="Select the LLM model for analysis">
<option value="" disabled>-- Select an LLM model --</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 ? 'Stop Analysis' : 'AI Deep Analysis' }}
</button>
</div>
<!-- Insert Control Blocks -->
<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">Insert Control Blocks</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">
➕ Insert Dialogue
</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">
➕ Insert 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">
➕ Insert Background Image
</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">Background Image Count</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="Number of bgImage blocks the LLM must insert" />
<span class="text-[10px] text-slate-400 whitespace-nowrap">images</span>
<span class="text-[10px] text-slate-400 ml-2">(To disable this, remove the background-image block instructions in Prompt Manager.)</span>
</div>
</div>
<!-- 配音/生成/Play -->
<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">Voiceover & Playback</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="Select the TTS service for generation">
<option value="" disabled>-- Select a TTS model --</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 ? 'Stop Generation' : (selectedLineIndex !== -1 ? 'Generate from Selected Line' : 'Generate All Voiceovers (skip existing)') }}
</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">
Clear Voiceovers
</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 ? '▶️ Play from Selected Position' : '▶️ Play Sequentially' }}
</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">
Stop Playback
</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. Script Dialogue List ({{ scriptLines.length }} lines)</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 Control块 -->
<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="Move up">▲</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="Move down">▼</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 Control
</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">▶ Play</option>
<option value="stop">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>-- Select BGM --</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">
Stop all currently playing background music
</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 Volume
</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>
<!-- Background Image Block -->
<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="Move up">▲</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="Move down">▼</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">
Background Image Block
</div>
<button @click="removeScriptLine(index)"
class="text-slate-300 hover:text-red-500 p-2"
title="Delete"><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">
<!-- 图片展示 -->
<div class="space-y-2">