Commit 6d1f74bd by HoMeTown

feat: 新增了大于5轮弹出开启新对话的按钮

parent 0cbee674
...@@ -108,7 +108,7 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth, ...@@ -108,7 +108,7 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
) )
return ( return (
<div className="ask-input flex items-end w-full h-auto relative mx-auto bg-white rounded-[36px] overflow-hidden transition duration-200 py-[8px] pl-[12px] pr-[12px] sm:py-[12px] sm:pl-[32px] sm:pr-[20px]"> <div className="border-1 border-[#f6f6f6] ask-input flex items-end w-full h-auto relative mx-auto bg-white rounded-[36px] overflow-hidden transition duration-200 py-[8px] pl-[12px] pr-[12px] sm:py-[12px] sm:pl-[32px] sm:pr-[20px]">
<div <div
ref={editorRef} ref={editorRef}
contentEditable contentEditable
......
...@@ -15,7 +15,7 @@ import { ChatEditor } from '@/components/ChatEditor' ...@@ -15,7 +15,7 @@ import { ChatEditor } from '@/components/ChatEditor'
import type { ChatRecord } from '@/types/chat' import type { ChatRecord } from '@/types/chat'
import { fetchUserQaRecordPage } from '@/api/conversation' import { fetchUserQaRecordPage } from '@/api/conversation'
import { fetchCheckTokenApi, fetchStreamResponse } from '@/api/chat' import { fetchCheckTokenApi, fetchStreamResponse } from '@/api/chat'
import { clearShouldSendQuestion, fetchConversations } from '@/store/conversationSlice' import { clearShouldSendQuestion, createConversation, fetchConversations } from '@/store/conversationSlice'
import type { RootState } from '@/store' import type { RootState } from '@/store'
import { useAppDispatch, useAppSelector } from '@/store/hook' import { useAppDispatch, useAppSelector } from '@/store/hook'
import ScrollBtoIcon from '@/assets/svg/scrollBto.svg?react' import ScrollBtoIcon from '@/assets/svg/scrollBto.svg?react'
...@@ -190,6 +190,14 @@ export const Chat: React.FC = () => { ...@@ -190,6 +190,14 @@ export const Chat: React.FC = () => {
scrollableRef.current.scrollTo(scrollableRef.current.scrollHeight, { behavior: 'smooth' }) scrollableRef.current.scrollTo(scrollableRef.current.scrollHeight, { behavior: 'smooth' })
} }
const handleCreateConversation = () => {
dispatch(createConversation({
conversationData: {},
shouldNavigate: true,
shouldSendQuestion: '',
}))
}
useEffect(() => { useEffect(() => {
if (id) { if (id) {
if (!ignore) { if (!ignore) {
...@@ -227,6 +235,11 @@ export const Chat: React.FC = () => { ...@@ -227,6 +235,11 @@ export const Chat: React.FC = () => {
{record.role === 'ai' && <ChatAnswerBox onSubmitQuestion={handleSubmitQuestion} isLastAnswer={index === allItems.length - 1} showIndex={0} record={record} index={index} />} {record.role === 'ai' && <ChatAnswerBox onSubmitQuestion={handleSubmitQuestion} isLastAnswer={index === allItems.length - 1} showIndex={0} record={record} index={index} />}
</div> </div>
))} ))}
{allItems.length >= 11 && (
<div className="w-full chatItem max-w-[912px] mx-auto text-center">
<Button className="bg-white text-[#20ABD9] font-medium rounded-[20px] sm:w-auto" onPress={handleCreateConversation}>开启新对话 ➔</Button>
</div>
)}
</div> </div>
</motion.div> </motion.div>
)} )}
......
...@@ -53,7 +53,7 @@ export const ChatAnswerBox: React.FC<ChatAnswerBoxProps> = ({ record, showIndex, ...@@ -53,7 +53,7 @@ export const ChatAnswerBox: React.FC<ChatAnswerBoxProps> = ({ record, showIndex,
index === showIndex && ( index === showIndex && (
<div className="chatItemBotContainer w-full" key={`${item.recordId}-${index}`}> <div className="chatItemBotContainer w-full" key={`${item.recordId}-${index}`}>
<div className="flex"> <div className="flex">
<Avatar className="sm:mr-[20px] hidden sm:block flex-shrink-0" src={AvatarBot} /> <Avatar className="sm:mr-[16px] hidden sm:block flex-shrink-0" src={AvatarBot} />
<div <div
className="bg-white rounded-[20px] box-border px-[16px] py-[12px] sm:px-[24px] sm:py-[20px] relative" className="bg-white rounded-[20px] box-border px-[16px] py-[12px] sm:px-[24px] sm:py-[20px] relative"
> >
......
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