From ac1823363dd9514027cbbccff21ee1a058c52b26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=97=E6=9E=B3?= <7854742+wang_rumeng@user.noreply.gitee.com> Date: Wed, 20 Aug 2025 00:06:41 +0800 Subject: [PATCH 1/5] xianshang --- api/constants.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/constants.ts b/api/constants.ts index 53e1866..8dfaed6 100644 --- a/api/constants.ts +++ b/api/constants.ts @@ -1,2 +1,3 @@ -export const BASE_URL = process.env.NEXT_PUBLIC_SMART_API +// export const BASE_URL = process.env.NEXT_PUBLIC_SMART_API // +export const BASE_URL = 'https://pre.movieflow.api.huiying.video' \ No newline at end of file From f21eebbbd2901892a76297bcfcbeceff3bee9caf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=97=E6=9E=B3?= <7854742+wang_rumeng@user.noreply.gitee.com> Date: Wed, 20 Aug 2025 00:52:55 +0800 Subject: [PATCH 2/5] shengchan --- api/constants.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/api/constants.ts b/api/constants.ts index 8dfaed6..53e1866 100644 --- a/api/constants.ts +++ b/api/constants.ts @@ -1,3 +1,2 @@ -// export const BASE_URL = process.env.NEXT_PUBLIC_SMART_API +export const BASE_URL = process.env.NEXT_PUBLIC_SMART_API // -export const BASE_URL = 'https://pre.movieflow.api.huiying.video' \ No newline at end of file From 0f65c0cd7f3bc2cea8eb24e87412cb1b02ba5c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=97=E6=9E=B3?= <7854742+wang_rumeng@user.noreply.gitee.com> Date: Wed, 20 Aug 2025 01:48:50 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=9B=BD=E5=A4=96=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/constants.ts b/api/constants.ts index 53e1866..8d41e9b 100644 --- a/api/constants.ts +++ b/api/constants.ts @@ -1,2 +1,2 @@ -export const BASE_URL = process.env.NEXT_PUBLIC_SMART_API +export const BASE_URL = 'https://www.movieflow.ai' // From 5c049fe9647adff8ea8fdade76adb598ce057092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=97=E6=9E=B3?= <7854742+wang_rumeng@user.noreply.gitee.com> Date: Wed, 20 Aug 2025 16:35:31 +0800 Subject: [PATCH 4/5] 77 --- api/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/constants.ts b/api/constants.ts index 8d41e9b..53e1866 100644 --- a/api/constants.ts +++ b/api/constants.ts @@ -1,2 +1,2 @@ -export const BASE_URL = 'https://www.movieflow.ai' +export const BASE_URL = process.env.NEXT_PUBLIC_SMART_API // From 3c5f2f6fe13199dd12a1a4282eeb1b1ff1a0e209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=97=E6=9E=B3?= <7854742+wang_rumeng@user.noreply.gitee.com> Date: Wed, 20 Aug 2025 21:54:27 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=A7=92=E8=89=B2?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=A1=86=E9=81=87=E5=88=B0=E7=89=B9=E6=AE=8A?= =?UTF-8?q?=E8=A7=92=E8=89=B2=E6=8F=8F=E8=BF=B0=E5=AF=BC=E8=87=B4=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=B4=A9=E6=BA=83=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/adapter/textToShot.ts | 53 +++++++++++++++++++----------- components/ui/character-editor.tsx | 11 +++++-- 2 files changed, 43 insertions(+), 21 deletions(-) diff --git a/app/service/adapter/textToShot.ts b/app/service/adapter/textToShot.ts index 6de8cf2..8a6ad2b 100644 --- a/app/service/adapter/textToShot.ts +++ b/app/service/adapter/textToShot.ts @@ -131,36 +131,45 @@ export class TextToShotAdapter { public static parseHighlight(text: string, tags: TagValueObject[]): ContentNode[] { const nodes: ContentNode[] = []; let currentText = text; - // 按内容长度降序排序,避免短名称匹配到长名称的一部分 - const sortedTags = [...tags].sort((a, b) => String(b.content).length - String(a.content).length); - - while (currentText.length > 0) { + + // 1. 确保 tags 是有效的数组 + if (!Array.isArray(tags)) { + console.warn('Invalid tags:', tags); + return [{ type: 'text', text: currentText }]; + } + + // 2. 恢复排序逻辑,并添加安全检查 + const sortedTags = [...tags] + .filter(tag => tag && tag.content) // 过滤无效的 tag + .sort((a, b) => String(b.content).length - String(a.content).length); + + // 3. 添加安全检查,防止无限循环 + let iterationCount = 0; + const MAX_ITERATIONS = 1000; // 设置一个合理的最大迭代次数 + + while (currentText.length > 0 && iterationCount < MAX_ITERATIONS) { + iterationCount++; let matchFound = false; - // 尝试匹配 for (const tag of sortedTags) { - if (currentText.startsWith(String(tag.content))) { - // 如果当前文本以tag内容开头 - if (currentText.length > String(tag.content).length) { - // 添加标记节点 + const tagContent = String(tag.content); + if (currentText.startsWith(tagContent)) { + if (currentText.length > tagContent.length) { nodes.push({ type: 'highlightText', attrs: { - text: String(tag.content), + text: tagContent, color: tag?.color || 'yellow' } }); - // 移除已处理的tag内容 - currentText = currentText.slice(String(tag.content).length); + currentText = currentText.slice(tagContent.length); matchFound = true; break; } } } - + if (!matchFound) { - // 如果没有找到tag匹配,处理普通文本 - // 查找下一个可能的tag内容位置 let nextTagIndex = currentText.length; for (const tag of sortedTags) { const index = currentText.indexOf(String(tag.content)); @@ -168,8 +177,7 @@ export class TextToShotAdapter { nextTagIndex = index; } } - - // 添加文本节点 + const textContent = currentText.slice(0, nextTagIndex); if (textContent) { nodes.push({ @@ -177,11 +185,18 @@ export class TextToShotAdapter { text: textContent }); } - // 移除已处理的文本 currentText = currentText.slice(nextTagIndex); } } - + + // 4. 如果达到最大迭代次数,处理剩余文本 + if (currentText.length > 0) { + nodes.push({ + type: 'text', + text: currentText + }); + } + return nodes; } private readonly ShotData: Shot; diff --git a/components/ui/character-editor.tsx b/components/ui/character-editor.tsx index 01b8fa9..08b10af 100644 --- a/components/ui/character-editor.tsx +++ b/components/ui/character-editor.tsx @@ -46,11 +46,18 @@ export const CharacterEditor = forwardRef(({ const paragraphs = TextToShotAdapter.fromTextToRole(description, highlight); console.log('-==========paragraphs===========-', paragraphs); setContent(paragraphs); - setTimeout(() => { + + // 保存定时器ID + const timerId = setTimeout(() => { setIsInit(false); setIsOptimizing(false); }, 100); - }, [highlight]); + + // 清理函数:组件卸载时清理定时器 + return () => { + clearTimeout(timerId); + }; + }, [description]); // 暴露方法给父组件 React.useImperativeHandle(ref, () => ({