Blame view

ant-design-vue-jeecg/src/store/modules/app.js 3.34 KB
肖超群 authored
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import Vue from 'vue'
import {
  SIDEBAR_TYPE,
  DEFAULT_THEME,
  DEFAULT_LAYOUT_MODE,
  DEFAULT_COLOR,
  DEFAULT_COLOR_WEAK,
  DEFAULT_FIXED_HEADER,
  DEFAULT_FIXED_SIDEMENU,
  DEFAULT_FIXED_HEADER_HIDDEN,
  DEFAULT_CONTENT_WIDTH_TYPE,
  DEFAULT_MULTI_PAGE
} from "@/store/mutation-types"

const app = {
  state: {
    sidebar: {
      opened: true,
      withoutAnimation: false
    },
    device: 'desktop',
    theme: '',
    layout: '',
    contentWidth: '',
    fixedHeader: false,
    fixSiderbar: false,
    autoHideHeader: false,
    color: null,
    weak: false,
    multipage: true //默认多页签模式
  },
  mutations: {
    SET_SIDEBAR_TYPE: (state, type) => {
      state.sidebar.opened = type
      Vue.ls.set(SIDEBAR_TYPE, type)
    },
    CLOSE_SIDEBAR: (state, withoutAnimation) => {
      Vue.ls.set(SIDEBAR_TYPE, true)
      state.sidebar.opened = false
      state.sidebar.withoutAnimation = withoutAnimation
    },
    TOGGLE_DEVICE: (state, device) => {
      state.device = device
    },
    TOGGLE_THEME: (state, theme) => {
      // setStore('_DEFAULT_THEME', theme)
      Vue.ls.set(DEFAULT_THEME, theme)
      state.theme = theme
    },
    TOGGLE_LAYOUT_MODE: (state, layout) => {
      Vue.ls.set(DEFAULT_LAYOUT_MODE, layout)
      state.layout = layout
    },
    TOGGLE_FIXED_HEADER: (state, fixed) => {
      Vue.ls.set(DEFAULT_FIXED_HEADER, fixed)
      state.fixedHeader = fixed
    },
    TOGGLE_FIXED_SIDERBAR: (state, fixed) => {
      Vue.ls.set(DEFAULT_FIXED_SIDEMENU, fixed)
      state.fixSiderbar = fixed
    },
    TOGGLE_FIXED_HEADER_HIDDEN: (state, show) => {
      Vue.ls.set(DEFAULT_FIXED_HEADER_HIDDEN, show)
      state.autoHideHeader = show
    },
    TOGGLE_CONTENT_WIDTH: (state, type) => {
      Vue.ls.set(DEFAULT_CONTENT_WIDTH_TYPE, type)
      state.contentWidth = type
    },
    TOGGLE_COLOR: (state, color) => {
      Vue.ls.set(DEFAULT_COLOR, color)
      state.color = color
    },
    TOGGLE_WEAK: (state, flag) => {
      Vue.ls.set(DEFAULT_COLOR_WEAK, flag)
      state.weak = flag
    },
肖超群 authored
78
    SET_MULTI_PAGE(state, multipageFlag) {
肖超群 authored
79
80
81
82
83
      Vue.ls.set(DEFAULT_MULTI_PAGE, multipageFlag)
      state.multipage = multipageFlag
    }
  },
  actions: {
肖超群 authored
84
    setSidebar: ({commit}, type) => {
肖超群 authored
85
86
      commit('SET_SIDEBAR_TYPE', type)
    },
肖超群 authored
87
    CloseSidebar({commit}, {withoutAnimation}) {
肖超群 authored
88
89
      commit('CLOSE_SIDEBAR', withoutAnimation)
    },
肖超群 authored
90
    ToggleDevice({commit}, device) {
肖超群 authored
91
92
      commit('TOGGLE_DEVICE', device)
    },
肖超群 authored
93
    ToggleTheme({commit}, theme) {
肖超群 authored
94
95
      commit('TOGGLE_THEME', theme)
    },
肖超群 authored
96
    ToggleLayoutMode({commit}, mode) {
肖超群 authored
97
98
      commit('TOGGLE_LAYOUT_MODE', mode)
    },
肖超群 authored
99
    ToggleFixedHeader({commit}, fixedHeader) {
肖超群 authored
100
101
102
103
104
      if (!fixedHeader) {
        commit('TOGGLE_FIXED_HEADER_HIDDEN', false)
      }
      commit('TOGGLE_FIXED_HEADER', fixedHeader)
    },
肖超群 authored
105
106
    ToggleFixSiderbar({commit}, fixSiderbar) {
      commit('TOGGLE_FIXED_SIDERBAR', fixSiderbar)
肖超群 authored
107
    },
肖超群 authored
108
    ToggleFixedHeaderHidden({commit}, show) {
肖超群 authored
109
110
      commit('TOGGLE_FIXED_HEADER_HIDDEN', show)
    },
肖超群 authored
111
    ToggleContentWidth({commit}, type) {
肖超群 authored
112
113
      commit('TOGGLE_CONTENT_WIDTH', type)
    },
肖超群 authored
114
    ToggleColor({commit}, color) {
肖超群 authored
115
116
      commit('TOGGLE_COLOR', color)
    },
肖超群 authored
117
    ToggleWeak({commit}, weakFlag) {
肖超群 authored
118
119
      commit('TOGGLE_WEAK', weakFlag)
    },
肖超群 authored
120
    ToggleMultipage({commit}, multipageFlag) {
肖超群 authored
121
122
123
124
125
126
      commit('SET_MULTI_PAGE', multipageFlag)
    }
  }
}

export default app