menu.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import store from '/@/store';
  2. import { hotModuleUnregisterModule } from '/@/utils/helper/vuexHelper';
  3. import { VuexModule, Module, getModule, Mutation } from 'vuex-module-decorators';
  4. import { appStore } from '/@/store/modules/app';
  5. const NAME = 'menu';
  6. hotModuleUnregisterModule(NAME);
  7. @Module({ namespaced: true, name: NAME, dynamic: true, store })
  8. class Menu extends VuexModule {
  9. // 是否开始拖拽
  10. private dragStartState = false;
  11. private currentTopSplitMenuPathState = '';
  12. /**
  13. * @description: 获取窗口名称
  14. */
  15. get getCollapsedState() {
  16. return appStore.getProjectConfig.menuSetting.collapsed;
  17. }
  18. get getCurrentTopSplitMenuPathState() {
  19. return this.currentTopSplitMenuPathState;
  20. }
  21. get getDragStartState() {
  22. return this.dragStartState;
  23. }
  24. get getMenuWidthState() {
  25. return appStore.getProjectConfig.menuSetting.menuWidth;
  26. }
  27. @Mutation
  28. commitDragStartState(dragStart: boolean): void {
  29. this.dragStartState = dragStart;
  30. }
  31. @Mutation
  32. commitCurrentTopSplitMenuPathState(path: string): void {
  33. this.currentTopSplitMenuPathState = path;
  34. }
  35. // 改变菜单展开状态
  36. @Mutation
  37. commitCollapsedState(collapsed: boolean): void {
  38. // this.collapsedState = collapsed;
  39. appStore.commitProjectConfigState({
  40. menuSetting: {
  41. collapsed: collapsed,
  42. },
  43. });
  44. }
  45. @Mutation
  46. commitMenuWidthState(menuWidth: number): void {
  47. // this.menuWidthState = menuWidth;
  48. appStore.commitProjectConfigState({
  49. menuSetting: {
  50. menuWidth: menuWidth,
  51. },
  52. });
  53. }
  54. }
  55. export { Menu };
  56. export const menuStore = getModule<Menu>(Menu);