// 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) => { state.loginFlag = action.payload.loginFlag; state.loginUser = action.payload.loginUser; }, switchMeasureAfterSave: (state, action: PayloadAction) => { state.newMeasureAfterSave = action.payload; }, }, }); export const { updateUser, switchMeasureAfterSave } = contextSlice.actions; // 默认导出 export default contextSlice.reducer;