Skip to content

Commit dae2aa5

Browse files
committed
fix(projects): recovery the layout config before is mobile. fixed #408, fixed #361
1 parent b3e9bba commit dae2aa5

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/store/modules/app/index.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { effectScope, onScopeDispose, ref, watch } from 'vue';
1+
import { effectScope, nextTick, onScopeDispose, ref, watch } from 'vue';
22
import { defineStore } from 'pinia';
33
import { breakpointsTailwind, useBreakpoints, useEventListener, useTitle } from '@vueuse/core';
44
import { useBoolean } from '@sa/hooks';
@@ -87,9 +87,26 @@ export const useAppStore = defineStore(SetupStoreId.App, () => {
8787
isMobile,
8888
newValue => {
8989
if (newValue) {
90-
setSiderCollapse(true);
90+
// backup theme setting before is mobile
91+
localStg.set('backupThemeSettingBeforeIsMobile', {
92+
layout: themeStore.layout.mode,
93+
siderCollapse: siderCollapse.value
94+
});
9195

9296
themeStore.setThemeLayout('vertical');
97+
setSiderCollapse(true);
98+
} else {
99+
// when is not mobile, recover the backup theme setting
100+
const backup = localStg.get('backupThemeSettingBeforeIsMobile');
101+
102+
if (backup) {
103+
nextTick(() => {
104+
themeStore.setThemeLayout(backup.layout);
105+
setSiderCollapse(backup.siderCollapse);
106+
107+
localStg.remove('backupThemeSettingBeforeIsMobile');
108+
});
109+
}
93110
}
94111
},
95112
{ immediate: true }

src/typings/storage.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,10 @@ declare namespace StorageType {
3232
overrideThemeFlag: string;
3333
/** The global tabs */
3434
globalTabs: App.Global.Tab[];
35+
/** The backup theme setting before is mobile */
36+
backupThemeSettingBeforeIsMobile: {
37+
layout: UnionKey.ThemeLayoutMode;
38+
siderCollapse: boolean;
39+
};
3540
}
3641
}

0 commit comments

Comments
 (0)