mirror of
https://github.com/PlayEdu/frontend.git
synced 2025-06-29 07:52:51 +08:00
存储部门信息
This commit is contained in:
parent
da56cd085e
commit
a0754cde00
@ -8,6 +8,7 @@ import {
|
||||
logoutAction,
|
||||
saveCurrentDepId,
|
||||
} from "../../store/user/loginUserSlice";
|
||||
import { setDepKey, setDepName, getDepName } from "../../utils/index";
|
||||
import { ChangePasswordModel } from "../change-password";
|
||||
import { UserInfoModel } from "../user-info";
|
||||
import { ExclamationCircleFilled } from "@ant-design/icons";
|
||||
@ -32,7 +33,7 @@ export const Header: React.FC = () => {
|
||||
|
||||
useEffect(() => {
|
||||
if (departments.length > 0) {
|
||||
setCurrentDepartment(departments[0].name);
|
||||
setCurrentDepartment(getDepName() || departments[0].name);
|
||||
const arr: any = [
|
||||
{
|
||||
key: "1",
|
||||
@ -129,6 +130,8 @@ export const Header: React.FC = () => {
|
||||
onOk() {
|
||||
setCurrentDepartment(name);
|
||||
dispatch(saveCurrentDepId(Number(key)));
|
||||
setDepKey(key);
|
||||
setDepName(name);
|
||||
const box = [...departments];
|
||||
const arr: any = [
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { createSlice } from "@reduxjs/toolkit";
|
||||
import { getDepKey } from "../../utils/index";
|
||||
|
||||
type UserStoreInterface = {
|
||||
user: null;
|
||||
@ -10,7 +11,7 @@ type UserStoreInterface = {
|
||||
let defaultValue: UserStoreInterface = {
|
||||
user: null,
|
||||
departments: [],
|
||||
currentDepId: 0,
|
||||
currentDepId: Number(getDepKey()) || 0,
|
||||
isLogin: false,
|
||||
};
|
||||
|
||||
|
@ -72,3 +72,26 @@ export function inStrArray(array: string[], value: string): boolean {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function getDepKey(): string {
|
||||
return window.localStorage.getItem("playedu-frontend-depatmentKey") || "";
|
||||
}
|
||||
|
||||
export function setDepKey(token: string) {
|
||||
window.localStorage.setItem("playedu-frontend-depatmentKey", token);
|
||||
}
|
||||
|
||||
export function clearDepKey() {
|
||||
window.localStorage.removeItem("playedu-frontend-depatmentKey");
|
||||
}
|
||||
export function getDepName(): string {
|
||||
return window.localStorage.getItem("playedu-frontend-depatmentName") || "";
|
||||
}
|
||||
|
||||
export function setDepName(token: string) {
|
||||
window.localStorage.setItem("playedu-frontend-depatmentName", token);
|
||||
}
|
||||
|
||||
export function clearDepName() {
|
||||
window.localStorage.removeItem("playedu-frontend-depatmentName");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user