修复从移动端切换为pc端侧边栏可能强制被收起的bug

This commit is contained in:
hooray
2020-11-25 16:59:11 +08:00
parent 7c6a669349
commit 136f7d6929
2 changed files with 9 additions and 7 deletions
+4 -7
View File
@@ -16,13 +16,10 @@ export default {
'$store.state.settings.mode': {
handler() {
if (this.$store.state.settings.mode == 'pc') {
if (this.$store.state.settings.enableSidebarCollapse) {
this.$store.commit('settings/updateThemeSetting', {
'sidebarCollapse': false
})
}
}
if (this.$store.state.settings.mode == 'mobile') {
this.$store.commit('settings/updateThemeSetting', {
'sidebarCollapse': this.$store.state.settings.sidebarCollapseLastStatus
})
} else if (this.$store.state.settings.mode == 'mobile') {
this.$store.commit('settings/updateThemeSetting', {
'sidebarCollapse': true
})
+5
View File
@@ -5,6 +5,8 @@ import setting from '@/setting'
const state = {
...setting,
// 侧边栏是否收起(用于记录 pc 模式下最后的状态)
sidebarCollapseLastStatus: setting.sidebarCollapse,
// 显示模式,支持:mobile、pc
mode: 'pc',
// 页面标题
@@ -31,6 +33,9 @@ const mutations = {
// 切换侧边栏导航展开/收起
toggleSidebarCollapse(state) {
state.sidebarCollapse = !state.sidebarCollapse
if (state.mode == 'pc') {
state.sidebarCollapseLastStatus = !state.sidebarCollapseLastStatus
}
},
// 更新主题配置
updateThemeSetting(state, data) {