module-menu-vue 0.0.31 → 0.0.33

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "module-menu-vue",
3
- "version": "0.0.31",
3
+ "version": "0.0.33",
4
4
  "description": "城市大数据平台菜单--Vue版",
5
5
  "main": "/index.js",
6
6
  "scripts": {
@@ -2,18 +2,10 @@ import axios from 'axios';
2
2
  import baseCof from './config';
3
3
  import getStore from './userInfo';
4
4
  import { checkToken} from './permessionUtils';
5
-
5
+ const DEFAULT_LOGOUT_URL = '/#/login'
6
6
  let tokenValue = '574536b1-5832-417b-b909-82e204679d67';
7
7
 
8
- const service = axios.create({
9
- timeout: 20000,
10
- headers: {
11
- 'X-Requested-With': 'XMLHttpRequest',
12
- 'Content-Type': 'application/json; charset=UTF-8'
13
- },
14
- })
15
-
16
- service.interceptors.response.use(
8
+ axios.interceptors.response.use(
17
9
  (response) => {
18
10
  if (response.status === 200) {
19
11
  return response;
@@ -42,12 +34,12 @@ service.interceptors.response.use(
42
34
  }
43
35
  }
44
36
  console.log('=========', JSON.stringify(error.response))
45
- return Promise.reject(error.response.data);
37
+ return Promise.reject(error.response);
46
38
  },
47
39
  );
48
40
 
49
41
  /** 全局请求拦截器 */
50
- service.interceptors.request.use(
42
+ axios.interceptors.request.use(
51
43
  async (params) => {
52
44
  // 多种环境,对接门户时,需要在请求头中设置token等信息
53
45
  const environmentList = ['production', 'development', 'test']
@@ -92,15 +84,16 @@ function Axios(method, api, params, map) {
92
84
  };
93
85
  console.log('httpDefult', JSON.stringify(httpDefult))
94
86
 
95
- return new Promise((resolve, reject) => {
96
- axios(httpDefult)
97
- .then((res) => {
98
- resolve(res);
99
- })
100
- .catch((err) => {
101
- reject(err);
102
- });
103
- })
87
+ axios(httpDefult)
88
+ .then((res) => {
89
+ console.log('res: ', res)
90
+ localStorage.clear();
91
+ sessionStorage.clear();
92
+ window.location.href = DEFAULT_LOGOUT_URL;
93
+ })
94
+ .catch((err) => {
95
+ console.log('err: ', err)
96
+ });
104
97
  }
105
98
 
106
99
  export default Axios;
@@ -1,10 +1,14 @@
1
1
  const address = window.location.hostname
2
2
  const port = window.location.port
3
- const baseCof = process.env.NODE_ENV === 'production' ?{
4
- baseSever: `https://${address}:${port}`,
5
- basePath: `/app/cmcc/data`,
6
- }:{
7
- baseSever: 'http://localhost:8000',
3
+ const baseCof =
4
+ process.env.NODE_ENV === 'production' ?
5
+ {
6
+ baseSever: `https://${address}:${port}`,
7
+ basePath: `/app/cmcc/data`,
8
+ }
9
+ :
10
+ {
11
+ baseSever: 'http://localhost:8080',
8
12
  basePath: '/cmcc/data',
9
13
  };
10
14
  export default baseCof;