Browse Source

feat: layout 新增 resize 监听 更新 isMaxM

lanceJiang 10 months ago
parent
commit
206bf44e38
1 changed files with 10 additions and 3 deletions
  1. 10 3
      src/layout/index.vue

+ 10 - 3
src/layout/index.vue

@@ -4,7 +4,7 @@
 </template>
 
 <script setup lang="ts" name="layout">
-import { computed, type Component } from 'vue'
+import { computed, type Component, onMounted, onUnmounted } from 'vue'
 import { LayoutType } from '@/store/interface'
 import useStore from '@/store'
 // import RightPanel from '@/components/RightPanel/index-old.vue'
@@ -20,9 +20,16 @@ const LayoutComponents: Record<LayoutType, Component> = {
 	topMix: LayoutTopMix,
 	top: LayoutTop
 }
-const { setting } = useStore()
-const layout = computed(() => setting.layout)
+const { setting, app } = useStore()
+const layout = computed(() => (app.isMaxM ? 'left' : setting.layout))
 const showSettings = computed(() => setting.showSettings)
+onMounted(() => {
+	window.addEventListener('resize', app.updateDevice)
+})
+
+onUnmounted(() => {
+	window.removeEventListener('resize', app.updateDevice)
+})
 </script>
 
 <style scoped lang="scss">