feat(用户): 添加移动端检测并完善登录逻辑
All checks were successful
test/timeline-frontend/pipeline/head This commit looks good
All checks were successful
test/timeline-frontend/pipeline/head This commit looks good
在注册页面添加移动端检测钩子 登录成功后保存用户信息到localStorage并更新全局状态
This commit is contained in:
@@ -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');
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user