選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 
 

64 行
1.5 KiB

  1. import Vue from 'vue'
  2. import Vuex, { Store } from 'vuex'
  3. import config from '@/config.js'
  4. import defaultConfig from '@/common/config.default.js'
  5. const state = {
  6. apiRoot: null,
  7. loginUser: null,
  8. loginMark: null,
  9. token: null,
  10. company: null,
  11. department: null,
  12. user: null,
  13. dataDictionary: null,
  14. pageParam: null,
  15. jumpParam: null
  16. }
  17. const mutations = {
  18. apiRoot(state, val) { state.apiRoot = val },
  19. loginUser(state, val) { state.loginUser = val },
  20. loginMark(state, val) { state.loginMark = val },
  21. token(state, val) { state.token = val },
  22. company(state, val) { state.company = val },
  23. department(state, val) { state.department = val },
  24. user(state, val) { state.user = val },
  25. dataDictionary(state, val) { state.dataDictionary = val },
  26. pageParam(state, val) { state.pageParam = val },
  27. jumpParam(state, val) { state.jumpParam = val }
  28. }
  29. // 获取用户定义的全局变量,依次注册它们
  30. const globalVariables = config['globalVariables'] || defaultConfig['globalVariables']
  31. globalVariables.forEach(t => state[t] = null)
  32. globalVariables.forEach(t => mutations[t] = (state, val) => { state[t] = val })
  33. mutations.clear = (state) => {
  34. state.loginUser = null
  35. state.token = null
  36. state.company = null
  37. state.department = null
  38. state.user = null
  39. state.dataDictionary = null
  40. state.pageParam = null
  41. state.jumpParam = null
  42. globalVariables.forEach(t => {
  43. state[t] = null
  44. })
  45. }
  46. Vue.use(Vuex)
  47. export default new Store({ state, mutations })