alpha version

This commit is contained in:
Hk-Gosuto
2024-04-05 17:38:06 +08:00
parent ac57b2c770
commit 958ab02d1e
16 changed files with 1118 additions and 177 deletions

View File

@@ -18,21 +18,25 @@
background-position: center;
background-color: var(--second);
display: flex;
position: relative;
justify-content: center;
align-items: center;
span {
.attach-file-info {
top: 5px;
width: 100%;
position: absolute;
font-size: 12px;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
font-weight: bolder;
text-align: center;
word-wrap: break-word;
word-break: break-all;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
line-height: 1.5;
top: 8px;
bottom: 8px;
left: 5px;
right: 10px;
pointer-events: none;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
}
.attach-file-mask {
@@ -516,6 +520,17 @@
transition: all ease 0.3s;
}
.chat-message-item-files {
display: grid;
grid-template-columns: repeat(var(--file-count), auto);
grid-gap: 5px;
}
.chat-message-item-file {
text-decoration: none;
color: #aaa;
}
.chat-message-item-image {
width: 100%;
margin-top: 10px;

View File

@@ -876,7 +876,7 @@ function _Chat() {
}
setIsLoading(true);
chatStore
.onUserInput(userInput, attachImages)
.onUserInput(userInput, attachImages, attachFiles)
.then(() => setIsLoading(false));
setAttachImages([]);
setAttachFiles([]);
@@ -1106,34 +1106,36 @@ function _Chat() {
// preview messages
const renderMessages = useMemo(() => {
return context
.concat(session.messages as RenderMessage[])
.concat(
isLoading
? [
{
...createMessage({
role: "assistant",
content: "……",
}),
preview: true,
},
]
: [],
)
.concat(
userInput.length > 0 && config.sendPreviewBubble
? [
{
...createMessage({
role: "user",
content: userInput,
}),
preview: true,
},
]
: [],
);
return (
context
.concat(session.messages as RenderMessage[])
// .concat(
// isLoading
// ? [
// {
// ...createMessage({
// role: "assistant",
// content: "……",
// }),
// preview: true,
// },
// ]
// : [],
// )
.concat(
userInput.length > 0 && config.sendPreviewBubble
? [
{
...createMessage({
role: "user",
content: userInput,
}),
preview: true,
},
]
: [],
)
);
}, [
config.sendPreviewBubble,
context,
@@ -1658,6 +1660,29 @@ function _Chat() {
parentRef={scrollRef}
defaultShow={i >= messages.length - 6}
/>
{message.fileInfos && message.fileInfos.length > 0 && (
<nav
className={styles["chat-message-item-files"]}
style={
{
"--file-count": message.fileInfos.length,
} as React.CSSProperties
}
>
{message.fileInfos.map((fileInfo, index) => {
return (
<a
key={index}
href={fileInfo.filePath}
className={styles["chat-message-item-file"]}
target="_blank"
>
{fileInfo.originalFilename}
</a>
);
})}
</nav>
)}
{getMessageImages(message).length == 1 && (
<img
className={styles["chat-message-item-image"]}
@@ -1784,7 +1809,9 @@ function _Chat() {
className={styles["attach-file"]}
title={file.originalFilename}
>
<span>{file.originalFilename}</span>
<div className={styles["attach-file-info"]}>
{file.originalFilename}
</div>
<div className={styles["attach-file-mask"]}>
<DeleteFileButton
deleteFile={() => {