mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-16 22:26:00 +08:00
image download
This commit is contained in:
parent
2a6d9c3211
commit
b491c93b1c
@ -6,6 +6,7 @@ type FileImageRenderProps = {
|
|||||||
alt?: string
|
alt?: string
|
||||||
onLoad?: () => void
|
onLoad?: () => void
|
||||||
onError?: () => void
|
onError?: () => void
|
||||||
|
showDownloadAction?: boolean
|
||||||
}
|
}
|
||||||
const FileImageRender = ({
|
const FileImageRender = ({
|
||||||
imageUrl,
|
imageUrl,
|
||||||
@ -13,15 +14,17 @@ const FileImageRender = ({
|
|||||||
alt,
|
alt,
|
||||||
onLoad,
|
onLoad,
|
||||||
onError,
|
onError,
|
||||||
|
showDownloadAction,
|
||||||
}: FileImageRenderProps) => {
|
}: FileImageRenderProps) => {
|
||||||
return (
|
return (
|
||||||
<div className={cn('border-[2px] border-effects-image-frame shadow-xs', className)}>
|
<div className={cn('border-[2px] border-effects-image-frame shadow-xs', className)}>
|
||||||
<img
|
<img
|
||||||
className='w-full h-full object-cover'
|
className={cn('w-full h-full object-cover', showDownloadAction && 'cursor-pointer')}
|
||||||
alt={alt}
|
alt={alt}
|
||||||
onLoad={onLoad}
|
onLoad={onLoad}
|
||||||
onError={onError}
|
onError={onError}
|
||||||
src={imageUrl}
|
src={imageUrl}
|
||||||
|
onClick={() => showDownloadAction && window.open(imageUrl, '_blank')}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
@ -8,12 +8,14 @@ import { ReplayLine } from '@/app/components/base/icons/src/vender/other'
|
|||||||
type FileImageItemProps = {
|
type FileImageItemProps = {
|
||||||
file: FileEntity
|
file: FileEntity
|
||||||
showDeleteAction?: boolean
|
showDeleteAction?: boolean
|
||||||
|
showDownloadAction?: boolean
|
||||||
onRemove?: (fileId: string) => void
|
onRemove?: (fileId: string) => void
|
||||||
onReUpload?: (fileId: string) => void
|
onReUpload?: (fileId: string) => void
|
||||||
}
|
}
|
||||||
const FileImageItem = ({
|
const FileImageItem = ({
|
||||||
file,
|
file,
|
||||||
showDeleteAction,
|
showDeleteAction,
|
||||||
|
showDownloadAction,
|
||||||
onRemove,
|
onRemove,
|
||||||
onReUpload,
|
onReUpload,
|
||||||
}: FileImageItemProps) => {
|
}: FileImageItemProps) => {
|
||||||
@ -34,6 +36,7 @@ const FileImageItem = ({
|
|||||||
<FileImageRender
|
<FileImageRender
|
||||||
className='w-[68px] h-[68px] shadow-md'
|
className='w-[68px] h-[68px] shadow-md'
|
||||||
imageUrl={base64Url || url || ''}
|
imageUrl={base64Url || url || ''}
|
||||||
|
showDownloadAction={showDownloadAction}
|
||||||
/>
|
/>
|
||||||
{
|
{
|
||||||
progress > 0 && progress < 100 && (
|
progress > 0 && progress < 100 && (
|
||||||
|
@ -33,6 +33,7 @@ export const FileList = ({
|
|||||||
key={file.id}
|
key={file.id}
|
||||||
file={file}
|
file={file}
|
||||||
showDeleteAction={showDeleteAction}
|
showDeleteAction={showDeleteAction}
|
||||||
|
showDownloadAction={showDownloadAction}
|
||||||
onRemove={onRemove}
|
onRemove={onRemove}
|
||||||
onReUpload={onReUpload}
|
onReUpload={onReUpload}
|
||||||
/>
|
/>
|
||||||
|
@ -14,7 +14,10 @@ import type {
|
|||||||
Inputs,
|
Inputs,
|
||||||
} from '@/app/components/base/chat/types'
|
} from '@/app/components/base/chat/types'
|
||||||
import type { InputForm } from '@/app/components/base/chat/chat/type'
|
import type { InputForm } from '@/app/components/base/chat/chat/type'
|
||||||
import { processOpeningStatement } from '@/app/components/base/chat/chat/utils'
|
import {
|
||||||
|
getProcessedInputs,
|
||||||
|
processOpeningStatement,
|
||||||
|
} from '@/app/components/base/chat/chat/utils'
|
||||||
import { useToastContext } from '@/app/components/base/toast'
|
import { useToastContext } from '@/app/components/base/toast'
|
||||||
import { TransferMethod } from '@/types/app'
|
import { TransferMethod } from '@/types/app'
|
||||||
import {
|
import {
|
||||||
@ -191,9 +194,10 @@ export const useChat = (
|
|||||||
|
|
||||||
handleResponding(true)
|
handleResponding(true)
|
||||||
|
|
||||||
const { files, ...restParams } = params
|
const { files, inputs, ...restParams } = params
|
||||||
const bodyParams = {
|
const bodyParams = {
|
||||||
files: getProcessedFiles(files || []),
|
files: getProcessedFiles(files || []),
|
||||||
|
inputs: getProcessedInputs(inputs || {}, formSettings?.inputsForm || []),
|
||||||
...restParams,
|
...restParams,
|
||||||
}
|
}
|
||||||
if (bodyParams?.files?.length) {
|
if (bodyParams?.files?.length) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user