@@ -39,50 +39,87 @@ const AttachmentsRender = observer(({ files, preview = false, columns = 3 }: IPr
3939 }
4040 } )
4141 } ) )
42- const DeleteIcon = observer ( ( { className, file } : { className : string , file : FileType } ) => {
42+
43+ const DeleteIcon = observer ( ( { className, file, size = 20 } : { className : string , file : FileType , size ?: number } ) => {
4344 return < >
4445 < TipsPopover isLoading = { store . deleteFile . loading . value } content = { t ( 'this-operation-will-be-delete-resource-are-you-sure' ) }
4546 onConfirm = { async e => {
4647 store . deleteFile . call ( file )
4748 } } >
48- < Icon className = { className }
49- icon = "basil:cross-solid" width = "20" height = "20" />
49+ < div className = { `opacity-70 hover:opacity-100 !bg-foreground cursor-pointer rounded-sm transition-al ${ className } ` } >
50+ < Icon className = 'white' icon = "basil:cross-solid" width = { size } height = { size } />
51+ </ div >
52+
5053 </ TipsPopover >
5154 </ >
5255 } )
5356
57+ const DownloadIcon = observer ( ( { className, file, size = 20 } : { className : string , file : FileType , size ?: number } ) => {
58+ return < div className = { `hidden p-1 group-hover:block transition-all absolute z-10 right-[5px] top-[5px] !text-background opacity-70 hover:opacity-100 !bg-foreground cursor-pointer rounded-sm transition-all ${ className } ` } >
59+ < Icon onClick = { ( ) => {
60+ helper . download . downloadByLink ( file . uploadPromise . value )
61+ } } icon = "tabler:download" width = "15" height = "15" />
62+ </ div >
63+ } )
64+
5465 return < >
66+ { /* image render */ }
5567 < div className = { `columns-${ columns } md:columns-${ columns } ` } >
5668 < PhotoProvider >
57- { files ?. filter ( i => i . isImage ) . map ( ( file , index ) => (
69+ { files ?. filter ( i => i . previewType == 'image' ) . map ( ( file , index ) => (
5870 < div className = 'relative group' >
5971 { file . uploadPromise ?. loading ?. value && < div className = 'absolute inset-0 flex items-center justify-center w-full h-full' >
6072 < Icon icon = "line-md:uploading-loop" width = "40" height = "40" />
6173 </ div > }
6274
6375 < PhotoView width = { 150 } src = { file . preview } >
64- < Image
65- src = { file . preview }
66- className = 'rounded-lg mb-4'
67- // onLoad={() => { URL.revokeObjectURL(file.preview) }}
68- />
76+ < Image src = { file . preview } className = 'rounded-lg mb-4' />
6977 </ PhotoView >
7078
7179 { ! file . uploadPromise ?. loading ?. value && ! preview &&
72- < DeleteIcon className = 'absolute z-10 right-[5px] top-[5px] !text-background opacity-80 hover:opacity-100 bg-foreground cursor-pointer rounded-sm transition-all '
80+ < DeleteIcon className = 'absolute z-10 right-[5px] top-[5px]'
7381 file = { file } />
7482 }
75- { preview && < Icon onClick = { ( ) => {
76- helper . download . downloadByLink ( file . uploadPromise . value )
77- } } className = 'hidden er:block transition-all absolute z-10 right-[5px] top-[5px] !text-background opacity-80 hover:opacity-100 bg-foreground cursor-pointer rounded-sm transition-all' icon = "tabler:download" width = "15" height = "15" />
83+ { preview && < DownloadIcon className = ''
84+ file = { file } />
7885 }
7986 </ div >
8087 ) ) }
8188 </ PhotoProvider >
89+ </ div >
8290
91+ { /* video render */ }
92+ < div className = { `columns-1 md:columns-1` } >
93+ { files ?. filter ( i => i . previewType == 'video' ) . map ( ( file , index ) => (
94+ < div className = 'group relative flex p-2 items-center gap-2 cursor-pointer tansition-all rounded-2xl' >
95+ < video src = { file . preview } id = "player" playsInline controls className = 'rounded-2xl w-full z-0' />
96+ { ! file . uploadPromise ?. loading ?. value && ! preview &&
97+ < DeleteIcon className = 'absolute z-10 right-[5px] top-[5px]'
98+ file = { file } />
99+ }
100+ { preview && < DownloadIcon className = 'top-[8px] right-[8px]' file = { file } /> }
101+ </ div >
102+ ) ) }
83103 </ div >
104+
105+ { /* audio render */ }
106+ < div className = { `columns-1 md:columns-1` } >
107+ { files ?. filter ( i => i . previewType == 'audio' ) . map ( ( file , index ) => (
108+ < div className = 'group relative flex p-2 items-center gap-2 cursor-pointer tansition-all rounded-2xl' >
109+ < audio src = { file . preview } id = "player" playsInline controls className = 'rounded-2xl w-full' />
110+ { ! file . uploadPromise ?. loading ?. value && ! preview &&
111+ < DeleteIcon className = 'absolute z-10 right-[5px] top-[5px]'
112+ file = { file } />
113+ }
114+ { preview && < DownloadIcon className = 'top-[8px] right-[8px]' file = { file } /> }
115+ </ div >
116+ ) ) }
117+ </ div >
118+
119+
120+ { /* other file render */ }
84121 < div className = { `${ helper . env . isIOS ? 'columns-1' : 'columns-' + columns } mt-3 select-none` } >
85- { files ?. filter ( i => ! i . isImage ) . map ( ( file , index ) => (
122+ { files ?. filter ( i => i . previewType == 'other' ) . map ( ( file , index ) => (
86123 < div onClick = { ( ) => {
87124 if ( preview ) {
88125 helper . download . downloadByLink ( file . uploadPromise . value )
@@ -91,8 +128,7 @@ const AttachmentsRender = observer(({ files, preview = false, columns = 3 }: IPr
91128 < FileIcons path = { file . name } isLoading = { file . uploadPromise ?. loading ?. value } />
92129 < div className = 'truncate text-sm font-bold' > { file . name } </ div >
93130 { ! file . uploadPromise ?. loading ?. value && ! preview &&
94- < DeleteIcon className = 'ml-auto w-[35px] !text-foreground hover:bg-background cursor-pointer rounded-sm tansition-all'
95- file = { file } /> }
131+ < DeleteIcon className = 'ml-auto w-[35px]' file = { file } /> }
96132 </ div >
97133 ) ) }
98134 </ div >
0 commit comments