|
1 | 1 | <template> |
2 | | - <div class="absolute h-screen w-screen"> |
3 | | - <NanoHeader/> |
4 | | - <NanoBody/> |
5 | | - <NanoFooter/> |
| 2 | + <div |
| 3 | + ref="root" |
| 4 | + class="relative h-screen w-screen" |
| 5 | + > |
| 6 | + <NanoContainer/> |
6 | 7 | </div> |
7 | 8 | </template> |
8 | 9 |
|
9 | 10 | <script setup lang="ts"> |
10 | | - import NanoHeader from '@NanoUI/NanoHeader/index.vue'; |
11 | | - import NanoBody from '@NanoUI/NanoBody/index.vue'; |
12 | | - import NanoFooter from '@NanoUI/NanoFooter/index.vue'; |
| 11 | + import NanoContainer from '@NanoUI/NanoContainer/index.vue'; |
| 12 | + import { nextTick, onBeforeUnmount, onMounted, ref } from 'vue'; |
| 13 | + import { controllerStore } from '@store/controller'; |
| 14 | +
|
| 15 | + const ctl = controllerStore(); |
| 16 | +
|
| 17 | + const root = ref<HTMLElement | null>(null); |
| 18 | + const resizeObserver = ref<ResizeObserver | null>(null); |
| 19 | +
|
| 20 | + onMounted(() => { |
| 21 | + resizeObserver.value = new ResizeObserver((entries: ResizeObserverEntry[]) => { |
| 22 | + const htmlEl = document.documentElement; |
| 23 | + for (const entry of entries) { |
| 24 | + const { target } = entry; |
| 25 | + const { clientWidth } = target as HTMLElement; |
| 26 | + if (clientWidth >= 2560) { |
| 27 | + htmlEl.style.setProperty('font-size', '18px'); |
| 28 | + ctl.allowDrag = true; |
| 29 | + ctl.articleFullscreen = false; |
| 30 | + ctl.hideLeftSidebar = false; |
| 31 | + ctl.hideRightSidebar = false; |
| 32 | + ctl.hideActionBar = false; |
| 33 | + ctl.hideHeaderTopNav = false; |
| 34 | + ctl.hidePaths = false; |
| 35 | + ctl.hideCopyright = false; |
| 36 | + } else if (clientWidth >= 1920) { |
| 37 | + htmlEl.style.setProperty('font-size', '16px'); |
| 38 | + ctl.allowDrag = true; |
| 39 | + ctl.articleFullscreen = false; |
| 40 | + ctl.hideLeftSidebar = false; |
| 41 | + ctl.hideRightSidebar = false; |
| 42 | + ctl.hideActionBar = false; |
| 43 | + ctl.hideHeaderTopNav = false; |
| 44 | + ctl.hidePaths = false; |
| 45 | + ctl.hideCopyright = false; |
| 46 | + } else if (clientWidth >= 1280) { |
| 47 | + htmlEl.style.setProperty('font-size', '14px'); |
| 48 | + ctl.allowDrag = false; |
| 49 | + ctl.articleFullscreen = false; |
| 50 | + ctl.hideLeftSidebar = false; |
| 51 | + ctl.hideRightSidebar = false; |
| 52 | + ctl.hideActionBar = false; |
| 53 | + ctl.hideHeaderTopNav = false; |
| 54 | + ctl.hidePaths = false; |
| 55 | + ctl.hideCopyright = false; |
| 56 | + } else if (clientWidth >= 768) { |
| 57 | + htmlEl.style.setProperty('font-size', '12px'); |
| 58 | + ctl.allowDrag = false; |
| 59 | + ctl.articleFullscreen = false; |
| 60 | + ctl.hideLeftSidebar = false; |
| 61 | + ctl.hideRightSidebar = true; |
| 62 | + ctl.hideActionBar = true; |
| 63 | + ctl.hideHeaderTopNav = true; |
| 64 | + ctl.hidePaths = true; |
| 65 | + ctl.hideCopyright = true; |
| 66 | + } else { |
| 67 | + htmlEl.style.setProperty('font-size', '10px'); |
| 68 | + ctl.allowDrag = false; |
| 69 | + ctl.articleFullscreen = true; |
| 70 | + ctl.hideLeftSidebar = true; |
| 71 | + ctl.hideRightSidebar = true; |
| 72 | + ctl.hideActionBar = true; |
| 73 | + ctl.hideHeaderTopNav = true; |
| 74 | + ctl.hidePaths = true; |
| 75 | + ctl.hideCopyright = true; |
| 76 | + } |
| 77 | + } |
| 78 | + }); |
| 79 | + resizeObserver.value.observe(root.value as HTMLElement); |
| 80 | + }); |
| 81 | +
|
| 82 | + onBeforeUnmount(() => { |
| 83 | + resizeObserver.value?.disconnect(); |
| 84 | + }); |
13 | 85 | </script> |
14 | 86 |
|
15 | 87 | <style lang="scss"> |
|
0 commit comments