张延森 5 lat temu
rodzic
commit
42ba27a36b

+ 5
- 5
config/config.js Wyświetl plik

23
         // default true, when it is true, will use `navigator.language` overwrite default
23
         // default true, when it is true, will use `navigator.language` overwrite default
24
         baseNavigator: true,
24
         baseNavigator: true,
25
       },
25
       },
26
-      // dynamicImport: {
27
-      //   loadingComponent: './components/PageLoading/index',
28
-      //   webpackChunkName: true,
29
-      //   level: 3,
30
-      // },
26
+      dynamicImport: {
27
+        loadingComponent: './components/PageLoading/index',
28
+        webpackChunkName: true,
29
+        level: 3,
30
+      },
31
       pwa: pwa
31
       pwa: pwa
32
         ? {
32
         ? {
33
           workboxPluginMode: 'InjectManifest',
33
           workboxPluginMode: 'InjectManifest',

+ 2
- 0
src/layouts/SecurityLayout.jsx Wyświetl plik

25
     const { isReady } = this.state;
25
     const { isReady } = this.state;
26
     const { children, loading, currentUser } = this.props;
26
     const { children, loading, currentUser } = this.props;
27
 
27
 
28
+    console.log('------------>', loading, currentUser)
29
+
28
     if ((!currentUser.userId && loading) || !isReady) {
30
     if ((!currentUser.userId && loading) || !isReady) {
29
       return <PageLoading />;
31
       return <PageLoading />;
30
     }
32
     }

+ 1
- 2
src/models/login.js Wyświetl plik

36
       }
36
       }
37
 
37
 
38
       yield put(routerRedux.replace(redirect || '/'));
38
       yield put(routerRedux.replace(redirect || '/'));
39
-      
40
     },
39
     },
41
 
40
 
42
     *getCaptcha({ payload }, { call }) {
41
     *getCaptcha({ payload }, { call }) {
60
   },
59
   },
61
   reducers: {
60
   reducers: {
62
     changeLoginStatus(state, { payload }) {
61
     changeLoginStatus(state, { payload }) {
63
-      setAuthority('admin');
62
+      setAuthority((payload.user.roles || []).map(x => x.roleId));
64
       return { ...state, status: 'ok', type: payload.type };
63
       return { ...state, status: 'ok', type: payload.type };
65
     },
64
     },
66
   },
65
   },

+ 8
- 1
src/utils/request.js Wyświetl plik

4
  */
4
  */
5
 import request from 'umi-request';
5
 import request from 'umi-request';
6
 import { notification } from 'antd';
6
 import { notification } from 'antd';
7
+import apis from '../services/apis';
8
+
7
 const codeMessage = {
9
 const codeMessage = {
8
   200: '服务器成功返回请求的数据。',
10
   200: '服务器成功返回请求的数据。',
9
   201: '新建或修改数据成功。',
11
   201: '新建或修改数据成功。',
25
 const replaceURLParams = (url, params = {}) => {
27
 const replaceURLParams = (url, params = {}) => {
26
   return Object.keys(params).reduce((acc, k) => { // 此方法对每个元素进行处理
28
   return Object.keys(params).reduce((acc, k) => { // 此方法对每个元素进行处理
27
     const re = new RegExp(`:${k}(?!w)`, 'i')
29
     const re = new RegExp(`:${k}(?!w)`, 'i')
28
-    return acc.replace(re, args[k])
30
+    return acc.replace(re, params[k])
29
   }, url)
31
   }, url)
30
 }
32
 }
31
 
33
 
92
   }
94
   }
93
 });
95
 });
94
 
96
 
97
+
98
+const fetch = api => options => request(api.url, {...api, ...options || {}})
99
+
95
 export default config => {
100
 export default config => {
96
   if (typeof config === 'string') {
101
   if (typeof config === 'string') {
97
     return request(config);
102
     return request(config);
100
     return request(url, options);
105
     return request(url, options);
101
   }
106
   }
102
 };
107
 };
108
+
109
+export { fetch, apis }