Skip to content

Commit

Permalink
fix(projects): recovery the layout config before is mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Jun 6, 2024
1 parent 6e80963 commit 851ae38
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/store/modules/app/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { effectScope, onScopeDispose, ref, watch } from 'vue';
import { effectScope, nextTick, onScopeDispose, ref, watch } from 'vue';
import { defineStore } from 'pinia';
import { breakpointsTailwind, useBreakpoints, useEventListener, useTitle } from '@vueuse/core';
import { useBoolean } from '@sa/hooks';
Expand Down Expand Up @@ -87,9 +87,26 @@ export const useAppStore = defineStore(SetupStoreId.App, () => {
isMobile,
newValue => {
if (newValue) {
setSiderCollapse(true);
// backup theme setting before is mobile
localStg.set('backupThemeSettingBeforeIsMobile', {
layout: themeStore.layout.mode,
siderCollapse: siderCollapse.value
});

themeStore.setThemeLayout('vertical');
setSiderCollapse(true);
} else {
// when is not mobile, recover the backup theme setting
const backup = localStg.get('backupThemeSettingBeforeIsMobile');

if (backup) {
nextTick(() => {
themeStore.setThemeLayout(backup.layout);
setSiderCollapse(backup.siderCollapse);

localStg.remove('backupThemeSettingBeforeIsMobile');
});
}
}
},
{ immediate: true }
Expand Down
5 changes: 5 additions & 0 deletions src/typings/storage.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,10 @@ declare namespace StorageType {
overrideThemeFlag: string;
/** The global tabs */
globalTabs: App.Global.Tab[];
/** The backup theme setting before is mobile */
backupThemeSettingBeforeIsMobile: {
layout: UnionKey.ThemeLayoutMode;
siderCollapse: boolean;
};
}
}

0 comments on commit 851ae38

Please sign in to comment.