refresh.js 853 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { isObject, isUnDef } from '@/utils/is'
  2. export default {
  3. namespace: 'refresh',
  4. state: {
  5. contactList: false,
  6. client: false,
  7. company: false,
  8. software: false,
  9. department: false,
  10. staffList: false,
  11. business: false,
  12. cloud: false,
  13. personal: false
  14. },
  15. effects: {
  16. *commitAction({ payload }, { put }) {
  17. yield put({
  18. type: 'changState',
  19. payload
  20. })
  21. }
  22. },
  23. reducers: {
  24. changState(state, action) {
  25. if (isObject(action.payload)) {
  26. const { main, target } = action.payload
  27. return { ...state, [main]: !state[main], [target]: !state[target] }
  28. }
  29. if (isUnDef(state[action.payload])) {
  30. return { ...state, [action.payload]: false }
  31. }
  32. return {
  33. ...state,
  34. [action.payload]: !state[action.payload]
  35. }
  36. }
  37. }
  38. }