@gct-paas/api 0.1.2-dev.2 → 0.1.2-dev.3

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.
@@ -198,6 +198,10 @@ export class HttpUtil {
198
198
  * @returns {Promise<T>} 请求结果
199
199
  */
200
200
  static async request(url, path, data, query, config = {}) {
201
+ const headers = config.headers || {};
202
+ if (config.headers) {
203
+ delete config.headers;
204
+ }
201
205
  const res = await instance.request({
202
206
  url: this.transformUrl(url, path || {}),
203
207
  data: data instanceof FormData ? data : JSON.stringify(data ? data : {}),
@@ -205,10 +209,16 @@ export class HttpUtil {
205
209
  timeout: 2 * 60 * 1e3,
206
210
  headers: {
207
211
  "Content-Type": ContentTypeEnum.JSON,
208
- ...config.headers
212
+ ...headers
209
213
  },
210
214
  ...config
211
215
  });
216
+ if (config.nativeResponse) {
217
+ return res;
218
+ }
219
+ if (config.nativeData) {
220
+ return res.data;
221
+ }
212
222
  if (res.status >= 200 && res.status < 300) {
213
223
  const data2 = res.data;
214
224
  if (data2.ok === true) {
@@ -169,3 +169,22 @@ declare global {
169
169
  subMessage?: string;
170
170
  }
171
171
  }
172
+
173
+ declare module 'axios' {
174
+ export interface AxiosRequestConfig {
175
+ /**
176
+ * 是否返回原生响应对象
177
+ *
178
+ * @default false
179
+ * @type {boolean}
180
+ */
181
+ nativeResponse?: boolean;
182
+ /**
183
+ * 是否返回原生数据对象,包含后台返回的所有状态码和消息等信息
184
+ *
185
+ * @default false
186
+ * @type {boolean}
187
+ */
188
+ nativeData?: boolean;
189
+ }
190
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gct-paas/api",
3
- "version": "0.1.2-dev.2",
3
+ "version": "0.1.2-dev.3",
4
4
  "description": "paas 平台底包",
5
5
  "type": "module",
6
6
  "keywords": [