2024-02-08 10:31:29 +08:00
|
|
|
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
|
|
|
export interface APIState {
|
|
|
|
showPaperManagement: boolean;
|
|
|
|
paperNumberRedux: string;
|
|
|
|
contentUpdatedFromNetwork: boolean;
|
2024-02-08 23:06:35 +08:00
|
|
|
isVip: boolean;
|
2024-02-08 10:31:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const initialState: APIState = {
|
|
|
|
showPaperManagement: false,
|
2024-02-08 21:57:21 +08:00
|
|
|
paperNumberRedux: "1", //默认得给个值
|
2024-02-08 10:31:29 +08:00
|
|
|
contentUpdatedFromNetwork: false,
|
2024-02-08 23:06:35 +08:00
|
|
|
isVip: false,
|
2024-02-08 10:31:29 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
export const stateSlice = createSlice({
|
|
|
|
name: "state",
|
|
|
|
initialState,
|
|
|
|
reducers: {
|
|
|
|
setShowPaperManagement: (state) => {
|
|
|
|
state.showPaperManagement = !state.showPaperManagement;
|
|
|
|
console.log("state.showPaperManagement", state.showPaperManagement);
|
|
|
|
},
|
|
|
|
setPaperNumberRedux: (state, action: PayloadAction<string>) => {
|
|
|
|
// state.paperNumberRedux = action.payload;
|
|
|
|
// console.log("state.paperNumberRedux", state.paperNumberRedux);
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
paperNumberRedux: action.payload,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
setContentUpdatedFromNetwork: (state, action: PayloadAction<boolean>) => {
|
|
|
|
state.contentUpdatedFromNetwork = action.payload;
|
|
|
|
},
|
2024-02-08 23:06:35 +08:00
|
|
|
setIsVip: (state, action: PayloadAction<boolean>) => {
|
|
|
|
state.isVip = action.payload;
|
|
|
|
},
|
2024-02-08 10:31:29 +08:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
// Action creators are generated for each case reducer function
|
|
|
|
export const {
|
|
|
|
setShowPaperManagement,
|
|
|
|
setPaperNumberRedux,
|
|
|
|
setContentUpdatedFromNetwork,
|
2024-02-08 23:06:35 +08:00
|
|
|
setIsVip,
|
2024-02-08 10:31:29 +08:00
|
|
|
} = stateSlice.actions;
|
|
|
|
|
|
|
|
export const stateReducer = stateSlice.reducer;
|