diff --git a/src/stores/Auth.js b/src/stores/Auth.js index 5a0942f..a564fec 100644 --- a/src/stores/Auth.js +++ b/src/stores/Auth.js @@ -1,7 +1,7 @@ import { makeAutoObservable, runInAction } from "mobx"; import { fetchJSON, postForm } from '@/utils/request'; import { HT_HOST } from "@/config"; -import { prepareUrl } from '@/utils/commons'; +import { isNotEmpty, prepareUrl } from '@/utils/commons'; const KEY_LOGIN_TOKEN = 'KEY_LOGIN_TOKEN'; @@ -11,6 +11,9 @@ class Auth { makeAutoObservable(this, { rootStore: false }); this.root = root; this.login.token = root.getSession(KEY_LOGIN_TOKEN); + if (isNotEmpty(this.login.token)) { + this.fetchUserDetail(); + } setInterval(() => { // console.info('Auth.check.token.'); }, 10000); @@ -34,7 +37,7 @@ class Auth { }); } - fetchUserDetail(userId) { + fetchUserDetail() { const fetchUrl = prepareUrl(HT_HOST + '/service-CooperateSOA/GetLinkManInfo') .append('token', this.login.token) .build(); diff --git a/src/views/Login.jsx b/src/views/Login.jsx index 8551568..92509de 100644 --- a/src/views/Login.jsx +++ b/src/views/Login.jsx @@ -14,7 +14,7 @@ function Login() { authStore.valdateUserPassword(values.username, values.password) .then((userId) => { noticeStore.getBulletinUnReadCount(userId); - authStore.fetchUserDetail(userId) + authStore.fetchUserDetail() .then((user) => { // navigate(-1) is equivalent to hitting the back button. navigate("/reservation/newest"); diff --git a/src/views/reservation/Newest.jsx b/src/views/reservation/Newest.jsx index 3e25ed2..2a485b2 100644 --- a/src/views/reservation/Newest.jsx +++ b/src/views/reservation/Newest.jsx @@ -49,14 +49,14 @@ function Newest() { if (reservation.guide === '') { return ( - + ); } else { return ( {reservation.guide} - + ); } @@ -107,7 +107,7 @@ function Newest() { onSearchClick(1, 1); } return () => { - console.info('unmount...'); + // unmount... }; }, []);