傅行帆 5 年前
父节点
当前提交
1925286503

+ 2
- 3
src/layouts/SecurityLayout.jsx 查看文件

@@ -24,13 +24,12 @@ class SecurityLayout extends React.Component {
24 24
   render() {
25 25
     const { isReady } = this.state;
26 26
     const { children, loading, currentUser } = this.props;
27
-    console.log('------------>', loading, currentUser)
28 27
 
29
-    if ((!currentUser.userid && loading) || !isReady) {
28
+    if ((!currentUser.userId && loading) || !isReady) {
30 29
       return <PageLoading />;
31 30
     }
32 31
 
33
-    if (!currentUser.userid) {
32
+    if (!currentUser.userId) {
34 33
       return <Redirect to="/user/login"></Redirect>;
35 34
     }
36 35
 

+ 18
- 19
src/models/login.js 查看文件

@@ -15,29 +15,28 @@ const Model = {
15 15
         type: 'changeLoginStatus',
16 16
         payload: response,
17 17
       }); // Login successfully
18
+            
19
+      const urlParams = new URL(window.location.href);
20
+      const params = getPageQuery();
21
+      let { redirect } = params;
18 22
 
19
-      if (response.status === 'ok') {
20
-        const urlParams = new URL(window.location.href);
21
-        const params = getPageQuery();
22
-        let { redirect } = params;
23
+      if (redirect) {
24
+        const redirectUrlParams = new URL(redirect);
23 25
 
24
-        if (redirect) {
25
-          const redirectUrlParams = new URL(redirect);
26
+        if (redirectUrlParams.origin === urlParams.origin) {
27
+          redirect = redirect.substr(urlParams.origin.length);
26 28
 
27
-          if (redirectUrlParams.origin === urlParams.origin) {
28
-            redirect = redirect.substr(urlParams.origin.length);
29
-
30
-            if (redirect.match(/^\/.*#/)) {
31
-              redirect = redirect.substr(redirect.indexOf('#') + 1);
32
-            }
33
-          } else {
34
-            window.location.href = redirect;
35
-            return;
29
+          if (redirect.match(/^\/.*#/)) {
30
+            redirect = redirect.substr(redirect.indexOf('#') + 1);
36 31
           }
32
+        } else {
33
+          window.location.href = redirect;
34
+          return;
37 35
         }
38
-
39
-        yield put(routerRedux.replace(redirect || '/'));
40 36
       }
37
+
38
+      yield put(routerRedux.replace(redirect || '/'));
39
+      
41 40
     },
42 41
 
43 42
     *getCaptcha({ payload }, { call }) {
@@ -61,8 +60,8 @@ const Model = {
61 60
   },
62 61
   reducers: {
63 62
     changeLoginStatus(state, { payload }) {
64
-      setAuthority(payload.currentAuthority);
65
-      return { ...state, status: payload.status, type: payload.type };
63
+      setAuthority('admin');
64
+      return { ...state, status: 'ok', type: payload.type };
66 65
     },
67 66
   },
68 67
 };

+ 1
- 0
src/models/user.js 查看文件

@@ -17,6 +17,7 @@ const UserModel = {
17 17
 
18 18
     *fetchCurrent(_, { call, put }) {
19 19
       const response = yield call(request, apis.user.current);
20
+
20 21
       yield put({
21 22
         type: 'saveCurrentUser',
22 23
         payload: response,

+ 1
- 6
src/pages/user/login/components/Login/LoginSubmit.jsx 查看文件

@@ -4,12 +4,7 @@ import classNames from 'classnames';
4 4
 import styles from './index.less';
5 5
 const FormItem = Form.Item;
6 6
 import router from 'umi/router';
7
-// 跳转到编辑商品
8
-function toIndex() {
9
-  router.push({
10
-    pathname: '/welcome',
11
-  });
12
-}
7
+
13 8
 const LoginSubmit = ({ className, ...rest }) => {
14 9
   const clsString = classNames(styles.submit, className);
15 10
   return (

+ 1
- 0
src/pages/user/login/index.jsx 查看文件

@@ -63,6 +63,7 @@ class Login extends Component {
63 63
         }
64 64
       });
65 65
     });
66
+    
66 67
   renderMessage = content => (
67 68
     <Alert
68 69
       style={{