import { message } from 'ant-design-vue'; import HttpService from './axios'; import { AxiosRequestConfig } from 'axios'; const baseURL = (import.meta as ImportMeta & { env: any}).env.VITE_APP_BASE_URL as string; type ResponseResult = { code: number; isAuthorized: boolean; isSuccess: boolean; result: T; error?: string; } const transformResponse = (response: any & ResponseResult, config: AxiosRequestConfig) => { if (config.responseType === 'blob') { return response; } if(response.code === 1) { return response.result; } else { message.warning(response.error as string); throw new Error(response.error) } }; export const http = new HttpService(baseURL, {transformResponse});