This commit is contained in:
root
2025-07-12 18:46:26 +08:00
parent b2ff4dba32
commit 0b9797ddef
2 changed files with 20 additions and 15 deletions

View File

@@ -92,13 +92,21 @@ pub async fn python_cli_auth_login(
app: AppHandle,
request: AuthLoginRequest,
) -> Result<PythonCliResponse, String> {
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
}

View File

@@ -64,16 +64,21 @@ class PythonCliAuth {
*/
async login(credentials: LoginCredentials): Promise<UserProfile> {
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 })