Skip to content

Commit

Permalink
fix: 🧩 修复横向布局下最大化失效
Browse files Browse the repository at this point in the history
  • Loading branch information
Halsey committed Jan 28, 2023
1 parent 5b4b926 commit e416ddb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
13 changes: 1 addition & 12 deletions src/layouts/components/Main/components/Maximize.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,14 @@
</template>

<script setup lang="ts">
import { computed, watch } from "vue";
import { computed } from "vue";
import { GlobalStore } from "@/stores";
const globalStore = GlobalStore();
const themeConfig = computed(() => globalStore.themeConfig);
const exitMaximize = () => {
globalStore.setThemeConfig({ ...themeConfig.value, maximize: false });
};
// 监听当前页是否全屏,动态添加 class
watch(
() => themeConfig.value.maximize,
() => {
const app = document.getElementById("app") as HTMLElement;
if (themeConfig.value.maximize) app.classList.add("main-maximize");
else app.classList.remove("main-maximize");
},
{ immediate: true }
);
</script>

<style scoped lang="scss">
Expand Down
13 changes: 12 additions & 1 deletion src/layouts/components/Main/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</template>

<script setup lang="ts">
import { ref, computed, onBeforeUnmount, provide } from "vue";
import { ref, computed, onBeforeUnmount, provide, watch } from "vue";
import { useDebounceFn } from "@vueuse/core";
import { GlobalStore } from "@/stores";
import { KeepAliveStore } from "@/stores/modules/keepAlive";
Expand All @@ -34,6 +34,17 @@ const isRouterShow = ref(true);
const refreshCurrentPage = (val: boolean) => (isRouterShow.value = val);
provide("refresh", refreshCurrentPage);
// 监听当前页是否最大化,动态添加 class
watch(
() => themeConfig.value.maximize,
() => {
const app = document.getElementById("app") as HTMLElement;
if (themeConfig.value.maximize) app.classList.add("main-maximize");
else app.classList.remove("main-maximize");
},
{ immediate: true }
);
// 监听窗口大小变化,折叠侧边栏
const screenWidth = ref(0);
const listeningWindow = useDebounceFn(() => {
Expand Down

1 comment on commit e416ddb

@vercel
Copy link

@vercel vercel bot commented on e416ddb Jan 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.