fix: 澄清卡片已回答用 label 显示,后端 payload 仍用 value
This commit is contained in:
@@ -1747,16 +1747,19 @@ const submitClarification = (answer) => {
|
|||||||
if (answeringClarification.value) return
|
if (answeringClarification.value) return
|
||||||
// 找最后一张未提交的卡片消息(mp-weixin 模板不支持内联箭头函数传 msg,改为自己查找)
|
// 找最后一张未提交的卡片消息(mp-weixin 模板不支持内联箭头函数传 msg,改为自己查找)
|
||||||
const card = [...resultMessages.value].reverse().find(m => m.kind === 'card' && !m.submitted)
|
const card = [...resultMessages.value].reverse().find(m => m.kind === 'card' && !m.submitted)
|
||||||
|
// 通过 value 查找选项的 label,用于前端显示;后端 payload 仍用 value(语义化)
|
||||||
|
const option = card?.card?.options?.find(opt => opt.value === answer)
|
||||||
|
const label = option?.label || answer
|
||||||
if (card) {
|
if (card) {
|
||||||
card.submitted = true
|
card.submitted = true
|
||||||
card.answer = answer
|
card.answer = label // 显示用 label(中文)
|
||||||
}
|
}
|
||||||
addResultMessage({ role: 'user', kind: 'text', content: answer })
|
addResultMessage({ role: 'user', kind: 'text', content: label })
|
||||||
answeringClarification.value = true
|
answeringClarification.value = true
|
||||||
currentStreamTask.value = followupStream({
|
currentStreamTask.value = followupStream({
|
||||||
sessionId: novelSessionId.value,
|
sessionId: novelSessionId.value,
|
||||||
action: 'answer_clarification',
|
action: 'answer_clarification',
|
||||||
payload: { answer },
|
payload: { answer }, // 后端仍收 value
|
||||||
onEvent: handleShortNovelEvent,
|
onEvent: handleShortNovelEvent,
|
||||||
onError: (errMsg) => markGenerationFailed(errMsg)
|
onError: (errMsg) => markGenerationFailed(errMsg)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user