|
2 | 2 | <div |
3 | 3 | ref="container" |
4 | 4 | class="nano-theme absolute" |
5 | | - :style="{ ...layout.containerLayout, ...animation }" |
| 5 | + :style="{ ...containerLayout, ...animation }" |
6 | 6 | > |
7 | 7 | <div v-show="!loading" class="relative w-full h-full flex flex-col"> |
8 | | - <NanoHeader ref="header" @dblclick="ctl.fullscreen = !ctl.fullscreen"/> |
| 8 | + <NanoHeader ref="header" @dblclick.self="ctl.fullscreen = !ctl.fullscreen"/> |
9 | 9 | <NanoBody/> |
10 | 10 | <NanoFooter/> |
11 | 11 | </div> |
|
25 | 25 | import NanoBackdrop from '@NanoUI/NanoBackdrop/index.vue'; |
26 | 26 | import NanoNavModal from '@NanoUI/NanoNavModal/index.vue'; |
27 | 27 | import NanoSidebarDirModal from '@NanoUI/NanoSidebarDirModal/index.vue'; |
28 | | - import { computed, onBeforeUnmount, onMounted, ref } from 'vue'; |
| 28 | + import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'; |
29 | 29 | import { controllerStore } from '@store/controller'; |
30 | | - import { contentLayoutStore, getWidthFromString } from '@store/contentLayout'; |
| 30 | + import { contentLayoutStore, getWidthFromString, LayoutBaseInfo } from '@store/contentLayout'; |
31 | 31 | import { drag } from '../../utils/drag'; |
| 32 | + import { debounce } from 'lodash-es'; |
32 | 33 |
|
33 | 34 | const ctl = controllerStore(); |
34 | 35 | const layout = contentLayoutStore(); |
|
47 | 48 | }; |
48 | 49 | }); |
49 | 50 |
|
| 51 | + const containerLayout = ref<LayoutBaseInfo>(layout.containerLayout); |
| 52 | +
|
| 53 | + watch(containerLayout, debounce((val) => { |
| 54 | + // console.log('containerLayout changed', val); |
| 55 | + layout.setContainerLayout(val); |
| 56 | + }, 200), { deep: true }); |
| 57 | +
|
50 | 58 | onMounted(() => { |
51 | 59 | const containerEl = container.value!; |
52 | 60 | resizeObserver.value = new ResizeObserver((entries: ResizeObserverEntry[]) => { |
|
81 | 89 | }, 1200); |
82 | 90 | } |
83 | 91 | }); |
84 | | - resizeObserver.value.observe(containerEl!); |
| 92 | + resizeObserver.value.observe(containerEl); |
85 | 93 |
|
86 | 94 | type OriginLayout = { |
87 | 95 | isFullscreen: boolean; |
|
107 | 115 | top: offsetTop |
108 | 116 | }; |
109 | 117 | }, |
110 | | - handlerFn: ({ x, y, originalData: { isFullscreen, notFullScreenWidth, screenWidth, screenHeight, left, top }, pointerWelt, initial }) => { |
| 118 | + handlerFn: ({ |
| 119 | + x, |
| 120 | + y, |
| 121 | + originalData: { isFullscreen, notFullScreenWidth, screenWidth, screenHeight, left, top }, |
| 122 | + pointerWelt, |
| 123 | + initial |
| 124 | + }) => { |
111 | 125 | let newLeft = left + x; |
112 | 126 | const newTop = top + y; |
113 | 127 | if (isFullscreen) { |
114 | 128 | ctl.fullscreen = false; |
115 | 129 | newLeft = initial.x - (initial.x / screenWidth) * notFullScreenWidth + x; |
116 | 130 | } |
117 | 131 | if (!pointerWelt.top && !pointerWelt.bottom && newTop > 0) { |
118 | | - layout.setContainerLayout({ |
119 | | - top: newTop / screenHeight * 100 + '%' |
120 | | - }); |
| 132 | + containerLayout.value.top = newTop / screenHeight * 100 + '%'; |
121 | 133 | } else { |
122 | | - layout.setContainerLayout({ |
123 | | - top: pointerWelt.bottom ? '98%' : '0' |
124 | | - }); |
| 134 | + containerLayout.value.top = pointerWelt.bottom ? '98%' : '0'; |
125 | 135 | } |
126 | 136 | if (!pointerWelt.left && !pointerWelt.right) { |
127 | | - layout.setContainerLayout({ |
128 | | - left: newLeft / screenWidth * 100 + '%' |
129 | | - }); |
| 137 | + containerLayout.value.left = newLeft / screenWidth * 100 + '%'; |
130 | 138 | } |
131 | 139 | }, |
132 | 140 | beforeFn: () => enableAnimation.value = false, |
|
0 commit comments