Commit 5b082fd7 by weiyudumei

feat: 历史记录中如果 firstQaFlag 为 true 则不展示该条 chatItem

parent eb862599
...@@ -949,6 +949,11 @@ export const Chat: React.FC = () => { ...@@ -949,6 +949,11 @@ export const Chat: React.FC = () => {
> >
<div className={styles.inter}> <div className={styles.inter}>
{allItems.map((record, index) => { {allItems.map((record, index) => {
// 如果历史记录中 firstQaFlag 为 true,则不展示该条 chatItem
if (record.role === 'ai' && record.answerList?.[0]?.firstQaFlag === true) {
return null
}
const recordId = record.answerList?.[0]?.recordId || record.groupId const recordId = record.answerList?.[0]?.recordId || record.groupId
const uniqueKey = recordId const uniqueKey = recordId
? `${record.role}-${recordId}` ? `${record.role}-${recordId}`
......
...@@ -391,11 +391,11 @@ export const TacticsChat: React.FC = () => { ...@@ -391,11 +391,11 @@ export const TacticsChat: React.FC = () => {
...prevItems, ...prevItems,
...(shouldIncludeQuestion ...(shouldIncludeQuestion
? [ ? [
{ {
role: 'user', role: 'user',
question, question,
} as ChatRecord, } as ChatRecord,
] ]
: []), : []),
{ {
role: 'ai', role: 'ai',
...@@ -500,12 +500,12 @@ export const TacticsChat: React.FC = () => { ...@@ -500,12 +500,12 @@ export const TacticsChat: React.FC = () => {
if (extra?.recordId) { if (extra?.recordId) {
requestBody.recordId = extra.recordId requestBody.recordId = extra.recordId
} }
// workFlowSessionId 的传递逻辑: // workFlowSessionId 的传递逻辑:
// 1. 如果是重新分析(isReanalyze === true),不传递 workFlowSessionId // 1. 如果是重新分析(isReanalyze === true),不传递 workFlowSessionId
// 2. 优先使用 extra 中的值 // 2. 优先使用 extra 中的值
// 3. 如果都没有,从会话历史中找到最后一个有 workFlowSessionId 的答案 // 3. 如果都没有,从会话历史中找到最后一个有 workFlowSessionId 的答案
const isReanalyze = extra?.isReanalyze === true // 注意:isReanalyze 已在上面声明(第 366 行),这里直接使用
if (!isReanalyze) { if (!isReanalyze) {
if (extra?.workFlowSessionId) { if (extra?.workFlowSessionId) {
requestBody.workFlowSessionId = extra.workFlowSessionId requestBody.workFlowSessionId = extra.workFlowSessionId
...@@ -1063,7 +1063,7 @@ export const TacticsChat: React.FC = () => { ...@@ -1063,7 +1063,7 @@ export const TacticsChat: React.FC = () => {
if (recordId) { if (recordId) {
extraParams.recordId = recordId extraParams.recordId = recordId
} }
if (orderMeta) { if (orderMeta) {
return handleSubmitQuestion( return handleSubmitQuestion(
question, question,
...@@ -1139,11 +1139,10 @@ export const TacticsChat: React.FC = () => { ...@@ -1139,11 +1139,10 @@ export const TacticsChat: React.FC = () => {
type="button" type="button"
onClick={handleReanalyze} onClick={handleReanalyze}
disabled={!currentIdRef.current || isLoading || isAsking || isRecommendLoading} disabled={!currentIdRef.current || isLoading || isAsking || isRecommendLoading}
className={`flex items-center gap-[4px] text-[14px] transition-opacity bg-transparent border-none outline-none ${ className={`flex items-center gap-[4px] text-[14px] transition-opacity bg-transparent border-none outline-none ${!currentIdRef.current || isLoading || isAsking || isRecommendLoading
!currentIdRef.current || isLoading || isAsking || isRecommendLoading ? 'text-[#B2B8C1] cursor-not-allowed opacity-60'
? 'text-[#B2B8C1] cursor-not-allowed opacity-60' : 'text-[#4A90E2] hover:opacity-80 cursor-pointer'
: 'text-[#4A90E2] hover:opacity-80 cursor-pointer' }`}
}`}
> >
<RefreshIcon className="w-[16px] h-[16px] text-[#B2B8C1]" /> <RefreshIcon className="w-[16px] h-[16px] text-[#B2B8C1]" />
<span>重新分析</span> <span>重新分析</span>
...@@ -1196,6 +1195,10 @@ export const TacticsChat: React.FC = () => { ...@@ -1196,6 +1195,10 @@ export const TacticsChat: React.FC = () => {
if (record.role === 'user' && !record.question) { if (record.role === 'user' && !record.question) {
return null return null
} }
// 如果历史记录中 firstQaFlag 为 true,则不展示该条 chatItem
if (record.role === 'ai' && record.answerList?.[0]?.firstQaFlag === true) {
return null
}
const matchedDivider = historyDividers.find(divider => divider.index === index + 1) const matchedDivider = historyDividers.find(divider => divider.index === index + 1)
const recordId = record.answerList?.[0]?.recordId || record.groupId const recordId = record.answerList?.[0]?.recordId || record.groupId
const uniqueKey = recordId const uniqueKey = recordId
...@@ -1214,7 +1217,7 @@ export const TacticsChat: React.FC = () => { ...@@ -1214,7 +1217,7 @@ export const TacticsChat: React.FC = () => {
<div <div
className="w-full chatItem mx-auto" className="w-full chatItem mx-auto"
> >
{record.role === 'system' && <TacticsWelcome cleared={hasCleared} />} {record.role === 'system' && <TacticsWelcome cleared={hasCleared} />}
{record.role === 'user' && <ChatItemUser record={record} />} {record.role === 'user' && <ChatItemUser record={record} />}
{record.role === 'ai' && ( {record.role === 'ai' && (
<ChatAnswerBox <ChatAnswerBox
......
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