feat: Oauth update
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
import axios, { AxiosInstance, AxiosRequestConfig } from "axios";
|
||||
import { message } from "antd";
|
||||
import { DecryptData, EncryptData } from "@/utils/encrypt/encrypt.ts";
|
||||
|
||||
class Request {
|
||||
private instance: AxiosInstance | undefined;
|
||||
@@ -12,9 +11,9 @@ class Request {
|
||||
// 全局请求拦截
|
||||
this.instance.interceptors.request.use(
|
||||
(config) => {
|
||||
if (config.method == "post") {
|
||||
config.data = EncryptData(JSON.stringify(config.data));
|
||||
}
|
||||
// if (config.method == "post") {
|
||||
// config.data = EncryptData(JSON.stringify(config.data));
|
||||
// }
|
||||
return config;
|
||||
},
|
||||
(error) => {
|
||||
@@ -26,13 +25,13 @@ class Request {
|
||||
this.instance.interceptors.response.use(
|
||||
(response) => {
|
||||
// 后端返回字符串表示需要解密操作
|
||||
if (typeof response.data == "string") {
|
||||
response.data = DecryptData(response.data);
|
||||
if (!response.data.code && response.data.code !== 200) {
|
||||
message.error(response.data.message).then();
|
||||
return Promise.reject(response.data);
|
||||
}
|
||||
}
|
||||
// if (typeof response.data == "string") {
|
||||
// response.data = DecryptData(response.data);
|
||||
// if (!response.data.code && response.data.code !== 200) {
|
||||
// message.error(response.data.message).then();
|
||||
// return Promise.reject(response.data);
|
||||
// }
|
||||
// }
|
||||
return response.data;
|
||||
},
|
||||
(error) => {
|
||||
|
Reference in New Issue
Block a user