fix(mini-program): 修复心愿实现页用户消息不显示 + 支持继续会话
1. runGeneration 补赋值 generationDisplayText,修复用户输入心愿不显示 2. 识别外部服务 DAILY_GENERATION_IN_PROGRESS 错误码,保存 session_id 3. 失败态新增'继续创作'按钮,调用 followup action=retry 恢复中断会话 4. 新增 resumeSession 方法,重置状态后恢复流式生成
This commit is contained in:
@@ -173,7 +173,8 @@
|
||||
<text class="loading-copy">{{ generationCopy }}</text>
|
||||
<text v-if="generationStatus !== 'failed'" class="loading-subcopy">{{ generationSubcopy }}</text>
|
||||
<view v-else class="generation-actions">
|
||||
<button class="generation-action primary" @click="retryGeneration">再试一次</button>
|
||||
<button v-if="resumeableSessionId" class="generation-action primary" @click="resumeSession">继续创作</button>
|
||||
<button v-else class="generation-action primary" @click="retryGeneration">再试一次</button>
|
||||
<button class="generation-action secondary" @click="returnToEdit">返回修改</button>
|
||||
</view>
|
||||
</view>
|
||||
@@ -346,6 +347,7 @@ const generationScrollTarget = ref('')
|
||||
const generationScrollTop = ref(0)
|
||||
const generationAutoFollow = ref(true)
|
||||
const generationDisplayText = ref('')
|
||||
const resumeableSessionId = ref('')
|
||||
const lastGenerationPrompt = ref('')
|
||||
const lastSubmitSource = ref('text')
|
||||
const lastGenerationRevision = ref(false)
|
||||
@@ -1641,7 +1643,9 @@ const runGeneration = async ({ prompt, displayText, source = 'text', saveTheme }
|
||||
novelOutline.value = null
|
||||
clarificationCard.value = null
|
||||
novelSessionId.value = ''
|
||||
resumeableSessionId.value = ''
|
||||
outlineFeedback.value = ''
|
||||
generationDisplayText.value = display
|
||||
generationScrollTarget.value = ''
|
||||
generationScrollTop.value = 0
|
||||
generationScrollAnchor.value = 'generation-stream-anchor-a'
|
||||
@@ -1709,7 +1713,13 @@ const handleShortNovelEvent = (event) => {
|
||||
viewMode.value = 'chat'
|
||||
break
|
||||
case 'error':
|
||||
markGenerationFailed(payload.message || '生成失败')
|
||||
// 识别每日限制错误,保存 session_id 供"继续创作"使用
|
||||
if (payload.code === 'DAILY_GENERATION_IN_PROGRESS' && session_id) {
|
||||
resumeableSessionId.value = session_id
|
||||
markGenerationFailed(payload.message || '今天已有未完成的创作,可点击继续创作恢复')
|
||||
} else {
|
||||
markGenerationFailed(payload.message || '生成失败')
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -1748,6 +1758,42 @@ const modifyOutline = (feedback) => {
|
||||
})
|
||||
}
|
||||
|
||||
const resumeSession = () => {
|
||||
if (!resumeableSessionId.value || generating.value) return
|
||||
novelSessionId.value = resumeableSessionId.value
|
||||
resumeableSessionId.value = ''
|
||||
generating.value = true
|
||||
streamContent.value = ''
|
||||
novelFullText.value = ''
|
||||
generationStatus.value = 'waiting'
|
||||
generationError.value = ''
|
||||
generationDisplayText.value = '继续之前的创作'
|
||||
streamWriter.reset()
|
||||
startGenerationFeedback()
|
||||
viewState.value = 'generating'
|
||||
keepGenerationAtBottom()
|
||||
|
||||
try {
|
||||
currentStreamTask.value = followupStream({
|
||||
sessionId: novelSessionId.value,
|
||||
action: 'retry',
|
||||
payload: null,
|
||||
onEvent: handleShortNovelEvent,
|
||||
onError: (msg) => {
|
||||
markGenerationFailed(msg)
|
||||
analytics.track('script_generate_fail', {
|
||||
source: 'resume',
|
||||
error: msg
|
||||
}, { eventType: 'script', pagePath })
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
markGenerationFailed(error.message || '恢复失败')
|
||||
} finally {
|
||||
generating.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const submitWish = async (source = 'text') => {
|
||||
const text = wishText.value.trim()
|
||||
if (!text || generating.value) return
|
||||
|
||||
Reference in New Issue
Block a user