|
@@ -76,12 +76,14 @@ service.interceptors.request.use(
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if (isEncrypt && (config.method === 'post' || config.method === 'put')) {
|
|
|
-
|
|
|
- const aesKey = generateAesKey();
|
|
|
- config.headers[encryptHeader] = encrypt(encryptBase64(aesKey));
|
|
|
- config.data = typeof config.data === 'object' ? encryptWithAes(JSON.stringify(config.data), aesKey) : encryptWithAes(config.data, aesKey);
|
|
|
+ if (import.meta.env.VITE_APP_ENCRYPT === 'true') {
|
|
|
+
|
|
|
+ if (isEncrypt && (config.method === 'post' || config.method === 'put')) {
|
|
|
+
|
|
|
+ const aesKey = generateAesKey();
|
|
|
+ config.headers[encryptHeader] = encrypt(encryptBase64(aesKey));
|
|
|
+ config.data = typeof config.data === 'object' ? encryptWithAes(JSON.stringify(config.data), aesKey) : encryptWithAes(config.data, aesKey);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (config.data instanceof FormData) {
|
|
@@ -97,19 +99,21 @@ service.interceptors.request.use(
|
|
|
|
|
|
service.interceptors.response.use(
|
|
|
(res: AxiosResponse) => {
|
|
|
-
|
|
|
- const keyStr = res.headers[encryptHeader];
|
|
|
-
|
|
|
- if (keyStr != null && keyStr != '') {
|
|
|
- const data = res.data;
|
|
|
-
|
|
|
- const base64Str = decrypt(keyStr);
|
|
|
-
|
|
|
- const aesKey = decryptBase64(base64Str.toString());
|
|
|
-
|
|
|
- const decryptData = decryptWithAes(data, aesKey);
|
|
|
-
|
|
|
- res.data = JSON.parse(decryptData);
|
|
|
+ if (import.meta.env.VITE_APP_ENCRYPT === 'true') {
|
|
|
+
|
|
|
+ const keyStr = res.headers[encryptHeader];
|
|
|
+
|
|
|
+ if (keyStr != null && keyStr != '') {
|
|
|
+ const data = res.data;
|
|
|
+
|
|
|
+ const base64Str = decrypt(keyStr);
|
|
|
+
|
|
|
+ const aesKey = decryptBase64(base64Str.toString());
|
|
|
+
|
|
|
+ const decryptData = decryptWithAes(data, aesKey);
|
|
|
+
|
|
|
+ res.data = JSON.parse(decryptData);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
const code = res.data.code || HttpStatus.SUCCESS;
|