import type { BasicTableProps } from '@/components/VxeTable';
import useResizeHeight from './useResizeHeight';
import { unref, watchEffect, onUnmounted } from 'vue';
/**
 * 初始化表格的高度
 */
function useInitTableHeight(tableListOptions: BasicTableProps, initHeight = 520, searchHeight = 243) {
    // 表格自适应屏幕高度 
    const { tableHeight } = useResizeHeight(searchHeight)
    const stop = watchEffect(() => {
        unref(tableHeight) > initHeight ? 
            (tableListOptions.height = unref(tableHeight))
            : initHeight
    })
    onUnmounted(stop)
}

export { useInitTableHeight }