@aliyun-obv/api 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.es.js +13 -6
- package/package.json +3 -3
package/dist/api.es.js
CHANGED
|
@@ -59,6 +59,7 @@ var __async$6 = (__this, __arguments, generator) => {
|
|
|
59
59
|
});
|
|
60
60
|
};
|
|
61
61
|
const isTest = process.env.NODE_ENV === "test";
|
|
62
|
+
const matchProxyApiReg = /common\/(getApi|postApi|putApi)/;
|
|
62
63
|
class BaseFetch {
|
|
63
64
|
constructor(fetchApi) {
|
|
64
65
|
__publicField(this, "fetchApi");
|
|
@@ -150,12 +151,18 @@ class BaseFetch {
|
|
|
150
151
|
const fetchInit = _.merge({}, defaultInit, {
|
|
151
152
|
body: contentType.includes("application/json") ? JSON.stringify(params) : getPostParam(params)
|
|
152
153
|
});
|
|
153
|
-
const { url
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
154
|
+
const { url, init: newInit } = yield this.beforeRequest(api, params, fetchInit, options);
|
|
155
|
+
let newApi = url;
|
|
156
|
+
try {
|
|
157
|
+
if (matchProxyApiReg.test(newApi)) {
|
|
158
|
+
if (typeof (params == null ? void 0 : params.methodName) === "string" && typeof (params == null ? void 0 : params.product) === "string" && !url.includes("__action__") && !url.includes("__product__")) {
|
|
159
|
+
const extra = `__action__=${params.methodName}&__product__=${params.product}`;
|
|
160
|
+
newApi = `${newApi}${newApi.includes("?") ? `&${extra}` : `?${extra}`}`;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
} catch (error) {
|
|
164
|
+
console.log(error);
|
|
165
|
+
}
|
|
159
166
|
const res = yield this.callFetch(newApi, newInit, options);
|
|
160
167
|
if (this.defaults.afterResponse) {
|
|
161
168
|
return yield this.defaults.afterResponse(res, options);
|
package/package.json
CHANGED
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
"urijs": "^1.19.1",
|
|
12
12
|
"lodash": "^4.17.21",
|
|
13
13
|
"@alicloud/console-base-error-prompt-proxy": "^1.9.12",
|
|
14
|
-
"@aliyun-obv/i18n": "0.2.
|
|
15
|
-
"@aliyun-obv/utils": "0.2.
|
|
14
|
+
"@aliyun-obv/i18n": "0.2.2",
|
|
15
|
+
"@aliyun-obv/utils": "0.2.2",
|
|
16
16
|
"@alifd/next": "^1.27.11",
|
|
17
17
|
"styled-components": "^5.2.0"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {},
|
|
20
|
-
"version": "0.2.
|
|
20
|
+
"version": "0.2.2"
|
|
21
21
|
}
|