import React, { useEffect } from "react"; import { useDispatch, useSelector } from "react-redux"; import { useParams } from "react-router"; import { Redirect } from "react-router-dom"; import { login, loginSelector } from "src/store/loginSlice"; interface AuthParam { code: string; } export function Auth() { const { code } = useParams(); const dispatch = useDispatch(); const loginState = useSelector(loginSelector); useEffect(() => { const loginFun = async () => { dispatch(login(code)); }; loginFun(); }, [code, dispatch]); return ( <> {loginState.login ? ( ) : loginState.failed ? (
登录失败,请重新获取连接
) : (
Logining...
)} ); }