From 50f94bfee4c58b864e335269d698a26f48b75ccb Mon Sep 17 00:00:00 2001
From: Vben <anncwb@126.com>
Date: 星期日, 06 六月 2021 15:12:15 +0800
Subject: [PATCH] chore(axios): remove useless code

---
 /dev/null                              |    2 --
 src/utils/http/axios/index.ts          |   14 ++++++--------
 src/utils/http/axios/helper.ts         |    4 ++--
 src/utils/http/axios/axiosTransform.ts |    2 +-
 src/utils/http/axios/Axios.ts          |    1 -
 5 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/src/utils/http/axios/Axios.ts b/src/utils/http/axios/Axios.ts
index 35ac743..84feddb 100644
--- a/src/utils/http/axios/Axios.ts
+++ b/src/utils/http/axios/Axios.ts
@@ -8,7 +8,6 @@
 import { isFunction } from '/@/utils/is';
 import { cloneDeep } from 'lodash-es';
 
-//import { errorResult } from './const';
 import { ContentTypeEnum } from '/@/enums/httpEnum';
 import { RequestEnum } from '../../../enums/httpEnum';
 
diff --git a/src/utils/http/axios/axiosTransform.ts b/src/utils/http/axios/axiosTransform.ts
index 27f9ba3..c4f0adf 100644
--- a/src/utils/http/axios/axiosTransform.ts
+++ b/src/utils/http/axios/axiosTransform.ts
@@ -5,7 +5,7 @@
 import type { RequestOptions, Result } from './types';
 
 export interface CreateAxiosOptions extends AxiosRequestConfig {
-  prefixUrl?: string;
+  urlPrefix?: string;
   transform?: AxiosTransform;
   requestOptions?: RequestOptions;
 }
diff --git a/src/utils/http/axios/const.ts b/src/utils/http/axios/const.ts
deleted file mode 100644
index 2d45c68..0000000
--- a/src/utils/http/axios/const.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-// The interface return value data cannot be this, otherwise the request will be judged as a failure
-export const errorResult = '__ERROR_RESULT__';
diff --git a/src/utils/http/axios/helper.ts b/src/utils/http/axios/helper.ts
index 30369d5..dc30e04 100644
--- a/src/utils/http/axios/helper.ts
+++ b/src/utils/http/axios/helper.ts
@@ -2,12 +2,12 @@
 
 const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm';
 
-export function createNow<T extends boolean>(
+export function joinTimestamp<T extends boolean>(
   join: boolean,
   restful: T
 ): T extends true ? string : object;
 
-export function createNow(join: boolean, restful = false): string | object {
+export function joinTimestamp(join: boolean, restful = false): string | object {
   if (!join) {
     return restful ? '' : {};
   }
diff --git a/src/utils/http/axios/index.ts b/src/utils/http/axios/index.ts
index daeb6b9..d847f9a 100644
--- a/src/utils/http/axios/index.ts
+++ b/src/utils/http/axios/index.ts
@@ -18,12 +18,11 @@
 import { setObjToUrlParams, deepMerge } from '/@/utils';
 import { useErrorLogStoreWithOut } from '/@/store/modules/errorLog';
 
-//import { errorResult } from './const';
 import { useI18n } from '/@/hooks/web/useI18n';
-import { createNow, formatRequestDate } from './helper';
+import { joinTimestamp, formatRequestDate } from './helper';
 
 const globSetting = useGlobSetting();
-const prefix = globSetting.urlPrefix;
+const urlPrefix = globSetting.urlPrefix;
 const { createMessage, createErrorModal } = useMessage();
 
 /**
@@ -51,7 +50,6 @@
     if (!data) {
       // return '[HTTP] Request has no return value';
       throw new Error(t('sys.api.apiRequestFailed'));
-      //return errorResult;
     }
     //  杩欓噷 code锛宺esult锛宮essage涓� 鍚庡彴缁熶竴鐨勫瓧娈碉紝闇�瑕佸湪 types.ts鍐呬慨鏀逛负椤圭洰鑷繁鐨勬帴鍙h繑鍥炴牸寮�
     const { code, result, message } = data;
@@ -91,7 +89,7 @@
     const { apiUrl, joinPrefix, joinParamsToUrl, formatDate, joinTime = true } = options;
 
     if (joinPrefix) {
-      config.url = `${prefix}${config.url}`;
+      config.url = `${urlPrefix}${config.url}`;
     }
 
     if (apiUrl && isString(apiUrl)) {
@@ -101,10 +99,10 @@
     if (config.method?.toUpperCase() === RequestEnum.GET) {
       if (!isString(params)) {
         // 缁� get 璇锋眰鍔犱笂鏃堕棿鎴冲弬鏁帮紝閬垮厤浠庣紦瀛樹腑鎷挎暟鎹��
-        config.params = Object.assign(params || {}, createNow(joinTime, false));
+        config.params = Object.assign(params || {}, joinTimestamp(joinTime, false));
       } else {
         // 鍏煎restful椋庢牸
-        config.url = config.url + params + `${createNow(joinTime, true)}`;
+        config.url = config.url + params + `${joinTimestamp(joinTime, true)}`;
         config.params = undefined;
       }
     } else {
@@ -173,7 +171,7 @@
         // 鍩虹鎺ュ彛鍦板潃
         // baseURL: globSetting.apiUrl,
         // 鎺ュ彛鍙兘浼氭湁閫氱敤鐨勫湴鍧�閮ㄥ垎锛屽彲浠ョ粺涓�鎶藉彇鍑烘潵
-        prefixUrl: prefix,
+        urlPrefix: urlPrefix,
         headers: { 'Content-Type': ContentTypeEnum.JSON },
         // 濡傛灉鏄痜orm-data鏍煎紡
         // headers: { 'Content-Type': ContentTypeEnum.FORM_URLENCODED },

--
Gitblit v1.8.0