From 244bf68c6505b99f2c82ad6f72ac6e469f23ecb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BA=E7=8B=A8?= <18119604035@163.com> Date: Tue, 25 Apr 2023 09:57:47 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=AD=A6=E5=91=98=E5=90=8E?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=E9=83=A8=E9=97=A8=E9=80=BB=E8=BE=91=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/compenents/header/index.tsx | 3 +-- src/pages/course/video.module.scss | 1 - src/pages/init/index.tsx | 5 ++--- src/store/user/loginUserSlice.ts | 12 +++++++++++- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/compenents/header/index.tsx b/src/compenents/header/index.tsx index 9c9bd77..3c47df9 100644 --- a/src/compenents/header/index.tsx +++ b/src/compenents/header/index.tsx @@ -73,8 +73,7 @@ export const Header: React.FC = () => { cancelText: "取消", onOk() { dispatch(logoutAction()); - clearToken(); - navigate("/login"); + navigate("/login", { replace: true }); }, onCancel() { console.log("Cancel"); diff --git a/src/pages/course/video.module.scss b/src/pages/course/video.module.scss index d94ee1f..e16947c 100644 --- a/src/pages/course/video.module.scss +++ b/src/pages/course/video.module.scss @@ -43,7 +43,6 @@ box-sizing: border-box; padding-top: 30px; margin-top: 60px; - animation: scaleBig 0.3s; .video-title { width: 100%; height: 36px; diff --git a/src/pages/init/index.tsx b/src/pages/init/index.tsx index de3d729..ea30b9a 100644 --- a/src/pages/init/index.tsx +++ b/src/pages/init/index.tsx @@ -15,6 +15,8 @@ interface Props { } export const InitPage = (props: Props) => { + const pathname = useLocation().pathname; + const params = useParams(); const dispatch = useDispatch(); if (props.loginData) { dispatch(loginAction(props.loginData)); @@ -43,9 +45,6 @@ export const InitPage = (props: Props) => { dispatch(saveConfigAction(config)); } - const pathname = useLocation().pathname; - const params = useParams(); - return ( <>
diff --git a/src/store/user/loginUserSlice.ts b/src/store/user/loginUserSlice.ts index 237e761..d75f83e 100644 --- a/src/store/user/loginUserSlice.ts +++ b/src/store/user/loginUserSlice.ts @@ -1,5 +1,11 @@ import { createSlice } from "@reduxjs/toolkit"; -import { getDepKey } from "../../utils/index"; +import { + getDepKey, + clearDepKey, + clearDepName, + setDepName, + clearToken, +} from "../../utils/index"; type UserStoreInterface = { user: null; @@ -27,6 +33,7 @@ const loginUserSlice = createSlice({ stage.value.isLogin = true; if (e.payload.departments.length > 0 && stage.value.currentDepId === 0) { stage.value.currentDepId = e.payload.departments[0].id; + setDepName(e.payload.departments[0].name); } }, logoutAction(stage) { @@ -34,6 +41,9 @@ const loginUserSlice = createSlice({ stage.value.departments = []; stage.value.isLogin = false; stage.value.currentDepId = 0; + clearToken(); + clearDepKey(); + clearDepName(); }, saveCurrentDepId(stage, e) { stage.value.currentDepId = e.payload;