mirror of
https://github.com/PlayEdu/frontend.git
synced 2025-12-26 14:21:47 +08:00
退出登录逻辑优化
This commit is contained in:
12
src/App.tsx
12
src/App.tsx
@@ -4,10 +4,6 @@ import { useLocation, useRoutes } from "react-router-dom";
|
||||
import routes from "./routes";
|
||||
import "./App.scss";
|
||||
import LoadingPage from "./pages/loading";
|
||||
import { user } from "./api/index";
|
||||
import { getToken } from "./utils/index";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { loginAction } from "./store/user/loginUserSlice";
|
||||
|
||||
const G_ID = import.meta.env.VITE_G_ID || "";
|
||||
if (G_ID) {
|
||||
@@ -15,16 +11,8 @@ if (G_ID) {
|
||||
}
|
||||
|
||||
const App = () => {
|
||||
const dispatch = useDispatch();
|
||||
const Views = () => useRoutes(routes);
|
||||
|
||||
if (getToken()) {
|
||||
user.detail().then((res: any) => {
|
||||
const data = res.data;
|
||||
dispatch(loginAction(data));
|
||||
});
|
||||
}
|
||||
|
||||
const location = useLocation();
|
||||
useEffect(() => {
|
||||
if (!G_ID) {
|
||||
|
||||
Reference in New Issue
Block a user