app.js 994 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. },
  19. CLOSE_SIDEBAR: (state, withoutAnimation) => {
  20. Cookies.set('sidebarStatus', 1)
  21. state.sidebar.opened = false
  22. state.sidebar.withoutAnimation = withoutAnimation
  23. },
  24. TOGGLE_DEVICE: (state, device) => {
  25. state.device = device
  26. }
  27. },
  28. actions: {
  29. ToggleSideBar: ({ commit }) => {
  30. commit('TOGGLE_SIDEBAR')
  31. },
  32. CloseSideBar({ commit }, { withoutAnimation }) {
  33. commit('CLOSE_SIDEBAR', withoutAnimation)
  34. },
  35. ToggleDevice({ commit }, device) {
  36. commit('TOGGLE_DEVICE', device)
  37. }
  38. }
  39. }
  40. export default app