fix(sdk): prefer iframe for embed-page urls in goView import

This commit is contained in:
clawdbot 2026-01-28 06:31:49 +08:00
parent ca3f5670e8
commit f87d82fe15

View File

@ -483,6 +483,19 @@ export function convertGoViewProjectToScreen(input: GoViewProjectLike | GoViewSt
const optionSaysVideo = looksLikeVideoOption(option);
const optionSaysIframe = looksLikeIframeOption(option);
// Some goView/fork widgets mislabel embedded platforms (YouTube/Vimeo/etc) as "Video"
// even though they are best represented as an iframe (a web page, not a media stream).
const urlLike = pickUrlLike(option);
const urlLooksLikeEmbedPage =
!!urlLike &&
/(youtube\.com|youtu\.be|vimeo\.com|bilibili\.com|youku\.com|iqiyi\.com|tencent|douyin\.com|kuaishou\.com)/i.test(
urlLike,
) &&
// Keep actual media URLs as video.
!/\.(mp4|m3u8|flv|webm|mov|m4v|ogv)(\?|#|$)/i.test(urlLike) &&
!/^data:video\//i.test(urlLike) &&
!/^(rtsp|rtmp):\/\//i.test(urlLike);
// Prefer evidence from the option payload over the widget key.
// Many forks mislabel widget keys (e.g. "Text*" / "Image*"), but the option payload
// clearly indicates iframe/video/image.
@ -490,7 +503,9 @@ export function convertGoViewProjectToScreen(input: GoViewProjectLike | GoViewSt
optionSaysIframe
? 'iframe'
: optionSaysVideo
? 'video'
? urlLooksLikeEmbedPage
? 'iframe'
: 'video'
: optionSaysImage
? 'image'
: isIframe(c)