|
@@ -11,7 +11,7 @@ import laySty from "./layout.module.less";
|
11
|
11
|
export default (props) => {
|
12
|
12
|
const { className, style, roles, tabBar = false, loading } = props;
|
13
|
13
|
|
14
|
|
- const { user, duty } = useModel("user");
|
|
14
|
+ const { user, duty, current: currentUser } = useModel("user");
|
15
|
15
|
const containerClass = `${laySty["page-conatiner"]} ${
|
16
|
16
|
tabBar ? laySty["with-tabbar"] : ""
|
17
|
17
|
} ${className}`;
|
|
@@ -50,17 +50,19 @@ export default (props) => {
|
50
|
50
|
console.log("userRef******************");
|
51
|
51
|
console.log(user);
|
52
|
52
|
console.log(!user);
|
53
|
|
- if (!userRef.current&&user) {
|
54
|
|
- userRef.current = user;
|
55
|
|
- }
|
|
53
|
+ // if (!userRef.current&&user) {
|
|
54
|
+ // userRef.current = user;
|
|
55
|
+ // }
|
56
|
56
|
|
57
|
|
- if (!userRef.current) {
|
58
|
|
- const currentPage = Taro.getCurrentPages().slice().pop();
|
59
|
|
- if (!currentPage.route.includes("pages/login/index")) {
|
60
|
|
- Taro.navigateTo({
|
61
|
|
- url: "/pages/login/index",
|
62
|
|
- });
|
63
|
|
- }
|
|
57
|
+ if (!user) {
|
|
58
|
+ currentUser().catch(() => {
|
|
59
|
+ const currentPage = Taro.getCurrentPages().slice().pop();
|
|
60
|
+ if (!currentPage.route.includes("pages/login/index")) {
|
|
61
|
+ Taro.navigateTo({
|
|
62
|
+ url: "/pages/login/index",
|
|
63
|
+ });
|
|
64
|
+ }
|
|
65
|
+ })
|
64
|
66
|
}
|
65
|
67
|
}, [user]);
|
66
|
68
|
|