退出登录逻辑优化

This commit is contained in:
禺狨
2023-04-17 17:25:31 +08:00
parent 76d3a939d2
commit a67db5dbfc
4 changed files with 65 additions and 59 deletions

View File

@@ -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) {