From 1203b5618d68cf82540d5194debdc6f1013b2acb Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Sat, 21 Dec 2024 23:45:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=89=93=E5=AD=97=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/render/components/textbox.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/core/render/components/textbox.tsx b/src/core/render/components/textbox.tsx index dfc421a..95d6596 100644 --- a/src/core/render/components/textbox.tsx +++ b/src/core/render/components/textbox.tsx @@ -130,7 +130,7 @@ const textContentOptions = { 'x', 'y' ], - emits: ['typeEnd'] + emits: ['typeEnd', 'typeStart'] } satisfies SetupComponentOptions; export const TextContent = defineComponent( @@ -168,7 +168,7 @@ export const TextContent = defineComponent( if (key in renderData && !isNil(value)) { if (key === 'width') { if (value && value <= 0) { - logger.warn(41); + logger.warn(41, String(props.width)); renderData.width = 200; } else { renderData.width = value; @@ -238,11 +238,12 @@ export const TextContent = defineComponent( const line = dirtyIndex[linePointer]; const data = renderable[line]; const pointer = char - data.from; - if (pointer >= data.to) { + if (char >= data.to) { data.pointer = data.text.length; linePointer++; } else { data.pointer = pointer; + break; } } if (linePointer >= dirtyIndex.length) { @@ -255,6 +256,7 @@ export const TextContent = defineComponent( onTick(tick); onMounted(() => { data.value = makeSplitData(); + lineData.value = splitLines(data.value); }); const renderContent = ( @@ -343,6 +345,7 @@ export const TextContent = defineComponent( * 从头开始渲染 */ const rawRender = (text: string, lines: number[]) => { + console.trace(); makeRenderable(text, lines, 0, 0); spriteElement.value?.update(); }; @@ -419,7 +422,6 @@ export const TextContent = defineComponent( rawRender(data.value.text, value); } }); - lineData.value = splitLines(data.value); return () => { return (