fix:移动端点击菜单之后面板不会隐藏

This commit is contained in:
不做码农
2023-05-07 09:33:06 +08:00
parent 3db1fecbb8
commit 1217f1abdc
3 changed files with 32 additions and 17 deletions
+5 -7
View File
@@ -1,33 +1,31 @@
import Cookies from 'js-cookie'
import defaultSettings from '@/settings'
const useAppStore = defineStore('app', {
state: () => ({
sidebar: {
opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true,
withoutAnimation: false,
// withoutAnimation: false,
hide: false
},
device: 'desktop',
size: Cookies.get('size') || 'small',
size: Cookies.get('size') || defaultSettings.defaultSize,
lang: Cookies.get('lang') || 'zh-cn'
}),
actions: {
toggleSideBar(withoutAnimation) {
toggleSideBar() {
if (this.sidebar.hide) {
return false
}
this.sidebar.opened = !this.sidebar.opened
this.sidebar.withoutAnimation = withoutAnimation
if (this.sidebar.opened) {
Cookies.set('sidebarStatus', 1)
} else {
Cookies.set('sidebarStatus', 0)
}
},
closeSideBar(withoutAnimation) {
closeSideBar() {
Cookies.set('sidebarStatus', 0)
this.sidebar.opened = false
this.sidebar.withoutAnimation = withoutAnimation
},
toggleDevice(device) {
this.device = device