app.js 760 B

123456789101112131415161718192021222324252627282930
  1. import Cookies from 'js-cookie'
  2. export default {
  3. state: {
  4. sidebar: {
  5. opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true,
  6. withoutAnimation: false
  7. },
  8. device: 'desktop'
  9. },
  10. toggleSideBar: function() {
  11. this.state.sidebar.opened = !this.state.sidebar.opened
  12. this.state.sidebar.withoutAnimation = false
  13. if (this.state.sidebar.opened) {
  14. Cookies.set('sidebarStatus', 1)
  15. } else {
  16. Cookies.set('sidebarStatus', 0)
  17. }
  18. },
  19. closeSideBar: function({ withoutAnimation }) {
  20. Cookies.set('sidebarStatus', 0)
  21. this.state.sidebar.opened = false
  22. this.state.sidebar.withoutAnimation = withoutAnimation
  23. },
  24. toggleDevice: function(device) {
  25. this.state.device = device
  26. }
  27. }