Skip to content

Commit

Permalink
feat: pageWrapper.vue加入sticky功能 (#3008)
Browse files Browse the repository at this point in the history
  • Loading branch information
k1ngbanana authored Sep 8, 2023
1 parent a244dcd commit 1c668f2
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/components/Page/src/PageWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
:ghost="ghost"
:title="title"
v-bind="omit($attrs, 'class')"
:style="getHeaderStyle"
ref="headerRef"
v-if="getShowHeader"
>
Expand Down Expand Up @@ -52,6 +53,7 @@
import { omit } from 'lodash-es';
import { PageHeader } from 'ant-design-vue';
import { useContentHeight } from '/@/hooks/web/useContentHeight';
import { useLayoutHeight } from '/@/layouts/default/content/useContentViewHeight';
import { PageWrapperFixedHeightKey } from '/@/enums/pageEnum';
defineOptions({
Expand All @@ -63,6 +65,8 @@
title: propTypes.string,
dense: propTypes.bool,
ghost: propTypes.bool,
headerSticky: propTypes.bool,
headerStyle: Object as PropType<CSSProperties>,
content: propTypes.string,
contentStyle: {
type: Object as PropType<CSSProperties>,
Expand Down Expand Up @@ -112,6 +116,20 @@
];
});
const { headerHeightRef } = useLayoutHeight();
const getHeaderStyle = computed((): CSSProperties => {
const { headerSticky } = props;
if (!headerSticky) {
return {};
}
return {
position: 'sticky',
top: `${unref(headerHeightRef)}px`,
...props.headerStyle,
};
});
const getShowHeader = computed(
() => props.content || slots?.headerContent || props.title || getHeaderSlots.value.length,
);
Expand Down

0 comments on commit 1c668f2

Please sign in to comment.