health.tsx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. activeArchived: any;
  12. eatArchivedTotal: number;
  13. activeArchivedTotal: number;
  14. showActionCircadian: boolean;
  15. isCompleted: boolean;
  16. schedules: any;
  17. footer: any;
  18. finish_setup: boolean;
  19. first_eat_id: any;
  20. eat_journal_tip: boolean;
  21. first_active_id: any;
  22. active_journal_tip: boolean;
  23. }
  24. const initialState: HealthState = {
  25. windows: null,
  26. fast_with_sleep: null,
  27. long_fast: null,
  28. mode: '',
  29. selTab: 0,
  30. refreshs: [],
  31. title: '',
  32. eatArchived: null,
  33. activeArchived: null,
  34. eatArchivedTotal: 0,
  35. activeArchivedTotal: 0,
  36. showActionCircadian: false,
  37. isCompleted: false,
  38. schedules: [],
  39. footer: null,
  40. finish_setup: false,
  41. //tip
  42. first_eat_id: '',
  43. first_active_id: '',
  44. eat_journal_tip: false,
  45. active_journal_tip: false,
  46. }
  47. const healthSlice = createSlice({
  48. name: 'health',
  49. initialState,
  50. reducers: {
  51. setWindows(state, action) {
  52. state.windows = action.payload
  53. },
  54. setFastWithSleep(state, action) {
  55. state.fast_with_sleep = action.payload
  56. },
  57. setLongFast(state, action) {
  58. state.long_fast = action.payload
  59. },
  60. setMode(state, action) {
  61. state.mode = action.payload
  62. },
  63. setTab(state, action) {
  64. state.selTab = action.payload
  65. },
  66. setRefreshs(state, action) {
  67. state.refreshs = action.payload
  68. },
  69. setTitle(state, action) {
  70. state.title = action.payload
  71. },
  72. setEatArchived(state, action) {
  73. state.eatArchived = action.payload
  74. },
  75. setActiveArchived(state, action) {
  76. state.activeArchived = action.payload
  77. },
  78. setEatArchivedTotal(state, action) {
  79. state.eatArchivedTotal = action.payload
  80. },
  81. setActiveArchivedTotal(state, action) {
  82. state.activeArchivedTotal = action.payload
  83. },
  84. setShowActionTip(state, action) {
  85. const { isShow, isCompleted } = action.payload
  86. state.showActionCircadian = isShow
  87. state.isCompleted = isCompleted
  88. },
  89. setSchedules(state, action) {
  90. debugger
  91. state.schedules = action.payload
  92. },
  93. setFooter(state, action) {
  94. state.footer = action.payload
  95. },
  96. setFinishSetup(state, action) {
  97. state.finish_setup = action.payload
  98. },
  99. setFirstEatId(state, action) {
  100. state.first_eat_id = action.payload
  101. },
  102. setFirstActiveId(state, action) {
  103. state.first_active_id = action.payload
  104. },
  105. setEatTip(state, action) {
  106. state.eat_journal_tip = action.payload
  107. },
  108. setActiveTip(state, action) {
  109. state.active_journal_tip = action.payload
  110. }
  111. }
  112. })
  113. export const { setWindows,
  114. setMode, setTab, setRefreshs,
  115. setTitle, setEatArchived, setActiveArchived,
  116. setEatArchivedTotal, setActiveArchivedTotal,
  117. setShowActionTip, setFastWithSleep, setLongFast,
  118. setSchedules, setFooter, setFinishSetup,
  119. setFirstEatId, setFirstActiveId,
  120. setEatTip, setActiveTip
  121. } = healthSlice.actions;
  122. export default healthSlice.reducer;