登录学员后检测部门逻辑优化

This commit is contained in:
禺狨 2023-04-25 09:57:47 +08:00
parent 09707c1fff
commit 244bf68c65
4 changed files with 14 additions and 7 deletions

View File

@ -73,8 +73,7 @@ export const Header: React.FC = () => {
cancelText: "取消",
onOk() {
dispatch(logoutAction());
clearToken();
navigate("/login");
navigate("/login", { replace: true });
},
onCancel() {
console.log("Cancel");

View File

@ -43,7 +43,6 @@
box-sizing: border-box;
padding-top: 30px;
margin-top: 60px;
animation: scaleBig 0.3s;
.video-title {
width: 100%;
height: 36px;

View File

@ -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 (
<>
<div>

View File

@ -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;