|
|
@@ -83,6 +83,8 @@ import { ExportMessageModal } from "./exporter";
|
|
|
import { getClientConfig } from "../config/client";
|
|
|
import { useAllModels } from "../utils/hooks";
|
|
|
import { nanoid } from "nanoid";
|
|
|
+import { message, Upload, UploadProps } from "antd";
|
|
|
+import { PaperClipOutlined, SendOutlined } from '@ant-design/icons';
|
|
|
|
|
|
export function createMessage(override: Partial<ChatMessage>): ChatMessage {
|
|
|
return {
|
|
|
@@ -864,7 +866,7 @@ function _Chat() {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- const doSubmit = (userInput: string) => {
|
|
|
+ const doSubmit = (userInput: string, fileList?: any[]) => {
|
|
|
if (userInput.trim() === "") return;
|
|
|
const matchCommand = chatCommands.match(userInput);
|
|
|
if (matchCommand.matched) {
|
|
|
@@ -874,12 +876,13 @@ function _Chat() {
|
|
|
return;
|
|
|
}
|
|
|
setIsLoading(true);
|
|
|
- chatStore.onUserInput(userInput, attachImages).then(() => setIsLoading(false));
|
|
|
+ chatStore.onUserInput(fileList || [], userInput, attachImages).then(() => setIsLoading(false));
|
|
|
setAttachImages([]);
|
|
|
localStorage.setItem(LAST_INPUT_KEY, userInput);
|
|
|
setUserInput("");
|
|
|
setPromptHints([]);
|
|
|
if (!isMobileScreen) inputRef.current?.focus();
|
|
|
+ setFileList([]);
|
|
|
setAutoScroll(true);
|
|
|
};
|
|
|
|
|
|
@@ -1025,7 +1028,7 @@ function _Chat() {
|
|
|
setIsLoading(true);
|
|
|
const textContent = getMessageTextContent(userMessage);
|
|
|
const images = getMessageImages(userMessage);
|
|
|
- chatStore.onUserInput(textContent, images).then(() => setIsLoading(false));
|
|
|
+ chatStore.onUserInput([], textContent, images).then(() => setIsLoading(false));
|
|
|
inputRef.current?.focus();
|
|
|
};
|
|
|
|
|
|
@@ -1303,6 +1306,15 @@ function _Chat() {
|
|
|
setAttachImages(images);
|
|
|
}
|
|
|
|
|
|
+ const [fileList, setFileList] = useState<any[]>([]);
|
|
|
+
|
|
|
+ // 上传配置
|
|
|
+ const uploadConfig: UploadProps = {
|
|
|
+ action: '/deepseek-api' + '/upload/file',
|
|
|
+ method: 'POST',
|
|
|
+ accept: ['.pdf', '.txt', '.doc', '.docx'].join(','),
|
|
|
+ };
|
|
|
+
|
|
|
return (
|
|
|
<div className={styles.chat} key={session.id}>
|
|
|
{
|
|
|
@@ -1443,6 +1455,17 @@ function _Chat() {
|
|
|
onSearch("");
|
|
|
}}
|
|
|
/>
|
|
|
+ {
|
|
|
+ fileList.length > 0 &&
|
|
|
+ <div style={{ marginBottom: 20 }}>
|
|
|
+ <Upload
|
|
|
+ fileList={fileList}
|
|
|
+ onRemove={(file) => {
|
|
|
+ setFileList(fileList.filter(item => item.uid !== file.uid));
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ }
|
|
|
<label
|
|
|
className={`${styles["chat-input-panel-inner"]} ${attachImages.length != 0
|
|
|
? styles["chat-input-panel-inner-attach"]
|
|
|
@@ -1511,28 +1534,74 @@ function _Chat() {
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div
|
|
|
- style={{ width: 35, height: 35, borderRadius: '50%', background: '#4357d2', display: 'flex', justifyContent: 'center', alignItems: 'center' }}
|
|
|
- onClick={() => doSubmit(userInput)}
|
|
|
- >
|
|
|
- <SendWhiteIcon />
|
|
|
+ <div style={{ display: 'flex', alignItems: 'center' }}>
|
|
|
+ <div style={{ marginRight: 20 }}>
|
|
|
+ <Upload
|
|
|
+ {...uploadConfig}
|
|
|
+ showUploadList={false}
|
|
|
+ maxCount={1}
|
|
|
+ onChange={(info) => {
|
|
|
+ const fileList = info.fileList.map((file) => {
|
|
|
+ const data = file.response;
|
|
|
+ return {
|
|
|
+ ...file,
|
|
|
+ url: data?.document_url || file.url,
|
|
|
+ documentId: data?.document_id || '',
|
|
|
+ }
|
|
|
+ });
|
|
|
+ setFileList(fileList);
|
|
|
+ if (info.file.status === 'done') {// 上传成功
|
|
|
+ const { code, message: msg } = info.file.response;
|
|
|
+ if (code === 200) {
|
|
|
+ message.success('上传成功');
|
|
|
+ } else {
|
|
|
+ message.error(msg);
|
|
|
+ }
|
|
|
+ } else if (info.file.status === 'error') {// 上传失败
|
|
|
+ message.error('上传失败');
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <div
|
|
|
+ style={{
|
|
|
+ width: 35, height: 35, borderRadius: '50%', background: '#4357d2', display: 'flex', justifyContent: 'center', alignItems: 'center', cursor: 'pointer'
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <PaperClipOutlined style={{ color: '#FFFFFF', fontSize: '18px' }} />
|
|
|
+ </div>
|
|
|
+ </Upload>
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ style={{
|
|
|
+ width: 35, height: 35, borderRadius: '50%', background: '#4357d2', display: 'flex', justifyContent: 'center', alignItems: 'center', cursor: 'pointer'
|
|
|
+ }}
|
|
|
+ onClick={() => doSubmit(userInput, fileList)}
|
|
|
+ >
|
|
|
+ <div style={{ transform: 'rotate(-45deg)', padding: '0px 0px 3px 5px' }}>
|
|
|
+ <SendOutlined style={{ color: '#FFFFFF' }} />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div style={{ marginTop: 10, textAlign: 'center', color: '#888888', fontSize: 12 }}>
|
|
|
内容由AI生成,仅供参考
|
|
|
</div>
|
|
|
</div>
|
|
|
- {showExport && (
|
|
|
- <ExportMessageModal onClose={() => setShowExport(false)} />
|
|
|
- )}
|
|
|
- {isEditingMessage && (
|
|
|
- <EditMessageModal
|
|
|
- onClose={() => {
|
|
|
- setIsEditingMessage(false);
|
|
|
- }}
|
|
|
- />
|
|
|
- )}
|
|
|
- </div>
|
|
|
+ {
|
|
|
+ showExport && (
|
|
|
+ <ExportMessageModal onClose={() => setShowExport(false)} />
|
|
|
+ )
|
|
|
+ }
|
|
|
+ {
|
|
|
+ isEditingMessage && (
|
|
|
+ <EditMessageModal
|
|
|
+ onClose={() => {
|
|
|
+ setIsEditingMessage(false);
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ )
|
|
|
+ }
|
|
|
+ </div >
|
|
|
);
|
|
|
}
|
|
|
|