Skip to content

Commit

Permalink
perf[Sidebar]: refine sidebar store #1473
Browse files Browse the repository at this point in the history
  • Loading branch information
PanJiaChen committed Dec 28, 2018
1 parent cc75728 commit 3f758bb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/store/modules/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Cookies from 'js-cookie'
const app = {
state: {
sidebar: {
opened: !+Cookies.get('sidebarStatus'),
opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true,
withoutAnimation: false
},
device: 'desktop',
Expand All @@ -12,16 +12,16 @@ const app = {
},
mutations: {
TOGGLE_SIDEBAR: state => {
state.sidebar.opened = !state.sidebar.opened
state.sidebar.withoutAnimation = false
if (state.sidebar.opened) {
Cookies.set('sidebarStatus', 1)
} else {
Cookies.set('sidebarStatus', 0)
}
state.sidebar.opened = !state.sidebar.opened
state.sidebar.withoutAnimation = false
},
CLOSE_SIDEBAR: (state, withoutAnimation) => {
Cookies.set('sidebarStatus', 1)
Cookies.set('sidebarStatus', 0)
state.sidebar.opened = false
state.sidebar.withoutAnimation = withoutAnimation
},
Expand Down

0 comments on commit 3f758bb

Please sign in to comment.