feat: 新增手机号登录、邮箱登录

This commit is contained in:
2024-04-24 22:25:13 +08:00
parent efa1c32e00
commit 7a09333744
11 changed files with 481 additions and 60 deletions

View File

@@ -8,6 +8,26 @@ export function accountLogin(req: Auth.AccountLoginReq) {
return http.post<Auth.LoginResp>(`${BASE_URL}/account`, req)
}
/** @desc 手机号登录 */
export function phoneLogin(req: Auth.PhoneLoginReq) {
return http.post<Auth.LoginResp>(`${BASE_URL}/phone`, req)
}
/** @desc 邮箱登录 */
export function emailLogin(req: Auth.EmailLoginReq) {
return http.post<Auth.LoginResp>(`${BASE_URL}/email`, req)
}
/** @desc 三方账号登录 */
export function socialLogin(source: string, req: any) {
return http.post<Auth.LoginResp>(`/oauth/${source}`, req)
}
/** @desc 三方账号登录授权 */
export function socialAuth(source: string) {
return http.get<Auth.SocialAuthAuthorizeResp>(`/oauth/${source}`)
}
/** @desc 退出登录 */
export function logout() {
return http.post(`${BASE_URL}/logout`)
@@ -22,8 +42,3 @@ export const getUserInfo = () => {
export const getUserRoute = () => {
return http.get<Auth.RouteItem[]>(`${BASE_URL}/route`)
}
/** @desc 第三方登录授权 */
export function socialAuth(source: string) {
return http.get<Auth.SocialAuthAuthorizeResp>(`/oauth/${source}`)
}

View File

@@ -40,6 +40,7 @@ export interface RouteItem {
affix: boolean
}
/** 账号登录请求参数 */
export interface AccountLoginReq {
username: string
password: string
@@ -47,6 +48,18 @@ export interface AccountLoginReq {
uuid: string
}
/** 手机号登录请求参数 */
export interface PhoneLoginReq {
phone: string
captcha: string
}
/** 邮箱登录请求参数 */
export interface EmailLoginReq {
email: string
captcha: string
}
// 登录响应类型
export interface LoginResp {
token: string

View File

@@ -7,11 +7,13 @@ const BASE_URL = '/captcha'
export function getImageCaptcha() {
return http.get<Common.ImageCaptchaResp>(`${BASE_URL}/img`)
}
/**@desc 获取手机验证码 */
export function getPhoneCaptcha(query: { phone: string }) {
/** @desc 获取短信验证码 */
export function getSmsCaptcha(query: { phone: string }) {
return http.get<boolean>(`${BASE_URL}/sms`, query)
}
/**@desc 获取邮箱验证码 */
/** @desc 获取邮箱验证码 */
export function getEmailCaptcha(query: { email: string }) {
return http.get<boolean>(`${BASE_URL}/mail`, query)
}