feat(project): sync all pending tenant ui changes
This commit is contained in:
@@ -163,16 +163,26 @@ const adjustCropperToAspectRatio = () => {
|
||||
const containerWidthVal = containerWidth.value;
|
||||
const containerHeightVal = containerHeight.value;
|
||||
|
||||
// 根据比例计算裁剪框尺寸
|
||||
let newHeight: number, newWidth: number;
|
||||
// 有固定比例时保留默认留白,避免初始裁剪框占满导致拖拽不便
|
||||
const padding = Math.min(
|
||||
CROPPER_CONSTANTS.MAX_PADDING,
|
||||
Math.floor(containerWidthVal * CROPPER_CONSTANTS.PADDING_RATIO),
|
||||
Math.floor(containerHeightVal * CROPPER_CONSTANTS.PADDING_RATIO),
|
||||
);
|
||||
const maxCropWidth = Math.max(
|
||||
CROPPER_CONSTANTS.MIN_WIDTH,
|
||||
containerWidthVal - padding * 2,
|
||||
);
|
||||
const maxCropHeight = Math.max(
|
||||
CROPPER_CONSTANTS.MIN_HEIGHT,
|
||||
containerHeightVal - padding * 2,
|
||||
);
|
||||
|
||||
// 先按宽度优先计算
|
||||
newWidth = containerWidthVal;
|
||||
newHeight = newWidth / ratio;
|
||||
|
||||
// 如果高度超出容器,按高度优先计算
|
||||
if (newHeight > containerHeightVal) {
|
||||
newHeight = containerHeightVal;
|
||||
// 根据比例在可用区域内计算裁剪框尺寸
|
||||
let newWidth = maxCropWidth;
|
||||
let newHeight = newWidth / ratio;
|
||||
if (newHeight > maxCropHeight) {
|
||||
newHeight = maxCropHeight;
|
||||
newWidth = newHeight * ratio;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user