|
|
@ -1,6 +1,10 @@
|
|
|
|
import { Message } from "@/store/zustand/message";
|
|
|
|
import { Message } from "@/store/zustand/message";
|
|
|
|
import { marked } from "@/labs/marked";
|
|
|
|
import { marked } from "@/labs/marked";
|
|
|
|
import Icon from "@/components/Icon";
|
|
|
|
import Icon from "@/components/Icon";
|
|
|
|
|
|
|
|
import Dropdown from "../kit/Dropdown";
|
|
|
|
|
|
|
|
import { useMemoStore } from "@/store/module";
|
|
|
|
|
|
|
|
import toast from "react-hot-toast";
|
|
|
|
|
|
|
|
import { useTranslate } from "@/utils/i18n";
|
|
|
|
|
|
|
|
|
|
|
|
interface MessageProps {
|
|
|
|
interface MessageProps {
|
|
|
|
index: number;
|
|
|
|
index: number;
|
|
|
@ -8,6 +12,19 @@ interface MessageProps {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const ChatMessage = ({ index, message }: MessageProps) => {
|
|
|
|
const ChatMessage = ({ index, message }: MessageProps) => {
|
|
|
|
|
|
|
|
const memoStore = useMemoStore();
|
|
|
|
|
|
|
|
const t = useTranslate();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleSaveAsMemos = async () => {
|
|
|
|
|
|
|
|
await memoStore.createMemo({
|
|
|
|
|
|
|
|
content: message.content,
|
|
|
|
|
|
|
|
visibility: "PRIVATE",
|
|
|
|
|
|
|
|
resourceIdList: [],
|
|
|
|
|
|
|
|
relationList: [],
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
toast.success(t("memo-chat.save-as-memo-success"));
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div key={index} className="w-full flex flex-col justify-start items-start space-y-2">
|
|
|
|
<div key={index} className="w-full flex flex-col justify-start items-start space-y-2">
|
|
|
|
{message.role === "user" ? (
|
|
|
|
{message.role === "user" ? (
|
|
|
@ -22,6 +39,18 @@ const ChatMessage = ({ index, message }: MessageProps) => {
|
|
|
|
<div className="memo-content-wrapper !w-auto flex flex-col justify-start items-start shadow rounded-lg rounded-tl-none px-3 py-2 bg-white dark:bg-zinc-800">
|
|
|
|
<div className="memo-content-wrapper !w-auto flex flex-col justify-start items-start shadow rounded-lg rounded-tl-none px-3 py-2 bg-white dark:bg-zinc-800">
|
|
|
|
<div className="memo-content-text">{marked(message.content)}</div>
|
|
|
|
<div className="memo-content-text">{marked(message.content)}</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<Dropdown
|
|
|
|
|
|
|
|
actions={
|
|
|
|
|
|
|
|
<>
|
|
|
|
|
|
|
|
<button
|
|
|
|
|
|
|
|
className="w-full m-auto text-left text-sm whitespace-nowrap leading-6 py-1 px-3 cursor-pointer rounded hover:bg-gray-100 dark:hover:bg-zinc-600"
|
|
|
|
|
|
|
|
onClick={() => handleSaveAsMemos()}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
{t("memo-chat.save-as-memo")}
|
|
|
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
</>
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|