feat: 前端实现登陆短信验证发送

This commit is contained in:
2025-12-17 23:01:45 +08:00
parent 2ef3507cea
commit e6fad12b30
2 changed files with 17 additions and 1 deletions

View File

@@ -46,4 +46,5 @@ export async function clientFetch<T = unknown>(
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'

View 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 })
})
}