mirror of
https://github.com/JOYCEQL/magic-resume.git
synced 2026-07-03 14:07:11 +02:00
perf: doubao request toast
This commit is contained in:
@@ -74,7 +74,7 @@ export const PreviewDock = ({
|
||||
try {
|
||||
const text = resumeContentRef.current.innerText;
|
||||
await checkGrammar(text);
|
||||
toast.success("语法检查完成");
|
||||
// toast.success("语法检查完成");
|
||||
} catch (error) {
|
||||
toast.error("语法检查失败,请重试");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { create } from "zustand";
|
||||
import { toast } from "sonner";
|
||||
import Mark from "mark.js";
|
||||
import { useAIConfigStore } from "@/store/useAIConfigStore";
|
||||
|
||||
@@ -73,11 +74,16 @@ export const useGrammarCheck = () => {
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.error.code === "AuthenticationError") {
|
||||
toast.error("ApiKey 或 模型Id 不正确");
|
||||
throw new Error(data.error.message);
|
||||
}
|
||||
|
||||
const aiResponse = data.choices[0]?.message?.content;
|
||||
|
||||
try {
|
||||
const grammarErrors = JSON.parse(aiResponse).errors;
|
||||
console.log(grammarErrors, "grammarErrors");
|
||||
toast.success("语法检查完成");
|
||||
setErrors(grammarErrors);
|
||||
|
||||
const preview = document.getElementById("resume-preview");
|
||||
@@ -93,11 +99,10 @@ export const useGrammarCheck = () => {
|
||||
});
|
||||
}
|
||||
} catch (parseError) {
|
||||
console.error("Failed to parse AI response:", parseError);
|
||||
toast.error(`解析AI响应失败: ${parseError}`);
|
||||
setErrors([]);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Grammar check error:", error);
|
||||
setErrors([]);
|
||||
} finally {
|
||||
setIsChecking(false);
|
||||
|
||||
Reference in New Issue
Block a user