From d346b5fc56c2b3d682e75b510998c2a1327a5862 Mon Sep 17 00:00:00 2001 From: brianling Date: Thu, 16 Jul 2026 05:59:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A4=84=E7=90=86=20AI=20API=20?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E4=B8=BA=E7=A9=BA=E7=9A=84=E6=83=85=E5=86=B5?= =?UTF-8?q?=EF=BC=8C=E6=8F=90=E7=A4=BA=E6=A3=80=E6=9F=A5=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/main/ipc.ts | 7 ++++++- electron/main/window.ts | 2 +- src/components/RubricEditor.vue | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/electron/main/ipc.ts b/electron/main/ipc.ts index b5a3469..8a59f4a 100644 --- a/electron/main/ipc.ts +++ b/electron/main/ipc.ts @@ -322,9 +322,14 @@ ${extras?.maxScore ?? 100} timeout: ((getStore().get('timeout') as number) ?? 120) * 1000 }) - const content = response.data.choices[0].message.content + const content = response.data?.choices?.[0]?.message?.content + if (!content) { + log.error('AI API 返回为空或格式异常:', JSON.stringify(response.data).slice(0, 1000)) + throw new Error(`API 返回为空,请检查模型名是否正确 (当前: ${config.model})`) + } const parsed = tryParseJson(content) if (!parsed) { + log.error('AI 返回 JSON 解析失败:', content.slice(0, 500)) throw new Error(`AI 返回格式异常,无法解析为 JSON。原始返回:\n${content}`) } return { diff --git a/electron/main/window.ts b/electron/main/window.ts index ff4a13d..2ca0bac 100644 --- a/electron/main/window.ts +++ b/electron/main/window.ts @@ -61,7 +61,7 @@ export function openDialogWindow(type: string): BrowserWindow | null { settings: { width: 520, height: 560 }, history: { width: 800, height: 600 }, templates: { width: 640, height: 520 }, - rubric: { width: 520, height: 480 }, + rubric: { width: 640, height: 700 }, result: { width: 440, height: 560 } } const size = sizes[type] || { width: 500, height: 500 } diff --git a/src/components/RubricEditor.vue b/src/components/RubricEditor.vue index cc2c18a..6c89756 100644 --- a/src/components/RubricEditor.vue +++ b/src/components/RubricEditor.vue @@ -130,5 +130,7 @@ function handleClose() { border: 1px solid #e4e7ed; border-radius: 6px; padding: 16px; + max-height: 480px; + overflow-y: auto; } \ No newline at end of file