张延森 před 4 roky
rodič
revize
1fa300d30b
3 změnil soubory, kde provedl 12 přidání a 8 odebrání
  1. 3
    6
      src/layout/IsLogin.jsx
  2. 8
    1
      src/layout/index.scss
  3. 1
    1
      src/reducers/user.js

+ 3
- 6
src/layout/IsLogin.jsx Zobrazit soubor

1
-import React from "react";
1
+import React, { useState, useEffect } from "react";
2
 import { View, ScrollView } from "@tarojs/components";
2
 import { View, ScrollView } from "@tarojs/components";
3
 import "./index.scss";
3
 import "./index.scss";
4
 import useUser from "../store/user";
4
 import useUser from "../store/user";
5
 
5
 
6
 const IsLogin = ({ children }) => {
6
 const IsLogin = ({ children }) => {
7
   const { user } = useUser();
7
   const { user } = useUser();
8
-  console.log(user, "user");
9
 
8
 
10
-  return user && user.userId
11
-    ? children
12
-    : <View style={{textAlign:'center', marginTop: '200px', fontSize: '0.7em', color: '#888'}}>您暂无权限访问当前页面</View>
13
-  ;
9
+  return user && user.userId ? children :
10
+    (<View className="no-rights">您暂无权限访问当前页面</View>)
14
 };
11
 };
15
 
12
 
16
 export default IsLogin;
13
 export default IsLogin;

+ 8
- 1
src/layout/index.scss Zobrazit soubor

2
     
2
     
3
     height: calc(100vh - 173.33px)
3
     height: calc(100vh - 173.33px)
4
     
4
     
5
-}
5
+}
6
+
7
+.no-rights {
8
+    text-align: center;
9
+    margin-top: 200px;
10
+    font-size: 0.7em;
11
+    color: #888;
12
+}

+ 1
- 1
src/reducers/user.js Zobrazit soubor

6
     case 'setUser':
6
     case 'setUser':
7
       return {
7
       return {
8
         ...state,
8
         ...state,
9
-        user: action.payload
9
+        ...action.payload || {}
10
       }
10
       }
11
       default:
11
       default:
12
         return state
12
         return state