import { request } from '@/utils/request';

export async function fetchLogin(body: API.LoginParams, options?: { [key: string]: any }) {
    return request<API.LoginResult>('/user/owLogin', {
        method: 'POST',
        data: body,
        ...(options || {}),
        requireToken: false,
    });
}

export async function fetchLogout(options?: { [key: string]: any }) {
    console.log('file: index.ts:13 ~ fetchLogout ~ options:', options);
    // return request<API.Result>('/user/logout', {
    //   method: 'POST',
    //   ...(options || {}),
    // });
    return Promise.resolve<API.Result>({
        success: true,
        errorCode: 0,
        errorMessage: '成功',
    });
}

export async function fetchRefreshToken(options?: { [key: string]: any }) {
    return request<API.RefreshTokenResult>('/user/refreshToken', {
        method: 'POST',
        ...(options || {}),
        requireToken: false,
    });
}

export async function fetchCaptcha(options?: { [key: string]: any }) {
    return request<API.CaptchaResult>('/captcha/get', {
        method: 'POST',
        ...(options || {}),
        requireToken: false,
    });
}
