health.tsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { createSlice } from "@reduxjs/toolkit";
  2. interface HealthState {
  3. windows: any;
  4. fast_with_sleep: any;
  5. long_fast:any;
  6. mode: string;
  7. selTab: number;
  8. refreshs: any; //刷新数据时间点
  9. title: string;
  10. eatArchived: any;
  11. showActionCircadian: boolean;
  12. isCompleted: boolean;
  13. }
  14. const initialState: HealthState = {
  15. windows: null,
  16. fast_with_sleep: null,
  17. long_fast:null,
  18. mode: 'DAY',
  19. selTab: 0,
  20. refreshs: [],
  21. title: '',
  22. eatArchived: null,
  23. showActionCircadian: false,
  24. isCompleted: false,
  25. }
  26. const healthSlice = createSlice({
  27. name: 'health',
  28. initialState,
  29. reducers: {
  30. setWindows(state, action) {
  31. state.windows = action.payload
  32. },
  33. setFastWithSleep(state, action) {
  34. state.fast_with_sleep = action.payload
  35. },
  36. setLongFast(state,action){
  37. state.long_fast = action.payload
  38. },
  39. setMode(state, action) {
  40. state.mode = action.payload
  41. },
  42. setTab(state, action) {
  43. state.selTab = action.payload
  44. },
  45. setRefreshs(state, action) {
  46. state.refreshs = action.payload
  47. },
  48. setTitle(state, action) {
  49. state.title = action.payload
  50. },
  51. setEatArchived(state, action) {
  52. state.eatArchived = action.payload
  53. },
  54. setShowActionTip(state, action) {
  55. const { isShow, isCompleted } = action.payload
  56. state.showActionCircadian = isShow
  57. state.isCompleted = isCompleted
  58. }
  59. }
  60. })
  61. export const { setWindows, setMode, setTab, setRefreshs, setTitle, setEatArchived, setShowActionTip, setFastWithSleep,setLongFast } = healthSlice.actions;
  62. export default healthSlice.reducer;