From e6fad12b30d8953450bf1ac3666fa2dcc9f8bccc Mon Sep 17 00:00:00 2001 From: tone Date: Wed, 17 Dec 2025 23:01:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=89=8D=E7=AB=AF=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E7=99=BB=E9=99=86=E7=9F=AD=E4=BF=A1=E9=AA=8C=E8=AF=81=E5=8F=91?= =?UTF-8?q?=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/frontend/lib/api/client.ts | 3 ++- apps/frontend/lib/api/endpoints/sms.client.ts | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 apps/frontend/lib/api/endpoints/sms.client.ts diff --git a/apps/frontend/lib/api/client.ts b/apps/frontend/lib/api/client.ts index 70130f6..319fcbe 100644 --- a/apps/frontend/lib/api/client.ts +++ b/apps/frontend/lib/api/client.ts @@ -46,4 +46,5 @@ export async function clientFetch( export * as AuthAPI from './endpoints/auth.client' -export * as UserAPI from './endpoints/user.client' \ No newline at end of file +export * as UserAPI from './endpoints/user.client' +export * as SmsAPI from './endpoints/sms.client' \ No newline at end of file diff --git a/apps/frontend/lib/api/endpoints/sms.client.ts b/apps/frontend/lib/api/endpoints/sms.client.ts new file mode 100644 index 0000000..4ae2336 --- /dev/null +++ b/apps/frontend/lib/api/endpoints/sms.client.ts @@ -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 }) + }) +} \ No newline at end of file