mirror of
https://github.com/PlayEdu/frontend.git
synced 2025-12-24 04:41:06 +08:00
个人信息修改和切花部门
This commit is contained in:
@@ -3,12 +3,14 @@ import { createSlice } from "@reduxjs/toolkit";
|
||||
type UserStoreInterface = {
|
||||
user: null;
|
||||
departments: string[];
|
||||
currentDepId: number;
|
||||
isLogin: boolean;
|
||||
};
|
||||
|
||||
let defaultValue: UserStoreInterface = {
|
||||
user: null,
|
||||
departments: [],
|
||||
currentDepId: 0,
|
||||
isLogin: false,
|
||||
};
|
||||
|
||||
@@ -22,16 +24,23 @@ const loginUserSlice = createSlice({
|
||||
stage.value.user = e.payload.user;
|
||||
stage.value.departments = e.payload.departments;
|
||||
stage.value.isLogin = true;
|
||||
if (e.payload.departments.length > 0 && stage.value.currentDepId === 0) {
|
||||
stage.value.currentDepId = e.payload.departments[0].id;
|
||||
}
|
||||
},
|
||||
logoutAction(stage) {
|
||||
stage.value.user = null;
|
||||
stage.value.departments = [];
|
||||
stage.value.isLogin = false;
|
||||
},
|
||||
saveCurrentDepId(stage, e) {
|
||||
stage.value.currentDepId = e.payload;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default loginUserSlice.reducer;
|
||||
export const { loginAction, logoutAction } = loginUserSlice.actions;
|
||||
export const { loginAction, logoutAction, saveCurrentDepId } =
|
||||
loginUserSlice.actions;
|
||||
|
||||
export type { UserStoreInterface };
|
||||
|
||||
Reference in New Issue
Block a user