Skip to content

Commit b994072

Browse files
committed
fix(upload): fix file preview blank error
1 parent 65ecf69 commit b994072

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/components/upload/index.vue

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
:show-upload-button="readonly ? false : option.showUploadButton"
1616
:disabled="option.disabled"
1717
:class="{
18+
'crco-upload-disabled-preview': option.disabledPreview || false,
1819
'crco-upload-readonly': readonly || option.readonly,
1920
'crco-upload-large': option.large
2021
}"
@@ -314,8 +315,15 @@ const handleDownloadFile = () => {
314315
window.open(clickFile.value.originUrl)
315316
}
316317
const preview = (file: any) => {
318+
if (props.option.disabledPreview) {
319+
return
320+
}
317321
if (props.option.listType !== 'picture' && props.option.listType !== 'picture-card') {
318322
const url = file.response && file.response.url ? file.response.url : file.url
323+
if (!url) {
324+
console.warn('Not fount url', file)
325+
return
326+
}
319327
if (!isImg(url)) {
320328
if (!isPdf(url) && !isOffice(url) && !isTxt(url)) {
321329
window.open(url)
@@ -430,6 +438,11 @@ const download = (url: string) => {
430438
white-space: normal;
431439
cursor: pointer;
432440
}
441+
.crco-upload-disabled-preview {
442+
::v-deep(.arco-upload-list-item-name-text) {
443+
cursor: unset;
444+
}
445+
}
433446
.crco-upload-readonly {
434447
::v-deep(.arco-upload-list-picture) {
435448
width: 40px;

src/types/components/upload.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,10 @@ export type UploadType = {
205205
* @default false
206206
*/
207207
large?: boolean
208+
209+
/**
210+
* @zh 是否禁用点击预览,默认false
211+
* @default false
212+
*/
213+
disabledPreview?: boolean
208214
}

0 commit comments

Comments
 (0)