张延森 5 yıl önce
ebeveyn
işleme
42ba27a36b

+ 5
- 5
config/config.js Dosyayı Görüntüle

@@ -23,11 +23,11 @@ const plugins = [
23 23
         // default true, when it is true, will use `navigator.language` overwrite default
24 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 31
       pwa: pwa
32 32
         ? {
33 33
           workboxPluginMode: 'InjectManifest',

+ 2
- 0
src/layouts/SecurityLayout.jsx Dosyayı Görüntüle

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

+ 1
- 2
src/models/login.js Dosyayı Görüntüle

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

+ 8
- 1
src/utils/request.js Dosyayı Görüntüle

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