This commit is contained in:
2026-04-28 22:04:24 +08:00
parent 80ee99e564
commit 71c940ab46
156 changed files with 5700 additions and 304 deletions

View File

@@ -5,7 +5,6 @@ function authHeaders() { return { 'Authorization': `Bearer ${token()}`, 'Content
export interface SmsMessage {
id: number;
user_id: number;
phone_number: string;
contact_name: string | null;
content: string;
@@ -31,21 +30,11 @@ async function parseError(res: Response): Promise<string> {
}
}
export async function login(username: string, password: string) {
const res = await fetch(`${BASE}/auth/login`, {
export async function verifyToken(t: string) {
const res = await fetch(`${BASE}/auth/verify`, {
method: 'POST',
headers: { 'Content-Type': 'application/json; charset=utf-8' },
body: JSON.stringify({ username, password }),
});
if (!res.ok) throw new Error(await parseError(res));
return res.json();
}
export async function register(username: string, password: string) {
const res = await fetch(`${BASE}/auth/register`, {
method: 'POST',
headers: { 'Content-Type': 'application/json; charset=utf-8' },
body: JSON.stringify({ username, password }),
body: JSON.stringify({ token: t }),
});
if (!res.ok) throw new Error(await parseError(res));
return res.json();