Browse Source

fix: 修复混合双列布局侧边栏拖拽线条位置显示bug,同步修复普通布局和混合双列布局切换时width计算导致侧边栏宽度显示异常问题,新增普通布局和混合双列布局侧边栏菜单折叠状态同步 (#7596)

pull/7603/head
zouawen 3 weeks ago
committed by GitHub
parent
commit
2a86404ba5
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 33
      packages/@core/ui-kit/layout-ui/src/components/layout-sidebar.vue
  2. 16
      packages/@core/ui-kit/layout-ui/src/vben-layout.vue

33
packages/@core/ui-kit/layout-ui/src/components/layout-sidebar.vue

@ -157,9 +157,9 @@ const extraTitleStyle = computed((): CSSProperties => {
}); });
const contentWidthStyle = computed((): CSSProperties => { const contentWidthStyle = computed((): CSSProperties => {
const { collapseWidth, fixedExtra, isSidebarMixed, mixedWidth } = props; const { fixedExtra, isSidebarMixed, mixedWidth } = props;
if (isSidebarMixed && fixedExtra) { if (isSidebarMixed && fixedExtra) {
return { width: `${collapse.value ? collapseWidth : mixedWidth}px` }; return { width: `${mixedWidth}px` };
} }
return {}; return {};
}); });
@ -202,19 +202,24 @@ watchEffect(() => {
}); });
function calcMenuWidthStyle(isHiddenDom: boolean): CSSProperties { function calcMenuWidthStyle(isHiddenDom: boolean): CSSProperties {
const { extraWidth, fixedExtra, isSidebarMixed, show, width } = props; const {
collapseWidth,
extraWidth,
mixedWidth,
fixedExtra,
isSidebarMixed,
show,
width,
} = props;
let widthValue = let widthValue =
width === 0 width === 0
? '0px' ? '0px'
: `${width + (isSidebarMixed && fixedExtra && extraVisible.value ? extraWidth : 0)}px`; : `${width + (isSidebarMixed && fixedExtra && extraVisible.value ? extraWidth : 0)}px`;
const { collapseWidth } = props;
if (isHiddenDom && expandOnHovering.value && !expandOnHover.value) { if (isHiddenDom && expandOnHovering.value && !expandOnHover.value) {
widthValue = `${collapseWidth}px`; widthValue = isSidebarMixed ? `${mixedWidth}px` : `${collapseWidth}px`;
} }
return { return {
...(widthValue === '0px' ? { overflow: 'hidden' } : {}), ...(widthValue === '0px' ? { overflow: 'hidden' } : {}),
flex: `0 0 ${widthValue}`, flex: `0 0 ${widthValue}`,
@ -261,9 +266,9 @@ const { startDrag } = useSidebarDrag();
const handleDragSidebar = (e: MouseEvent) => { const handleDragSidebar = (e: MouseEvent) => {
const { isSidebarMixed, collapseWidth, extraWidth, width } = props; const { isSidebarMixed, collapseWidth, extraWidth, width } = props;
const minLimit = collapseWidth; const minLimit = isSidebarMixed ? width + collapseWidth : collapseWidth;
const maxLimit = 320; const maxLimit = isSidebarMixed ? width + 320 : 320;
const startWidth = isSidebarMixed ? extraWidth : width; const startWidth = isSidebarMixed ? width + extraWidth : width;
startDrag( startDrag(
e, e,
@ -277,11 +282,13 @@ const handleDragSidebar = (e: MouseEvent) => {
dragBar: dragBarRef.value, dragBar: dragBarRef.value,
}, },
(newWidth) => { (newWidth) => {
emit('update:width', newWidth);
if (isSidebarMixed) { if (isSidebarMixed) {
extraCollapse.value = newWidth <= collapseWidth; emit('update:width', newWidth - width);
extraCollapse.value = collapse.value =
newWidth - width <= collapseWidth;
} else { } else {
collapse.value = newWidth <= collapseWidth; emit('update:width', newWidth);
collapse.value = extraCollapse.value = newWidth <= collapseWidth;
} }
}, },
); );

16
packages/@core/ui-kit/layout-ui/src/vben-layout.vue

@ -247,9 +247,7 @@ const mainStyle = computed(() => {
sidebarExtraVisible.value; sidebarExtraVisible.value;
if (isSideNavEffective) { if (isSideNavEffective) {
const sideCollapseWidth = sidebarCollapse.value const sideCollapseWidth = props.sidebarMixedWidth;
? getSideCollapseWidth.value
: props.sidebarMixedWidth;
const sideWidth = sidebarExtraCollapse.value const sideWidth = sidebarExtraCollapse.value
? props.sidebarExtraCollapsedWidth ? props.sidebarExtraCollapsedWidth
: props.sidebarWidth; : props.sidebarWidth;
@ -258,10 +256,14 @@ const mainStyle = computed(() => {
sidebarAndExtraWidth = `${sideCollapseWidth + sideWidth}px`; sidebarAndExtraWidth = `${sideCollapseWidth + sideWidth}px`;
width = `calc(100% - ${sidebarAndExtraWidth})`; width = `calc(100% - ${sidebarAndExtraWidth})`;
} else { } else {
sidebarAndExtraWidth = let sidebarWidth = getSidebarWidth.value;
sidebarExpandOnHovering.value && !sidebarExpandOnHover.value if (sidebarExpandOnHovering.value && !sidebarExpandOnHover.value) {
? `${getSideCollapseWidth.value}px` sidebarWidth =
: `${getSidebarWidth.value}px`; isSidebarMixedNav.value || isHeaderMixedNav.value
? props.sidebarMixedWidth
: getSideCollapseWidth.value;
}
sidebarAndExtraWidth = `${sidebarWidth}px`;
width = `calc(100% - ${sidebarAndExtraWidth})`; width = `calc(100% - ${sidebarAndExtraWidth})`;
} }
} }

Loading…
Cancel
Save