|
|
@@ -43,12 +43,13 @@ const requestInterceptor = (config) => {
|
|
|
const userStore = useUserStore();
|
|
|
const cId = userStore.userInfo?.cId;
|
|
|
|
|
|
- const method = String(config.method || "GET").toUpperCase();
|
|
|
- if (method === "GET") {
|
|
|
- config.data = { ...(config.data || {}), cId };
|
|
|
- } else {
|
|
|
- config.data = { ...(config.data || {}), cId };
|
|
|
- }
|
|
|
+ const method = String(config.method || "GET").toUpperCase();
|
|
|
+ if (method === "GET") {
|
|
|
+ config.data = { ...(config.data || {}) };
|
|
|
+ } else {
|
|
|
+ console.log(config.data,'ccc')
|
|
|
+ config.data = { ...(config.data || {}) };
|
|
|
+ }
|
|
|
if (!config.header["Content-Type"]) {
|
|
|
config.header["Content-Type"] = "application/json";
|
|
|
}
|
|
|
@@ -60,9 +61,9 @@ const responseInterceptor = (response, options = {}) => {
|
|
|
const { data, statusCode } = response;
|
|
|
// 处理业务错误
|
|
|
if (statusCode === 200) {
|
|
|
- if (options.responseType === "arraybuffer" || data instanceof ArrayBuffer) {
|
|
|
- return data;
|
|
|
- }
|
|
|
+ if (options.responseType === "arraybuffer" || data instanceof ArrayBuffer) {
|
|
|
+ return data;
|
|
|
+ }
|
|
|
// 1. 捕获 401 未授权错误
|
|
|
if (data.code === 401 || data.code === 600) {
|
|
|
// 关键:判断当前页面是否为登录页,避免循环跳转
|
|
|
@@ -312,16 +313,16 @@ export const uploadFile = (url, file, data = {}, header = {}, checkCode = true)
|
|
|
};
|
|
|
|
|
|
// 快捷方法
|
|
|
-export const get = (url, data = {}, typeOrOptions = {}, options = {}) => {
|
|
|
- const mergedOptions =
|
|
|
- typeof typeOrOptions === "string"
|
|
|
- ? { type: typeOrOptions, ...(options || {}) }
|
|
|
- : (typeOrOptions || {});
|
|
|
+export const get = (url, data = {}, typeOrOptions = {}, options = {}) => {
|
|
|
+ const mergedOptions =
|
|
|
+ typeof typeOrOptions === "string"
|
|
|
+ ? { type: typeOrOptions, ...(options || {}) }
|
|
|
+ : (typeOrOptions || {});
|
|
|
return request({
|
|
|
url,
|
|
|
method: "GET",
|
|
|
data,
|
|
|
- ...mergedOptions,
|
|
|
+ ...mergedOptions,
|
|
|
});
|
|
|
};
|
|
|
|