...
|
...
|
@@ -10,58 +10,17 @@ import { useGlobSetting } from '/@/hooks/setting'; |
10
|
10
|
import { useMessage } from '/@/hooks/web/useMessage';
|
11
|
11
|
import { RequestEnum, ContentTypeEnum } from '/@/enums/httpEnum';
|
12
|
12
|
import { isString } from '/@/utils/is';
|
13
|
|
-import { getJwtToken, getAuthCache } from '/@/utils/auth';
|
|
13
|
+import { getJwtToken } from '/@/utils/auth';
|
14
|
14
|
import { setObjToUrlParams, deepMerge } from '/@/utils';
|
15
|
15
|
import { useErrorLogStoreWithOut } from '/@/store/modules/errorLog';
|
16
|
16
|
import { useI18n } from '/@/hooks/web/useI18n';
|
17
|
17
|
import { joinTimestamp, formatRequestDate } from './helper';
|
18
|
18
|
import { PageEnum } from '/@/enums/pageEnum';
|
19
|
|
-import { REFRESH_TOKEN_KEY } from '/@/enums/cacheEnum';
|
20
|
19
|
import { router } from '/@/router';
|
21
|
20
|
|
22
|
|
-// import { useUserStore } from '/@/store/modules/user';
|
23
|
|
-// const userStore = useUserStore();
|
24
|
|
-// console.log(userStore.userInfo);
|
25
|
|
-
|
26
|
|
-// YUNTENG IOT__DEVELOPMENT__2.7.1__COMMON__LOCAL__KEY__
|
27
|
|
-
|
28
|
|
-function timestampToTime(timestamp) {
|
29
|
|
- const date = new Date(timestamp); //时间戳为10位需*1000,时间戳为13位的话不需乘1000
|
30
|
|
- const Y = date.getFullYear() + '-';
|
31
|
|
- const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
|
32
|
|
- const D = date.getDate() + ' ';
|
33
|
|
- const h = date.getHours() + ':';
|
34
|
|
- const m = date.getMinutes() + ':';
|
35
|
|
- const s = date.getSeconds();
|
36
|
|
- return Y + M + D + h + m + s;
|
37
|
|
-}
|
38
|
|
-
|
39
|
|
-function convertToDate() {
|
40
|
|
- const date = new Date();
|
41
|
|
- const y = date.getFullYear();
|
42
|
|
- let m = date.getMonth() + 1;
|
43
|
|
- let d = date.getDate();
|
44
|
|
- let h = date.getHours();
|
45
|
|
- let min = date.getMinutes();
|
46
|
|
- let s = date.getSeconds();
|
47
|
|
- m = m < 10 ? '0' + m : m; //月小于10,加0
|
48
|
|
- d = d < 10 ? '0' + d : d; //day小于10,加0
|
49
|
|
- h = h < 10 ? '0' + h : h;
|
50
|
|
- min = min < 10 ? '0' + min : min;
|
51
|
|
- s = s < 10 ? '0' + s : s;
|
52
|
|
- return y + '-' + m + '-' + d + ' ' + h + ':' + min + ':' + s;
|
53
|
|
-}
|
54
|
|
-
|
55
|
21
|
const globSetting = useGlobSetting();
|
56
|
22
|
const urlPrefix = globSetting.urlPrefix;
|
57
|
23
|
const { createMessage, createErrorModal } = useMessage();
|
58
|
|
-const getJwtTokenInfo = getAuthCache(REFRESH_TOKEN_KEY);
|
59
|
|
-const getExiper = window.localStorage.getItem(
|
60
|
|
- 'UNDEFINED__DEVELOPMENT__2.7.1__COMMON__LOCAL__KEY__'
|
61
|
|
-);
|
62
|
|
-const getExiperValue = JSON.parse(getExiper);
|
63
|
|
-const expireTime = timestampToTime(getExiperValue.expire);
|
64
|
|
-const nowTime = convertToDate();
|
65
|
24
|
|
66
|
25
|
/**
|
67
|
26
|
* @description: 数据处理,方便区分多种处理方式
|
...
|
...
|
@@ -166,40 +125,10 @@ const transform: AxiosTransform = { |
166
|
125
|
try {
|
167
|
126
|
console.log(response.data);
|
168
|
127
|
if (response.data.status == '401' || response.data.message == '"Authentication failed"') {
|
169
|
|
- // window.localStorage.removeItem('UNDEFINED__DEVELOPMENT__2.7.1__COMMON__LOCAL__KEY__');
|
170
|
|
- // window.localStorage.removeItem('UNDEFINED__DEVELOPMENT__2.7.1__LOCALE__');
|
171
|
128
|
window.localStorage.clear();
|
172
|
129
|
window.sessionStorage.clear();
|
173
|
130
|
router.push(PageEnum.BASE_HOME);
|
174
|
|
- // doRefresh();
|
175
|
|
-
|
176
|
|
- // console.log(router);
|
177
|
|
- // router.push('/other');
|
178
|
|
- // if (expireTime < nowTime) {
|
179
|
|
- // // console.log('过期');
|
180
|
|
- // createMessage.error('token已经过期,请退回登录');
|
181
|
|
- // } else {
|
182
|
|
- // // console.log('未过期');
|
183
|
|
- // }
|
184
|
|
- // router.push(PageEnum.BASE_LOGIN);
|
185
|
|
- // if (getJwtTokenInfo) {
|
186
|
|
- // if (PageEnum.BASE_LOGIN) {
|
187
|
|
- // router.push(PageEnum.BASE_LOGIN);
|
188
|
|
- // }
|
189
|
|
- // }
|
190
|
|
- // router.beforeEach((to, from, next) => {
|
191
|
|
- // console.log(to);
|
192
|
|
- // if (getJwtTokenInfo) {
|
193
|
|
- // if (to.path !== '/login') {
|
194
|
|
- // // doRefresh();
|
195
|
|
- // next({ path: '/adass' });
|
196
|
|
- // }
|
197
|
|
- // }
|
198
|
|
- // });
|
199
|
|
- } else {
|
200
|
|
- // doRefresh();
|
201
|
131
|
}
|
202
|
|
-
|
203
|
132
|
if (code === 'ECONNABORTED' && message.indexOf('timeout') !== -1) {
|
204
|
133
|
errMessage = t('sys.api.apiTimeoutMessage');
|
205
|
134
|
}
|
...
|
...
|
|