diff --git a/src/hooks/setting/useProjectSetting.ts b/src/hooks/setting/useProjectSetting.ts index 7b7bec3..1a08980 100644 --- a/src/hooks/setting/useProjectSetting.ts +++ b/src/hooks/setting/useProjectSetting.ts @@ -8,6 +8,8 @@ export function useProjectSetting() { const getNavTheme = computed(() => projectStore.navTheme); + const getIsMobile = computed(() => projectStore.isMobile); + const getHeaderSetting = computed(() => projectStore.headerSetting); const getMultiTabsSetting = computed(() => projectStore.multiTabsSetting); @@ -27,6 +29,7 @@ export function useProjectSetting() { return { getNavMode, getNavTheme, + getIsMobile, getHeaderSetting, getMultiTabsSetting, getMenuSetting, diff --git a/src/layout/components/Menu/index.vue b/src/layout/components/Menu/index.vue index 70515a8..3036c19 100644 --- a/src/layout/components/Menu/index.vue +++ b/src/layout/components/Menu/index.vue @@ -15,152 +15,153 @@ diff --git a/src/layout/components/TagsView/index.vue b/src/layout/components/TagsView/index.vue index d85b435..8fd8513 100644 --- a/src/layout/components/TagsView/index.vue +++ b/src/layout/components/TagsView/index.vue @@ -80,593 +80,600 @@ diff --git a/src/layout/index.vue b/src/layout/index.vue index 66a8b93..665c1fc 100644 --- a/src/layout/index.vue +++ b/src/layout/index.vue @@ -25,7 +25,7 @@ class="layout-side-drawer" > - + @@ -97,7 +97,10 @@ const collapsed = ref(false); const { mobileWidth, menuWidth } = unref(getMenuSetting); -const isMobile = ref(false); +const isMobile = computed({ + get: () => settingStore.getIsMobile, + set: (val) => settingStore.setIsMobile(val) +}); const fixedHeader = computed(() => { const { fixed } = unref(getHeaderSetting); @@ -162,7 +165,6 @@ const showSideDrawder = computed({ const checkMobileMode = () => { if (document.body.clientWidth <= mobileWidth) { isMobile.value = true; - } else { isMobile.value = false; } diff --git a/src/settings/projectSetting.ts b/src/settings/projectSetting.ts index 5abea51..8612fa4 100644 --- a/src/settings/projectSetting.ts +++ b/src/settings/projectSetting.ts @@ -3,6 +3,8 @@ const setting = { navMode: 'vertical', //导航风格 dark 暗色侧边栏 light 白色侧边栏 header-dark 暗色顶栏 navTheme: 'dark', + // 是否处于移动端模式 + isMobile: false, //顶部 headerSetting: { //背景色 diff --git a/src/store/modules/projectSetting.ts b/src/store/modules/projectSetting.ts index 49a78ae..9c2c3cd 100644 --- a/src/store/modules/projectSetting.ts +++ b/src/store/modules/projectSetting.ts @@ -6,6 +6,7 @@ import type { IheaderSetting, ImenuSetting, ImultiTabsSetting, IcrumbsSetting } const { navMode, navTheme, + isMobile, headerSetting, showFooter, menuSetting, @@ -27,6 +28,7 @@ interface ProjectSettingState { permissionMode: string; //权限模式 isPageAnimate: boolean; //是否开启路由动画 pageAnimateType: string; //路由动画类型 + isMobile: boolean; // 是否处于移动端模式 } export const useProjectSettingStore = defineStore({ @@ -34,6 +36,7 @@ export const useProjectSettingStore = defineStore({ state: (): ProjectSettingState => ({ navMode: navMode, navTheme, + isMobile, headerSetting, showFooter, menuSetting, @@ -50,6 +53,9 @@ export const useProjectSettingStore = defineStore({ getNavTheme(): string { return this.navTheme; }, + getIsMobile(): boolean { + return this.isMobile; + }, getHeaderSetting(): object { return this.headerSetting; }, @@ -79,6 +85,9 @@ export const useProjectSettingStore = defineStore({ setNavTheme(value: string): void { this.navTheme = value; }, + setIsMobile(value: boolean): void { + this.isMobile = value; + }, }, });