首页工作流产出:resultFileUrl 逗号拼接多 URL 统一拆分(兼容字符串/数组入参),修复回显与实时产出渲染异常
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -199,21 +199,28 @@ export function extractWorkflowOutputs(data: any, backendId?: string): WorkflowO
|
||||
// 不依赖执行详情的异步查询,type 同样按扩展名推断,去重后归一为 { url, name, type, backendId }。
|
||||
// 用于完成事件即时渲染产出卡片,删除时 backendId 为空则跳过删除接口(安全降级)。
|
||||
export function buildOutputsFromUrls(urls: any, backendId?: string): WorkflowOutput[] {
|
||||
if (!Array.isArray(urls)) return [];
|
||||
// 兼容两种入参:字符串(逗号拼接多 URL)或数组(元素本身可能是逗号拼接串);
|
||||
// 合法 URL 不含裸逗号,统一按逗号拆分后逐条归一化,避免把整串误当单个产出
|
||||
const arr: string[] = typeof urls === 'string' ? [urls] : Array.isArray(urls) ? urls : [];
|
||||
const seen = new Set<string>();
|
||||
const outputs: WorkflowOutput[] = [];
|
||||
for (const u of urls) {
|
||||
for (const u of arr) {
|
||||
if (typeof u !== 'string') continue;
|
||||
const url = u.trim();
|
||||
if (!url || seen.has(url)) continue;
|
||||
seen.add(url);
|
||||
const name = String(url).split('?')[0].split('/').pop() || '产出文件';
|
||||
outputs.push({
|
||||
url,
|
||||
name,
|
||||
type: guessFileType(url),
|
||||
backendId: backendId || '',
|
||||
});
|
||||
const parts = u
|
||||
.split(',')
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean);
|
||||
for (const url of parts) {
|
||||
if (seen.has(url)) continue;
|
||||
seen.add(url);
|
||||
const name = String(url).split('?')[0].split('/').pop() || '产出文件';
|
||||
outputs.push({
|
||||
url,
|
||||
name,
|
||||
type: guessFileType(url),
|
||||
backendId: backendId || '',
|
||||
});
|
||||
}
|
||||
}
|
||||
return outputs;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user