import { createSlice } from "@reduxjs/toolkit"; interface HealthState { windows: any; fast_with_sleep: any; long_fast:any; mode: string; selTab: number; refreshs: any; //刷新数据时间点 title: string; eatArchived: any; showActionCircadian: boolean; isCompleted: boolean; } const initialState: HealthState = { windows: null, fast_with_sleep: null, long_fast:null, mode: 'DAY', selTab: 0, refreshs: [], title: '', eatArchived: null, showActionCircadian: false, isCompleted: false, } const healthSlice = createSlice({ name: 'health', initialState, reducers: { setWindows(state, action) { state.windows = action.payload }, setFastWithSleep(state, action) { state.fast_with_sleep = action.payload }, setLongFast(state,action){ state.long_fast = action.payload }, setMode(state, action) { state.mode = action.payload }, setTab(state, action) { state.selTab = action.payload }, setRefreshs(state, action) { state.refreshs = action.payload }, setTitle(state, action) { state.title = action.payload }, setEatArchived(state, action) { state.eatArchived = action.payload }, setShowActionTip(state, action) { const { isShow, isCompleted } = action.payload state.showActionCircadian = isShow state.isCompleted = isCompleted } } }) export const { setWindows, setMode, setTab, setRefreshs, setTitle, setEatArchived, setShowActionTip, setFastWithSleep,setLongFast } = healthSlice.actions; export default healthSlice.reducer;