@@ -372,14 +372,11 @@ fn prompt_gemini_config(current: Option<&Value>) -> Result<Value, AppError> {
372372 let current_auth_type = detect_gemini_auth_type ( current) ;
373373 let default_index = match current_auth_type. as_deref ( ) {
374374 Some ( "oauth" ) => 0 ,
375- Some ( "packycode" ) => 1 ,
376- Some ( "generic" ) => 2 ,
377- _ => 1 , // 默认 PackyCode
375+ _ => 1 , // 默认 Generic API Key(包括 packycode 和 generic)
378376 } ;
379377
380378 let auth_options = vec ! [
381379 texts:: google_oauth_official( ) ,
382- texts:: packycode_api_key( ) ,
383380 texts:: generic_api_key( ) ,
384381 ] ;
385382
@@ -391,62 +388,15 @@ fn prompt_gemini_config(current: Option<&Value>) -> Result<Value, AppError> {
391388
392389 // Match using the translated strings
393390 let google_oauth = texts:: google_oauth_official ( ) ;
394- let packycode = texts:: packycode_api_key ( ) ;
395391
396392 if auth_type == google_oauth {
397393 println ! ( "{}" , texts:: use_google_oauth_warning( ) . yellow( ) ) ;
398394 Ok ( json ! ( {
399395 "env" : { } ,
400396 "config" : { }
401397 } ) )
402- } else if auth_type == packycode {
403- let api_key = if let Some ( current_key) = current
404- . and_then ( |v| v. get ( "env" ) )
405- . and_then ( |e| e. get ( "GEMINI_API_KEY" ) )
406- . and_then ( |k| k. as_str ( ) )
407- . filter ( |s| !s. is_empty ( ) )
408- {
409- Text :: new ( texts:: gemini_api_key_label ( ) )
410- . with_initial_value ( current_key)
411- . with_help_message ( texts:: packycode_api_key_help ( ) )
412- . prompt ( )
413- . map_err ( |e| AppError :: Message ( texts:: input_failed_error ( & e. to_string ( ) ) ) ) ?
414- } else {
415- Text :: new ( texts:: gemini_api_key_label ( ) )
416- . with_placeholder ( "pk-..." )
417- . with_help_message ( texts:: packycode_api_key_help ( ) )
418- . prompt ( )
419- . map_err ( |e| AppError :: Message ( texts:: input_failed_error ( & e. to_string ( ) ) ) ) ?
420- } ;
421-
422- let base_url = if let Some ( current_url) = current
423- . and_then ( |v| v. get ( "env" ) )
424- . and_then ( |e| e. get ( "GOOGLE_GEMINI_BASE_URL" ) )
425- . and_then ( |u| u. as_str ( ) )
426- . filter ( |s| !s. is_empty ( ) )
427- {
428- Text :: new ( texts:: gemini_base_url_label ( ) )
429- . with_initial_value ( current_url)
430- . with_help_message ( texts:: packycode_endpoint_help ( ) )
431- . prompt ( )
432- . map_err ( |e| AppError :: Message ( texts:: input_failed_error ( & e. to_string ( ) ) ) ) ?
433- } else {
434- Text :: new ( texts:: gemini_base_url_label ( ) )
435- . with_placeholder ( "https://packycode.com/api" )
436- . with_help_message ( texts:: packycode_endpoint_help ( ) )
437- . prompt ( )
438- . map_err ( |e| AppError :: Message ( texts:: input_failed_error ( & e. to_string ( ) ) ) ) ?
439- } ;
440-
441- Ok ( json ! ( {
442- "env" : {
443- "GEMINI_API_KEY" : api_key. trim( ) ,
444- "GOOGLE_GEMINI_BASE_URL" : base_url. trim( )
445- } ,
446- "config" : { }
447- } ) )
448398 } else {
449- // Generic API Key
399+ // Generic API Key (统一处理所有 API Key 供应商,包括 PackyCode)
450400 let api_key = if let Some ( current_key) = current
451401 . and_then ( |v| v. get ( "env" ) )
452402 . and_then ( |e| e. get ( "GEMINI_API_KEY" ) )
@@ -460,15 +410,15 @@ fn prompt_gemini_config(current: Option<&Value>) -> Result<Value, AppError> {
460410 . map_err ( |e| AppError :: Message ( texts:: input_failed_error ( & e. to_string ( ) ) ) ) ?
461411 } else {
462412 Text :: new ( texts:: gemini_api_key_label ( ) )
463- . with_placeholder ( "AIza..." )
413+ . with_placeholder ( "AIza... or pk-... " )
464414 . with_help_message ( texts:: generic_api_key_help ( ) )
465415 . prompt ( )
466416 . map_err ( |e| AppError :: Message ( texts:: input_failed_error ( & e. to_string ( ) ) ) ) ?
467417 } ;
468418
469419 let base_url = if let Some ( current_url) = current
470420 . and_then ( |v| v. get ( "env" ) )
471- . and_then ( |e| e. get ( "BASE_URL " ) )
421+ . and_then ( |e| e. get ( "GOOGLE_GEMINI_BASE_URL " ) )
472422 . and_then ( |u| u. as_str ( ) )
473423 . filter ( |s| !s. is_empty ( ) )
474424 {
@@ -488,7 +438,7 @@ fn prompt_gemini_config(current: Option<&Value>) -> Result<Value, AppError> {
488438 Ok ( json ! ( {
489439 "env" : {
490440 "GEMINI_API_KEY" : api_key. trim( ) ,
491- "BASE_URL " : base_url. trim( )
441+ "GOOGLE_GEMINI_BASE_URL " : base_url. trim( )
492442 } ,
493443 "config" : { }
494444 } ) )
0 commit comments