diff --git a/src-tauri/src/commands/python_cli.rs b/src-tauri/src/commands/python_cli.rs index 4f83ede..08d1f40 100644 --- a/src-tauri/src/commands/python_cli.rs +++ b/src-tauri/src/commands/python_cli.rs @@ -92,13 +92,21 @@ pub async fn python_cli_auth_login( app: AppHandle, request: AuthLoginRequest, ) -> Result { - let mut args = vec!["auth".to_string(), "login".to_string(), request.username, request.password]; + let mut args = vec!["auth".to_string(), "login".to_string(), request.username_or_email]; if let Some(password) = request.password { args.push("--password".to_string()); args.push(password); } + if request.verbose.unwrap_or(false) { + args.push("--verbose".to_string()); + } + + if request.json_output.unwrap_or(false) { + args.push("--json".to_string()); + } + execute_python_cli_command(app, args, None).await } @@ -120,14 +128,6 @@ pub async fn python_cli_auth_register( args.push(password); } - if request.verbose.unwrap_or(false) { - args.push("--verbose".to_string()); - } - - if request.json_output.unwrap_or(false) { - args.push("--json".to_string()); - } - execute_python_cli_command(app, args, None).await } diff --git a/src/services/pythonCliAuth.ts b/src/services/pythonCliAuth.ts index ce6a03b..7b6cfad 100644 --- a/src/services/pythonCliAuth.ts +++ b/src/services/pythonCliAuth.ts @@ -64,16 +64,21 @@ class PythonCliAuth { */ async login(credentials: LoginCredentials): Promise { try { - const username_or_email = credentials.email || credentials.username; - if (!username_or_email) { + // 确定使用邮箱还是用户名登录 + let username_or_email: string; + if (credentials.email) { + username_or_email = credentials.email; + } else if (credentials.username) { + username_or_email = credentials.username; + } else { throw new Error('Email or username is required'); } const response: PythonCliAuthResponse = await invoke('python_cli_auth_login', { request: { - username: credentials.username, - email: credentials.email, - password: credentials.password + username_or_email: username_or_email, + password: credentials.password, + json_output: true } }); @@ -133,7 +138,7 @@ class PythonCliAuth { email: credentials.email, password: credentials.password, display_name: credentials.displayName, - json_output: true + verbose: true } }); console.log({ response })