index.js 439 B

12345678910111213141516171819202122232425
  1. /**
  2. * 用于代替components库对vuex的依赖
  3. */
  4. import { reactive, readonly } from 'vue'
  5. import * as actions from './actions'
  6. const state = reactive({
  7. accountInfo: {},
  8. app: {}
  9. })
  10. const dispatch = (type, payload) => {
  11. const action = actions[type]
  12. if (action) {
  13. action.bind(this, { state, dispatch })(payload)
  14. } else {
  15. Error('type action not found!!')
  16. }
  17. }
  18. export default {
  19. state: readonly(state),
  20. dispatch
  21. }