improve preview icon display logic, #3644

This commit is contained in:
afc163 2016-11-22 14:43:20 +08:00
parent 57f5d299af
commit e62dc08d2c
2 changed files with 10 additions and 7 deletions

View File

@ -37,11 +37,10 @@ const ImageUploadList = React.createClass({
name: 'xxx.png',
status: 'done',
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
thumbUrl: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
}],
onPreview: (file) => {
this.setState({
previewImage: file.url,
previewImage: file.url || file.thumbUrl,
previewVisible: true,
});
},

View File

@ -80,10 +80,10 @@ export default class UploadList extends React.Component<UploadListProps, any> {
<a
className={`${prefixCls}-list-item-thumbnail`}
onClick={e => this.handlePreview(file, e)}
href={file.thumbUrl || file.url}
href={file.url || file.thumbUrl}
target="_blank" rel="noopener noreferrer"
>
<img src={file.thumbUrl || file.url} alt={file.name} />
<img src={file.url || file.thumbUrl} alt={file.name} />
</a>
);
}
@ -129,9 +129,13 @@ export default class UploadList extends React.Component<UploadListProps, any> {
? (
<span>
<a
href={file.url}
target="_blank" rel="noopener noreferrer"
style={{ pointerEvents: file.url || file.thumbUrl ? '' : 'none' }}
href={file.url || file.thumbUrl}
target="_blank"
rel="noopener noreferrer"
style={(file.url || file.thumbUrl) ? undefined : {
pointerEvents: 'none',
opacity: 0.5,
}}
onClick={e => this.handlePreview(file, e)}
>
<Icon type="eye-o" />