|
|
@@ -84,7 +84,7 @@ 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';
|
|
|
+import { PaperClipOutlined, SendOutlined, FileOutlined, FilePdfOutlined, FileTextOutlined, FileWordOutlined } from '@ant-design/icons';
|
|
|
|
|
|
export function createMessage(override: Partial<ChatMessage>): ChatMessage {
|
|
|
return {
|
|
|
@@ -1315,6 +1315,37 @@ function _Chat() {
|
|
|
accept: ['.pdf', '.txt', '.doc', '.docx'].join(','),
|
|
|
};
|
|
|
|
|
|
+ interface FileIconProps {
|
|
|
+ fileName: string;
|
|
|
+ }
|
|
|
+
|
|
|
+ const FileIcon: React.FC<FileIconProps> = (props: FileIconProps) => {
|
|
|
+ const style = {
|
|
|
+ fontSize: '30px',
|
|
|
+ color: '#3875f6',
|
|
|
+ }
|
|
|
+
|
|
|
+ let icon = <FileOutlined style={style} />
|
|
|
+ if (props.fileName) {
|
|
|
+ const suffix = props.fileName.split('.').pop() || '';
|
|
|
+ switch (suffix) {
|
|
|
+ case 'pdf':
|
|
|
+ icon = <FilePdfOutlined style={style} />
|
|
|
+ break;
|
|
|
+ case 'txt':
|
|
|
+ icon = <FileTextOutlined style={style} />
|
|
|
+ break;
|
|
|
+ case 'doc':
|
|
|
+ case 'docx':
|
|
|
+ icon = <FileWordOutlined style={style} />
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return icon;
|
|
|
+ }
|
|
|
+
|
|
|
return (
|
|
|
<div className={styles.chat} key={session.id}>
|
|
|
{
|
|
|
@@ -1362,7 +1393,7 @@ function _Chat() {
|
|
|
isUser ? styles["chat-message-user"] : styles["chat-message"]
|
|
|
}
|
|
|
>
|
|
|
- <div className={styles["chat-message-container"]} style={{ display: 'flex', flexDirection: 'row' }}>
|
|
|
+ <div className={styles["chat-message-container"]} style={{ display: 'flex', flexDirection: isUser ? 'column' : 'row' }}>
|
|
|
<div className={styles["chat-message-header"]}>
|
|
|
<div className={styles["chat-message-avatar"]}>
|
|
|
{isUser ? null : (
|
|
|
@@ -1370,12 +1401,15 @@ function _Chat() {
|
|
|
)}
|
|
|
</div>
|
|
|
</div>
|
|
|
- {/* {
|
|
|
- isUser && message.document && message.document.url &&
|
|
|
- <div>
|
|
|
- {message.document.url}
|
|
|
- </div>
|
|
|
- } */}
|
|
|
+ {
|
|
|
+ isUser && message.document && message.document.id &&
|
|
|
+ <a style={{ padding: '10px', background: '#f7f7f7', borderRadius: '10px', textDecoration: 'none', color: '#24292f', display: 'flex', alignItems: 'center' }} href={message.document.url} target="_blank">
|
|
|
+ <FileIcon fileName={message.document.name} />
|
|
|
+ <div style={{ marginLeft: 10 }}>
|
|
|
+ {message.document.name}
|
|
|
+ </div>
|
|
|
+ </a>
|
|
|
+ }
|
|
|
{/* {showTyping && (
|
|
|
<div className={styles["chat-message-status"]}>
|
|
|
正在输入…
|