mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-11-02 16:57:11 +08:00
feat: 支持手机号登录(演示环境不开放)
1.在个人中心-安全设置中绑手机号后,才支持手机号登录 2.SMS4J(短信聚合框架,轻松集成多家短信服务,解决接入多个短信 SDK 的繁琐流程)
This commit is contained in:
@@ -4,8 +4,7 @@ import { UserState } from '@/store/modules/user/types';
|
||||
|
||||
const BASE_URL = '/auth';
|
||||
|
||||
export interface LoginReq {
|
||||
phone?: string;
|
||||
export interface AccountLoginReq {
|
||||
username?: string;
|
||||
password?: string;
|
||||
captcha: string;
|
||||
@@ -16,7 +15,7 @@ export interface LoginRes {
|
||||
token: string;
|
||||
}
|
||||
|
||||
export function accountLogin(req: LoginReq) {
|
||||
export function accountLogin(req: AccountLoginReq) {
|
||||
return axios.post<LoginRes>(`${BASE_URL}/account`, req);
|
||||
}
|
||||
|
||||
@@ -29,6 +28,15 @@ export function emailLogin(req: EmailLoginReq) {
|
||||
return axios.post<LoginRes>(`${BASE_URL}/email`, req);
|
||||
}
|
||||
|
||||
export interface PhoneLoginReq {
|
||||
phone: string;
|
||||
captcha: string;
|
||||
}
|
||||
|
||||
export function phoneLogin(req: PhoneLoginReq) {
|
||||
return axios.post<LoginRes>(`${BASE_URL}/phone`, req);
|
||||
}
|
||||
|
||||
export function logout() {
|
||||
return axios.post(`${BASE_URL}/logout`);
|
||||
}
|
||||
|
||||
@@ -1,22 +1,19 @@
|
||||
import axios from 'axios';
|
||||
import qs from 'query-string';
|
||||
|
||||
const BASE_URL = '/common/captcha';
|
||||
|
||||
export interface ImageCaptchaRes {
|
||||
uuid: string;
|
||||
img: string;
|
||||
}
|
||||
export function getImageCaptcha() {
|
||||
return axios.get<ImageCaptchaRes>('/common/captcha/img');
|
||||
return axios.get<ImageCaptchaRes>(`${BASE_URL}/img`);
|
||||
}
|
||||
|
||||
export interface MailCaptchaReq {
|
||||
email: string;
|
||||
export function getMailCaptcha(email: string) {
|
||||
return axios.get(`${BASE_URL}/mail?email=${email}`);
|
||||
}
|
||||
export function getMailCaptcha(params: MailCaptchaReq) {
|
||||
return axios.get('/common/captcha/mail', {
|
||||
params,
|
||||
paramsSerializer: (obj) => {
|
||||
return qs.stringify(obj);
|
||||
},
|
||||
});
|
||||
|
||||
export function getSmsCaptcha(phone: string) {
|
||||
return axios.get(`${BASE_URL}/sms?phone=${phone}`);
|
||||
}
|
||||
|
||||
@@ -16,31 +16,41 @@ export function uploadAvatar(data: FormData) {
|
||||
return axios.post<AvatarRes>(`${BASE_URL}/avatar`, data);
|
||||
}
|
||||
|
||||
export interface UpdateBasicInfoReq {
|
||||
export interface UserBasicInfoUpdateReq {
|
||||
nickname: string;
|
||||
gender: number;
|
||||
}
|
||||
|
||||
export function updateBasicInfo(req: UpdateBasicInfoReq) {
|
||||
export function updateBasicInfo(req: UserBasicInfoUpdateReq) {
|
||||
return axios.patch(`${BASE_URL}/basic/info`, req);
|
||||
}
|
||||
|
||||
export interface UpdatePasswordReq {
|
||||
export interface UserPasswordUpdateReq {
|
||||
oldPassword: string;
|
||||
newPassword: string;
|
||||
}
|
||||
|
||||
export function updatePassword(req: UpdatePasswordReq) {
|
||||
export function updatePassword(req: UserPasswordUpdateReq) {
|
||||
return axios.patch(`${BASE_URL}/password`, req);
|
||||
}
|
||||
|
||||
export interface UpdateEmailReq {
|
||||
export interface UserPhoneUpdateReq {
|
||||
newPhone: string;
|
||||
captcha: string;
|
||||
currentPassword: string;
|
||||
}
|
||||
|
||||
export function updatePhone(req: UserPhoneUpdateReq) {
|
||||
return axios.patch(`${BASE_URL}/phone`, req);
|
||||
}
|
||||
|
||||
export interface UserEmailUpdateReq {
|
||||
newEmail: string;
|
||||
captcha: string;
|
||||
currentPassword: string;
|
||||
}
|
||||
|
||||
export function updateEmail(req: UpdateEmailReq) {
|
||||
export function updateEmail(req: UserEmailUpdateReq) {
|
||||
return axios.patch(`${BASE_URL}/email`, req);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user