import { authService } from './authService'; // API Base URL const API_BASE_URL = import.meta.env.VITE_API_BASE_URL ?? 'http://localhost:8010'; // 密码强度等级 export type PasswordStrengthLevel = 'weak' | 'medium' | 'strong'; // 密码强度检测响应 export interface PasswordStrengthResponse { strength: PasswordStrengthLevel; score: number; suggestions: string[]; meets_requirements: boolean; } /** * 密码强度API服务类 */ class PasswordApiService { private baseUrl = `${API_BASE_URL}/api/password`; /** * 检测密码强度 */ async checkPasswordStrength(password: string): Promise { const response = await fetch(`${this.baseUrl}/check-strength`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ password }), }); if (!response.ok) { throw new Error('密码强度检测失败'); } return response.json(); } } // 导出单例 export const passwordApi = new PasswordApiService();