app.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import Vue from 'vue'
  2. import { SIDEBAR_TYPE, DEFAULT_THEME, DEFAULT_COLOR, DEFAULT_COLOR_WEAK } from "@/store/mutation-types"
  3. const app = {
  4. state: {
  5. sidebar: {
  6. opened: true,
  7. withoutAnimation: false
  8. },
  9. device: 'desktop',
  10. theme: '',
  11. color: null,
  12. weak: false
  13. },
  14. mutations: {
  15. SET_SIDEBAR_TYPE: (state, type) => {
  16. state.sidebar.opened = type
  17. Vue.ls.set(SIDEBAR_TYPE, type)
  18. },
  19. CLOSE_SIDEBAR: (state, withoutAnimation) => {
  20. Vue.ls.set(SIDEBAR_TYPE, true)
  21. state.sidebar.opened = false
  22. state.sidebar.withoutAnimation = withoutAnimation
  23. },
  24. TOGGLE_DEVICE: (state, device) => {
  25. state.device = device
  26. },
  27. TOGGLE_THEME: (state, theme) => {
  28. // setStore('_DEFAULT_THEME', theme)
  29. Vue.ls.set(DEFAULT_THEME, theme)
  30. state.theme = theme
  31. },
  32. TOGGLE_COLOR: (state, color) => {
  33. Vue.ls.set(DEFAULT_COLOR, color)
  34. state.color = color
  35. },
  36. TOGGLE_WEAK: (state, flag) => {
  37. Vue.ls.set(DEFAULT_COLOR_WEAK, flag)
  38. state.weak = flag
  39. }
  40. },
  41. actions: {
  42. setSidebar: ({ commit }, type) => {
  43. commit('SET_SIDEBAR_TYPE', type)
  44. },
  45. CloseSidebar({ commit }, { withoutAnimation }) {
  46. commit('CLOSE_SIDEBAR', withoutAnimation)
  47. },
  48. ToggleDevice({ commit }, device) {
  49. commit('TOGGLE_DEVICE', device)
  50. },
  51. ToggleTheme({ commit }, theme) {
  52. commit('TOGGLE_THEME', theme)
  53. },
  54. ToggleColor({ commit }, color) {
  55. commit('TOGGLE_COLOR', color)
  56. },
  57. ToggleWeak({ commit }, weakFlag) {
  58. commit('TOGGLE_WEAK', weakFlag)
  59. }
  60. }
  61. }
  62. export default app