Skip to content

Commit 0870488

Browse files
committed
修复章节参与实体字段修改不同步问题
1 parent 01ac53f commit 0870488

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

frontend/src/renderer/src/views/Editor.vue

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
:volume-number="chapterVolumeNumber"
139139
:chapter-number="chapterChapterNumber"
140140
:participants="chapterParticipants"
141+
@update:participants="handleContextParticipantsUpdate"
141142
/>
142143
</el-tab-pane>
143144

@@ -1117,6 +1118,24 @@ async function assembleChapterContext() {
11171118
}
11181119
}
11191120
1121+
// 当右侧“参与实体”面板中手动增删参与者时,将变更写回当前章节卡片的内容
1122+
async function handleContextParticipantsUpdate(names: string[]) {
1123+
try {
1124+
if (!isChapterContent.value || !activeCard.value) return
1125+
const card = activeCard.value as any
1126+
const content: any = { ...(card.content || {}) }
1127+
// 仅以名称列表作为实体列表的来源(对象形态后续仍可由分析流程补全)
1128+
const normalized = (names || [])
1129+
.map(n => (typeof n === 'string' ? n.trim() : String(n || '')).trim())
1130+
.filter(Boolean)
1131+
content.entity_list = normalized
1132+
await cardStore.modifyCard(card.id, { content } as any)
1133+
// modifyCard 成功后,cards watcher 会触发 assembleChapterContext 使用新的参与者
1134+
} catch (e) {
1135+
console.error('Failed to update participants on card:', e)
1136+
}
1137+
}
1138+
11201139
11211140
async function refreshAssistantContext() {
11221141
try {

0 commit comments

Comments
 (0)