home.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import Vue from 'vue'
  2. import { ADD_ACTIVE_MENU_ID, REMOVE_ACTIVE_MENU_ID, SET_CUR_REFRESH_TABLE_TAB_ID, SET_AUTHORITIES, SET_THEME } from '@/store/mutation-types'
  3. const state = {
  4. activeMenuIds: [],
  5. refreshTabId: null,
  6. curRemoveMenuName: null,
  7. authorities: [],
  8. theme: '',
  9. }
  10. // getters
  11. const getters = {
  12. }
  13. // actions
  14. const actions = {
  15. }
  16. // mutations
  17. const mutations = {
  18. [ADD_ACTIVE_MENU_ID](state, menuId) {
  19. var index = state.activeMenuIds.indexOf(menuId, 'menuId');
  20. if(index == -1){
  21. state.activeMenuIds.push({
  22. menuId: menuId,
  23. destroy: false
  24. });
  25. } else {
  26. // Vue.set(state.activeMenuIds, index, {
  27. // menuId: menuId,
  28. // destroy: true
  29. // });
  30. }
  31. },
  32. [REMOVE_ACTIVE_MENU_ID](state, menuId) {
  33. var index = state.activeMenuIds.indexOf(menuId, 'menuId');
  34. if(index != -1){
  35. state.activeMenuIds.splice(index, 1);
  36. }
  37. state.curRemoveMenuName = menuId + "_" + new Date().getTime();
  38. },
  39. [SET_CUR_REFRESH_TABLE_TAB_ID](state, menuId) {
  40. state.refreshTabId = menuId;
  41. },
  42. [SET_AUTHORITIES](state, authorities) {
  43. state.authorities = authorities;
  44. },
  45. [SET_THEME](state, theme) {
  46. state.theme = theme;
  47. },
  48. }
  49. export default {
  50. namespaced: true,
  51. state,
  52. getters,
  53. actions,
  54. mutations
  55. }