app.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import Cookies from 'js-cookie'
  2. const app = {
  3. state: {
  4. sidebar: {
  5. opened: !+Cookies.get('sidebarStatus'),
  6. withoutAnimation: false
  7. },
  8. device: 'desktop'
  9. },
  10. mutations: {
  11. TOGGLE_SIDEBAR: state => {
  12. if (state.sidebar.opened) {
  13. Cookies.set('sidebarStatus', 1)
  14. } else {
  15. Cookies.set('sidebarStatus', 0)
  16. }
  17. state.sidebar.opened = !state.sidebar.opened
  18. state.sidebar.withoutAnimation = false
  19. },
  20. CLOSE_SIDEBAR: (state, withoutAnimation) => {
  21. Cookies.set('sidebarStatus', 1)
  22. state.sidebar.opened = false
  23. state.sidebar.withoutAnimation = withoutAnimation
  24. },
  25. TOGGLE_DEVICE: (state, device) => {
  26. state.device = device
  27. }
  28. },
  29. actions: {
  30. ToggleSideBar: ({ commit }) => {
  31. commit('TOGGLE_SIDEBAR')
  32. },
  33. CloseSideBar({ commit }, { withoutAnimation }) {
  34. commit('CLOSE_SIDEBAR', withoutAnimation)
  35. },
  36. ToggleDevice({ commit }, device) {
  37. commit('TOGGLE_DEVICE', device)
  38. }
  39. }
  40. }
  41. export default app