redux 加入

This commit is contained in:
mmc
2026-04-21 10:33:48 +08:00
parent fc23b6fa22
commit 79f8252b08
8 changed files with 138 additions and 68 deletions

View File

@@ -16,11 +16,14 @@ import {
import { motion } from 'motion/react';
import bgcImg from '../assets/bgc2.png';
import logincard from '../assets/logincard.png';
import { useDispatch } from 'react-redux';
import { login } from '../store/userSlice';
const { Text, Title } = Typography;
export default function Login() {
const navigate = useNavigate();
const dispatch = useDispatch();
// 账号密码登录
const onFinish = (values: any) => {
@@ -49,6 +52,11 @@ export default function Login() {
localStorage.setItem('user', JSON.stringify(userInfo));
message.success(`欢迎回来, ${name}`);
dispatch(login({
token: 'mock_token_' + Date.now(),
userInfo: userInfo
}));
navigate('/');
};