image download

This commit is contained in:
StyleZhang 2024-09-26 15:49:53 +08:00
parent 2a6d9c3211
commit b491c93b1c
4 changed files with 14 additions and 3 deletions

View File

@ -6,6 +6,7 @@ type FileImageRenderProps = {
alt?: string
onLoad?: () => void
onError?: () => void
showDownloadAction?: boolean
}
const FileImageRender = ({
imageUrl,
@ -13,15 +14,17 @@ const FileImageRender = ({
alt,
onLoad,
onError,
showDownloadAction,
}: FileImageRenderProps) => {
return (
<div className={cn('border-[2px] border-effects-image-frame shadow-xs', className)}>
<img
className='w-full h-full object-cover'
className={cn('w-full h-full object-cover', showDownloadAction && 'cursor-pointer')}
alt={alt}
onLoad={onLoad}
onError={onError}
src={imageUrl}
onClick={() => showDownloadAction && window.open(imageUrl, '_blank')}
/>
</div>
)

View File

@ -8,12 +8,14 @@ import { ReplayLine } from '@/app/components/base/icons/src/vender/other'
type FileImageItemProps = {
file: FileEntity
showDeleteAction?: boolean
showDownloadAction?: boolean
onRemove?: (fileId: string) => void
onReUpload?: (fileId: string) => void
}
const FileImageItem = ({
file,
showDeleteAction,
showDownloadAction,
onRemove,
onReUpload,
}: FileImageItemProps) => {
@ -34,6 +36,7 @@ const FileImageItem = ({
<FileImageRender
className='w-[68px] h-[68px] shadow-md'
imageUrl={base64Url || url || ''}
showDownloadAction={showDownloadAction}
/>
{
progress > 0 && progress < 100 && (

View File

@ -33,6 +33,7 @@ export const FileList = ({
key={file.id}
file={file}
showDeleteAction={showDeleteAction}
showDownloadAction={showDownloadAction}
onRemove={onRemove}
onReUpload={onReUpload}
/>

View File

@ -14,7 +14,10 @@ import type {
Inputs,
} from '@/app/components/base/chat/types'
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 { TransferMethod } from '@/types/app'
import {
@ -191,9 +194,10 @@ export const useChat = (
handleResponding(true)
const { files, ...restParams } = params
const { files, inputs, ...restParams } = params
const bodyParams = {
files: getProcessedFiles(files || []),
inputs: getProcessedInputs(inputs || {}, formSettings?.inputsForm || []),
...restParams,
}
if (bodyParams?.files?.length) {