fix(ai): 产物地址兼容字符串元素,视频/图片卡片取得到链接
video_result/photo_files 的元素可能直接是地址字符串,原实现按对象取 url, 字符串元素一律取空——视频有文件却不播放、复制链接永远为空。
This commit is contained in:
@@ -1541,6 +1541,11 @@
|
||||
return payload || {}
|
||||
},
|
||||
getCreativeFileUrl(item) {
|
||||
// 元素退化成裸地址字符串时也要能取到链接:视频分支上游有时直接给
|
||||
// 地址数组,取不到 url 就只剩「当前文件缺少链接」(见禅道 bug #1)。
|
||||
if (typeof item === 'string') {
|
||||
return item.trim()
|
||||
}
|
||||
return String(
|
||||
(item && (item.url || item.remote_url || item.downloadUrl || item.download_url || item.path)) || ''
|
||||
).trim()
|
||||
@@ -1563,7 +1568,10 @@
|
||||
)
|
||||
},
|
||||
formatFileList(title, list = []) {
|
||||
if (!Array.isArray(list) || !list.length) {
|
||||
if (!Array.isArray(list)) {
|
||||
list = list ? [list] : []
|
||||
}
|
||||
if (!list.length) {
|
||||
return ''
|
||||
}
|
||||
return `\n\n### ${title}\n${list
|
||||
@@ -1579,7 +1587,10 @@
|
||||
.join('\n')}`
|
||||
},
|
||||
formatImageList(title, list = []) {
|
||||
if (!Array.isArray(list) || !list.length) {
|
||||
if (!Array.isArray(list)) {
|
||||
list = list ? [list] : []
|
||||
}
|
||||
if (!list.length) {
|
||||
return ''
|
||||
}
|
||||
const lines = list
|
||||
|
||||
@@ -179,7 +179,7 @@
|
||||
return !!String(this.content || '').trim()
|
||||
},
|
||||
videoFiles() {
|
||||
return (this.workflowOutputs && this.workflowOutputs.video_result) || []
|
||||
return this.asFileList(this.workflowOutputs && this.workflowOutputs.video_result)
|
||||
},
|
||||
scriptMarkdown() {
|
||||
return String((this.workflowOutputs && this.workflowOutputs.Script_result) || '')
|
||||
@@ -193,7 +193,7 @@
|
||||
.trim()
|
||||
},
|
||||
photoFiles() {
|
||||
return (this.workflowOutputs && this.workflowOutputs.photo_files) || []
|
||||
return this.asFileList(this.workflowOutputs && this.workflowOutputs.photo_files)
|
||||
},
|
||||
statusMessage() {
|
||||
return (
|
||||
@@ -253,10 +253,28 @@
|
||||
}
|
||||
return payload
|
||||
},
|
||||
/**
|
||||
* 文件列表兜底:上游的 video_result 可能给成单个对象或裸地址字符串,
|
||||
* 不是数组时直接当一项处理,避免整条视频列表空掉(见禅道 bug #1)。
|
||||
*/
|
||||
asFileList(value) {
|
||||
if (!value) {
|
||||
return []
|
||||
}
|
||||
const items = Array.isArray(value) ? value : [value]
|
||||
// 裸地址统一包成 { url },下游的 resolveFileUrl / getFileName 不必各自判类型。
|
||||
return items.map((item) => (typeof item === 'string' ? { url: item } : item))
|
||||
},
|
||||
resolveFileUrl(file) {
|
||||
if (!file) {
|
||||
return ''
|
||||
}
|
||||
// 后端已把 video_result 归一到 { url, name, type },这里再兜一层:
|
||||
// 元素退化成裸地址字符串时也要能取到链接,否则卡片不播放、
|
||||
// 复制链接只会提示「当前文件缺少链接」。
|
||||
if (typeof file === 'string') {
|
||||
return file.trim()
|
||||
}
|
||||
return String(file.url || file.downloadUrl || file.thumbnail || file.path || '')
|
||||
},
|
||||
getFileName(file) {
|
||||
|
||||
Reference in New Issue
Block a user