fix: 修复 request 属性挂载问题

This commit is contained in:
winixt 2025-03-14 17:57:30 +08:00
parent 4169cc8c5f
commit 6649e0615b
2 changed files with 4 additions and 6 deletions

View File

@ -33,7 +33,7 @@
},
"dependencies": {
"@fesjs/utils": "^3.0.3",
"@qlin/request": "^0.3.0"
"@qlin/request": "^0.3.1"
},
"typings": "./types.d.ts"
}

View File

@ -15,16 +15,14 @@ function getRequestInstance() {
return createRequest(defaultConfig);
}
// 不能立马初始化,用户配置可能还没准备好
let currentRequest;
export function rawRequest(url, data, options = {}) {
if (typeof options === 'string') {
options = {
method: options,
};
}
if (!currentRequest) {
currentRequest = getRequestInstance();
// 将 request 实例上的属性挂在到 rawRequest 上。
Object.assign(rawRequest, currentRequest);
}
return currentRequest(url, data, options);
}