diff --git a/src/pages/user/login/index.tsx b/src/pages/user/login/index.tsx index b6f4f83..e5093af 100644 --- a/src/pages/user/login/index.tsx +++ b/src/pages/user/login/index.tsx @@ -125,8 +125,13 @@ const Login: React.FC = () => { defaultMessage: '登录成功!', }); message.success(defaultLoginSuccessMessage); - // await fetchUserInfo(); + // 保存用户信息到 localStorage localStorage.setItem('timeline_user', JSON.stringify(response.data)); + // 更新全局 initialState,确保跳转后权限检查通过 + await setInitialState((s: any) => ({ + ...s, + currentUser: response.data, + })); const urlParams = new URL(window.location.href).searchParams; // 修复:直接使用 redirect 参数,如果不存在则跳转到首页 const redirect = urlParams.get('redirect'); diff --git a/src/pages/user/register/index.tsx b/src/pages/user/register/index.tsx index 6235700..7afa924 100644 --- a/src/pages/user/register/index.tsx +++ b/src/pages/user/register/index.tsx @@ -6,6 +6,7 @@ import type { Store } from 'antd/es/form/interface'; import type { FC } from 'react'; import { useEffect, useState } from 'react'; import useStyles from './style.style'; +import { useIsMobile } from '@/hooks/useIsMobile'; const FormItem = Form.Item; const { Option } = Select;