You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
540 B
TypeScript

import { computed, type Ref } from "vue";
import { buildSegments } from "../services/segmentService";
/**
* 根据屏宽和配置生成分段布局及容器高度。
*/
export function useSegmentLayout(
screenWidth: Ref<number>,
totalWidth: Ref<number>,
segmentHeight: Ref<number>,
) {
const segments = computed(() =>
buildSegments(screenWidth.value, totalWidth.value, segmentHeight.value),
);
const containerHeight = computed(() => segments.value.length * segmentHeight.value);
return { segments, containerHeight };
}