From 7f4b1dcd752f405a9a1cf6d34e4b60fa7f55a3d8 Mon Sep 17 00:00:00 2001 From: XianYuDaXian Date: Wed, 18 Mar 2026 18:43:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20URL=20=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E5=8E=86=E5=8F=B2=E8=A7=86=E9=A2=91=E9=A2=84=E8=A7=88?= =?UTF-8?q?=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/static/public/js/video.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/app/static/public/js/video.js b/app/static/public/js/video.js index 189a5e4..473202d 100644 --- a/app/static/public/js/video.js +++ b/app/static/public/js/video.js @@ -1890,9 +1890,17 @@ return { url: urlMatch[1] }; } } - const urlMatches = buffer.match(/https?:\/\/[^\s<)]+/g); - if (urlMatches && urlMatches.length) { - return { url: urlMatches[urlMatches.length - 1] }; + const mp4Matches = buffer.match(/https?:\/\/[^\s"'<>]+?\.mp4(?![a-zA-Z0-9])/gi); + if (mp4Matches && mp4Matches.length) { + return { url: mp4Matches[mp4Matches.length - 1] }; + } + const localMatches = buffer.match(/(?:https?:\/\/[^\s"'<>]+)?\/v1\/files\/video\/[^\s"'<>]+?\.mp4(?![a-zA-Z0-9])/gi); + if (localMatches && localMatches.length) { + const last = localMatches[localMatches.length - 1]; + if (/^https?:\/\//i.test(last)) { + return { url: last }; + } + return { url: `${window.location.origin}${last}` }; } return null; } @@ -1902,9 +1910,9 @@ if (!raw) return ''; const info = extractVideoInfo(raw); if (info && info.url) return info.url; - const mp4 = raw.match(/https?:\/\/[^\s"'<>]+\.mp4[^\s"'<>]*/i); + const mp4 = raw.match(/https?:\/\/[^\s"'<>]+\.mp4(?![a-zA-Z0-9])/i); if (mp4 && mp4[0]) return mp4[0]; - const local = raw.match(/\/v1\/files\/video\/[^\s"'<>]+/i); + const local = raw.match(/\/v1\/files\/video\/[^\s"'<>]+(?![a-zA-Z0-9])/i); if (local && local[0]) { if (local[0].startsWith('http')) return local[0]; return `${window.location.origin}${local[0]}`; @@ -2626,7 +2634,7 @@ const choice = payload.choices && payload.choices[0]; const delta = choice && choice.delta ? choice.delta : null; if (delta && delta.content) { - buffer += String(delta.content); + buffer += `${String(delta.content)}\n`; const info = extractVideoInfo(buffer); const payloadUrl = extractVideoUrlFromAnyText(JSON.stringify(payload)); if ((info && info.url) || payloadUrl) { @@ -2801,7 +2809,7 @@ } if (taskState.collectingContent) { - taskState.contentBuffer += text; + taskState.contentBuffer += `${text}\n`; const info = extractVideoInfo(taskState.contentBuffer); let videoUrl = (info && info.url) ? info.url : extractVideoUrlFromAnyText(taskState.contentBuffer);