module-menu-vue 0.0.15 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/Util/axios.js +0 -61
package/package.json
CHANGED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
// import axios from 'axios';
|
|
2
|
-
import { getStore } from './userInfo.js';
|
|
3
|
-
import { checkToken} from '../User/service.js';
|
|
4
|
-
// import qs from "qs";
|
|
5
|
-
|
|
6
|
-
let tokenValue='200ad182-7aec-4473-98a4-08d3d8bccf73';
|
|
7
|
-
|
|
8
|
-
this.axios.interceptors.response.use(
|
|
9
|
-
(response) => {
|
|
10
|
-
if (response.status === 200) {
|
|
11
|
-
return response;
|
|
12
|
-
} else if (response.status === 401 || response.status === 302 || response.status === 403) {
|
|
13
|
-
if (process.env.NODE_ENV === 'production') {
|
|
14
|
-
tokenValue = getStore({ name: 'access_token' });
|
|
15
|
-
}
|
|
16
|
-
checkToken(tokenValue);
|
|
17
|
-
} else {
|
|
18
|
-
console.log('接口异常 response');
|
|
19
|
-
return Promise.reject('error');
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
(error) => {
|
|
23
|
-
console.log('error', error)
|
|
24
|
-
if (error.response) {
|
|
25
|
-
if (error.response.status === 401) {
|
|
26
|
-
if (process.env.NODE_ENV === 'production') {
|
|
27
|
-
tokenValue = getStore({ name: 'access_token' });
|
|
28
|
-
}
|
|
29
|
-
checkToken(tokenValue);
|
|
30
|
-
} else if (error.response.status === 403) {
|
|
31
|
-
// 提示无权限等
|
|
32
|
-
} else {
|
|
33
|
-
// 其他错误处理
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return Promise.reject(error.response?.data);
|
|
37
|
-
},
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
this.axios.interceptors.request.use(config => {
|
|
41
|
-
console.log('-----', token, isToken, TENANT_ID)
|
|
42
|
-
const TENANT_ID = getStore({ name: "tenantId" }) || '1';
|
|
43
|
-
const isToken = (config.headers || {}).isToken === false;
|
|
44
|
-
const token = getStore({ name: 'access_token' });
|
|
45
|
-
if (token && !isToken) {
|
|
46
|
-
config.headers["Authorization"] = `Bearer ${token}`; // token
|
|
47
|
-
}
|
|
48
|
-
if (TENANT_ID) {
|
|
49
|
-
config.headers["TENANT-ID"] = TENANT_ID; // 租户ID
|
|
50
|
-
}
|
|
51
|
-
// config.headers["Authorization"] = "Bearer " + '9e3f86b0-41e2-436a-9f0d-aeace114cc66'; // token
|
|
52
|
-
// config.headers["TENANT-ID"] = 1; // 租户ID
|
|
53
|
-
// config.paramsSerializer = function (params) {
|
|
54
|
-
// return qs.stringify(params, { arrayFormat: "repeat" });
|
|
55
|
-
// };
|
|
56
|
-
return config;
|
|
57
|
-
},
|
|
58
|
-
error => {
|
|
59
|
-
return Promise.reject(error);
|
|
60
|
-
}
|
|
61
|
-
);
|