feat: 前端实现登陆短信验证发送
This commit is contained in:
@@ -47,3 +47,4 @@ export async function clientFetch<T = unknown>(
|
|||||||
|
|
||||||
export * as AuthAPI from './endpoints/auth.client'
|
export * as AuthAPI from './endpoints/auth.client'
|
||||||
export * as UserAPI from './endpoints/user.client'
|
export * as UserAPI from './endpoints/user.client'
|
||||||
|
export * as SmsAPI from './endpoints/sms.client'
|
||||||
15
apps/frontend/lib/api/endpoints/sms.client.ts
Normal file
15
apps/frontend/lib/api/endpoints/sms.client.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import { clientFetch } from "../client";
|
||||||
|
import { APIError } from "../common";
|
||||||
|
|
||||||
|
export async function sendLoginSms(phone: string) {
|
||||||
|
phone = phone.trim();
|
||||||
|
|
||||||
|
if (!/^1[3-9]\d{9}$/.test(phone)) {
|
||||||
|
throw new APIError('请输入合法的中国大陆手机号');
|
||||||
|
}
|
||||||
|
|
||||||
|
return clientFetch('/api/sms/send/login', {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({ phone })
|
||||||
|
})
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user