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