forked from ponysb/91Writing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWriter.vue
More file actions
7878 lines (6841 loc) · 245 KB
/
Writer.vue
File metadata and controls
7878 lines (6841 loc) · 245 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
<template>
<div class="writer-container">
<!-- 顶部标题栏 -->
<div class="title-bar">
<div class="title-left">
<el-button @click="goBack" size="small">
<el-icon><ArrowLeft /></el-icon>
返回列表
</el-button>
<span class="novel-title">{{ currentNovel?.title || '小说编辑' }}</span>
</div>
</div>
<!-- 标签栏 -->
<div class="tabs-bar">
<el-tabs v-model="activeTab" class="main-tabs">
<el-tab-pane label="📝 编辑" name="editor"></el-tab-pane>
<el-tab-pane label="🤖 AI助手" name="ai"></el-tab-pane>
<el-tab-pane label="👥 人物" name="characters"></el-tab-pane>
<el-tab-pane label="🌍 世界观" name="worldview"></el-tab-pane>
<el-tab-pane label="📚 语料库" name="corpus"></el-tab-pane>
<el-tab-pane label="📊 事件线" name="events"></el-tab-pane>
</el-tabs>
</div>
<!-- 主要内容区域 -->
<div class="main-content">
<!-- 左侧面板 -->
<div class="left-panel">
<!-- 章节列表面板 -->
<div v-show="activeTab === 'editor'" class="panel-content">
<el-card shadow="never" class="chapters-card">
<template #header>
<div class="card-header">
<span>📝 章节列表</span>
<el-dropdown @command="handleChapterCommand">
<el-button size="small" type="primary">
<el-icon><Plus /></el-icon>
新增章节 <el-icon><ArrowDown /></el-icon>
</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="manual">手动创建</el-dropdown-item>
<el-dropdown-item command="ai-single">AI生成单章</el-dropdown-item>
<el-dropdown-item command="ai-batch">AI批量生成</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
</template>
<div class="chapters-list">
<div
v-for="(chapter, index) in chapters"
:key="chapter.id"
class="chapter-item"
:class="{ active: currentChapter?.id === chapter.id }"
@click="selectChapter(chapter)"
>
<div class="chapter-info">
<h4>第{{ index + 1 }}章</h4>
<p>{{ chapter.title }}</p>
<div class="chapter-meta">
<span>{{ chapter.wordCount || 0 }}字</span>
<el-tag v-if="chapter.status" :type="getChapterStatusType(chapter.status)" size="small">
{{ getChapterStatusText(chapter.status) }}
</el-tag>
</div>
<p v-if="chapter.description" class="chapter-desc">{{ chapter.description }}</p>
</div>
<div class="chapter-actions">
<el-dropdown @command="(cmd) => handleChapterAction(cmd, chapter)">
<el-button size="small" type="text">
<el-icon><MoreFilled /></el-icon>
</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="edit">编辑信息</el-dropdown-item>
<el-dropdown-item command="generate">AI生成正文</el-dropdown-item>
<el-dropdown-item command="optimize">AI优化</el-dropdown-item>
<el-dropdown-item divided command="delete">删除</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
</div>
<div v-if="chapters.length === 0" class="empty-chapters">
<p>暂无章节</p>
<el-button size="small" type="primary" @click="addNewChapter">
创建第一章
</el-button>
</div>
</div>
</el-card>
</div>
<!-- AI助手面板 -->
<div v-show="activeTab === 'ai'" class="panel-content">
<el-card shadow="never">
<template #header>
<span>🤖 AI创作助手</span>
</template>
<!-- 流式生成内容显示区域 -->
<div v-if="isStreaming" class="streaming-content-area">
<el-card shadow="never" class="streaming-card">
<template #header>
<div class="streaming-header">
<span>🔄 AI正在生成 - {{ getStreamingTypeText() }}</span>
<el-tag type="success" size="small">实时生成中...</el-tag>
</div>
</template>
<div class="streaming-content">
<div v-if="streamingType === 'content' || streamingType === 'continue' || streamingType === 'optimize'"
v-html="streamingContent"
class="streaming-text">
</div>
<pre v-else class="streaming-text-plain">{{ streamingContent }}</pre>
</div>
</el-card>
</div>
<div class="ai-tools">
<el-collapse v-model="activeAITools">
<el-collapse-item title="📝 章节生成" name="chapter-gen">
<div class="ai-section">
<el-form :model="aiChapterForm" label-width="80px" size="small">
<el-form-item label="生成数量">
<el-input-number v-model="aiChapterForm.count" :min="1" :max="10" />
</el-form-item>
<el-form-item label="情节要求">
<el-input v-model="aiChapterForm.plotRequirement" type="textarea" :rows="3" placeholder="描述希望的情节发展..." />
</el-form-item>
<el-form-item label="提示词模板">
<el-select v-model="aiChapterForm.template" placeholder="选择模板">
<el-option label="通用章节" value="general" />
<el-option label="战斗场景" value="battle" />
<el-option label="情感戏" value="emotion" />
<el-option label="转折剧情" value="turning" />
</el-select>
</el-form-item>
</el-form>
<div class="ai-button-group">
<el-button type="primary" @click="generateChapters" :loading="isGeneratingChapters" style="flex: 1;">
<el-icon><Star /></el-icon>
生成章节大纲
</el-button>
<el-button @click="openPromptDialog('outline')" style="margin-left: 8px;">
📝 选择提示词
</el-button>
<el-button @click="testChapterParse" size="small" style="margin-left: 8px;" v-if="isDevelopment">
🔧 测试解析
</el-button>
</div>
</div>
</el-collapse-item>
<el-collapse-item title="✍️ 正文生成" name="content-gen">
<div class="ai-section">
<el-form :model="aiContentForm" label-width="80px" size="small">
<el-form-item label="目标字数">
<el-input-number v-model="aiContentForm.wordCount" :min="500" :max="5000" />
</el-form-item>
<el-form-item label="写作风格">
<el-select v-model="aiContentForm.style">
<el-option label="第一人称" value="first-person" />
<el-option label="第三人称" value="third-person" />
<el-option label="全知视角" value="omniscient" />
</el-select>
</el-form-item>
<el-form-item label="情节重点">
<el-input v-model="aiContentForm.focus" placeholder="本章重点内容..." />
</el-form-item>
<el-form-item label="上下文关联">
<el-checkbox v-model="aiContentForm.useContext">关联前文内容</el-checkbox>
<el-checkbox v-model="aiContentForm.useCharacters">关联人物设定</el-checkbox>
<el-checkbox v-model="aiContentForm.useWorldview">关联世界观</el-checkbox>
</el-form-item>
</el-form>
<div class="ai-button-group">
<el-button type="primary" @click="generateContent" :loading="isGeneratingContent" style="flex: 1;">
<el-icon><Edit /></el-icon>
生成正文内容
</el-button>
<el-button @click="openPromptDialog('content')" style="margin-left: 8px;">
📝 选择提示词
</el-button>
</div>
</div>
</el-collapse-item>
<el-collapse-item title="🔧 文本优化" name="optimize">
<div class="ai-section">
<el-radio-group v-model="optimizeType" direction="vertical">
<el-radio label="grammar">语法润色</el-radio>
<el-radio label="style">文风优化</el-radio>
<el-radio label="emotion">情感增强</el-radio>
<el-radio label="logic">逻辑梳理</el-radio>
</el-radio-group>
<div class="ai-button-group" style="margin-top: 10px;">
<el-button type="primary" @click="optimizeText" :loading="isOptimizing" style="flex: 1;">
<el-icon><Tools /></el-icon>
快速优化
</el-button>
<el-button @click="openOptimizePromptDialog" style="margin-left: 8px;">
📝 提示词优化
</el-button>
</div>
</div>
</el-collapse-item>
<el-collapse-item title="🚀 智能续写" name="continue">
<div class="ai-section">
<p class="section-desc">基于现有内容智能续写,保持风格一致</p>
<div class="ai-button-group">
<el-button type="success" @click="continueWriting" :loading="isGeneratingContent" style="flex: 1;">
<el-icon><Right /></el-icon>
智能续写
</el-button>
<el-button @click="openPromptDialog('continue')" style="margin-left: 8px;">
📝 选择提示词
</el-button>
</div>
</div>
</el-collapse-item>
<el-collapse-item title="✨ 内容增强" name="enhance">
<div class="ai-section">
<p class="section-desc">增强现有内容的表现力和感染力</p>
<el-button type="warning" @click="enhanceContent" :loading="isOptimizing" block>
<el-icon><Star /></el-icon>
内容增强
</el-button>
</div>
</el-collapse-item>
</el-collapse>
</div>
</el-card>
</div>
<!-- 人物管理面板 -->
<div v-show="activeTab === 'characters'" class="panel-content">
<el-card shadow="never">
<template #header>
<div class="card-header">
<span>👥 人物角色</span>
<div class="character-actions">
<el-button size="small" type="primary" @click="addCharacter">
<el-icon><Plus /></el-icon>
新增
</el-button>
<el-button size="small" type="success" @click="showBatchGenerateDialog">
🤖 AI批量生成
</el-button>
</div>
</div>
</template>
<div class="characters-list">
<div v-for="character in characters" :key="character.id" class="character-item">
<div class="character-content" @click="editCharacter(character)">
<div class="character-avatar">
<img v-if="character.avatar" :src="character.avatar" />
<div v-else class="default-avatar">{{ character.name?.charAt(0) || '?' }}</div>
</div>
<div class="character-info">
<h4>{{ character.name }}</h4>
<div class="character-meta">
<el-tag :type="getRoleType(character.role)" size="small">{{ getRoleText(character.role) }}</el-tag>
<el-tag v-if="character.gender" type="info" size="small">{{ getGenderText(character.gender) }}</el-tag>
<span v-if="character.age" class="age-text">{{ character.age }}岁</span>
</div>
<p v-if="character.personality" class="character-desc">{{ character.personality }}</p>
<div class="character-tags" v-if="character.tags && character.tags.length">
<el-tag v-for="tag in character.tags" :key="tag" size="small">{{ tag }}</el-tag>
</div>
</div>
</div>
<div class="character-actions">
<el-dropdown @command="(cmd) => handleCharacterAction(cmd, character)" trigger="click">
<el-button size="small" type="text" @click.stop>
<el-icon><MoreFilled /></el-icon>
</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="edit">
<el-icon><Edit /></el-icon>
编辑
</el-dropdown-item>
<el-dropdown-item command="delete" divided>
<el-icon><Delete /></el-icon>
删除
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
</div>
<div v-if="characters.length === 0" class="empty-state">
<p>暂无人物设定</p>
<el-button size="small" @click="addCharacter">创建第一个角色</el-button>
</div>
</div>
</el-card>
</div>
<!-- 世界观管理面板 -->
<div v-show="activeTab === 'worldview'" class="panel-content">
<el-card shadow="never">
<template #header>
<div class="card-header">
<span>🌍 世界观设定</span>
<div class="world-actions">
<el-button size="small" type="primary" @click="addWorldSetting">
<el-icon><Plus /></el-icon>
新增
</el-button>
<el-button size="small" type="success" @click="openWorldGenerateDialog">
🤖 AI生成
</el-button>
</div>
</div>
</template>
<div class="worldview-list">
<div v-for="setting in worldSettings" :key="setting.id" class="worldview-item">
<div class="worldview-content" @click="editWorldSetting(setting)">
<div class="worldview-header">
<h4>{{ setting.title }}</h4>
<el-tag v-if="setting.category" :type="getWorldSettingTagType(setting.category)" size="small">
{{ setting.category }}
</el-tag>
</div>
<p class="worldview-description">
{{ setting.description ? setting.description.substring(0, 80) + (setting.description.length > 80 ? '...' : '') : '暂无描述' }}
</p>
<div class="worldview-meta">
<span class="create-time">{{ formatDate(setting.createdAt) }}</span>
<span v-if="setting.generated" class="ai-generated">AI生成</span>
</div>
</div>
<div class="worldview-actions">
<el-dropdown @command="(cmd) => handleWorldSettingAction(cmd, setting)" trigger="click">
<el-button size="small" type="text" @click.stop>
<el-icon><MoreFilled /></el-icon>
</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="edit">
<el-icon><Edit /></el-icon>
编辑
</el-dropdown-item>
<el-dropdown-item command="duplicate">
<el-icon><CopyDocument /></el-icon>
复制
</el-dropdown-item>
<el-dropdown-item command="delete" divided>
<el-icon><Delete /></el-icon>
删除
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
</div>
<div v-if="worldSettings.length === 0" class="empty-state">
<p>暂无世界观设定</p>
<el-button size="small" @click="addWorldSetting">创建第一个设定</el-button>
</div>
</div>
</el-card>
</div>
<!-- 语料库面板 -->
<div v-show="activeTab === 'corpus'" class="panel-content">
<el-card shadow="never">
<template #header>
<div class="card-header">
<span>📚 语料库</span>
<el-button size="small" type="primary" @click="addCorpus">
<el-icon><Plus /></el-icon>
新增
</el-button>
</div>
</template>
<div class="corpus-list">
<div v-for="corpus in corpusData" :key="corpus.id" class="corpus-item">
<div class="corpus-header">
<h4>{{ corpus.title }}</h4>
<el-tag :type="getCorpusType(corpus.type)">{{ corpus.type }}</el-tag>
</div>
<p class="corpus-preview">{{ corpus.content.substring(0, 100) }}...</p>
<div class="corpus-actions">
<el-button size="small" @click="useCorpus(corpus)">使用</el-button>
<el-button size="small" @click="editCorpus(corpus)">编辑</el-button>
</div>
</div>
<div v-if="corpusData.length === 0" class="empty-state">
<p>暂无语料数据</p>
<el-button size="small" @click="addCorpus">添加第一个语料</el-button>
</div>
</div>
</el-card>
</div>
<!-- 事件线面板 -->
<div v-show="activeTab === 'events'" class="panel-content">
<el-card shadow="never">
<template #header>
<div class="card-header">
<span>📊 事件时间线</span>
<el-button size="small" type="primary" @click="addEvent">
<el-icon><Plus /></el-icon>
新增
</el-button>
</div>
</template>
<div class="events-timeline">
<div v-for="event in events" :key="event.id" class="event-item">
<div class="event-marker"></div>
<div class="event-content">
<h4>{{ event.title }}</h4>
<p>{{ event.description }}</p>
<div class="event-meta">
<el-tag size="small">{{ event.chapter }}</el-tag>
<span class="event-time">{{ event.time }}</span>
</div>
</div>
</div>
<div v-if="events.length === 0" class="empty-state">
<p>暂无事件记录</p>
<el-button size="small" @click="addEvent">添加第一个事件</el-button>
</div>
</div>
</el-card>
</div>
</div>
<!-- 右侧编辑器区域 -->
<div class="editor-panel">
<el-card shadow="never" v-if="currentChapter">
<template #header>
<div class="card-header">
<div class="editor-title-section">
<span>✍️ {{ currentChapter.title }}</span>
<div class="editor-stats">
<span>字数:{{ contentWordCount }}</span>
<el-tag v-if="currentChapter.status" :type="getChapterStatusType(currentChapter.status)" size="small">
{{ getChapterStatusText(currentChapter.status) }}
</el-tag>
<span v-if="hasUnsavedChanges" class="unsaved-indicator">● 未保存</span>
</div>
</div>
<div class="editor-actions">
<el-button @click="saveContent" :loading="isSaving" size="small">
<el-icon><DocumentAdd /></el-icon>
{{ isSaving ? '保存中...' : '保存' }}
</el-button>
<el-button @click="showPreview = !showPreview" size="small">
<el-icon><View /></el-icon>
{{ showPreview ? '编辑' : '预览' }}
</el-button>
</div>
</div>
</template>
<!-- AI生成工具栏 -->
<div class="ai-toolbar" v-if="activeTab === 'editor'">
<el-button-group>
<el-button size="small" @click="generateFromOutline" :disabled="!currentChapter.description">
<el-icon><Star /></el-icon>
根据大纲生成
</el-button>
<el-button size="small" @click="continueWriting">
<el-icon><ArrowRight /></el-icon>
续写
</el-button>
<el-button size="small" @click="enhanceContent">
<el-icon><Tools /></el-icon>
优化
</el-button>
</el-button-group>
</div>
<div class="editor-container" v-show="!showPreview">
<div class="editor-wrapper">
<Toolbar
:editor="editorRef"
:defaultConfig="toolbarConfig"
mode="default"
style="border-bottom: 1px solid #e4e7ed;"
/>
<Editor
v-model="content"
:defaultConfig="editorConfig"
mode="default"
@onCreated="handleCreated"
@onChange="onContentChange"
style="overflow-y: hidden;"
/>
</div>
</div>
<!-- 预览区域 -->
<div class="preview-container" v-show="showPreview">
<div class="preview-content" v-html="content"></div>
</div>
</el-card>
<!-- 未选择章节状态 -->
<el-card shadow="never" v-else>
<div class="empty-editor">
<el-icon class="empty-icon"><Document /></el-icon>
<p>请选择或创建一个章节开始编辑</p>
<el-button type="primary" @click="addNewChapter">创建第一章</el-button>
</div>
</el-card>
</div>
</div>
<!-- 章节编辑对话框 -->
<el-dialog v-model="showChapterDialog" :title="editingChapter ? '编辑章节' : '新增章节'" width="600px">
<el-form :model="chapterForm" label-width="80px">
<el-form-item label="章节标题">
<el-input v-model="chapterForm.title" placeholder="请输入章节标题" />
</el-form-item>
<el-form-item label="章节简介">
<div class="form-item-with-ai">
<el-input
v-model="chapterForm.description"
type="textarea"
:rows="4"
placeholder="简要描述本章节内容..."
/>
<el-button
size="small"
type="primary"
@click="generateChapterOutline"
:loading="isGeneratingOutline"
style="margin-top: 8px;"
>
<el-icon><Star /></el-icon>
AI生成大纲
</el-button>
</div>
</el-form-item>
<el-form-item label="章节状态">
<el-select v-model="chapterForm.status">
<el-option label="大纲" value="outline" />
<el-option label="草稿" value="draft" />
<el-option label="完成" value="completed" />
</el-select>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="showChapterDialog = false">取消</el-button>
<el-button type="primary" @click="saveChapter">确定</el-button>
</template>
</el-dialog>
<!-- 人物编辑对话框 -->
<el-dialog v-model="showCharacterDialog" title="编辑角色" width="700px">
<el-form :model="characterForm" label-width="80px">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="姓名">
<el-input v-model="characterForm.name" />
</el-form-item>
<el-form-item label="角色">
<el-select v-model="characterForm.role">
<el-option label="主角" value="protagonist" />
<el-option label="配角" value="supporting" />
<el-option label="反派" value="antagonist" />
<el-option label="路人" value="minor" />
</el-select>
</el-form-item>
<el-form-item label="性别">
<el-radio-group v-model="characterForm.gender">
<el-radio label="male">男</el-radio>
<el-radio label="female">女</el-radio>
<el-radio label="other">其他</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="年龄">
<el-input-number v-model="characterForm.age" :min="0" :max="1000" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="外貌">
<el-input v-model="characterForm.appearance" type="textarea" :rows="3" />
</el-form-item>
<el-form-item label="性格">
<el-input v-model="characterForm.personality" type="textarea" :rows="3" />
</el-form-item>
</el-col>
</el-row>
<el-form-item label="背景故事">
<div class="form-item-with-ai">
<el-input v-model="characterForm.background" type="textarea" :rows="4" />
<div class="ai-button-group" style="margin-top: 8px;">
<el-button
size="small"
type="primary"
@click="generateCharacterAI"
style="flex: 1;"
>
<el-icon><Star /></el-icon>
AI生成角色信息
</el-button>
<el-button size="small" @click="openPromptDialog('character')" style="margin-left: 8px;">
📝 提示词
</el-button>
</div>
</div>
</el-form-item>
<el-form-item label="标签">
<el-input v-model="characterTagInput" placeholder="输入标签后按回车" @keyup.enter="addCharacterTag">
<template #append>
<el-button @click="addCharacterTag">添加</el-button>
</template>
</el-input>
<div v-if="characterForm.tags.length > 0" style="margin-top: 8px;">
<el-tag
v-for="(tag, index) in characterForm.tags"
:key="index"
closable
@close="removeCharacterTag(index)"
style="margin-right: 8px;"
>
{{ tag }}
</el-tag>
</div>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="showCharacterDialog = false">取消</el-button>
<el-button type="primary" @click="saveCharacter">保存</el-button>
</template>
</el-dialog>
<!-- 世界观编辑对话框 -->
<el-dialog v-model="showWorldDialog" title="编辑世界观设定" width="600px">
<el-form :model="worldForm" label-width="80px">
<el-form-item label="设定标题">
<el-input v-model="worldForm.title" />
</el-form-item>
<el-form-item label="类别">
<el-select v-model="worldForm.category">
<el-option label="世界设定" value="setting" />
<el-option label="魔法体系" value="magic" />
<el-option label="政治势力" value="politics" />
<el-option label="地理环境" value="geography" />
<el-option label="历史背景" value="history" />
</el-select>
</el-form-item>
<el-form-item label="详细描述">
<div class="form-item-with-ai">
<el-input v-model="worldForm.description" type="textarea" :rows="6" />
<el-button
size="small"
type="primary"
@click="generateWorldSettingAI"
:loading="isGeneratingWorldSetting"
style="margin-top: 8px;"
>
<el-icon><Star /></el-icon>
AI生成描述
</el-button>
</div>
</el-form-item>
</el-form>
<!-- 流式生成状态显示 -->
<div v-if="isStreaming && streamingType === 'worldSetting'" class="streaming-status-card">
<div class="streaming-header">
<span class="streaming-title">🤖 AI正在生成世界观设定...</span>
</div>
<div class="streaming-content-display" v-html="formatStreamingContent(streamingContent)"></div>
</div>
<template #footer>
<el-button @click="showWorldDialog = false">取消</el-button>
<el-button type="primary" @click="saveWorldSetting">保存</el-button>
</template>
</el-dialog>
<!-- 语料库编辑对话框 -->
<el-dialog v-model="showCorpusDialog" title="编辑语料" width="700px">
<el-form :model="corpusForm" label-width="80px">
<el-form-item label="标题">
<el-input v-model="corpusForm.title" />
</el-form-item>
<el-form-item label="类型">
<el-select v-model="corpusForm.type">
<el-option label="场景描述" value="description" />
<el-option label="对话模板" value="dialogue" />
<el-option label="情感表达" value="emotion" />
<el-option label="动作描写" value="action" />
<el-option label="心理描写" value="psychology" />
</el-select>
</el-form-item>
<el-form-item label="内容">
<el-input v-model="corpusForm.content" type="textarea" :rows="8" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="showCorpusDialog = false">取消</el-button>
<el-button type="primary" @click="saveCorpus">保存</el-button>
</template>
</el-dialog>
<!-- 事件编辑对话框 -->
<el-dialog v-model="showEventDialog" title="编辑事件" width="600px">
<el-form :model="eventForm" label-width="80px">
<el-form-item label="事件标题">
<el-input v-model="eventForm.title" />
</el-form-item>
<el-form-item label="相关章节">
<el-select v-model="eventForm.chapter" placeholder="选择章节">
<el-option
v-for="chapter in chapters"
:key="chapter.id"
:label="chapter.title"
:value="chapter.title"
/>
</el-select>
</el-form-item>
<el-form-item label="时间线">
<el-input v-model="eventForm.time" placeholder="如:第三天傍晚" />
</el-form-item>
<el-form-item label="重要程度">
<el-radio-group v-model="eventForm.importance">
<el-radio label="low">次要</el-radio>
<el-radio label="normal">一般</el-radio>
<el-radio label="high">重要</el-radio>
<el-radio label="critical">关键</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="事件描述">
<el-input v-model="eventForm.description" type="textarea" :rows="4" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="showEventDialog = false">取消</el-button>
<el-button type="primary" @click="saveEvent">保存</el-button>
</template>
</el-dialog>
<!-- 章节内容生成对话框 -->
<el-dialog v-model="showChapterGenerateDialog" title="AI生成章节内容" width="1200px" @close="showChapterGenerateDialog = false">
<div class="chapter-generate-content">
<!-- 顶部配置区域 -->
<div class="generate-config-section">
<el-card shadow="hover" class="config-card-modern">
<template #header>
<div class="config-header">
<div class="config-left">
<span class="config-title">⚙️ 生成配置</span>
<el-tag type="info" size="small">{{ currentChapter?.title || '未选择章节' }}</el-tag>
</div>
<el-button
type="primary"
@click="generateChapterContentWithDialog"
:loading="isGeneratingContent"
:disabled="!selectedPrompt"
size="small"
>
<el-icon><MagicStick /></el-icon>
{{ isGeneratingContent ? '生成中' : '生成' }}
</el-button>
</div>
</template>
<el-row :gutter="16">
<el-col :span="6">
<el-form-item label="目标字数" class="config-item">
<el-input-number
v-model="generateConfig.wordCount"
:min="500"
:max="5000"
size="small"
controls-position="right"
/>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="写作视角" class="config-item">
<el-select v-model="generateConfig.style" size="small" style="width: 100%">
<el-option label="第一人称" value="first-person" />
<el-option label="第三人称" value="third-person" />
<el-option label="全知视角" value="omniscient" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="重点内容" class="config-item">
<el-input
v-model="generateConfig.focus"
placeholder="本章重点内容..."
size="small"
/>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="关联设置" class="config-item">
<div class="checkbox-group">
<el-checkbox v-model="generateConfig.useContext" size="small">前文</el-checkbox>
<el-checkbox v-model="generateConfig.useCharacters" size="small">人物</el-checkbox>
<el-checkbox v-model="generateConfig.useWorldview" size="small">世界观</el-checkbox>
</div>
</el-form-item>
</el-col>
</el-row>
</el-card>
</div>
<el-row :gutter="20" style="margin-top: 16px;">
<!-- 左侧:素材选择 -->
<el-col :span="14">
<div class="materials-section">
<div class="section-header">
<h4 class="section-title">📚 创作素材</h4>
<el-button size="small" @click="clearAllMaterials">清空选择</el-button>
</div>
<!-- 素材选择标签页 -->
<el-tabs v-model="activeMaterialTab" class="materials-tabs">
<el-tab-pane label="👥 人物角色" name="characters">
<div class="tab-header">
<span class="tab-count">已选择 {{ selectedMaterials.characters.length }}/{{ characters.length }}</span>
<el-button size="small" @click="selectAllMaterials('characters')" v-if="characters.length > 0">全选</el-button>
</div>
<div class="materials-grid">
<div
v-for="character in characters"
:key="character.id"
class="material-card"
:class="{ selected: selectedMaterials.characters.some(c => c.id === character.id) }"
@click="toggleMaterial('characters', character)"
>
<div class="material-header">
<span class="material-name">{{ character.name }}</span>
<el-tag :type="getRoleType(character.role)" size="small">{{ getRoleText(character.role) }}</el-tag>
</div>
<p class="material-desc">{{ character.personality?.substring(0, 40) || '暂无描述' }}...</p>
<div class="material-tags">
<el-tag v-for="tag in character.tags?.slice(0, 2)" :key="tag" size="small">{{ tag }}</el-tag>
</div>
</div>
</div>
<div v-if="characters.length === 0" class="empty-materials">
<p>暂无人物角色</p>
<el-button size="small" @click="addCharacter">创建角色</el-button>
</div>
</el-tab-pane>
<el-tab-pane label="🌍 世界观" name="worldSettings">
<div class="tab-header">
<span class="tab-count">已选择 {{ selectedMaterials.worldSettings.length }}/{{ worldSettings.length }}</span>
<el-button size="small" @click="selectAllMaterials('worldSettings')" v-if="worldSettings.length > 0">全选</el-button>
</div>
<div class="materials-grid">
<div
v-for="setting in worldSettings"
:key="setting.id"
class="material-card"
:class="{ selected: selectedMaterials.worldSettings.some(w => w.id === setting.id) }"
@click="toggleMaterial('worldSettings', setting)"
>
<div class="material-header">
<span class="material-name">{{ setting.title }}</span>
<el-tag v-if="setting.category" size="small">{{ setting.category }}</el-tag>
</div>
<p class="material-desc">{{ setting.description?.substring(0, 50) || '暂无描述' }}...</p>
</div>
</div>
<div v-if="worldSettings.length === 0" class="empty-materials">
<p>暂无世界观设定</p>
<el-button size="small" @click="addWorldSetting">创建设定</el-button>
</div>
</el-tab-pane>
<el-tab-pane label="📝 语料库" name="corpus">
<div class="tab-header">
<span class="tab-count">已选择 {{ selectedMaterials.corpus.length }}/{{ corpusData.length }}</span>
<el-button size="small" @click="selectAllMaterials('corpus')" v-if="corpusData.length > 0">全选</el-button>
</div>
<div class="materials-grid">
<div
v-for="corpus in corpusData"
:key="corpus.id"
class="material-card"
:class="{ selected: selectedMaterials.corpus.some(c => c.id === corpus.id) }"
@click="toggleMaterial('corpus', corpus)"
>
<div class="material-header">
<span class="material-name">{{ corpus.title }}</span>
<el-tag :type="getCorpusType(corpus.type)" size="small">{{ corpus.type }}</el-tag>
</div>
<p class="material-desc">{{ corpus.content?.substring(0, 40) || '暂无内容' }}...</p>
</div>
</div>
<div v-if="corpusData.length === 0" class="empty-materials">
<p>暂无语料库</p>
<el-button size="small" @click="addCorpus">创建语料</el-button>
</div>
</el-tab-pane>
</el-tabs>
</div>
</el-col>
<!-- 右侧:提示词选择 -->
<el-col :span="10">
<div class="prompt-section">
<div class="section-header">
<h4 class="section-title">📝 提示词模板</h4>
<el-button size="small" @click="useDefaultPrompt">使用默认</el-button>
</div>
<!-- 提示词分类选择 -->
<div class="category-selection-modern">
<div class="category-header">
<span>🏷️ 正文类型</span>
</div>
<div class="category-grid">
<div
v-for="category in contentCategories"
:key="category.key"
class="category-card"
:class="{ active: selectedContentCategory === category.key }"
@click="selectedContentCategory = category.key"
>
<span class="category-icon">{{ category.icon }}</span>
<span class="category-name">{{ category.name }}</span>
</div>
</div>
</div>
<!-- 提示词列表 -->
<div class="prompt-selection-modern">
<div class="prompt-header">
<span>可用模板 ({{ getPromptsByCategory(selectedContentCategory).length }})</span>
<el-button size="small" @click="refreshPrompts">刷新</el-button>
</div>
<div class="prompt-list-modern">
<div
v-for="prompt in getPromptsByCategory(selectedContentCategory)"
:key="prompt.id"
class="prompt-item-modern"
:class="{ active: selectedPrompt?.id === prompt.id }"
@click="selectPromptForChapter(prompt)"
>
<div class="prompt-content">
<h5 class="prompt-title">{{ prompt.title }}</h5>
<p class="prompt-desc">{{ prompt.description }}</p>
<div class="prompt-meta">
<div class="prompt-tags">
<el-tag v-for="tag in prompt.tags?.slice(0, 2)" :key="tag" size="small">{{ tag }}</el-tag>
</div>
<span class="prompt-usage">使用 {{ prompt.usageCount || 0 }} 次</span>
</div>
</div>
<div class="prompt-actions">
<el-icon v-if="selectedPrompt?.id === prompt.id" class="selected-icon"><Check /></el-icon>
</div>
</div>
</div>
<div v-if="getPromptsByCategory(selectedContentCategory).length === 0" class="empty-prompts">
<p>暂无该类型的提示词模板</p>
<el-button size="small" @click="createPromptForCategory">创建模板</el-button>
</div>
</div>
<!-- 变量填充区域 -->
<div v-if="selectedPrompt && Object.keys(promptVariables).length > 0" class="variables-section">
<div class="variables-header">
<span>📋 变量配置</span>
<el-button size="small" @click="autoFillVariables">智能填充</el-button>
</div>
<div class="variables-form">
<div
v-for="(value, variable) in promptVariables"
:key="variable"
class="variable-item"
>
<label class="variable-label">{{ variable }}</label>
<el-input
v-model="promptVariables[variable]"
:type="['章节大纲', '主要人物', '世界观设定', '参考语料', '前文概要'].includes(variable) ? 'textarea' : 'text'"
:rows="2"
:placeholder="'请输入' + variable"
@input="generateFinalPrompt"
size="small"
/>