diff --git a/packages/@core/ui-kit/layout-ui/src/components/layout-sidebar.vue b/packages/@core/ui-kit/layout-ui/src/components/layout-sidebar.vue index dfeca386..e717c905 100644 --- a/packages/@core/ui-kit/layout-ui/src/components/layout-sidebar.vue +++ b/packages/@core/ui-kit/layout-ui/src/components/layout-sidebar.vue @@ -157,9 +157,9 @@ const extraTitleStyle = computed((): CSSProperties => { }); const contentWidthStyle = computed((): CSSProperties => { - const { collapseWidth, fixedExtra, isSidebarMixed, mixedWidth } = props; + const { fixedExtra, isSidebarMixed, mixedWidth } = props; if (isSidebarMixed && fixedExtra) { - return { width: `${collapse.value ? collapseWidth : mixedWidth}px` }; + return { width: `${mixedWidth}px` }; } return {}; }); @@ -202,19 +202,24 @@ watchEffect(() => { }); function calcMenuWidthStyle(isHiddenDom: boolean): CSSProperties { - const { extraWidth, fixedExtra, isSidebarMixed, show, width } = props; + const { + collapseWidth, + extraWidth, + mixedWidth, + fixedExtra, + isSidebarMixed, + show, + width, + } = props; let widthValue = width === 0 ? '0px' : `${width + (isSidebarMixed && fixedExtra && extraVisible.value ? extraWidth : 0)}px`; - const { collapseWidth } = props; - if (isHiddenDom && expandOnHovering.value && !expandOnHover.value) { - widthValue = `${collapseWidth}px`; + widthValue = isSidebarMixed ? `${mixedWidth}px` : `${collapseWidth}px`; } - return { ...(widthValue === '0px' ? { overflow: 'hidden' } : {}), flex: `0 0 ${widthValue}`, @@ -261,9 +266,9 @@ const { startDrag } = useSidebarDrag(); const handleDragSidebar = (e: MouseEvent) => { const { isSidebarMixed, collapseWidth, extraWidth, width } = props; - const minLimit = collapseWidth; - const maxLimit = 320; - const startWidth = isSidebarMixed ? extraWidth : width; + const minLimit = isSidebarMixed ? width + collapseWidth : collapseWidth; + const maxLimit = isSidebarMixed ? width + 320 : 320; + const startWidth = isSidebarMixed ? width + extraWidth : width; startDrag( e, @@ -277,11 +282,13 @@ const handleDragSidebar = (e: MouseEvent) => { dragBar: dragBarRef.value, }, (newWidth) => { - emit('update:width', newWidth); if (isSidebarMixed) { - extraCollapse.value = newWidth <= collapseWidth; + emit('update:width', newWidth - width); + extraCollapse.value = collapse.value = + newWidth - width <= collapseWidth; } else { - collapse.value = newWidth <= collapseWidth; + emit('update:width', newWidth); + collapse.value = extraCollapse.value = newWidth <= collapseWidth; } }, ); diff --git a/packages/@core/ui-kit/layout-ui/src/vben-layout.vue b/packages/@core/ui-kit/layout-ui/src/vben-layout.vue index 2ab4aaa2..7e444068 100644 --- a/packages/@core/ui-kit/layout-ui/src/vben-layout.vue +++ b/packages/@core/ui-kit/layout-ui/src/vben-layout.vue @@ -247,9 +247,7 @@ const mainStyle = computed(() => { sidebarExtraVisible.value; if (isSideNavEffective) { - const sideCollapseWidth = sidebarCollapse.value - ? getSideCollapseWidth.value - : props.sidebarMixedWidth; + const sideCollapseWidth = props.sidebarMixedWidth; const sideWidth = sidebarExtraCollapse.value ? props.sidebarExtraCollapsedWidth : props.sidebarWidth; @@ -258,10 +256,14 @@ const mainStyle = computed(() => { sidebarAndExtraWidth = `${sideCollapseWidth + sideWidth}px`; width = `calc(100% - ${sidebarAndExtraWidth})`; } else { - sidebarAndExtraWidth = - sidebarExpandOnHovering.value && !sidebarExpandOnHover.value - ? `${getSideCollapseWidth.value}px` - : `${getSidebarWidth.value}px`; + let sidebarWidth = getSidebarWidth.value; + if (sidebarExpandOnHovering.value && !sidebarExpandOnHover.value) { + sidebarWidth = + isSidebarMixedNav.value || isHeaderMixedNav.value + ? props.sidebarMixedWidth + : getSideCollapseWidth.value; + } + sidebarAndExtraWidth = `${sidebarWidth}px`; width = `calc(100% - ${sidebarAndExtraWidth})`; } }