fix file item display

pull/21369/head
JzoNg 11 months ago
parent f218b23fb7
commit cc7828d438

@ -135,7 +135,7 @@ export const getProcessedFilesFromResponse = (files: FileResponse[]) => {
transferMethod: fileItem.transfer_method, transferMethod: fileItem.transfer_method,
supportFileType: fileItem.type, supportFileType: fileItem.type,
uploadedId: fileItem.upload_file_id || fileItem.related_id, uploadedId: fileItem.upload_file_id || fileItem.related_id,
url: fileItem.url, url: fileItem.url || fileItem.remote_url,
} }
}) })
} }

@ -13,7 +13,7 @@ import {
validateJSONSchema, validateJSONSchema,
} from '@/app/components/workflow/variable-inspect/utils' } from '@/app/components/workflow/variable-inspect/utils'
import { useFeatures } from '@/app/components/base/features/hooks' import { useFeatures } from '@/app/components/base/features/hooks'
import { getProcessedFiles } from '@/app/components/base/file-uploader/utils' import { getProcessedFiles, getProcessedFilesFromResponse } from '@/app/components/base/file-uploader/utils'
import { JSON_SCHEMA_MAX_DEPTH } from '@/config' import { JSON_SCHEMA_MAX_DEPTH } from '@/config'
import { TransferMethod } from '@/types/app' import { TransferMethod } from '@/types/app'
import { FILE_EXTS } from '@/app/components/base/prompt-editor/constants' import { FILE_EXTS } from '@/app/components/base/prompt-editor/constants'
@ -47,9 +47,9 @@ const ValueContent = ({
const fileFeature = useFeatures(s => s.features.file) const fileFeature = useFeatures(s => s.features.file)
const [fileValue, setFileValue] = useState<any>( const [fileValue, setFileValue] = useState<any>(
currentVar.value_type === 'array[file]' currentVar.value_type === 'array[file]'
? currentVar.value || [] ? getProcessedFilesFromResponse(currentVar.value || [])
: currentVar.value : currentVar.value
? [currentVar.value] ? getProcessedFilesFromResponse([currentVar.value])
: [], : [],
) )
@ -68,11 +68,12 @@ const ValueContent = ({
setJson(currentVar.value ? JSON.stringify(currentVar.value, null, 2) : '') setJson(currentVar.value ? JSON.stringify(currentVar.value, null, 2) : '')
if (showFileEditor) { if (showFileEditor) {
console.log(getProcessedFilesFromResponse(currentVar.value || []))
setFileValue( setFileValue(
(currentVar.value_type === 'array[file]' || isSysFiles) (currentVar.value_type === 'array[file]' || isSysFiles)
? currentVar.value || [] ? getProcessedFilesFromResponse(currentVar.value || [])
: currentVar.value : currentVar.value
? [currentVar.value] ? getProcessedFilesFromResponse([currentVar.value])
: [], : [],
) )
} }

@ -201,6 +201,7 @@ export type FileResponse = {
type: string type: string
url: string url: string
upload_file_id: string upload_file_id: string
remote_url: string
} }
export type NodeFinishedResponse = { export type NodeFinishedResponse = {

Loading…
Cancel
Save