feat: make Gemini CLI project ID optional

- Remove required validation for project ID field
- Update translations to indicate field is optional (zh-CN, en)
- Auto-select first available project when left empty
- Backend already supports empty project ID by fetching project list

This improves user experience by eliminating the need to manually enter project ID for users with only one or a preferred default project.
This commit is contained in:
yanyuhualb
2025-12-31 23:06:44 +08:00
parent 40ddd3c066
commit f139598526
3 changed files with 8 additions and 13 deletions

View File

@@ -501,9 +501,9 @@
"gemini_cli_oauth_title": "Gemini CLI OAuth",
"gemini_cli_oauth_button": "Start Gemini CLI Login",
"gemini_cli_oauth_hint": "Login to Google Gemini CLI service through OAuth flow, automatically obtain and save authentication files.",
"gemini_cli_project_id_label": "Google Cloud Project ID:",
"gemini_cli_project_id_placeholder": "Enter Google Cloud Project ID",
"gemini_cli_project_id_hint": "Project ID is required for Gemini CLI OAuth.",
"gemini_cli_project_id_label": "Google Cloud Project ID (Optional):",
"gemini_cli_project_id_placeholder": "Leave blank to auto-select first available project",
"gemini_cli_project_id_hint": "Optional. If not provided, the system will automatically select the first available project from your account.",
"gemini_cli_project_id_required": "Please enter a Google Cloud project ID.",
"gemini_cli_oauth_url_label": "Authorization URL:",
"gemini_cli_open_link": "Open Link",

View File

@@ -501,9 +501,9 @@
"gemini_cli_oauth_title": "Gemini CLI OAuth",
"gemini_cli_oauth_button": "开始 Gemini CLI 登录",
"gemini_cli_oauth_hint": "通过 OAuth 流程登录 Google Gemini CLI 服务,自动获取并保存认证文件。",
"gemini_cli_project_id_label": "Google Cloud 项目 ID:",
"gemini_cli_project_id_placeholder": "输入 Google Cloud 项目 ID",
"gemini_cli_project_id_hint": "填写项目 ID,用于 Gemini CLI OAuth 登录。",
"gemini_cli_project_id_label": "Google Cloud 项目 ID (可选):",
"gemini_cli_project_id_placeholder": "留空将自动选择第一个可用项目",
"gemini_cli_project_id_hint": "可选填写项目 ID。如不填写,系统将自动选择您账号下的第一个可用项目。",
"gemini_cli_project_id_required": "请填写 Google Cloud 项目 ID。",
"gemini_cli_oauth_url_label": "授权链接:",
"gemini_cli_open_link": "打开链接",

View File

@@ -131,12 +131,7 @@ export function OAuthPage() {
const startAuth = async (provider: OAuthProvider) => {
const projectId = provider === 'gemini-cli' ? (states[provider]?.projectId || '').trim() : undefined;
if (provider === 'gemini-cli' && !projectId) {
const message = t('auth_login.gemini_cli_project_id_required');
updateProviderState(provider, { projectIdError: message });
showNotification(message, 'warning');
return;
}
// 项目 ID 现在是可选的,如果不输入将自动选择第一个可用项目
if (provider === 'gemini-cli') {
updateProviderState(provider, { projectIdError: undefined });
}
@@ -151,7 +146,7 @@ export function OAuthPage() {
try {
const res = await oauthApi.startAuth(
provider,
provider === 'gemini-cli' ? { projectId: projectId! } : undefined
provider === 'gemini-cli' ? { projectId: projectId || undefined } : undefined
);
updateProviderState(provider, { url: res.url, state: res.state, status: 'waiting', polling: true });
if (res.state) {