Your Name 4 лет назад
Родитель
Сommit
86b5e75e1e

+ 1
- 14
src/layouts/BasicLayout.jsx Просмотреть файл

@@ -62,20 +62,6 @@ const BasicLayout = (props) => {
62 62
       pathname: '/',
63 63
     },
64 64
   } = props;
65
-  /**
66
-   * constructor
67
-   */
68
-
69
-  // useEffect(() => {
70
-  //   if (dispatch) {
71
-  //     dispatch({
72
-  //       type: 'user/fetchCurrent',
73
-  //     });
74
-  //   }
75
-  // }, []);
76
-  /**
77
-   * init variables
78
-   */
79 65
 
80 66
   const handleMenuCollapse = (payload) => {
81 67
     if (dispatch) {
@@ -89,6 +75,7 @@ const BasicLayout = (props) => {
89 75
   const authorized = getAuthorityFromRouter(props.route.routes, location.pathname || '/') || {
90 76
     authority: undefined,
91 77
   };
78
+
92 79
   return (
93 80
     <ProLayout
94 81
       logo={logo}

+ 2
- 5
src/layouts/BlankLayout.jsx Просмотреть файл

@@ -1,9 +1,6 @@
1
-import React, { useState, useEffect } from 'react';
2
-import { PageHeaderWrapper } from '@ant-design/pro-layout';
3
-
4
-const Layout = ({ history, children }) => {
5
-  console.log('-------->', history)
1
+import React from 'react';
6 2
 
3
+const Layout = ({ children }) => {
7 4
   return (
8 5
     <>{children}</>
9 6
   );

+ 7
- 9
src/layouts/SecurityLayout.jsx Просмотреть файл

@@ -7,22 +7,20 @@ import { stringify } from 'querystring';
7 7
 const SecurityLayout = (props) => {
8 8
   const [isReady, setIsReady] = useState(false)
9 9
 
10
-  useEffect(() => {
11
-    setIsReady(true)
12
-    props.dispatch({
13
-      type: 'user/fetchCurrent',
14
-    });
15
-  }, [])
16
-
17 10
   const { children, loading, currentUser, history } = props;
18 11
 
19
-  console.log('--------->', history)
20
-
21 12
   const isLogin = currentUser && currentUser.userId;
22 13
 
23 14
   const queryString = stringify({
24 15
     redirect: window.location.href,
25 16
   });
17
+  
18
+  useEffect(() => {
19
+    setIsReady(true)
20
+    props.dispatch({
21
+      type: 'user/fetchCurrent',
22
+    });
23
+  }, [])
26 24
 
27 25
   if (loading || !isReady) {
28 26
     return <PageLoading />;

+ 1
- 1
src/models/global.js Просмотреть файл

@@ -101,7 +101,7 @@ const GlobalModel = {
101 101
     },
102 102
   },
103 103
   subscriptions: {
104
-    setup({ history }) {
104
+    setup({ history, dispatch }) {
105 105
       // Subscribe history(url) change, trigger `load` action if pathname is `/`
106 106
       history.listen(({ pathname, search }) => {
107 107
         if (typeof window.ga !== 'undefined') {

+ 6
- 2
src/pages/Admin.jsx Просмотреть файл

@@ -1,7 +1,11 @@
1 1
 import React from 'react';
2 2
 import { Card, Typography, Alert, Icon } from 'antd';
3 3
 import { PageHeaderWrapper } from '@ant-design/pro-layout';
4
-export default () => (
4
+export default () => {
5
+  
6
+  console.log('--------admin-----')
7
+
8
+  return (
5 9
   <PageHeaderWrapper content=" 这个页面只有 admin 权限才能查看">
6 10
     <Card>
7 11
       <Alert
@@ -37,4 +41,4 @@ export default () => (
37 41
38 42
     </p>
39 43
   </PageHeaderWrapper>
40
-);
44
+)};

+ 56
- 49
src/pages/Welcome.jsx Просмотреть файл

@@ -1,4 +1,4 @@
1
-import React from 'react';
1
+import React, { useEffect } from 'react';
2 2
 import { PageHeaderWrapper } from '@ant-design/pro-layout';
3 3
 import { FormattedMessage } from 'umi-plugin-react/locale';
4 4
 import { Card, Typography, Alert } from 'antd';
@@ -12,55 +12,62 @@ const CodePreview = ({ children }) => (
12 12
   </pre>
13 13
 );
14 14
 
15
-export default () => (
16
-  <PageHeaderWrapper>
17
-    <Card>
18
-      <Alert
19
-        message="umi ui 现已发布,点击右下角 umi 图标即可使用"
20
-        type="success"
21
-        showIcon
22
-        banner
23
-        style={{
24
-          margin: -12,
25
-          marginBottom: 24,
26
-        }}
27
-      />
28
-      <Typography.Text strong>
29
-        <a target="_blank" rel="noopener noreferrer" href="https://pro.ant.design/docs/block">
30
-          <FormattedMessage
31
-            id="app.welcome.link.block-list"
32
-            defaultMessage="基于 block 开发,快速构建标准页面"
33
-          />
34
-        </a>
35
-      </Typography.Text>
36
-      <CodePreview> npm run ui</CodePreview>
37
-      <Typography.Text
38
-        strong
15
+export default (props) => {
16
+  console.log('--------welcome-----', JSON.stringify(props))
17
+  useEffect(() => {
18
+    console.log('------useEffect-------')
19
+  }, [])
20
+  
21
+  return (
22
+    <PageHeaderWrapper>
23
+      <Card>
24
+        <Alert
25
+          message="umi ui 现已发布,点击右下角 umi 图标即可使用"
26
+          type="success"
27
+          showIcon
28
+          banner
29
+          style={{
30
+            margin: -12,
31
+            marginBottom: 24,
32
+          }}
33
+        />
34
+        <Typography.Text strong>
35
+          <a target="_blank" rel="noopener noreferrer" href="https://pro.ant.design/docs/block">
36
+            <FormattedMessage
37
+              id="app.welcome.link.block-list"
38
+              defaultMessage="基于 block 开发,快速构建标准页面"
39
+            />
40
+          </a>
41
+        </Typography.Text>
42
+        <CodePreview> npm run ui</CodePreview>
43
+        <Typography.Text
44
+          strong
45
+          style={{
46
+            marginBottom: 12,
47
+          }}
48
+        >
49
+          <a
50
+            target="_blank"
51
+            rel="noopener noreferrer"
52
+            href="https://pro.ant.design/docs/available-script#npm-run-fetchblocks"
53
+          >
54
+            <FormattedMessage id="app.welcome.link.fetch-blocks" defaultMessage="获取全部区块" />
55
+          </a>
56
+        </Typography.Text>
57
+        <CodePreview> npm run fetch:blocks</CodePreview>
58
+      </Card>
59
+      <p
39 60
         style={{
40
-          marginBottom: 12,
61
+          textAlign: 'center',
62
+          marginTop: 24,
41 63
         }}
42 64
       >
43
-        <a
44
-          target="_blank"
45
-          rel="noopener noreferrer"
46
-          href="https://pro.ant.design/docs/available-script#npm-run-fetchblocks"
47
-        >
48
-          <FormattedMessage id="app.welcome.link.fetch-blocks" defaultMessage="获取全部区块" />
65
+        Want to add more pages? Please refer to{' '}
66
+        <a href="https://pro.ant.design/docs/block-cn" target="_blank" rel="noopener noreferrer">
67
+          use block
49 68
         </a>
50
-      </Typography.Text>
51
-      <CodePreview> npm run fetch:blocks</CodePreview>
52
-    </Card>
53
-    <p
54
-      style={{
55
-        textAlign: 'center',
56
-        marginTop: 24,
57
-      }}
58
-    >
59
-      Want to add more pages? Please refer to{' '}
60
-      <a href="https://pro.ant.design/docs/block-cn" target="_blank" rel="noopener noreferrer">
61
-        use block
62
-      </a>
63
-      。
64
-    </p>
65
-  </PageHeaderWrapper>
66
-);
69
+        。
70
+      </p>
71
+    </PageHeaderWrapper>
72
+  )
73
+};