import type { AuthResponse, LoginPayload } from '$lib/types/auth'; import { ApiError } from '$lib/types/api.ts'; import type { ApiClient } from '$lib/api/httpClient.ts'; export const authService = { /** * 登录流程 */ login: async (api: ApiClient,payload: LoginPayload): Promise => { const response = await api.post('/auth/login', payload); if (response.code !== 200 || !response.data) { throw new ApiError(response); } return response.data; }, /** * 登出流程 */ logout: async (api: ApiClient) => { try { await api.post('/auth/logout', {}); } catch (error) { console.warn('Logout API call failed:', error); } } };