Skip to content

Commit

Permalink
feat: Fix image show
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoBingyu committed Sep 13, 2023
1 parent f5e6c0e commit 3a5f1f8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions clients/components/file-upload/file-list/img-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,17 @@ export function ImgList({
originalThumbnail,
uploadProgressRender,
}: Props): JSX.Element {
const _files = JSON.parse(JSON.stringify(files || []));
const [fileImgObj, setFileImgObj] = useState([]);

const handleFileSrc = (file: any, index: any)=>{
const _fileImgObj: any = [...fileImgObj];
const _fileImgObj = JSON.parse(JSON.stringify(fileImgObj));
if (file.state === 'success' || !file.state) {
const { uid } = file;
if (!(fileBucket === OSS_PRIVATE_BUCKET_NAME)) {
_fileImgObj[index] = `${window.location.protocol}//${OSS_PUBLIC_BUCKET_NAME}.${OSS_DOMAIN}/${uid}`;
setFileImgObj(_fileImgObj);
_files[index].url = `${window.location.protocol}//${OSS_PUBLIC_BUCKET_NAME}.${OSS_DOMAIN}/${uid}`;
return;
}

Expand All @@ -52,7 +54,9 @@ export function ImgList({
})
.then(({ url }) => {
_fileImgObj[index] = url;
setFileImgObj(_fileImgObj);
_files[index].url = url;
}).catch((err: any)=>{
console.log('handleFileSrc err', err);
});
}
};
Expand All @@ -68,7 +72,7 @@ export function ImgList({
className: 'preview-img-modal',
content: (
<div>
<img width={'auto'} height={'auto'} src={fileImgObj[index]} />
<img width={'auto'} height={'auto'} src={_files[index].url} />
</div>
),
});
Expand Down

0 comments on commit 3a5f1f8

Please sign in to comment.