Skip to content

Commit

Permalink
fix: 只有在AI返回的内容没有错之后才能添加文献
Browse files Browse the repository at this point in the history
  • Loading branch information
14790897 committed Feb 18, 2024
1 parent c55a93c commit 3040c11
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
5 changes: 3 additions & 2 deletions components/GetArxiv.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ interface Author {

async function getArxivPapers(
query: string,
maxResults = 5,
maxResults = 2,
offset = -1,
sortBy = "submittedDate",
sortOrder = "descending"
) {
const maxOffset = 20 - maxResults; // 假设总记录数为 20
const maxOffset = 30 - maxResults; // 假设总记录数为 20
if (offset === -1) offset = getRandomOffset(maxOffset);
console.log("offset in arxiv", offset);
const url = `https://export.arxiv.org/api/query?search_query=${query}&start=${offset}&max_results=${maxResults}&sortBy=${sortBy}&sortOrder=${sortOrder}`;

try {
Expand Down
16 changes: 8 additions & 8 deletions components/QuillEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -345,14 +345,6 @@ const QEditor = ({ lng }) => {
})
.join("");
}
//在对应的位置添加文献
const nearestNumber = getNumberBeforeCursor(quill!);
dispatch(
addReferencesRedux({
references: newReferences,
position: nearestNumber,
})
);

// 确保搜索到的论文不超过 3000 个字符
const trimmedMessage =
Expand All @@ -378,6 +370,14 @@ const QEditor = ({ lng }) => {
// 重新获取更新后的内容并更新 Redux store
const updatedContent = quill!.root.innerHTML;
dispatch(setEditorContent(updatedContent));
//在对应的位置添加文献
const nearestNumber = getNumberBeforeCursor(quill!);
dispatch(
addReferencesRedux({
references: newReferences,
position: nearestNumber,
})
);
if (isVip) {
//在云端同步supabase
const data = await submitPaper(
Expand Down

0 comments on commit 3040c11

Please sign in to comment.