mirror of
https://github.com/PlayEdu/backend
synced 2025-12-23 02:41:19 +08:00
左侧栏初步
This commit is contained in:
29
src/store/store.ts
Normal file
29
src/store/store.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { createStore } from "redux";
|
||||
interface IAction {
|
||||
type: string;
|
||||
payload?: any;
|
||||
}
|
||||
interface IState {
|
||||
isshow: boolean;
|
||||
}
|
||||
const reducer = (
|
||||
preState: IState = {
|
||||
isshow: false,
|
||||
},
|
||||
action: IAction
|
||||
) => {
|
||||
const { type } = action;
|
||||
const newState = { ...preState };
|
||||
switch (type) {
|
||||
case "show":
|
||||
newState.isshow = true;
|
||||
return newState;
|
||||
case "hidden":
|
||||
newState.isshow = false;
|
||||
return newState;
|
||||
default:
|
||||
return preState;
|
||||
}
|
||||
};
|
||||
const store = createStore(reducer);
|
||||
export default store;
|
||||
Reference in New Issue
Block a user