4.8-alpha fix (#1424)

This commit is contained in:
Archer
2024-05-09 22:48:44 +08:00
committed by GitHub
parent 6463427d93
commit 434af56abd
19 changed files with 255 additions and 148 deletions

View File

@@ -55,6 +55,8 @@ const MessageInput = ({
const { t } = useTranslation();
const havInput = !!inputValue || fileList.length > 0;
const hasFileUploading = fileList.some((item) => !item.url);
const canSendMessage = havInput && !hasFileUploading;
/* file selector and upload */
const { File, onOpen: onOpenSelectFile } = useSelectFile({
@@ -142,7 +144,8 @@ const MessageInput = ({
);
/* on send */
const handleSend = useCallback(async () => {
const handleSend = async () => {
if (!canSendMessage) return;
const textareaValue = TextareaDom.current?.value || '';
onSendMessage({
@@ -150,7 +153,7 @@ const MessageInput = ({
files: fileList
});
replaceFile([]);
}, [TextareaDom, fileList, onSendMessage, replaceFile]);
};
/* whisper init */
const {
@@ -466,16 +469,20 @@ const MessageInput = ({
h={['28px', '32px']}
w={['28px', '32px']}
borderRadius={'md'}
bg={isSpeaking || isChatting ? '' : !havInput ? '#E5E5E5' : 'primary.500'}
bg={
isSpeaking || isChatting
? ''
: !havInput || hasFileUploading
? '#E5E5E5'
: 'primary.500'
}
cursor={havInput ? 'pointer' : 'not-allowed'}
lineHeight={1}
onClick={() => {
if (isChatting) {
return onStop();
}
if (havInput) {
return handleSend();
}
return handleSend();
}}
>
{isChatting ? (

View File

@@ -53,7 +53,7 @@ const Markdown = ({
);
const formatSource = source
.replace(/\\n/g, '\n ')
// .replace(/\\n/g, '\n')
.replace(/(http[s]?:\/\/[^\s。]+)([。,])/g, '$1 $2')
.replace(/\n*(\[QUOTE SIGN\]\(.*\))/g, '$1');