mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-14 20:56:13 +08:00
Optimized the chat interface (including the chat API after sharing) (#1215)
### What problem does this PR solve? Optimized the chat interface (including the chat API after sharing) 1. Change the background color of the dialog box between the assistant and the user (use the theme color of the interface) 2. Add rounded corners to the dialog box 3. When the input box is empty, you can't click the send button(because some models will report an error when sending empty data) Color reference(can be a bit subjective):  ### Type of change - [x] Refactor Co-authored-by: 海贼宅 <stu_xyx@163.com>
This commit is contained in:
parent
9fcf9a10c6
commit
80163c043e
@ -27,8 +27,18 @@
|
|||||||
.messageText {
|
.messageText {
|
||||||
.chunkText();
|
.chunkText();
|
||||||
padding: 0 14px;
|
padding: 0 14px;
|
||||||
background-color: rgba(249, 250, 251, 1);
|
background-color: rgb(230, 230, 232);
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
.messageUserText {
|
||||||
|
.chunkText();
|
||||||
|
padding: 0 14px;
|
||||||
|
background-color: rgb(45, 100, 245);
|
||||||
|
word-break: break-all;
|
||||||
|
border-radius: 10px;
|
||||||
|
color: #fdfdfd;
|
||||||
|
text-align: justify;
|
||||||
}
|
}
|
||||||
.messageEmpty {
|
.messageEmpty {
|
||||||
width: 300px;
|
width: 300px;
|
||||||
|
@ -14,7 +14,7 @@ import {
|
|||||||
useFetchConversationOnMount,
|
useFetchConversationOnMount,
|
||||||
useGetFileIcon,
|
useGetFileIcon,
|
||||||
useGetSendButtonDisabled,
|
useGetSendButtonDisabled,
|
||||||
useSelectConversationLoading,
|
useSelectConversationLoading, useSendButtonDisabled,
|
||||||
useSendMessage,
|
useSendMessage,
|
||||||
} from '../hooks';
|
} from '../hooks';
|
||||||
import MarkdownContent from '../markdown-content';
|
import MarkdownContent from '../markdown-content';
|
||||||
@ -87,7 +87,7 @@ const MessageItem = ({
|
|||||||
)}
|
)}
|
||||||
<Flex vertical gap={8} flex={1}>
|
<Flex vertical gap={8} flex={1}>
|
||||||
<b>{isAssistant ? '' : userInfo.nickname}</b>
|
<b>{isAssistant ? '' : userInfo.nickname}</b>
|
||||||
<div className={styles.messageText}>
|
<div className={isAssistant ? styles.messageText : styles.messageUserText}>
|
||||||
<MarkdownContent
|
<MarkdownContent
|
||||||
content={content}
|
content={content}
|
||||||
reference={reference}
|
reference={reference}
|
||||||
@ -157,6 +157,7 @@ const ChatContainer = () => {
|
|||||||
const { visible, hideModal, documentId, selectedChunk, clickDocumentButton } =
|
const { visible, hideModal, documentId, selectedChunk, clickDocumentButton } =
|
||||||
useClickDrawer();
|
useClickDrawer();
|
||||||
const disabled = useGetSendButtonDisabled();
|
const disabled = useGetSendButtonDisabled();
|
||||||
|
const sendDisabled = useSendButtonDisabled(value);
|
||||||
useGetFileIcon();
|
useGetFileIcon();
|
||||||
const loading = useSelectConversationLoading();
|
const loading = useSelectConversationLoading();
|
||||||
const { t } = useTranslate('chat');
|
const { t } = useTranslate('chat');
|
||||||
@ -196,7 +197,7 @@ const ChatContainer = () => {
|
|||||||
type="primary"
|
type="primary"
|
||||||
onClick={handlePressEnter}
|
onClick={handlePressEnter}
|
||||||
loading={sendLoading}
|
loading={sendLoading}
|
||||||
disabled={disabled}
|
disabled={sendDisabled}
|
||||||
>
|
>
|
||||||
{t('send')}
|
{t('send')}
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -54,6 +54,7 @@ import {
|
|||||||
} from './interface';
|
} from './interface';
|
||||||
import { ChatModelState } from './model';
|
import { ChatModelState } from './model';
|
||||||
import { isConversationIdExist } from './utils';
|
import { isConversationIdExist } from './utils';
|
||||||
|
import {public_path} from "@/utils/api";
|
||||||
|
|
||||||
export const useSelectCurrentDialog = () => {
|
export const useSelectCurrentDialog = () => {
|
||||||
const currentDialog: IDialog = useSelector(
|
const currentDialog: IDialog = useSelector(
|
||||||
@ -630,6 +631,7 @@ export const useSendMessage = (
|
|||||||
handlePressEnter,
|
handlePressEnter,
|
||||||
handleInputChange,
|
handleInputChange,
|
||||||
value,
|
value,
|
||||||
|
setValue,
|
||||||
loading: !done,
|
loading: !done,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -762,6 +764,10 @@ export const useGetSendButtonDisabled = () => {
|
|||||||
|
|
||||||
return dialogId === '' && conversationId === '';
|
return dialogId === '' && conversationId === '';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const useSendButtonDisabled = (value: string) => {
|
||||||
|
return value === '';
|
||||||
|
};
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region API provided for external calls
|
//#region API provided for external calls
|
||||||
|
@ -33,8 +33,18 @@
|
|||||||
.messageText {
|
.messageText {
|
||||||
.chunkText();
|
.chunkText();
|
||||||
padding: 0 14px;
|
padding: 0 14px;
|
||||||
background-color: rgba(249, 250, 251, 1);
|
background-color: rgb(230, 230, 232);
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
.messageUserText {
|
||||||
|
.chunkText();
|
||||||
|
padding: 0 14px;
|
||||||
|
background-color: rgb(45, 100, 245);
|
||||||
|
word-break: break-all;
|
||||||
|
border-radius: 10px;
|
||||||
|
color: #fdfdfd;
|
||||||
|
text-align: justify;
|
||||||
}
|
}
|
||||||
.messageEmpty {
|
.messageEmpty {
|
||||||
width: 300px;
|
width: 300px;
|
||||||
|
@ -19,6 +19,7 @@ import {
|
|||||||
} from '../shared-hooks';
|
} from '../shared-hooks';
|
||||||
import { buildMessageItemReference } from '../utils';
|
import { buildMessageItemReference } from '../utils';
|
||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
|
import {useSendButtonDisabled} from "@/pages/chat/hooks";
|
||||||
|
|
||||||
const MessageItem = ({
|
const MessageItem = ({
|
||||||
item,
|
item,
|
||||||
@ -76,7 +77,7 @@ const MessageItem = ({
|
|||||||
)}
|
)}
|
||||||
<Flex vertical gap={8} flex={1}>
|
<Flex vertical gap={8} flex={1}>
|
||||||
<b>{isAssistant ? '' : 'You'}</b>
|
<b>{isAssistant ? '' : 'You'}</b>
|
||||||
<div className={styles.messageText}>
|
<div className={isAssistant ? styles.messageText : styles.messageUserText}>
|
||||||
<MarkdownContent
|
<MarkdownContent
|
||||||
reference={reference}
|
reference={reference}
|
||||||
clickDocumentButton={() => {}}
|
clickDocumentButton={() => {}}
|
||||||
@ -149,6 +150,7 @@ const ChatContainer = () => {
|
|||||||
setCurrentConversation,
|
setCurrentConversation,
|
||||||
addNewestAnswer,
|
addNewestAnswer,
|
||||||
);
|
);
|
||||||
|
const sendDisabled = useSendButtonDisabled(value);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -184,7 +186,7 @@ const ChatContainer = () => {
|
|||||||
type="primary"
|
type="primary"
|
||||||
onClick={handlePressEnter}
|
onClick={handlePressEnter}
|
||||||
loading={sendLoading}
|
loading={sendLoading}
|
||||||
// disabled={disabled}
|
disabled={sendDisabled}
|
||||||
>
|
>
|
||||||
{t('send')}
|
{t('send')}
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -133,6 +133,10 @@ export const useSelectCurrentSharedConversation = (conversationId: string) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const useSendButtonDisabled = (value: string) => {
|
||||||
|
return value === '';
|
||||||
|
};
|
||||||
|
|
||||||
export const useSendSharedMessage = (
|
export const useSendSharedMessage = (
|
||||||
conversation: IClientConversation,
|
conversation: IClientConversation,
|
||||||
addNewestConversation: (message: string) => void,
|
addNewestConversation: (message: string) => void,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user