Commit 974b0191 by weiyudumei

fix: 修复隐藏逻辑,只隐藏答案文本部分,保留 ChatAnswerAttachment 渲染以确保 CardWorkflowForm 的自动提交逻辑能够正常执行

parent 5c59a5d0
...@@ -178,30 +178,31 @@ export const ChatAnswerParser: React.FC<ChatAnswerParserProps> = ({ isLastAnswer ...@@ -178,30 +178,31 @@ export const ChatAnswerParser: React.FC<ChatAnswerParserProps> = ({ isLastAnswer
const shouldHideOperate = hideOperateByCard || hideOperate const shouldHideOperate = hideOperateByCard || hideOperate
// 如果 firstQaFlag 为 true 且存在 workflow 卡片,隐藏整个答案内容(表单会自动提交,用户不需要看到这次的结果) // 如果 firstQaFlag 为 true 且存在 workflow 卡片,隐藏答案文本(表单会自动提交,用户不需要看到这次的结果)
// 但保留 ChatAnswerAttachment 的渲染,确保 CardWorkflowForm 的自动提交逻辑能够执行
const hasWorkflowCard = (answer.cardList || []).some(attachment => attachment.type === 'card-workflow') const hasWorkflowCard = (answer.cardList || []).some(attachment => attachment.type === 'card-workflow')
if (answer.firstQaFlag === true && hasWorkflowCard) { const shouldHideAnswerText = answer.firstQaFlag === true && hasWorkflowCard
return null
}
return ( return (
<div className="answerParser"> <div className="answerParser">
<div className="mb-[8px]"> {!shouldHideAnswerText && (
{/* <Chip color="primary" className="mb-[12px]">{answer.step?.message}</Chip> */} <div className="mb-[8px]">
{ answer.step?.step === 'answering' && ( {/* <Chip color="primary" className="mb-[12px]">{answer.step?.message}</Chip> */}
<Chip color="warning" variant="flat"> { answer.step?.step === 'answering' && (
{answer.step?.message} <Chip color="warning" variant="flat">
</Chip> {answer.step?.message}
)} </Chip>
{answer.step?.step === 'finished' && ( )}
<Chip color="primary" variant="flat" startContent={<CheckIcon />}> {answer.step?.step === 'finished' && (
{answer.step?.message} <Chip color="primary" variant="flat" startContent={<CheckIcon />}>
</Chip> {answer.step?.message}
)} </Chip>
</div> )}
</div>
{!!displayedText.length && ( )}
{!!displayedText.length && !shouldHideAnswerText && (
<div style={{ background: '#F7FAFD' }} className={answer.cardList?.length ? 'mb-[20px]' : ''}> <div style={{ background: '#F7FAFD' }} className={answer.cardList?.length ? 'mb-[20px]' : ''}>
<MarkdownDetail> <MarkdownDetail>
{displayedText} {displayedText}
...@@ -223,9 +224,9 @@ export const ChatAnswerParser: React.FC<ChatAnswerParserProps> = ({ isLastAnswer ...@@ -223,9 +224,9 @@ export const ChatAnswerParser: React.FC<ChatAnswerParserProps> = ({ isLastAnswer
)} )}
{/* 操作区:仅根据卡片类型 / 上层显式 hideOperate 控制是否展示 */} {/* 操作区:仅根据卡片类型 / 上层显式 hideOperate 控制是否展示 */}
{!isTyping && !shouldHideOperate && <ChatAnswerOperate answer={answer} />} {!isTyping && !shouldHideOperate && !shouldHideAnswerText && <ChatAnswerOperate answer={answer} />}
{!isTyping && <div className="flex text-[10px] right-[16px] text-[#d0d1d2] bottom-[4px]">AI生成</div>} {!isTyping && !shouldHideAnswerText && <div className="flex text-[10px] right-[16px] text-[#d0d1d2] bottom-[4px]">AI生成</div>}
</div> </div>
) )
} }
...@@ -19,15 +19,14 @@ export const ChatAnswerShower: React.FC<ChatAnswerShowerProps> = ({ answer, isLa ...@@ -19,15 +19,14 @@ export const ChatAnswerShower: React.FC<ChatAnswerShowerProps> = ({ answer, isLa
const hideOperateByCard = (answer.cardList || []).some(attachment => attachment.type === 'box' || attachment?.type?.includes('card-')) const hideOperateByCard = (answer.cardList || []).some(attachment => attachment.type === 'box' || attachment?.type?.includes('card-'))
const hideOperate = hideOperateByCard || hideOperateProp const hideOperate = hideOperateByCard || hideOperateProp
// 如果 firstQaFlag 为 true 且存在 workflow 卡片,隐藏整个答案内容(表单会自动提交,用户不需要看到这次的结果) // 如果 firstQaFlag 为 true 且存在 workflow 卡片,隐藏答案文本(表单会自动提交,用户不需要看到这次的结果)
// 但保留 ChatAnswerAttachment 的渲染,确保 CardWorkflowForm 的自动提交逻辑能够执行
const hasWorkflowCard = (answer.cardList || []).some(attachment => attachment.type === 'card-workflow') const hasWorkflowCard = (answer.cardList || []).some(attachment => attachment.type === 'card-workflow')
if (answer.firstQaFlag === true && hasWorkflowCard) { const shouldHideAnswerText = answer.firstQaFlag === true && hasWorkflowCard
return null
}
return ( return (
<div className="answerShower"> <div className="answerShower">
{answer.answer && ( {answer.answer && !shouldHideAnswerText && (
<div className={answer.cardList?.length ? 'mb-[12px] sm:mb-[20px]' : ''}> <div className={answer.cardList?.length ? 'mb-[12px] sm:mb-[20px]' : ''}>
<MarkdownDetail> <MarkdownDetail>
{formatMarkdown(answer.answer || '')} {formatMarkdown(answer.answer || '')}
...@@ -45,8 +44,8 @@ export const ChatAnswerShower: React.FC<ChatAnswerShowerProps> = ({ answer, isLa ...@@ -45,8 +44,8 @@ export const ChatAnswerShower: React.FC<ChatAnswerShowerProps> = ({ answer, isLa
/> />
)} )}
{/* 操作区:仅根据卡片类型 / 上层显式 hideOperate 控制是否展示 */} {/* 操作区:仅根据卡片类型 / 上层显式 hideOperate 控制是否展示 */}
{!hideOperate && <ChatAnswerOperate answer={answer} />} {!hideOperate && !shouldHideAnswerText && <ChatAnswerOperate answer={answer} />}
<div className="flex text-[10px] right-[16px] text-[#d0d1d2] bottom-[4px]">AI生成</div> {!shouldHideAnswerText && <div className="flex text-[10px] right-[16px] text-[#d0d1d2] bottom-[4px]">AI生成</div>}
</div> </div>
) )
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment