From e25c914e52c1046ad6c807a24808fce18d8f415b Mon Sep 17 00:00:00 2001 From: hex2077 Date: Sun, 20 Jul 2025 22:37:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=AA=8C=E8=AF=81=E9=A1=B9=E7=9B=AEID?= =?UTF-8?q?=E5=B9=B6=E7=A7=BB=E9=99=A4=E8=B0=83=E8=AF=95=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加对默认项目ID的验证,防止使用无效的'default'作为项目ID 移除callApi方法中不必要的调试日志输出 --- gemini-core.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gemini-core.js b/gemini-core.js index f75dabe..2a82ba7 100644 --- a/gemini-core.js +++ b/gemini-core.js @@ -147,6 +147,9 @@ export class GeminiApiService { this.availableModels = ['gemini-2.5-pro', 'gemini-2.5-flash']; console.log(`[Service] Using fixed models: [${this.availableModels.join(', ')}]`); } + if (this.projectId === 'default') { + throw new Error("Error: 'default' is not a valid project ID. Please provide a valid Google Cloud Project ID using the --project-id argument."); + } this.isInitialized = true; console.log(`[Service] Initialization complete. Project ID: ${this.projectId}`); } @@ -291,14 +294,11 @@ export class GeminiApiService { async callApi(method, body, isRetry = false) { try { - console.log(`${CODE_ASSIST_ENDPOINT}/${CODE_ASSIST_API_VERSION}:${method}`); - console.log(body); const res = await this.authClient.request({ url: `${CODE_ASSIST_ENDPOINT}/${CODE_ASSIST_API_VERSION}:${method}`, method: "POST", headers: { "Content-Type": "application/json" }, responseType: "json", body: JSON.stringify(body), }); - console.log(res.data); return res.data; } catch (error) { if (error.response?.status === 401 && !isRetry) {