From daade6ba91dba141bc31c279e2480a1a105ae5c7 Mon Sep 17 00:00:00 2001 From: brianling Date: Thu, 16 Jul 2026 06:30:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=AF=84=E5=88=86=E6=A0=87=E5=87=86?= =?UTF-8?q?=E7=9B=B4=E8=AF=BB=20DB=EF=BC=8C=E7=A7=BB=E9=99=A4=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E5=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/main/ipc.ts | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/electron/main/ipc.ts b/electron/main/ipc.ts index 2df439a..0fb10a7 100644 --- a/electron/main/ipc.ts +++ b/electron/main/ipc.ts @@ -262,31 +262,21 @@ export function setupIpc(win: BrowserWindow): void { const q = questions[i] insert.run(q.questionTitle || '', q.maxScore ?? 100, q.referenceAnswer || '', q.rubric || '', i) } - rubricPayload = data }) ipcMain.handle('rubric:getData', () => { - function fromDb() { - const d = getDb() - const rows: any[] = d.prepare('SELECT * FROM rubric ORDER BY sort_order').all() - if (rows.length) { - return { - questions: rows.map(r => ({ - questionTitle: r.question_title, - maxScore: r.max_score, - referenceAnswer: r.reference_answer, - rubric: r.rubric - })), - currentIndex: 0 - } + const d = getDb() + const rows: any[] = d.prepare('SELECT * FROM rubric ORDER BY sort_order').all() + if (rows.length) { + return { + questions: rows.map(r => ({ + questionTitle: r.question_title, + maxScore: r.max_score, + referenceAnswer: r.reference_answer, + rubric: r.rubric + })), + currentIndex: 0 } - return null - } - if (rubricPayload && rubricPayload.questions?.length) return rubricPayload - const dbResult = fromDb() - if (dbResult) { - rubricPayload = dbResult - return dbResult } return null }) @@ -300,7 +290,6 @@ export function setupIpc(win: BrowserWindow): void { } const dialogPayloads: Record = {} -let rubricPayload: any = null let gradingPayload: any = null async function callAiApi(imageBase64: string, rubric: string, config: { apiKey: string; baseUrl: string; model: string }, extras?: { maxScore?: number; referenceAnswer?: string; questionTitle?: string }): Promise<{