From 49a757f6c7d2a18bbde0e95cf57d4aaf5127e24c Mon Sep 17 00:00:00 2001 From: liuweiqing Date: Fri, 23 Feb 2024 20:59:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E4=BA=86=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E8=8C=83=E5=9B=B4=E9=80=89=E6=8B=A9,=E9=99=A4arxiv?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/i18n/locales/en/translation.json | 2 ++ app/i18n/locales/zh-CN/translation.json | 2 ++ components/GetPubMed .tsx | 2 +- components/QuillEditor.tsx | 31 +++++++++++++++++++++++-- 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/app/i18n/locales/en/translation.json b/app/i18n/locales/en/translation.json index 09378845..415c9825 100644 --- a/app/i18n/locales/en/translation.json +++ b/app/i18n/locales/en/translation.json @@ -4,6 +4,8 @@ "AI写作": "AI writing", "Paper2AI": "Paper2AI", "点击AI写作就是正常的对话交流,点击寻找文献会根据输入的主题词去寻找对应论文": "Click AI Write for normal conversation, click Paper2AI to find corresponding papers based on the input topic", + "生成轮数": "Generation Rounds", + "时间范围": "Range of literature release dates, from this time to this year", "+ Add Paper": "+ Add Paper", "Buy VIP TO UNLOCK Cloud Sync and Edit Mutiple Papers Simultaneously": "Buy VIP TO UNLOCK Cloud Sync and Edit Mutiple Papers Simultaneously", "Paper Management": "Paper Management", diff --git a/app/i18n/locales/zh-CN/translation.json b/app/i18n/locales/zh-CN/translation.json index a10a3699..f0b4eb27 100644 --- a/app/i18n/locales/zh-CN/translation.json +++ b/app/i18n/locales/zh-CN/translation.json @@ -4,6 +4,8 @@ "AI写作": "AI写作", "Paper2AI": "寻找文献", "点击AI写作就是正常的对话交流,点击寻找文献会根据输入的主题词去寻找对应论文": "点击AI写作就是正常的对话交流,点击寻找文献会根据输入的主题词去寻找对应论文", + "生成轮数": "生成轮数", + "时间范围": "文献发布日期范围,从这个时间到今年", "+ Add Paper": "+ 添加新论文(会直接替换编辑器里的内容)", "Buy VIP TO UNLOCK Cloud Sync and Edit Mutiple Papers Simultaneously": "购买VIP解锁云同步和同时编辑多篇论文", "Paper Management": "论文管理", diff --git a/components/GetPubMed .tsx b/components/GetPubMed .tsx index 07928041..9d760257 100644 --- a/components/GetPubMed .tsx +++ b/components/GetPubMed .tsx @@ -23,7 +23,7 @@ async function getPubMedPapers( const retMax = limit; // 检索的最大记录数 const maxOffset = 20 - limit; // 假设总记录数为 20 if (offset === -1) offset = getRandomOffset(maxOffset); - const url = `${baseURL}?db=${db}&term=${query}[Title/Abstract]+AND+2018:3000[Date - Publication]&retMax=${retMax}&retStart=${offset}&api_key=${process.env.NEXT_PUBLIC_PUBMED_API_KEY}`; + const url = `${baseURL}?db=${db}&term=${query}[Title/Abstract]+AND+${year}:3000[Date - Publication]&retMax=${retMax}&retStart=${offset}&api_key=${process.env.NEXT_PUBLIC_PUBMED_API_KEY}`; const response = await axios.get(url, { responseType: "text" }); console.log(response.data); // 解析XML数据 diff --git a/components/QuillEditor.tsx b/components/QuillEditor.tsx index 7885f8b4..9b1bf3a2 100644 --- a/components/QuillEditor.tsx +++ b/components/QuillEditor.tsx @@ -44,6 +44,10 @@ import { import { debounce } from "lodash"; //i18n import { useTranslation } from "@/app/i18n/client"; +//notification +import { ToastContainer } from "react-toastify"; +import "react-toastify/dist/ReactToastify.css"; +import NotifyButton from "@/components/Notification"; // 确保路径正确 const toolbarOptions = [ ["bold", "italic", "underline", "strike"], // 加粗、斜体、下划线和删除线 @@ -110,6 +114,8 @@ const QEditor = ({ lng }) => { "生成次数", 1 ); // 初始值设为1 + //选择时间范围 + const [timeRange, setTimeRange] = useLocalStorage("时间范围", "2019"); const [generateNumber, setGenerateNumber] = useState(0); //当前任务的进行数 const [openProgressBar, setOpenProgressBar] = useState(false); @@ -338,7 +344,12 @@ const QEditor = ({ lng }) => { }) .join(""); } else if (selectedSource === "semanticScholar") { - rawData = await getSemanticPapers(topic, "2015-2023", offset, limit); + rawData = await getSemanticPapers( + topic, + `${timeRange}-2024`, + offset, + limit + ); //判断返回的文献是否跟用户输入的主题相关 if (isEvaluateTopicMatch) { const { relevantPapers, nonRelevantPapers } = @@ -367,7 +378,12 @@ const QEditor = ({ lng }) => { }) .join(""); } else if (selectedSource === "pubmed") { - rawData = await fetchPubMedData(topic, 2020, offset, limit); + rawData = await fetchPubMedData( + topic, + Number(timeRange)!, + offset, + limit + ); if (!rawData) { throw new Error("未搜索到文献 from PubMed."); } @@ -501,12 +517,22 @@ const QEditor = ({ lng }) => { + {/* 进行几轮生成 */} + {/* 时间范围 */} + setTimeRange(e.target.value)} + className="border border-gray-300 text-gray-700 text-sm p-1 rounded w-16" + />