import { request } from './request'; import type { ApiResponse } from '@/types/common'; // 登录响应数据类型 export interface LoginResponse { token: string; token_expired: string; member: { id: number; username: string; account: string; avatar?: string; s2_accountId: string; }; } // 验证码响应类型 export interface VerificationCodeResponse { code: string; expire_time: string; } // 认证相关API export const authApi = { // 账号密码登录 login: async (account: string, password: string) => { const response = await request.post>('/v1/auth/login', { account, password, typeId: 1 // 默认使用用户类型1 }); return response as unknown as ApiResponse; }, // 验证码登录 loginWithCode: async (account: string, code: string) => { const response = await request.post>('/v1/auth/login/code', { account, code, typeId: 1 }); return response as unknown as ApiResponse; }, // 发送验证码 sendVerificationCode: async (account: string) => { const response = await request.post>('/v1/auth/send-code', { account, type: 'login' // 登录验证码 }); return response as unknown as ApiResponse; }, // 获取用户信息 getUserInfo: async () => { const response = await request.get>('/v1/auth/info'); return response as unknown as ApiResponse; }, // 刷新Token refreshToken: async () => { const response = await request.post>('/v1/auth/refresh', {}); return response as unknown as ApiResponse<{ token: string; token_expired: string }>; }, // 微信登录 wechatLogin: async (code: string) => { const response = await request.post>('/v1/auth/wechat', { code }); return response as unknown as ApiResponse; }, // Apple登录 appleLogin: async (identityToken: string, authorizationCode: string) => { const response = await request.post>('/v1/auth/apple', { identity_token: identityToken, authorization_code: authorizationCode }); return response as unknown as ApiResponse; }, };