mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-18 01:45:52 +08:00
fix: file progress
This commit is contained in:
parent
3f16caf244
commit
543503c398
@ -5,6 +5,7 @@ import {
|
|||||||
} from '@remixicon/react'
|
} from '@remixicon/react'
|
||||||
import FileTypeIcon from '../file-type-icon'
|
import FileTypeIcon from '../file-type-icon'
|
||||||
import {
|
import {
|
||||||
|
fileIsUploaded,
|
||||||
getFileAppearanceType,
|
getFileAppearanceType,
|
||||||
getFileExtension,
|
getFileExtension,
|
||||||
} from '../utils'
|
} from '../utils'
|
||||||
@ -81,7 +82,7 @@ const FileInAttachmentItem = ({
|
|||||||
</div>
|
</div>
|
||||||
<div className='shrink-0 flex items-center'>
|
<div className='shrink-0 flex items-center'>
|
||||||
{
|
{
|
||||||
progress >= 0 && !file.uploadedId && (
|
progress >= 0 && !fileIsUploaded(file) && (
|
||||||
<ProgressCircle
|
<ProgressCircle
|
||||||
className='mr-2.5'
|
className='mr-2.5'
|
||||||
percentage={progress}
|
percentage={progress}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { RiCloseLine } from '@remixicon/react'
|
import { RiCloseLine } from '@remixicon/react'
|
||||||
import FileImageRender from '../file-image-render'
|
import FileImageRender from '../file-image-render'
|
||||||
import type { FileEntity } from '../types'
|
import type { FileEntity } from '../types'
|
||||||
|
import { fileIsUploaded } from '../utils'
|
||||||
import Button from '@/app/components/base/button'
|
import Button from '@/app/components/base/button'
|
||||||
import ProgressCircle from '@/app/components/base/progress-bar/progress-circle'
|
import ProgressCircle from '@/app/components/base/progress-bar/progress-circle'
|
||||||
import { ReplayLine } from '@/app/components/base/icons/src/vender/other'
|
import { ReplayLine } from '@/app/components/base/icons/src/vender/other'
|
||||||
@ -39,7 +40,7 @@ const FileImageItem = ({
|
|||||||
showDownloadAction={showDownloadAction}
|
showDownloadAction={showDownloadAction}
|
||||||
/>
|
/>
|
||||||
{
|
{
|
||||||
progress > 0 && progress < 100 && (
|
progress >= 0 && !fileIsUploaded(file) && (
|
||||||
<div className='absolute inset-0 flex items-center justify-center border-[2px] border-effects-image-frame bg-background-overlay-alt z-10'>
|
<div className='absolute inset-0 flex items-center justify-center border-[2px] border-effects-image-frame bg-background-overlay-alt z-10'>
|
||||||
<ProgressCircle
|
<ProgressCircle
|
||||||
percentage={progress}
|
percentage={progress}
|
||||||
|
@ -3,6 +3,7 @@ import {
|
|||||||
RiDownloadLine,
|
RiDownloadLine,
|
||||||
} from '@remixicon/react'
|
} from '@remixicon/react'
|
||||||
import {
|
import {
|
||||||
|
fileIsUploaded,
|
||||||
getFileAppearanceType,
|
getFileAppearanceType,
|
||||||
getFileExtension,
|
getFileExtension,
|
||||||
} from '../utils'
|
} from '../utils'
|
||||||
@ -84,7 +85,7 @@ const FileItem = ({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
progress >= 0 && !file.uploadedId && (
|
progress >= 0 && !fileIsUploaded(file) && (
|
||||||
<ProgressCircle
|
<ProgressCircle
|
||||||
percentage={progress}
|
percentage={progress}
|
||||||
size={12}
|
size={12}
|
||||||
|
@ -6,6 +6,7 @@ import { upload } from '@/service/base'
|
|||||||
import { FILE_EXTS } from '@/app/components/base/prompt-editor/constants'
|
import { FILE_EXTS } from '@/app/components/base/prompt-editor/constants'
|
||||||
import { SupportUploadFileTypes } from '@/app/components/workflow/types'
|
import { SupportUploadFileTypes } from '@/app/components/workflow/types'
|
||||||
import type { FileResponse } from '@/types/workflow'
|
import type { FileResponse } from '@/types/workflow'
|
||||||
|
import { TransferMethod } from '@/types/app'
|
||||||
|
|
||||||
type FileUploadParams = {
|
type FileUploadParams = {
|
||||||
file: File
|
file: File
|
||||||
@ -158,3 +159,10 @@ export const getFilesInLogs = (rawData: any) => {
|
|||||||
}).filter(Boolean)).filter(item => item?.model_identity === '__dify__file__')
|
}).filter(Boolean)).filter(item => item?.model_identity === '__dify__file__')
|
||||||
return getProcessedFilesFromResponse(originalFiles)
|
return getProcessedFilesFromResponse(originalFiles)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const fileIsUploaded = (file: FileEntity) => {
|
||||||
|
const localFileUploaded = file.transferMethod === TransferMethod.local_file && file.uploadedId
|
||||||
|
const fromUrlFileUploaded = file.transferMethod === TransferMethod.remote_url && file.progress === 100
|
||||||
|
|
||||||
|
return localFileUploaded || fromUrlFileUploaded
|
||||||
|
}
|
||||||
|
@ -20,6 +20,9 @@ import type { StartNodeType } from '../nodes/start/types'
|
|||||||
import { TransferMethod } from '../../base/text-generation/types'
|
import { TransferMethod } from '../../base/text-generation/types'
|
||||||
import Button from '@/app/components/base/button'
|
import Button from '@/app/components/base/button'
|
||||||
import { useFeatures } from '@/app/components/base/features/hooks'
|
import { useFeatures } from '@/app/components/base/features/hooks'
|
||||||
|
import {
|
||||||
|
getProcessedInputs,
|
||||||
|
} from '@/app/components/base/chat/chat/utils'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
onRun: () => void
|
onRun: () => void
|
||||||
@ -76,8 +79,8 @@ const InputsPanel = ({ onRun }: Props) => {
|
|||||||
|
|
||||||
const doRun = useCallback(() => {
|
const doRun = useCallback(() => {
|
||||||
onRun()
|
onRun()
|
||||||
handleRun({ inputs, files })
|
handleRun({ inputs: getProcessedInputs(inputs, variables as any), files })
|
||||||
}, [files, handleRun, inputs, onRun])
|
}, [files, handleRun, inputs, onRun, variables])
|
||||||
|
|
||||||
const canRun = useMemo(() => {
|
const canRun = useMemo(() => {
|
||||||
if (files?.some(item => (item.transfer_method as any) === TransferMethod.local_file && !item.upload_file_id))
|
if (files?.some(item => (item.transfer_method as any) === TransferMethod.local_file && !item.upload_file_id))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user