Skip to content

Commit

Permalink
fix: 自动保存编辑器内容
Browse files Browse the repository at this point in the history
  • Loading branch information
14790897 committed Jan 30, 2024
1 parent ba8722a commit 6107267
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 3 additions & 2 deletions app/store/slices/authSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ export interface APIState {
}

const initialState: APIState = {
apiKey: "sk-aiHrrRLYUUelHstX69E9484509254dBf92061d6744FfFaD1",
apiKey:
"https://api.cocopilot.org/copilot_internal/v2/token||ghu_ThisIsARealFreeCopilotKeyByCoCopilot",
referencesRedux: [],
editorContent: "",
upsreamUrl: "https://one.caifree.com", //https://api.openai.com
upsreamUrl: "https://chatserver.3211000.xyz", //https://api.openai.com https://one.caifree.com
systemPrompt: "",
};

Expand Down
8 changes: 7 additions & 1 deletion components/QuillEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ const QEditor = () => {
upsreamUrl,
prompt
);
// 重新获取更新后的内容并更新 Redux store
const updatedContent = quill.root.innerHTML;
dispatch(setEditorContent(updatedContent));
};

// 处理paper2AI
Expand Down Expand Up @@ -241,14 +244,17 @@ const QEditor = () => {
quill,
500
)},搜索到的论文内容:${trimmedMessage},需要完成的论文主题:${topic},请根据搜索到的论文内容完成用户的论文`;
sendMessageToOpenAI(
await sendMessageToOpenAI(
content,
quill,
selectedModel,
apiKey,
upsreamUrl,
systemPrompt
);
// 重新获取更新后的内容并更新 Redux store
const updatedContent = quill.root.innerHTML;
dispatch(setEditorContent(updatedContent));
} catch (error) {
console.error("Error fetching data:", error);
// 在处理错误后,再次抛出这个错误
Expand Down
2 changes: 2 additions & 0 deletions components/chatAI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ const sendMessageToOpenAI = async (
const decoder = new TextDecoder();

await processResult(reader, decoder, editor);
console.log("流式输出完成接下来要插入一个换行符");
editor.insertText(editor.getSelection().index, "\n");

convertToSuperscript(editor);
updateBracketNumbersInDeltaKeepSelection(editor);
Expand Down

0 comments on commit 6107267

Please sign in to comment.