You've already forked DataMate
refactor(request): 优化请求处理逻辑并添加PDF提取接口定义
- 简化catch语句移除不必要的异常变量 - 删除无用的FormData条件判断代码 - 将变量声明从let改为const提升代码质量 - 移除响应拦截器中的冗余参数传递 - 在数据集模式模块中添加PDF文本提取相关的请求响应模型 - 更新模块导出列表包含新的PDF提取接口类型定义
This commit is contained in:
@@ -123,7 +123,7 @@ class Request {
|
||||
} else {
|
||||
response = xhr.responseText;
|
||||
}
|
||||
} catch (e) {
|
||||
} catch {
|
||||
response = xhr.responseText;
|
||||
}
|
||||
|
||||
@@ -270,8 +270,6 @@ class Request {
|
||||
return await this.handleXHRResponse(xhrResponse, processedConfig);
|
||||
}
|
||||
// 否则使用fetch
|
||||
if (processedConfig.body instanceof FormData) {
|
||||
}
|
||||
const response = await fetch(url, processedConfig);
|
||||
return await this.handleResponse(response, processedConfig);
|
||||
}
|
||||
@@ -368,7 +366,7 @@ class Request {
|
||||
*/
|
||||
async delete(url, params = null, options = {}) {
|
||||
let fullURL = this.baseURL + url;
|
||||
let config = {
|
||||
const config = {
|
||||
method: "DELETE",
|
||||
redirect: "follow",
|
||||
headers: {
|
||||
@@ -525,7 +523,7 @@ request.addRequestInterceptor((config) => {
|
||||
});
|
||||
|
||||
// 添加默认响应拦截器 - 错误处理
|
||||
request.addResponseInterceptor((response, config) => {
|
||||
request.addResponseInterceptor((response) => {
|
||||
// 可以在这里添加全局错误处理逻辑
|
||||
// 比如token过期自动跳转登录页等
|
||||
return response;
|
||||
|
||||
Reference in New Issue
Block a user