Skip to content

Commit 311796a

Browse files
authored
perf[Sidebar]: refine sidebar store #1473 (#1474)
1 parent cc75728 commit 311796a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/store/modules/app.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Cookies from 'js-cookie'
33
const app = {
44
state: {
55
sidebar: {
6-
opened: !+Cookies.get('sidebarStatus'),
6+
opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true,
77
withoutAnimation: false
88
},
99
device: 'desktop',
@@ -12,16 +12,16 @@ const app = {
1212
},
1313
mutations: {
1414
TOGGLE_SIDEBAR: state => {
15+
state.sidebar.opened = !state.sidebar.opened
16+
state.sidebar.withoutAnimation = false
1517
if (state.sidebar.opened) {
1618
Cookies.set('sidebarStatus', 1)
1719
} else {
1820
Cookies.set('sidebarStatus', 0)
1921
}
20-
state.sidebar.opened = !state.sidebar.opened
21-
state.sidebar.withoutAnimation = false
2222
},
2323
CLOSE_SIDEBAR: (state, withoutAnimation) => {
24-
Cookies.set('sidebarStatus', 1)
24+
Cookies.set('sidebarStatus', 0)
2525
state.sidebar.opened = false
2626
state.sidebar.withoutAnimation = withoutAnimation
2727
},

0 commit comments

Comments
 (0)