refactor: 优化深度模式输出体验
- 深度模式下只流式输出最终润色结果 - 前置阶段(初稿/质检/反思)仅显示进度提示 - 提升用户体验,减少中间过程干扰 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -187,7 +187,6 @@ export const useAppStore = defineStore('app', () => {
|
||||
console.log('Store: 进入草稿生成阶段')
|
||||
}
|
||||
|
||||
// 实时更新 UI 显示(流式输出)
|
||||
// 提取当前已接收的 thinking 和 draft 内容
|
||||
const thinkingMatch = buffer.match(/<thinking>([\s\S]*?)(?:<\/thinking>|$)/)
|
||||
const draftMatch = buffer.match(/<draft>([\s\S]*?)(?:<\/draft>|$)/)
|
||||
@@ -195,13 +194,16 @@ export const useAppStore = defineStore('app', () => {
|
||||
if (thinkingMatch) {
|
||||
thinkingContent.value = thinkingMatch[1].trim()
|
||||
}
|
||||
if (draftMatch) {
|
||||
generatedContent.value = draftMatch[1].trim()
|
||||
}
|
||||
|
||||
// 如果 AI 没有按 XML 格式输出,直接显示原始内容
|
||||
if (!thinkingMatch && !draftMatch && buffer.length > 50) {
|
||||
generatedContent.value = buffer
|
||||
// 深度模式下,初稿阶段不流式输出到预览区,只在非深度模式下流式显示
|
||||
if (!isDeepMode.value) {
|
||||
if (draftMatch) {
|
||||
generatedContent.value = draftMatch[1].trim()
|
||||
}
|
||||
// 如果 AI 没有按 XML 格式输出,直接显示原始内容
|
||||
if (!thinkingMatch && !draftMatch && buffer.length > 50) {
|
||||
generatedContent.value = buffer
|
||||
}
|
||||
}
|
||||
}, { paradigm: activeParadigm.value })
|
||||
|
||||
@@ -210,10 +212,16 @@ export const useAppStore = defineStore('app', () => {
|
||||
console.log('Store: XML 解析完成', { hasStructuredOutput, thinkingLength: thinking.length, draftLength: draft.length })
|
||||
|
||||
thinkingContent.value = thinking
|
||||
generatedContent.value = draft
|
||||
// 非深度模式下才直接显示初稿
|
||||
if (!isDeepMode.value) {
|
||||
generatedContent.value = draft
|
||||
}
|
||||
|
||||
// 如果是深度模式,进入 Agentic Workflow
|
||||
if (isDeepMode.value) {
|
||||
// 深度模式下显示进度提示
|
||||
generatedContent.value = '⏳ **深度模式处理中...**\n\n'
|
||||
generatedContent.value += '✅ 初稿生成完成\n'
|
||||
// 2. 质检阶段(如果有专家指令)
|
||||
if (activeParadigm.value && expertGuidelines.value.length > 0) {
|
||||
generationStage.value = 'inspect'
|
||||
@@ -268,25 +276,27 @@ ${draft}
|
||||
summary: '质检结果解析失败,建议人工复核'
|
||||
}
|
||||
}
|
||||
generatedContent.value += '✅ 质检完成\n'
|
||||
}
|
||||
|
||||
// 3. 批判阶段
|
||||
generationStage.value = 'critique'
|
||||
console.log('Store: 进入批判阶段...')
|
||||
generatedContent.value += '\n\n---\n\n💡 **AI 深度反思 (Critique Stage)**:\n正在分析逻辑漏洞与改进空间...\n\n'
|
||||
generatedContent.value += '🔍 AI 深度反思中...\n'
|
||||
|
||||
const critiquePrompt = `你是一个严厉的主编。请分析以下文章的逻辑漏洞、论证强度和风格一致性。请列出3-5条具体的修改建议。不要重写文章,只提供建议。\n\n文章内容:\n${draft}`
|
||||
|
||||
let critiqueContent = ''
|
||||
await api.generateContent(critiquePrompt, (content) => {
|
||||
generatedContent.value += content
|
||||
// 不流式输出到预览区,只收集内容
|
||||
critiqueContent += content
|
||||
})
|
||||
generatedContent.value += '✅ 反思分析完成\n'
|
||||
|
||||
// 4. 修正阶段
|
||||
// 4. 修正阶段 - 只有这个阶段流式输出
|
||||
generationStage.value = 'refine'
|
||||
console.log('Store: 进入修正阶段...')
|
||||
generatedContent.value += '\n\n---\n\n✨ **深度润色 (Refinement Stage)**:\n正在根据反思意见重写...\n\n'
|
||||
generatedContent.value += '✨ 深度润色中...\n\n---\n\n'
|
||||
|
||||
const refinePrompt = `你是一个专业的写作专家。请根据以下修改建议,重写这篇文章。保持原文的优秀风格,同时修复提到的问题。\n\n原文:\n${draft}\n\n修改建议:\n${critiqueContent}\n\n请直接输出重写后的正文:`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user