mirror of
https://github.com/PlayEdu/frontend.git
synced 2025-12-26 22:20:14 +08:00
登录初步
This commit is contained in:
14
src/App.tsx
14
src/App.tsx
@@ -3,9 +3,23 @@ import routes from "./routes";
|
||||
import "./App.scss";
|
||||
import { Suspense } from "react";
|
||||
import LoadingPage from "./pages/loading";
|
||||
import { user } from "./api/index";
|
||||
import { getToken } from "./utils/index";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { logoutAction } from "./store/user/loginUserSlice";
|
||||
|
||||
function App() {
|
||||
const Views = () => useRoutes(routes);
|
||||
const dispatch = useDispatch();
|
||||
const getUser = () => {
|
||||
user.detail().then((res: any) => {
|
||||
const data = res.data;
|
||||
dispatch(logoutAction(data.user));
|
||||
});
|
||||
};
|
||||
if (getToken()) {
|
||||
getUser();
|
||||
}
|
||||
|
||||
return (
|
||||
<Suspense fallback={<LoadingPage />}>
|
||||
|
||||
Reference in New Issue
Block a user