mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-04-06 03:59:53 +08:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
831a91bded | ||
|
2cb7d5d4e0 |
@ -1,3 +1,12 @@
|
|||||||
|
## [3.4.11](https://github.com/WeBankFinTech/fes.js/compare/v3.4.10...v3.4.11) (2025-03-14)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* request 属性代理问题 ([2cb7d5d](https://github.com/WeBankFinTech/fes.js/commit/2cb7d5d4e0bf53ffd89fa8dd1b51266499642fac))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [3.4.10](https://github.com/WeBankFinTech/fes.js/compare/v3.4.9...v3.4.10) (2025-03-14)
|
## [3.4.10](https://github.com/WeBankFinTech/fes.js/compare/v3.4.9...v3.4.10) (2025-03-14)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "fes.js",
|
"name": "fes.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "3.4.10",
|
"version": "3.4.11",
|
||||||
"private": true,
|
"private": true,
|
||||||
"packageManager": "pnpm@8.6.6",
|
"packageManager": "pnpm@8.6.6",
|
||||||
"description": "一个好用的前端管理台快速开发框架",
|
"description": "一个好用的前端管理台快速开发框架",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@fesjs/plugin-request",
|
"name": "@fesjs/plugin-request",
|
||||||
"version": "4.0.0",
|
"version": "4.0.1",
|
||||||
"description": "@fesjs/plugin-request",
|
"description": "@fesjs/plugin-request",
|
||||||
"author": "qlin",
|
"author": "qlin",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -18,15 +18,23 @@ function getRequestInstance() {
|
|||||||
// 不能立马初始化,用户配置可能还没准备好
|
// 不能立马初始化,用户配置可能还没准备好
|
||||||
let currentRequest;
|
let currentRequest;
|
||||||
|
|
||||||
export function rawRequest(url, data, options = {}) {
|
function _rawRequest(url, data, options = {}) {
|
||||||
if (!currentRequest) {
|
if (!currentRequest) {
|
||||||
currentRequest = getRequestInstance();
|
currentRequest = getRequestInstance();
|
||||||
// 将 request 实例上的属性挂在到 rawRequest 上。
|
|
||||||
Object.assign(rawRequest, currentRequest);
|
|
||||||
}
|
}
|
||||||
return currentRequest(url, data, options);
|
return currentRequest(url, data, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 代理 request 上的属性
|
||||||
|
export const rawRequest = new Proxy(_rawRequest, {
|
||||||
|
get(_, key) {
|
||||||
|
if (!currentRequest) {
|
||||||
|
currentRequest = getRequestInstance();
|
||||||
|
}
|
||||||
|
return currentRequest[key];
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
export async function request(url, data, options = {}) {
|
export async function request(url, data, options = {}) {
|
||||||
const response = await rawRequest(url, data, options);
|
const response = await rawRequest(url, data, options);
|
||||||
return response.data;
|
return response.data;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user