app.js 487 B

123456789101112131415161718192021222324252627
  1. import Cookies from 'js-cookie'
  2. const app = {
  3. state: {
  4. sidebar: {
  5. opened: !+Cookies.get('sidebarStatus')
  6. }
  7. },
  8. mutations: {
  9. TOGGLE_SIDEBAR: state => {
  10. if (state.sidebar.opened) {
  11. Cookies.set('sidebarStatus', 1)
  12. } else {
  13. Cookies.set('sidebarStatus', 0)
  14. }
  15. state.sidebar.opened = !state.sidebar.opened
  16. }
  17. },
  18. actions: {
  19. ToggleSideBar: ({ commit }) => {
  20. commit('TOGGLE_SIDEBAR')
  21. }
  22. }
  23. }
  24. export default app