diff --git a/src/stores/GlobalConfigStore.js b/src/stores/GlobalConfigStore.js index d772470..b92b663 100644 --- a/src/stores/GlobalConfigStore.js +++ b/src/stores/GlobalConfigStore.js @@ -1,4 +1,4 @@ -import { ref } from 'vue' +import { ref, watch } from 'vue' import { defineStore } from 'pinia' import { useDark, useMediaQuery } from '@vueuse/core' import { GlobalLayoutMode, GlobalLocales, LoadSaveParamMode } from '@/consts/GlobalConstants' @@ -14,13 +14,19 @@ export const useGlobalConfigStore = defineStore('globalConfig', () => { storageKey: `__${systemKey}__vueuse-color-scheme` }) : ref(false) - const isCollapseLeft = ref(false) + const isSmallScreen = useMediaQuery('(max-width: 1200px)') + const isCollapseLeft = ref(isSmallScreen.value && AUTO_LAYOUT_ENABLED) const isShowSettings = ref(false) const isShowBreadcrumb = ref(true) const showMenuIcon = ref(true) - const isLargeScreen = useMediaQuery('(min-width: 1440px)') - const layoutMode = !isLargeScreen.value && AUTO_LAYOUT_ENABLED ? ref(GlobalLayoutMode.TOP) : ref(GlobalLayoutMode.LEFT) + const layoutMode = ref(GlobalLayoutMode.LEFT) const loadSaveParamMode = ref(LoadSaveParamMode.BACK) + + if (AUTO_LAYOUT_ENABLED) { + watch(isSmallScreen, (small) => { + isCollapseLeft.value = small + }) + } return { currentLocale, isDarkTheme,