fix: TextContent autoHeight

This commit is contained in:
unanmed 2025-08-16 16:35:27 +08:00
parent 3b6b534211
commit 3aab8f3987
2 changed files with 7 additions and 7 deletions

View File

@ -18,10 +18,6 @@ const iconsProps = {
props: ['loc'] props: ['loc']
} satisfies SetupComponentOptions<IconsProps>; } satisfies SetupComponentOptions<IconsProps>;
type PathGenerator = (width: number, height: number) => Path2D;
type PadFn = (
divisor: number
) => [left: number, right: number, top: number, bottom: number];
type IconLoc = [ type IconLoc = [
x: number, x: number,
y: number, y: number,
@ -30,6 +26,9 @@ type IconLoc = [
cx: number, cx: number,
cy: number cy: number
]; ];
type IconPad = [left: number, right: number, top: number, bottom: number];
type PathGenerator = (width: number, height: number) => Path2D;
type PadFn = (divisor: number) => IconPad;
/** /**
* @param loc * @param loc
@ -51,7 +50,7 @@ function pad(
width: number, width: number,
height: number, height: number,
divisor: number divisor: number
): [left: number, right: number, top: number, bottom: number] { ): IconPad {
return [ return [
x + width / divisor, // left x + width / divisor, // left
x + width - width / divisor, // right x + width - width / divisor, // right

View File

@ -117,7 +117,7 @@ export const TextContent = defineComponent<
TextContentEmits, TextContentEmits,
keyof TextContentEmits keyof TextContentEmits
>((props, { emit, expose }) => { >((props, { emit, expose }) => {
const loc = ref<ElementLocator>( const loc = shallowRef<ElementLocator>(
(props.loc?.slice() as ElementLocator) ?? [] (props.loc?.slice() as ElementLocator) ?? []
); );
@ -160,7 +160,8 @@ export const TextContent = defineComponent<
const updateLoc = () => { const updateLoc = () => {
const height = getHeight(); const height = getHeight();
if (props.autoHeight) { if (props.autoHeight) {
const [x = 0, y = 0, width = 200, , ax = 0, ay = 0] = loc.value; const [x = 0, y = 0, width = props.width, , ax = 0, ay = 0] =
loc.value;
loc.value = [x, y, width, height, ax, ay]; loc.value = [x, y, width, height, ax, ay];
} }
emit('updateHeight', height); emit('updateHeight', height);