diff --git a/src/core/register.py b/src/core/register.py index 4f1b8e1..431e093 100644 --- a/src/core/register.py +++ b/src/core/register.py @@ -154,9 +154,9 @@ class RegistrationEngine: logger.warning(f"记录任务日志失败: {e}") # 根据级别记录到日志系统 - if level == "error": + if level == 'error': logger.error(message) - elif level == "warning": + elif level == 'warning': logger.warning(message) else: logger.info(message) @@ -170,7 +170,7 @@ class RegistrationEngine: try: return self.http_client.check_ip_location() except Exception as e: - self._log(f"检查 IP 地理位置失败: {e}", "error") + self._log(f"检查 IP 地理位置失败: {e}", 'error') return False, None def _create_email(self) -> bool: @@ -180,7 +180,7 @@ class RegistrationEngine: self.email_info = self.email_service.create_email() if not self.email_info or "email" not in self.email_info: - self._log("创建邮箱失败: 返回信息不完整", "error") + self._log("创建邮箱失败: 返回信息不完整", 'error') return False self.email = self.email_info["email"] @@ -188,7 +188,7 @@ class RegistrationEngine: return True except Exception as e: - self._log(f"创建邮箱失败: {e}", "error") + self._log(f"创建邮箱失败: {e}", 'error') return False def _start_oauth(self) -> bool: @@ -199,7 +199,7 @@ class RegistrationEngine: self._log(f"OAuth URL 已生成: {self.oauth_start.auth_url[:80]}...") return True except Exception as e: - self._log(f"生成 OAuth URL 失败: {e}", "error") + self._log(f"生成 OAuth URL 失败: {e}", 'error') return False def _init_session(self) -> bool: @@ -208,7 +208,7 @@ class RegistrationEngine: self.session = self.http_client.session return True except Exception as e: - self._log(f"初始化会话失败: {e}", "error") + self._log(f"初始化会话失败: {e}", 'error') return False def _get_device_id(self) -> Optional[str]: @@ -234,12 +234,12 @@ class RegistrationEngine: self._log( f"获取 Device ID 失败: 未返回 oai-did Cookie (HTTP {response.status_code}, 第 {attempt}/{max_attempts} 次)", - "warning" if attempt < max_attempts else "error" + 'warning' if attempt < max_attempts else 'error' ) except Exception as e: self._log( f"获取 Device ID 失败: {e} (第 {attempt}/{max_attempts} 次)", - "warning" if attempt < max_attempts else "error" + 'warning' if attempt < max_attempts else 'error' ) if attempt < max_attempts: @@ -269,11 +269,11 @@ class RegistrationEngine: self._log(f"Sentinel token 获取成功") return sen_token else: - self._log(f"Sentinel 检查失败: {response.status_code}", "warning") + self._log(f"Sentinel 检查失败: {response.status_code}", 'warning') return None except Exception as e: - self._log(f"Sentinel 检查异常: {e}", "warning") + self._log(f"Sentinel 检查异常: {e}", 'warning') return None def _submit_signup_form(self, did: str, sen_token: Optional[str]) -> SignupFormResult: @@ -332,12 +332,12 @@ class RegistrationEngine: ) except Exception as parse_error: - self._log(f"解析响应失败: {parse_error}", "warning") + self._log(f"解析响应失败: {parse_error}", 'warning') # 无法解析,默认成功 return SignupFormResult(success=True) except Exception as e: - self._log(f"提交注册表单失败: {e}", "error") + self._log(f"提交注册表单失败: {e}", 'error') return SignupFormResult(success=False, error_message=str(e)) def _register_password(self) -> Tuple[bool, Optional[str]]: @@ -367,17 +367,17 @@ class RegistrationEngine: self._log(f"提交密码状态: {response.status_code}") if response.status_code != 200: - self._log(f"密码注册失败: {response.json().get("error", {}).get("message", "")}", "warning") + self._log(f"密码注册失败: {response.json().get('error', {}).get('message', "")}", 'warning') # 解析错误信息,判断是否是邮箱已注册 try: error_json = response.json() - error_msg = error_json.get("error", {}).get("message", "") - error_code = error_json.get("error", {}).get("code", "") + error_msg = error_json.get('error', {}).get('message', "") + error_code = error_json.get('error', {}).get('code', "") # 检测邮箱已注册的情况 if "already" in error_msg.lower() or "exists" in error_msg.lower() or "again" in error_msg.lower() or error_code == "user_exists" or error_code == "invalid_request": - self._log(f"邮箱 {self.email} 可能已在 OpenAI 注册过", "error") + self._log(f"邮箱 {self.email} 可能已在 OpenAI 注册过", 'error') # 标记此邮箱为已注册状态 self._mark_email_as_registered() except Exception: @@ -388,7 +388,7 @@ class RegistrationEngine: return True, password except Exception as e: - self._log(f"密码注册失败: {e}", "error") + self._log(f"密码注册失败: {e}", 'error') return False, None @@ -441,7 +441,7 @@ class RegistrationEngine: return response.status_code == 200 except Exception as e: - self._log(f"发送验证码失败: {e}", "error") + self._log(f"发送验证码失败: {e}", 'error') return False def _get_verification_code(self) -> Optional[str]: @@ -462,11 +462,11 @@ class RegistrationEngine: self._log(f"成功获取验证码: {code}") return code else: - self._log("等待验证码超时", "error") + self._log("等待验证码超时", 'error') return None except Exception as e: - self._log(f"获取验证码失败: {e}", "error") + self._log(f"获取验证码失败: {e}", 'error') return None def _validate_verification_code(self, code: str) -> bool: @@ -488,7 +488,7 @@ class RegistrationEngine: return response.status_code == 200 except Exception as e: - self._log(f"验证验证码失败: {e}", "error") + self._log(f"验证验证码失败: {e}", 'error') return False def _create_user_account(self) -> bool: @@ -511,13 +511,13 @@ class RegistrationEngine: self._log(f"账户创建状态: {response.status_code}") if response.status_code != 200: - self._log(f"账户创建失败: {response.text[:200]}", "warning") + self._log(f"账户创建失败: {response.text[:200]}", 'warning') return False return True except Exception as e: - self._log(f"创建账户失败: {e}", "error") + self._log(f"创建账户失败: {e}", 'error') return False def _add_phone(self) -> bool: @@ -574,5 +574,5 @@ class RegistrationEngine: return True except Exception as e: - self._log(f"保存到数据库失败: {e}", "error") + self._log(f"保存到数据库失败: {e}", 'error') return False diff --git a/static/js/app.js b/static/js/app.js index 543dc0b..4e1132b 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -1049,7 +1049,6 @@ function resetButtons() { elements.cancelBtn.disabled = true; currentTask = null; currentBatch = null; - isBatchMode = false; // 重置完成标志 taskCompleted = false; batchCompleted = false; @@ -1275,12 +1274,13 @@ function connectBatchWebSocket(batchId) { if (!toastShown) { toastShown = true; if (data.status === 'completed') { - addLog('success', `[完成] Outlook 批量任务完成!成功: ${data.success}, 失败: ${data.failed}, 跳过: ${data.skipped || 0}`); + const batchLabel = isOutlookBatchMode ? 'Outlook 批量' : '批量'; + addLog('success', `[完成] ${batchLabel}任务完成!成功: ${data.success}, 失败: ${data.failed}, 跳过: ${data.skipped || 0}`); if (data.success > 0) { - toast.success(`Outlook 批量注册完成,成功 ${data.success} 个`); + toast.success(`${batchLabel}注册完成,成功 ${data.success} 个`); loadRecentAccounts(); } else { - toast.warning('Outlook 批量注册完成,但没有成功注册任何账号'); + toast.warning(`${batchLabel}注册完成,但没有成功注册任何账号`); } } else if (data.status === 'failed') { addLog('error', '[错误] 批量任务执行失败');