You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

30 lines
787 B

// counterSlice.ts 文件
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
import { ContextMessage } from "../../services/wsTypes";
const initialState: ContextMessage["data"] = {
loginFlag: false,
loginUser: {},
newMeasureAfterSave: false,
};
export const contextSlice = createSlice({
name: "context",
initialState,
reducers: {
updateUser: (state, action: PayloadAction<ContextMessage["data"]>) => {
state.loginFlag = action.payload.loginFlag;
state.loginUser = action.payload.loginUser;
},
switchMeasureAfterSave: (state, action: PayloadAction<boolean>) => {
state.newMeasureAfterSave = action.payload;
},
},
});
export const { updateUser, switchMeasureAfterSave } = contextSlice.actions;
// 默认导出
export default contextSlice.reducer;