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