feat: 论文搜索完成进行提示
This commit is contained in:
parent
93f8889c57
commit
6c37459fe3
|
@ -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%;
|
||||
}
|
||||
|
|
34
components/Notification.tsx
Normal file
34
components/Notification.tsx
Normal 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",
|
||||
});
|
||||
};
|
|
@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user