2024-05-19 13:20:42 +00:00
|
|
|
|
<script setup lang="ts">
|
2024-08-05 13:12:22 +00:00
|
|
|
|
import type { VbenLayoutProps } from './vben-layout';
|
|
|
|
|
|
2024-05-19 13:20:42 +00:00
|
|
|
|
import type { CSSProperties } from 'vue';
|
2024-06-08 11:49:06 +00:00
|
|
|
|
import { computed, ref, watch } from 'vue';
|
2024-05-19 13:20:42 +00:00
|
|
|
|
|
|
|
|
|
import { useMouse, useScroll, useThrottleFn } from '@vueuse/core';
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
LayoutContent,
|
|
|
|
|
LayoutFooter,
|
|
|
|
|
LayoutHeader,
|
2024-06-09 07:39:11 +00:00
|
|
|
|
LayoutSidebar,
|
|
|
|
|
LayoutTabbar,
|
2024-05-19 13:20:42 +00:00
|
|
|
|
} from './components';
|
2024-08-14 12:37:21 +00:00
|
|
|
|
import { useLayout } from './hooks/use-layout';
|
2024-05-19 13:20:42 +00:00
|
|
|
|
|
|
|
|
|
interface Props extends VbenLayoutProps {}
|
|
|
|
|
|
|
|
|
|
defineOptions({
|
|
|
|
|
name: 'VbenLayout',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const props = withDefaults(defineProps<Props>(), {
|
|
|
|
|
contentCompact: 'wide',
|
2024-07-18 13:59:18 +00:00
|
|
|
|
contentCompactWidth: 1200,
|
2024-05-19 13:20:42 +00:00
|
|
|
|
contentPadding: 0,
|
|
|
|
|
contentPaddingBottom: 0,
|
|
|
|
|
contentPaddingLeft: 0,
|
|
|
|
|
contentPaddingRight: 0,
|
|
|
|
|
contentPaddingTop: 0,
|
2024-06-09 05:31:43 +00:00
|
|
|
|
footerEnable: false,
|
2024-05-19 13:20:42 +00:00
|
|
|
|
footerFixed: true,
|
|
|
|
|
footerHeight: 32,
|
|
|
|
|
headerHeight: 50,
|
2024-06-01 14:17:52 +00:00
|
|
|
|
headerHidden: false,
|
2024-05-19 13:20:42 +00:00
|
|
|
|
headerMode: 'fixed',
|
2024-07-10 13:20:11 +00:00
|
|
|
|
headerToggleSidebarButton: true,
|
2024-05-19 13:20:42 +00:00
|
|
|
|
headerVisible: true,
|
|
|
|
|
isMobile: false,
|
2024-06-09 07:39:11 +00:00
|
|
|
|
layout: 'sidebar-nav',
|
|
|
|
|
sidebarCollapseShowTitle: false,
|
2024-07-18 13:59:18 +00:00
|
|
|
|
sidebarExtraCollapsedWidth: 60,
|
2024-06-09 07:39:11 +00:00
|
|
|
|
sidebarHidden: false,
|
|
|
|
|
sidebarMixedWidth: 80,
|
|
|
|
|
sidebarTheme: 'dark',
|
|
|
|
|
sidebarWidth: 180,
|
2024-07-22 16:03:59 +00:00
|
|
|
|
sideCollapseWidth: 60,
|
2024-06-09 07:39:11 +00:00
|
|
|
|
tabbarEnable: true,
|
2024-07-18 13:31:34 +00:00
|
|
|
|
tabbarHeight: 36,
|
2024-05-19 13:20:42 +00:00
|
|
|
|
zIndex: 200,
|
|
|
|
|
});
|
|
|
|
|
|
2024-06-09 07:39:11 +00:00
|
|
|
|
const emit = defineEmits<{ sideMouseLeave: []; toggleSidebar: [] }>();
|
|
|
|
|
const sidebarCollapse = defineModel<boolean>('sidebarCollapse');
|
|
|
|
|
const sidebarExtraVisible = defineModel<boolean>('sidebarExtraVisible');
|
|
|
|
|
const sidebarExtraCollapse = defineModel<boolean>('sidebarExtraCollapse');
|
|
|
|
|
const sidebarExpandOnHover = defineModel<boolean>('sidebarExpandOnHover');
|
|
|
|
|
const sidebarEnable = defineModel<boolean>('sidebarEnable', { default: true });
|
2024-05-19 13:20:42 +00:00
|
|
|
|
|
2024-08-13 14:09:46 +00:00
|
|
|
|
// side是否处于hover状态展开菜单中
|
|
|
|
|
const sidebarExpandOnHovering = ref(false);
|
|
|
|
|
const headerIsHidden = ref(false);
|
|
|
|
|
const contentRef = ref();
|
|
|
|
|
|
2024-05-19 13:20:42 +00:00
|
|
|
|
const {
|
|
|
|
|
arrivedState,
|
|
|
|
|
directions,
|
|
|
|
|
isScrolling,
|
|
|
|
|
y: scrollY,
|
|
|
|
|
} = useScroll(document);
|
2024-07-18 13:59:18 +00:00
|
|
|
|
|
2024-08-13 14:09:46 +00:00
|
|
|
|
const { y: mouseY } = useMouse({ target: contentRef, type: 'client' });
|
2024-05-19 13:20:42 +00:00
|
|
|
|
|
2024-08-14 12:37:21 +00:00
|
|
|
|
const {
|
|
|
|
|
currentLayout,
|
|
|
|
|
isFullContent,
|
|
|
|
|
isHeaderNav,
|
|
|
|
|
isMixedNav,
|
|
|
|
|
isSidebarMixedNav,
|
|
|
|
|
} = useLayout(props);
|
2024-05-19 13:20:42 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 顶栏是否自动隐藏
|
|
|
|
|
*/
|
2024-07-18 13:59:18 +00:00
|
|
|
|
const isHeaderAutoMode = computed(() => props.headerMode === 'auto');
|
2024-05-19 13:20:42 +00:00
|
|
|
|
|
|
|
|
|
const headerWrapperHeight = computed(() => {
|
|
|
|
|
let height = 0;
|
2024-06-01 14:17:52 +00:00
|
|
|
|
if (props.headerVisible && !props.headerHidden) {
|
2024-08-14 12:37:21 +00:00
|
|
|
|
height += props.headerHeight;
|
2024-05-19 13:20:42 +00:00
|
|
|
|
}
|
2024-06-09 07:39:11 +00:00
|
|
|
|
if (props.tabbarEnable) {
|
2024-07-10 13:20:11 +00:00
|
|
|
|
height += props.tabbarHeight;
|
2024-05-19 13:20:42 +00:00
|
|
|
|
}
|
|
|
|
|
return height;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const getSideCollapseWidth = computed(() => {
|
2024-07-22 16:03:59 +00:00
|
|
|
|
const { sidebarCollapseShowTitle, sidebarMixedWidth, sideCollapseWidth } =
|
2024-06-09 07:39:11 +00:00
|
|
|
|
props;
|
2024-06-30 14:58:57 +00:00
|
|
|
|
|
2024-06-09 07:39:11 +00:00
|
|
|
|
return sidebarCollapseShowTitle || isSidebarMixedNav.value
|
|
|
|
|
? sidebarMixedWidth
|
2024-05-19 13:20:42 +00:00
|
|
|
|
: sideCollapseWidth;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 动态获取侧边区域是否可见
|
|
|
|
|
*/
|
2024-06-09 07:39:11 +00:00
|
|
|
|
const sidebarEnableState = computed(() => {
|
|
|
|
|
return !isHeaderNav.value && sidebarEnable.value;
|
2024-05-19 13:20:42 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 侧边区域离顶部高度
|
|
|
|
|
*/
|
2024-07-18 13:59:18 +00:00
|
|
|
|
const sidebarMarginTop = computed(() => {
|
2024-08-14 12:37:21 +00:00
|
|
|
|
const { headerHeight, isMobile } = props;
|
|
|
|
|
return isMixedNav.value && !isMobile ? headerHeight : 0;
|
2024-05-19 13:20:42 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 动态获取侧边宽度
|
|
|
|
|
*/
|
2024-06-09 07:39:11 +00:00
|
|
|
|
const getSidebarWidth = computed(() => {
|
|
|
|
|
const { isMobile, sidebarHidden, sidebarMixedWidth, sidebarWidth } = props;
|
2024-05-19 13:20:42 +00:00
|
|
|
|
let width = 0;
|
|
|
|
|
|
2024-06-09 07:39:11 +00:00
|
|
|
|
if (sidebarHidden) {
|
2024-06-01 14:17:52 +00:00
|
|
|
|
return width;
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-19 13:20:42 +00:00
|
|
|
|
if (
|
2024-06-09 07:39:11 +00:00
|
|
|
|
!sidebarEnableState.value ||
|
|
|
|
|
(sidebarHidden && !isSidebarMixedNav.value && !isMixedNav.value)
|
2024-05-19 13:20:42 +00:00
|
|
|
|
) {
|
|
|
|
|
return width;
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-09 07:39:11 +00:00
|
|
|
|
if (isSidebarMixedNav.value && !isMobile) {
|
|
|
|
|
width = sidebarMixedWidth;
|
|
|
|
|
} else if (sidebarCollapse.value) {
|
2024-05-19 13:20:42 +00:00
|
|
|
|
width = isMobile ? 0 : getSideCollapseWidth.value;
|
|
|
|
|
} else {
|
2024-06-09 07:39:11 +00:00
|
|
|
|
width = sidebarWidth;
|
2024-05-19 13:20:42 +00:00
|
|
|
|
}
|
|
|
|
|
return width;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取扩展区域宽度
|
|
|
|
|
*/
|
2024-07-18 13:59:18 +00:00
|
|
|
|
const sidebarExtraWidth = computed(() => {
|
|
|
|
|
const { sidebarExtraCollapsedWidth, sidebarWidth } = props;
|
2024-06-30 14:58:57 +00:00
|
|
|
|
|
2024-07-18 13:59:18 +00:00
|
|
|
|
return sidebarExtraCollapse.value ? sidebarExtraCollapsedWidth : sidebarWidth;
|
2024-05-19 13:20:42 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 是否侧边栏模式,包含混合侧边
|
|
|
|
|
*/
|
2024-08-14 12:37:21 +00:00
|
|
|
|
const isSideMode = computed(
|
|
|
|
|
() =>
|
|
|
|
|
currentLayout.value === 'mixed-nav' ||
|
|
|
|
|
currentLayout.value === 'sidebar-mixed-nav' ||
|
|
|
|
|
currentLayout.value === 'sidebar-nav',
|
2024-05-19 13:20:42 +00:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* header fixed值
|
|
|
|
|
*/
|
|
|
|
|
const headerFixed = computed(() => {
|
2024-07-16 14:07:28 +00:00
|
|
|
|
const { headerMode } = props;
|
2024-05-19 13:20:42 +00:00
|
|
|
|
return (
|
|
|
|
|
isMixedNav.value ||
|
2024-07-16 14:07:28 +00:00
|
|
|
|
headerMode === 'fixed' ||
|
|
|
|
|
headerMode === 'auto-scroll' ||
|
|
|
|
|
headerMode === 'auto'
|
2024-05-19 13:20:42 +00:00
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
2024-08-14 12:37:21 +00:00
|
|
|
|
const showSidebar = computed(() => {
|
|
|
|
|
// if (isMixedNav.value && !props.sideHidden) {
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
return isSideMode.value && sidebarEnable.value;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 遮罩可见性
|
|
|
|
|
*/
|
|
|
|
|
const maskVisible = computed(() => !sidebarCollapse.value && props.isMobile);
|
|
|
|
|
|
2024-05-19 13:20:42 +00:00
|
|
|
|
const mainStyle = computed(() => {
|
|
|
|
|
let width = '100%';
|
2024-06-09 07:39:11 +00:00
|
|
|
|
let sidebarAndExtraWidth = 'unset';
|
2024-05-19 13:20:42 +00:00
|
|
|
|
if (
|
|
|
|
|
headerFixed.value &&
|
2024-08-14 12:37:21 +00:00
|
|
|
|
currentLayout.value !== 'header-nav' &&
|
|
|
|
|
currentLayout.value !== 'mixed-nav' &&
|
2024-06-09 07:39:11 +00:00
|
|
|
|
showSidebar.value &&
|
2024-05-19 13:20:42 +00:00
|
|
|
|
!props.isMobile
|
|
|
|
|
) {
|
2024-06-09 07:39:11 +00:00
|
|
|
|
// fixed模式下生效
|
2024-05-19 13:20:42 +00:00
|
|
|
|
const isSideNavEffective =
|
2024-06-09 07:39:11 +00:00
|
|
|
|
isSidebarMixedNav.value &&
|
|
|
|
|
sidebarExpandOnHover.value &&
|
|
|
|
|
sidebarExtraVisible.value;
|
2024-05-19 13:20:42 +00:00
|
|
|
|
|
|
|
|
|
if (isSideNavEffective) {
|
2024-06-09 07:39:11 +00:00
|
|
|
|
const sideCollapseWidth = sidebarCollapse.value
|
2024-05-19 13:20:42 +00:00
|
|
|
|
? getSideCollapseWidth.value
|
2024-06-09 07:39:11 +00:00
|
|
|
|
: props.sidebarMixedWidth;
|
|
|
|
|
const sideWidth = sidebarExtraCollapse.value
|
2024-08-14 12:37:21 +00:00
|
|
|
|
? props.sidebarExtraCollapsedWidth
|
2024-06-09 07:39:11 +00:00
|
|
|
|
: props.sidebarWidth;
|
2024-05-19 13:20:42 +00:00
|
|
|
|
|
|
|
|
|
// 100% - 侧边菜单混合宽度 - 菜单宽度
|
2024-06-09 07:39:11 +00:00
|
|
|
|
sidebarAndExtraWidth = `${sideCollapseWidth + sideWidth}px`;
|
|
|
|
|
width = `calc(100% - ${sidebarAndExtraWidth})`;
|
2024-05-19 13:20:42 +00:00
|
|
|
|
} else {
|
2024-06-09 07:39:11 +00:00
|
|
|
|
sidebarAndExtraWidth =
|
|
|
|
|
sidebarExpandOnHovering.value && !sidebarExpandOnHover.value
|
2024-05-19 13:20:42 +00:00
|
|
|
|
? `${getSideCollapseWidth.value}px`
|
2024-06-09 07:39:11 +00:00
|
|
|
|
: `${getSidebarWidth.value}px`;
|
|
|
|
|
width = `calc(100% - ${sidebarAndExtraWidth})`;
|
2024-05-19 13:20:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return {
|
2024-06-09 07:39:11 +00:00
|
|
|
|
sidebarAndExtraWidth,
|
2024-05-19 13:20:42 +00:00
|
|
|
|
width,
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
2024-07-18 13:59:18 +00:00
|
|
|
|
// 计算 tabbar 的样式
|
2024-06-09 07:39:11 +00:00
|
|
|
|
const tabbarStyle = computed((): CSSProperties => {
|
2024-05-19 13:20:42 +00:00
|
|
|
|
let width = '';
|
|
|
|
|
let marginLeft = 0;
|
|
|
|
|
|
2024-07-18 13:59:18 +00:00
|
|
|
|
// 如果不是混合导航,tabbar 的宽度为 100%
|
2024-05-19 13:20:42 +00:00
|
|
|
|
if (!isMixedNav.value) {
|
|
|
|
|
width = '100%';
|
2024-06-09 07:39:11 +00:00
|
|
|
|
} else if (sidebarEnable.value) {
|
2024-07-18 13:59:18 +00:00
|
|
|
|
// 鼠标在侧边栏上时,且侧边栏展开时的宽度
|
|
|
|
|
const onHoveringWidth = sidebarExpandOnHover.value
|
|
|
|
|
? props.sidebarWidth
|
|
|
|
|
: getSideCollapseWidth.value;
|
|
|
|
|
|
|
|
|
|
// 设置 marginLeft,根据侧边栏是否折叠来决定
|
2024-06-09 07:39:11 +00:00
|
|
|
|
marginLeft = sidebarCollapse.value
|
2024-05-19 13:20:42 +00:00
|
|
|
|
? getSideCollapseWidth.value
|
2024-07-18 13:59:18 +00:00
|
|
|
|
: onHoveringWidth;
|
2024-07-15 16:14:24 +00:00
|
|
|
|
|
2024-07-18 13:59:18 +00:00
|
|
|
|
// 设置 tabbar 的宽度,计算方式为 100% 减去侧边栏的宽度
|
|
|
|
|
width = `calc(100% - ${sidebarCollapse.value ? getSidebarWidth.value : onHoveringWidth}px)`;
|
2024-05-19 13:20:42 +00:00
|
|
|
|
} else {
|
2024-07-18 13:59:18 +00:00
|
|
|
|
// 默认情况下,tabbar 的宽度为 100%
|
2024-05-19 13:20:42 +00:00
|
|
|
|
width = '100%';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
marginLeft: `${marginLeft}px`,
|
|
|
|
|
width,
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const contentStyle = computed((): CSSProperties => {
|
|
|
|
|
const fixed = headerFixed.value;
|
|
|
|
|
|
2024-07-06 07:49:21 +00:00
|
|
|
|
const { footerEnable, footerFixed, footerHeight } = props;
|
2024-05-19 13:20:42 +00:00
|
|
|
|
return {
|
|
|
|
|
marginTop:
|
|
|
|
|
fixed &&
|
2024-08-14 12:37:21 +00:00
|
|
|
|
!isFullContent.value &&
|
2024-05-19 13:20:42 +00:00
|
|
|
|
!headerIsHidden.value &&
|
2024-07-18 13:59:18 +00:00
|
|
|
|
(!isHeaderAutoMode.value || scrollY.value < headerWrapperHeight.value)
|
2024-05-19 13:20:42 +00:00
|
|
|
|
? `${headerWrapperHeight.value}px`
|
|
|
|
|
: 0,
|
2024-07-06 07:49:21 +00:00
|
|
|
|
paddingBottom: `${footerEnable && footerFixed ? footerHeight : 0}px`,
|
2024-05-19 13:20:42 +00:00
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const headerZIndex = computed(() => {
|
|
|
|
|
const { zIndex } = props;
|
|
|
|
|
const offset = isMixedNav.value ? 1 : 0;
|
|
|
|
|
return zIndex + offset;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const headerWrapperStyle = computed((): CSSProperties => {
|
|
|
|
|
const fixed = headerFixed.value;
|
|
|
|
|
return {
|
2024-08-14 12:37:21 +00:00
|
|
|
|
height: isFullContent.value ? '0' : `${headerWrapperHeight.value}px`,
|
2024-06-09 07:39:11 +00:00
|
|
|
|
left: isMixedNav.value ? 0 : mainStyle.value.sidebarAndExtraWidth,
|
2024-05-19 13:20:42 +00:00
|
|
|
|
position: fixed ? 'fixed' : 'static',
|
|
|
|
|
top:
|
2024-08-14 12:37:21 +00:00
|
|
|
|
headerIsHidden.value || isFullContent.value
|
2024-05-19 13:20:42 +00:00
|
|
|
|
? `-${headerWrapperHeight.value}px`
|
|
|
|
|
: 0,
|
|
|
|
|
width: mainStyle.value.width,
|
|
|
|
|
'z-index': headerZIndex.value,
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 侧边栏z-index
|
|
|
|
|
*/
|
2024-06-09 07:39:11 +00:00
|
|
|
|
const sidebarZIndex = computed(() => {
|
2024-05-19 13:20:42 +00:00
|
|
|
|
const { isMobile, zIndex } = props;
|
2024-07-18 13:59:18 +00:00
|
|
|
|
let offset = isMobile || isSideMode.value ? 1 : -1;
|
|
|
|
|
|
|
|
|
|
if (isMixedNav.value) {
|
|
|
|
|
offset += 1;
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-19 13:20:42 +00:00
|
|
|
|
return zIndex + offset;
|
|
|
|
|
});
|
|
|
|
|
|
2024-06-09 07:39:11 +00:00
|
|
|
|
const footerWidth = computed(() => {
|
|
|
|
|
if (!props.footerFixed) {
|
|
|
|
|
return '100%';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return mainStyle.value.width;
|
|
|
|
|
});
|
|
|
|
|
|
2024-05-19 13:20:42 +00:00
|
|
|
|
const maskStyle = computed((): CSSProperties => {
|
2024-06-09 07:39:11 +00:00
|
|
|
|
return { zIndex: props.zIndex };
|
2024-05-19 13:20:42 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const showHeaderToggleButton = computed(() => {
|
|
|
|
|
return (
|
2024-07-10 13:20:11 +00:00
|
|
|
|
props.headerToggleSidebarButton &&
|
2024-05-19 13:20:42 +00:00
|
|
|
|
isSideMode.value &&
|
2024-06-09 07:39:11 +00:00
|
|
|
|
!isSidebarMixedNav.value &&
|
2024-05-19 13:20:42 +00:00
|
|
|
|
!isMixedNav.value &&
|
|
|
|
|
!props.isMobile
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const showHeaderLogo = computed(() => {
|
|
|
|
|
return !isSideMode.value || isMixedNav.value || props.isMobile;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
() => props.isMobile,
|
|
|
|
|
(val) => {
|
2024-07-18 13:59:18 +00:00
|
|
|
|
if (val) {
|
|
|
|
|
sidebarCollapse.value = true;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
immediate: true,
|
2024-05-19 13:20:42 +00:00
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
const mouseMove = () => {
|
|
|
|
|
mouseY.value > headerWrapperHeight.value
|
|
|
|
|
? (headerIsHidden.value = true)
|
|
|
|
|
: (headerIsHidden.value = false);
|
|
|
|
|
};
|
|
|
|
|
watch(
|
|
|
|
|
[() => props.headerMode, () => mouseY.value],
|
|
|
|
|
() => {
|
2024-08-14 12:37:21 +00:00
|
|
|
|
if (!isHeaderAutoMode.value || isMixedNav.value || isFullContent.value) {
|
|
|
|
|
if (props.headerMode !== 'auto-scroll') {
|
|
|
|
|
headerIsHidden.value = false;
|
|
|
|
|
}
|
2024-05-19 13:20:42 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
headerIsHidden.value = true;
|
|
|
|
|
mouseMove();
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
immediate: true,
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
const checkHeaderIsHidden = useThrottleFn((top, bottom, topArrived) => {
|
|
|
|
|
if (scrollY.value < headerWrapperHeight.value) {
|
|
|
|
|
headerIsHidden.value = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (topArrived) {
|
|
|
|
|
headerIsHidden.value = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (top) {
|
|
|
|
|
headerIsHidden.value = false;
|
|
|
|
|
} else if (bottom) {
|
|
|
|
|
headerIsHidden.value = true;
|
|
|
|
|
}
|
|
|
|
|
}, 300);
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
() => scrollY.value,
|
|
|
|
|
() => {
|
|
|
|
|
if (
|
|
|
|
|
props.headerMode !== 'auto-scroll' ||
|
|
|
|
|
isMixedNav.value ||
|
2024-08-14 12:37:21 +00:00
|
|
|
|
isFullContent.value
|
2024-05-19 13:20:42 +00:00
|
|
|
|
) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (isScrolling.value) {
|
|
|
|
|
checkHeaderIsHidden(
|
|
|
|
|
directions.top,
|
|
|
|
|
directions.bottom,
|
|
|
|
|
arrivedState.top,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleClickMask() {
|
2024-06-09 07:39:11 +00:00
|
|
|
|
sidebarCollapse.value = true;
|
2024-05-19 13:20:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleOpenMenu() {
|
2024-06-09 07:39:11 +00:00
|
|
|
|
sidebarCollapse.value = false;
|
2024-05-19 13:20:42 +00:00
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2024-05-28 15:38:36 +00:00
|
|
|
|
<div class="relative flex min-h-full w-full">
|
2024-06-09 07:39:11 +00:00
|
|
|
|
<LayoutSidebar
|
|
|
|
|
v-if="sidebarEnableState"
|
|
|
|
|
v-model:collapse="sidebarCollapse"
|
|
|
|
|
v-model:expand-on-hover="sidebarExpandOnHover"
|
|
|
|
|
v-model:expand-on-hovering="sidebarExpandOnHovering"
|
|
|
|
|
v-model:extra-collapse="sidebarExtraCollapse"
|
|
|
|
|
v-model:extra-visible="sidebarExtraVisible"
|
2024-06-09 05:31:43 +00:00
|
|
|
|
:collapse-width="getSideCollapseWidth"
|
2024-05-19 13:20:42 +00:00
|
|
|
|
:dom-visible="!isMobile"
|
2024-07-18 13:59:18 +00:00
|
|
|
|
:extra-width="sidebarExtraWidth"
|
2024-06-09 07:39:11 +00:00
|
|
|
|
:fixed-extra="sidebarExpandOnHover"
|
2024-08-14 12:37:21 +00:00
|
|
|
|
:header-height="isMixedNav ? 0 : headerHeight"
|
2024-06-09 07:39:11 +00:00
|
|
|
|
:is-sidebar-mixed="isSidebarMixedNav"
|
2024-07-18 13:59:18 +00:00
|
|
|
|
:margin-top="sidebarMarginTop"
|
2024-06-09 07:39:11 +00:00
|
|
|
|
:mixed-width="sidebarMixedWidth"
|
|
|
|
|
:show="showSidebar"
|
2024-08-14 12:37:21 +00:00
|
|
|
|
:theme="sidebarTheme"
|
2024-06-09 07:39:11 +00:00
|
|
|
|
:width="getSidebarWidth"
|
|
|
|
|
:z-index="sidebarZIndex"
|
2024-05-19 13:20:42 +00:00
|
|
|
|
@leave="() => emit('sideMouseLeave')"
|
|
|
|
|
>
|
|
|
|
|
<template v-if="isSideMode && !isMixedNav" #logo>
|
|
|
|
|
<slot name="logo"></slot>
|
|
|
|
|
</template>
|
|
|
|
|
|
2024-06-09 07:39:11 +00:00
|
|
|
|
<template v-if="isSidebarMixedNav">
|
2024-05-19 13:20:42 +00:00
|
|
|
|
<slot name="mixed-menu"></slot>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else>
|
|
|
|
|
<slot name="menu"></slot>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<template #extra>
|
|
|
|
|
<slot name="side-extra"></slot>
|
|
|
|
|
</template>
|
|
|
|
|
<template #extra-title>
|
|
|
|
|
<slot name="side-extra-title"></slot>
|
|
|
|
|
</template>
|
2024-06-09 07:39:11 +00:00
|
|
|
|
</LayoutSidebar>
|
2024-05-19 13:20:42 +00:00
|
|
|
|
|
2024-05-28 15:38:36 +00:00
|
|
|
|
<div
|
2024-08-13 14:09:46 +00:00
|
|
|
|
ref="contentRef"
|
2024-05-28 15:38:36 +00:00
|
|
|
|
class="flex flex-1 flex-col overflow-hidden transition-all duration-300 ease-in"
|
|
|
|
|
>
|
|
|
|
|
<div
|
|
|
|
|
:style="headerWrapperStyle"
|
2024-06-01 14:17:52 +00:00
|
|
|
|
class="overflow-hidden transition-all duration-200"
|
2024-05-28 15:38:36 +00:00
|
|
|
|
>
|
2024-05-19 13:20:42 +00:00
|
|
|
|
<LayoutHeader
|
|
|
|
|
v-if="headerVisible"
|
|
|
|
|
:full-width="!isSideMode"
|
2024-08-14 12:37:21 +00:00
|
|
|
|
:height="headerHeight"
|
2024-06-09 05:31:43 +00:00
|
|
|
|
:is-mixed-nav="isMixedNav"
|
|
|
|
|
:is-mobile="isMobile"
|
2024-08-14 12:37:21 +00:00
|
|
|
|
:show="!isFullContent && !headerHidden"
|
2024-05-19 13:20:42 +00:00
|
|
|
|
:show-toggle-btn="showHeaderToggleButton"
|
2024-06-09 07:39:11 +00:00
|
|
|
|
:sidebar-width="sidebarWidth"
|
2024-08-14 13:47:37 +00:00
|
|
|
|
:theme="headerTheme"
|
2024-05-19 13:20:42 +00:00
|
|
|
|
:width="mainStyle.width"
|
|
|
|
|
:z-index="headerZIndex"
|
|
|
|
|
@open-menu="handleOpenMenu"
|
2024-07-18 13:59:18 +00:00
|
|
|
|
@toggle-sidebar="() => emit('toggleSidebar')"
|
2024-05-19 13:20:42 +00:00
|
|
|
|
>
|
|
|
|
|
<template v-if="showHeaderLogo" #logo>
|
|
|
|
|
<slot name="logo"></slot>
|
|
|
|
|
</template>
|
|
|
|
|
<slot name="header"></slot>
|
|
|
|
|
</LayoutHeader>
|
|
|
|
|
|
2024-06-09 07:39:11 +00:00
|
|
|
|
<LayoutTabbar
|
|
|
|
|
v-if="tabbarEnable"
|
2024-07-10 13:20:11 +00:00
|
|
|
|
:height="tabbarHeight"
|
2024-06-09 07:39:11 +00:00
|
|
|
|
:style="tabbarStyle"
|
|
|
|
|
>
|
|
|
|
|
<slot name="tabbar"></slot>
|
|
|
|
|
</LayoutTabbar>
|
2024-05-19 13:20:42 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- </div> -->
|
|
|
|
|
<LayoutContent
|
|
|
|
|
:content-compact="contentCompact"
|
|
|
|
|
:content-compact-width="contentCompactWidth"
|
|
|
|
|
:padding="contentPadding"
|
|
|
|
|
:padding-bottom="contentPaddingBottom"
|
|
|
|
|
:padding-left="contentPaddingLeft"
|
|
|
|
|
:padding-right="contentPaddingRight"
|
|
|
|
|
:padding-top="contentPaddingTop"
|
2024-06-09 05:31:43 +00:00
|
|
|
|
:style="contentStyle"
|
|
|
|
|
class="transition-[margin-top] duration-200"
|
2024-05-19 13:20:42 +00:00
|
|
|
|
>
|
|
|
|
|
<slot name="content"></slot>
|
2024-08-15 13:48:52 +00:00
|
|
|
|
|
|
|
|
|
<template #overlay="{ overlayStyle }">
|
|
|
|
|
<slot :overlay-style="overlayStyle" name="content-overlay"></slot>
|
|
|
|
|
</template>
|
2024-05-19 13:20:42 +00:00
|
|
|
|
</LayoutContent>
|
|
|
|
|
|
|
|
|
|
<LayoutFooter
|
2024-06-09 05:31:43 +00:00
|
|
|
|
v-if="footerEnable"
|
2024-05-19 13:20:42 +00:00
|
|
|
|
:fixed="footerFixed"
|
|
|
|
|
:height="footerHeight"
|
2024-08-14 12:37:21 +00:00
|
|
|
|
:show="!isFullContent"
|
2024-05-19 13:20:42 +00:00
|
|
|
|
:width="footerWidth"
|
|
|
|
|
:z-index="zIndex"
|
|
|
|
|
>
|
|
|
|
|
<slot name="footer"></slot>
|
|
|
|
|
</LayoutFooter>
|
|
|
|
|
</div>
|
2024-07-11 03:05:01 +00:00
|
|
|
|
<slot name="extra"></slot>
|
2024-05-19 13:20:42 +00:00
|
|
|
|
<div
|
|
|
|
|
v-if="maskVisible"
|
|
|
|
|
:style="maskStyle"
|
2024-07-16 15:13:03 +00:00
|
|
|
|
class="bg-overlay fixed left-0 top-0 h-full w-full transition-[background-color] duration-200"
|
2024-05-19 13:20:42 +00:00
|
|
|
|
@click="handleClickMask"
|
|
|
|
|
></div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|