|
|
@@ -29,16 +29,6 @@ const LoginMessage: React.FC<{
|
|
|
/>
|
|
|
);
|
|
|
|
|
|
-/** 此方法会跳转到 redirect 参数所在的位置 */
|
|
|
-const goto = () => {
|
|
|
- if (!history) return;
|
|
|
- setTimeout(() => {
|
|
|
- const { query } = history.location;
|
|
|
- const { redirect } = query as { redirect: string };
|
|
|
- history.push(redirect || '/');
|
|
|
- }, 10);
|
|
|
-};
|
|
|
-
|
|
|
const Login: React.FC = () => {
|
|
|
const [submitting, setSubmitting] = useState(false);
|
|
|
const [userLoginState, setUserLoginState] = useState<API.LoginResult>({});
|
|
|
@@ -50,10 +40,10 @@ const Login: React.FC = () => {
|
|
|
const fetchUserInfo = async () => {
|
|
|
const userInfo = await initialState?.fetchUserInfo?.();
|
|
|
if (userInfo) {
|
|
|
- setInitialState({
|
|
|
- ...initialState,
|
|
|
+ await setInitialState((s) => ({
|
|
|
+ ...s,
|
|
|
currentUser: userInfo,
|
|
|
- });
|
|
|
+ }));
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -69,7 +59,11 @@ const Login: React.FC = () => {
|
|
|
});
|
|
|
message.success(defaultloginSuccessMessage);
|
|
|
await fetchUserInfo();
|
|
|
- goto();
|
|
|
+ /** 此方法会跳转到 redirect 参数所在的位置 */
|
|
|
+ if (!history) return;
|
|
|
+ const { query } = history.location;
|
|
|
+ const { redirect } = query as { redirect: string };
|
|
|
+ history.push(redirect || '/');
|
|
|
return;
|
|
|
}
|
|
|
// 如果失败去设置用户错误信息
|