feat: 论文搜索完成进行提示

This commit is contained in:
liuweiqing 2024-02-24 12:07:55 +08:00
parent 93f8889c57
commit 6c37459fe3
3 changed files with 42 additions and 4 deletions

View File

@ -167,3 +167,8 @@
transform: scale(1.2); /* 放大到原大小的1.2倍 */
transition: transform 0.3s ease; /* 平滑过渡效果 */
}
/* 去除toast的最大宽度限制 */
.Toastify__toast-container--top-center:has(div.toastDetail) {
width: 80%;
}

View File

@ -0,0 +1,34 @@
import React, { useState } from "react";
import { toast } from "react-toastify";
// 自定义Toast内容组件
const ExpandableToastContent = ({ fullText }) => {
const [isExpanded, setIsExpanded] = useState(false);
const toggleExpand = () => setIsExpanded(!isExpanded);
return (
<div className="w-full max-w-none p-4 bg-white rounded-lg shadow dark:bg-gray-800">
{/* 可以继续添加更多的Tailwind CSS类来定制外观 */}
<div className="text-sm text-gray-500 dark:text-gray-400">
{isExpanded ? fullText : `${fullText.substring(0, 100)}...`}
</div>
<button
onClick={toggleExpand}
className="mt-2 text-blue-500 hover:text-blue-600 dark:hover:text-blue-400"
>
{isExpanded ? "Show Less" : "Show More"}
</button>
</div>
);
};
// 使用自定义Toast内容的函数
export const showExpandableToast = (message: string) => {
toast(<ExpandableToastContent fullText={message} />, {
position: "top-center",
autoClose: 5000,
pauseOnHover: true,
className: "toastDetail",
});
};

View File

@ -47,6 +47,7 @@ import { useTranslation } from "@/app/i18n/client";
//notification
import { ToastContainer, toast } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";
import { showExpandableToast } from "@/components/Notification";
const toolbarOptions = [
["bold", "italic", "underline", "strike"], // 加粗、斜体、下划线和删除线
@ -430,10 +431,7 @@ const QEditor = ({ lng }) => {
quill!,
800
)},搜索到的论文内容:${trimmedMessage},${topic},`;
// toast.info(`搜索论文完成,内容:${content}`, {
// position: "top-right",
// autoClose: 5000,
// });
showExpandableToast(`搜索论文完成,搜索到的论文:${trimmedMessage}`);
await sendMessageToOpenAI(
content,
quill!,
@ -474,6 +472,7 @@ const QEditor = ({ lng }) => {
toast.error(`Paper2AI出现错误: ${error}`, {
position: "top-center",
autoClose: 5000,
pauseOnHover: true,
});
}
}