|
|
@ -125,6 +125,11 @@ onMounted(() => { |
|
|
|
handleSidebarOpenOnMobileForNonViews() |
|
|
|
handleSidebarOpenOnMobileForNonViews() |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const remToPx = (rem: number) => { |
|
|
|
|
|
|
|
const fontSize = parseFloat(getComputedStyle(document.documentElement).fontSize) |
|
|
|
|
|
|
|
return rem * fontSize |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function onResize(widthPercent: any) { |
|
|
|
function onResize(widthPercent: any) { |
|
|
|
if (isMobileMode.value) return |
|
|
|
if (isMobileMode.value) return |
|
|
|
|
|
|
|
|
|
|
@ -135,23 +140,31 @@ function onResize(widthPercent: any) { |
|
|
|
const widthRem = width / fontSize |
|
|
|
const widthRem = width / fontSize |
|
|
|
|
|
|
|
|
|
|
|
if (widthRem < 16) { |
|
|
|
if (widthRem < 16) { |
|
|
|
currentSidebarSize.value = ((16 * fontSize) / viewportWidth.value) * 100 |
|
|
|
sideBarSize.value.old = ((16 * fontSize) / viewportWidth.value) * 100 |
|
|
|
|
|
|
|
if (isLeftSidebarOpen.value) sideBarSize.value.current = sideBarSize.value.old |
|
|
|
return |
|
|
|
return |
|
|
|
} else if (widthRem > 23.5) { |
|
|
|
} else if (widthRem > 23.5) { |
|
|
|
currentSidebarSize.value = ((23.5 * fontSize) / viewportWidth.value) * 100 |
|
|
|
sideBarSize.value.old = ((23.5 * fontSize) / viewportWidth.value) * 100 |
|
|
|
|
|
|
|
if (isLeftSidebarOpen.value) sideBarSize.value.current = sideBarSize.value.old |
|
|
|
|
|
|
|
|
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
console.log('onResize', widthRem, fontSize) |
|
|
|
sideBarSize.value.old = widthPercent |
|
|
|
currentSidebarSize.value = widthPercent |
|
|
|
sideBarSize.value.current = sideBarSize.value.old |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
watch( |
|
|
|
const normalizedWidth = computed(() => { |
|
|
|
() => sideBarSize.value.current, |
|
|
|
const maxSize = remToPx(23.5) |
|
|
|
() => { |
|
|
|
const minSize = remToPx(16) |
|
|
|
console.log('sidebarState', sideBarSize.value.current) |
|
|
|
if (sidebarWidth.value > maxSize) { |
|
|
|
}, |
|
|
|
return maxSize |
|
|
|
) |
|
|
|
} else if (sidebarWidth.value < minSize) { |
|
|
|
|
|
|
|
return minSize |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return sidebarWidth.value |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
<template> |
|
|
@ -166,14 +179,14 @@ watch( |
|
|
|
min-size="15%" |
|
|
|
min-size="15%" |
|
|
|
:size="mobileNormalizedSidebarSize" |
|
|
|
:size="mobileNormalizedSidebarSize" |
|
|
|
max-size="40%" |
|
|
|
max-size="40%" |
|
|
|
class="nc-sidebar-splitpane !sm:(min-w-64 max-w-94) relative !overflow-visible" |
|
|
|
class="nc-sidebar-splitpane !sm:max-w-94 relative !overflow-visible flex" |
|
|
|
:style="{ |
|
|
|
:style="{ |
|
|
|
width: `${mobileNormalizedSidebarSize}%`, |
|
|
|
width: `${mobileNormalizedSidebarSize}%`, |
|
|
|
}" |
|
|
|
}" |
|
|
|
> |
|
|
|
> |
|
|
|
<div |
|
|
|
<div |
|
|
|
ref="wrapperRef" |
|
|
|
ref="wrapperRef" |
|
|
|
class="nc-sidebar-wrapper relative flex flex-col h-full justify-center !sm:(min-w-64 max-w-94) absolute overflow-visible" |
|
|
|
class="nc-sidebar-wrapper relative flex flex-col h-full justify-center !sm:(max-w-94) absolute overflow-visible" |
|
|
|
:class="{ |
|
|
|
:class="{ |
|
|
|
'mobile': isMobileMode, |
|
|
|
'mobile': isMobileMode, |
|
|
|
'minimized-height': !isLeftSidebarOpen, |
|
|
|
'minimized-height': !isLeftSidebarOpen, |
|
|
@ -181,6 +194,7 @@ watch( |
|
|
|
}" |
|
|
|
}" |
|
|
|
:style="{ |
|
|
|
:style="{ |
|
|
|
width: sidebarState === 'hiddenEnd' ? '0px' : `${sidebarWidth}px`, |
|
|
|
width: sidebarState === 'hiddenEnd' ? '0px' : `${sidebarWidth}px`, |
|
|
|
|
|
|
|
minWidth: sidebarState === 'hiddenEnd' ? '0px' : `${normalizedWidth}px`, |
|
|
|
}" |
|
|
|
}" |
|
|
|
> |
|
|
|
> |
|
|
|
<slot name="sidebar" /> |
|
|
|
<slot name="sidebar" /> |
|
|
@ -188,8 +202,9 @@ watch( |
|
|
|
</Pane> |
|
|
|
</Pane> |
|
|
|
<Pane |
|
|
|
<Pane |
|
|
|
:size="mobileNormalizedContentSize" |
|
|
|
:size="mobileNormalizedContentSize" |
|
|
|
|
|
|
|
class="flex-grow" |
|
|
|
:style="{ |
|
|
|
:style="{ |
|
|
|
width: `${100 - mobileNormalizedSidebarSize}%`, |
|
|
|
'min-width': `${100 - mobileNormalizedSidebarSize}%`, |
|
|
|
}" |
|
|
|
}" |
|
|
|
> |
|
|
|
> |
|
|
|
<slot name="content" /> |
|
|
|
<slot name="content" /> |
|
|
|