client: fix type

pull/65/head
fantasticit 2022-06-04 23:03:06 +08:00
parent aaa2b7acb9
commit 2932e1d6bd
2 changed files with 4 additions and 3 deletions

View File

@ -1,4 +1,5 @@
import { FILE_CHUNK_SIZE, FileApiDefinition } from '@think/domains';
import { string } from 'lib0';
import SparkMD5 from 'spark-md5';
import { HttpClient } from './http-client';
@ -37,7 +38,7 @@ const uploadFileToServer = (arg: {
const formData = new FormData();
formData.append('file', file);
return HttpClient.request({
return HttpClient.request<string>({
method: FileApiDefinition[api].method,
url: FileApiDefinition[api].client(),
data: formData,
@ -60,7 +61,7 @@ export const uploadFile = async (
file: File,
onUploadProgress?: (progress: number) => void,
onTooLarge?: () => void
) => {
): Promise<string> => {
const wraponUploadProgress = (percent) => {
return onUploadProgress && onUploadProgress(Math.ceil(percent * 100));
};

View File

@ -5,7 +5,7 @@ import { toLogin } from 'data/user';
type WithCookieAxiosRequestConfig = AxiosRequestConfig & { cookie?: string };
interface AxiosInstance extends Axios {
request<T = any, R = AxiosResponse<T>>(config: WithCookieAxiosRequestConfig): Promise<R>;
request<T>(config: WithCookieAxiosRequestConfig): Promise<T>;
}
export const HttpClient = axios.create({