11<script setup lang="ts">
2- import {
3- computed ,
4- nextTick ,
5- onMounted ,
6- ref ,
7- type StyleValue ,
8- useTemplateRef ,
9- } from ' vue' ;
2+ import { computed , nextTick , onMounted , ref , useTemplateRef } from ' vue' ;
103
11- import { preferences } from ' @vben-core/preferences ' ;
4+ import { CSS_VARIABLE_LAYOUT_CONTENT_HEIGHT } from ' @vben/constants ' ;
125import { cn } from ' @vben-core/shared/utils' ;
136
147interface Props {
@@ -19,8 +12,6 @@ interface Props {
1912 * 根据content可见高度自适应
2013 */
2114 autoContentHeight? : boolean ;
22- /** 头部固定(暂未实现) */
23- fixedHeader? : boolean ;
2415 headerClass? : string ;
2516 footerClass? : string ;
2617}
@@ -29,13 +20,7 @@ defineOptions({
2920 name: ' Page' ,
3021});
3122
32- const {
33- contentClass = ' ' ,
34- description = ' ' ,
35- autoContentHeight = false ,
36- title = ' ' ,
37- fixedHeader = false ,
38- } = defineProps <Props >();
23+ const { autoContentHeight = false } = defineProps <Props >();
3924
4025const headerHeight = ref (0 );
4126const footerHeight = ref (0 );
@@ -44,22 +29,11 @@ const shouldAutoHeight = ref(false);
4429const headerRef = useTemplateRef <HTMLDivElement >(' headerRef' );
4530const footerRef = useTemplateRef <HTMLDivElement >(' footerRef' );
4631
47- const headerStyle = computed <StyleValue >(() => {
48- return fixedHeader
49- ? {
50- position: ' sticky' ,
51- zIndex: 200 ,
52- top:
53- preferences .header .mode === ' fixed' ? ' var(--vben-header-height)' : 0 ,
54- }
55- : undefined ;
56- });
57-
5832const contentStyle = computed (() => {
5933 if (autoContentHeight ) {
6034 return {
6135 height: shouldAutoHeight .value
62- ? ` calc(var(--vben-content-height) - ${ headerHeight . value }px - ${footerHeight .value }px) `
36+ ? ` calc(var(${ CSS_VARIABLE_LAYOUT_CONTENT_HEIGHT }) - ${headerHeight .value }px) `
6337 : ' 0' ,
6438 // 'overflow-y': shouldAutoHeight.value?'auto':'unset',
6539 };
@@ -97,28 +71,26 @@ onMounted(() => {
9771 ref =" headerRef"
9872 :class ="
9973 cn(
100- 'bg-card relative px-6 py-4',
74+ 'bg-card border-border relative flex items-end border-b px-6 py-4',
10175 headerClass,
102- fixedHeader
103- ? 'border-border border-b transition-all duration-200'
104- : '',
10576 )
10677 "
107- :style =" headerStyle"
10878 >
109- <slot name =" title" >
110- <div v-if =" title" class =" mb-2 flex text-lg font-semibold" >
111- {{ title }}
112- </div >
113- </slot >
79+ <div class =" flex-auto" >
80+ <slot name =" title" >
81+ <div v-if =" title" class =" mb-2 flex text-lg font-semibold" >
82+ {{ title }}
83+ </div >
84+ </slot >
11485
115- <slot name =" description" >
116- <p v-if =" description" class =" text-muted-foreground" >
117- {{ description }}
118- </p >
119- </slot >
86+ <slot name =" description" >
87+ <p v-if =" description" class =" text-muted-foreground" >
88+ {{ description }}
89+ </p >
90+ </slot >
91+ </div >
12092
121- <div v-if =" $slots.extra" class = " absolute bottom-4 right-4 " >
93+ <div v-if =" $slots.extra" >
12294 <slot name =" extra" ></slot >
12395 </div >
12496 </div >
@@ -132,8 +104,8 @@ onMounted(() => {
132104 ref =" footerRef"
133105 :class ="
134106 cn(
135- footerClass,
136107 'bg-card align-center absolute bottom-0 left-0 right-0 flex px-6 py-4',
108+ footerClass,
137109 )
138110 "
139111 >
0 commit comments