增强文件上传功能
- 在创作模式中,支持从工作空间获取文件 URL,提升文件处理的灵活性。 - 处理 API 返回的文件 URL,确保正确构建文件链接,优化用户体验。
This commit is contained in:
@@ -1238,6 +1238,11 @@ const sendMessage = async () => {
|
||||
try {
|
||||
// 1. 先上传文件到 OSS,获取文件 URL
|
||||
const fileUrls: string[] = [];
|
||||
|
||||
if (isFromWorkspace.value && currentWorkflowForCreation.value?.fileUrls) {
|
||||
fileUrls.push(...currentWorkflowForCreation.value.fileUrls);
|
||||
}
|
||||
|
||||
if (selectedFiles.value.length > 0) {
|
||||
for (const file of selectedFiles.value) {
|
||||
const uploadRes = await uploadFile(file);
|
||||
@@ -1368,6 +1373,24 @@ const handleTreeNodeClick = async (data: TreeNode) => {
|
||||
// 标记为从工作空间进入
|
||||
isFromWorkspace.value = true;
|
||||
|
||||
// 处理 fileUrl
|
||||
const fileUrls: string[] = [];
|
||||
if (res.data.outputParams && Array.isArray(res.data.outputParams)) {
|
||||
const prefix = res.data.imgAddressPrefix || '';
|
||||
res.data.outputParams.forEach((param: any) => {
|
||||
Object.values(param).forEach((value: any) => {
|
||||
if (typeof value === 'string' && value) {
|
||||
if (value.startsWith('http://') || value.startsWith('https://')) {
|
||||
fileUrls.push(value);
|
||||
} else {
|
||||
fileUrls.push(prefix ? `${prefix}${value}` : value);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
res.data.fileUrls = fileUrls;
|
||||
|
||||
// 切换到创作模式
|
||||
isCreationMode.value = true;
|
||||
currentWorkflowForCreation.value = res.data;
|
||||
|
||||
Reference in New Issue
Block a user