魏超 5 years ago
parent
commit
9c577d5f6e
3 changed files with 13 additions and 9 deletions
  1. 4
    0
      src/components/GlobalHeader/ShowPassword.jsx
  2. 8
    8
      src/utils/request.js
  3. 1
    1
      src/utils/upload.js

+ 4
- 0
src/components/GlobalHeader/ShowPassword.jsx View File

26
       if (!err) {
26
       if (!err) {
27
         request({ ...apis.user.changePassword, params: { ...values } }).then(() => {
27
         request({ ...apis.user.changePassword, params: { ...values } }).then(() => {
28
           openNotificationWithIcon('success', '操作成功!')
28
           openNotificationWithIcon('success', '操作成功!')
29
+          window.localStorage.removeItem('test-foobar-center')      
30
+          router.push({
31
+            pathname: '/user/login',
32
+          });
29
           props.form.resetFields()
33
           props.form.resetFields()
30
           props.onSuccess()
34
           props.onSuccess()
31
         }).catch(error => {
35
         }).catch(error => {

+ 8
- 8
src/utils/request.js View File

35
 request.interceptors.request.use((url, options) => {
35
 request.interceptors.request.use((url, options) => {
36
   const { urlData, headers = {}, logout = false, login = false, action, data, ...opts } = options
36
   const { urlData, headers = {}, logout = false, login = false, action, data, ...opts } = options
37
   const apiURL = urlData ? replaceURLParams(url, urlData) : url
37
   const apiURL = urlData ? replaceURLParams(url, urlData) : url
38
-  const token = mixStr(window.localStorage.getItem('test-channel-foobar'))
38
+  const token = mixStr(window.localStorage.getItem('test-foobar-center'))
39
 
39
 
40
   if (login || logout) {
40
   if (login || logout) {
41
-    window.localStorage.removeItem('test-channel-foobar')
41
+    window.localStorage.removeItem('test-foobar-center')
42
   }
42
   }
43
 
43
 
44
   const authHeader = !login ? { Authorization: `Bearer ${token}` } : {}
44
   const authHeader = !login ? { Authorization: `Bearer ${token}` } : {}
71
       const errorText = codeMessage[response.status] || response.statusText;
71
       const errorText = codeMessage[response.status] || response.statusText;
72
       const { status, url } = response;
72
       const { status, url } = response;
73
       notification.error({
73
       notification.error({
74
-        message: `请求错误 ${status}: ${url}`,
74
+        message: `请登录系统 ${status}: ${url}`,
75
         description: errorText,
75
         description: errorText,
76
       });
76
       });
77
       throw new Error(response.statusText);
77
       throw new Error(response.statusText);
86
       if (code != 1000) {
86
       if (code != 1000) {
87
         if (code === 1001) {
87
         if (code === 1001) {
88
           notification.error({
88
           notification.error({
89
-            message: `请求错误`,
90
-            description: '请登录系统',
89
+            message: `请登录系统`,
90
+            // description: '请登录系统',
91
           });
91
           });
92
           throw new Error('请登录系统');
92
           throw new Error('请登录系统');
93
         } else {
93
         } else {
94
           notification.error({
94
           notification.error({
95
-            message: `请求错误`,
96
-            description: message,
95
+            message: `请登录系统`,
96
+            // description: message,
97
           });
97
           });
98
           throw new Error(message);
98
           throw new Error(message);
99
         }
99
         }
100
       }
100
       }
101
 
101
 
102
       if (data && data.token) {
102
       if (data && data.token) {
103
-        window.localStorage.setItem('test-foobar', mixStr(data.token))
103
+        window.localStorage.setItem('test-foobar-center', mixStr(data.token))
104
       }
104
       }
105
 
105
 
106
       return data;
106
       return data;

+ 1
- 1
src/utils/upload.js View File

1
 import { fetch, apis } from './request';
1
 import { fetch, apis } from './request';
2
 import mixStr from './mixStr';
2
 import mixStr from './mixStr';
3
 
3
 
4
-const getToken = () => mixStr(window.localStorage.getItem('test-foobar'))
4
+const getToken = () => mixStr(window.localStorage.getItem('test-foobar-center'))
5
 
5
 
6
 const uploadImage = fetch(apis.image.upload)
6
 const uploadImage = fetch(apis.image.upload)
7
 
7