in linkis-web-next/src/service/api.ts [283:342]
const param = function (url: string | URL, data: any, option: any) {
const method = 'post';
if (util.isNull(url)) {
return window.console.error('请传入URL');
} else if (!util.isNull(url) && util.isNull(data) && util.isNull(option)) {
option = {
method,
};
} else if (!util.isNull(url) && !util.isNull(data) && util.isNull(option)) {
option = {
method,
};
if (util.isString(data)) {
option.method = data;
} else if (util.isObject(data)) {
option.data = data;
}
} else if (
!util.isNull(url) &&
!util.isNull(data) &&
!util.isNull(option)
) {
if (!util.isObject(data)) {
data = {};
}
if (util.isString(option)) {
option = {
method: option,
};
} else if (util.isObject(option)) {
option.method = option.method || method;
} else {
option = {
method,
};
}
if (
option.method === 'get' ||
option.method === 'delete' ||
option.method === 'head' ||
option.method === 'options'
) {
option.params = data;
}
if (
option.method === 'post' ||
option.method === 'put' ||
option.method === 'patch'
) {
option.data = data;
}
}
// cacheOptions interface data cache {time} When the time is 0, the data cached in the memory will not be cleaned up after the request(cacheOptions接口数据缓存 {time} time为0则请求之后缓存在内存里的数据不清理)
if (option.cacheOptions) {
option.adapter = cache(option.cacheOptions);
}
option.url = url;
return instance.request(option);
};