feat: 添加登出和修改密码的API

This commit is contained in:
2025-12-18 17:09:29 +08:00
parent fa4a31a6ff
commit 90d36d4cfb
2 changed files with 18 additions and 0 deletions

View File

@@ -50,3 +50,7 @@ export async function loginBySms(phone: string, code: string) {
})
});
}
export async function logout() {
return clientFetch('/api/auth/logout', { method: 'POST' });
}

View File

@@ -1,6 +1,20 @@
import { User } from "@/lib/types/user";
import { clientFetch } from "../client";
import { APIError } from "../common";
export async function me() {
return clientFetch<User>('/api/user/me');
}
export async function updatePassword(password: string) {
if (! /^(?=.*[a-zA-Z])(?=.*\d)[a-zA-Z\d!@#$%^&*()_+\-=\[\]{};:'",.<>/?]{6,32}$/.test(password)) {
throw new APIError('新密码不符合规范,请重新输入')
}
return clientFetch<null>('/api/user/password', {
method: 'PUT',
body: JSON.stringify({
password,
}),
})
}