Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Upload] fix disabled image card can not show #3573

Merged
merged 6 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/upload/themes/image-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ export default defineComponent({
{file.status === 'progress' && renderProgressFile(file, loadCard)}
{file.status === 'fail' && renderFailFile(file, index, loadCard)}
{!['progress', 'fail'].includes(file.status) && renderMainContent(file, index)}
{fileName &&
props.showImageFileName &&
{Boolean(fileName && props.showImageFileName) &&
(file.url ? (
<Link href={file.url} class={fileNameClassName} target="_blank" hover="color" size="small">
{fileName}
Expand All @@ -168,17 +167,22 @@ export default defineComponent({
);
})}

{showTrigger.value && !props.disabled && (
{showTrigger.value && (
<li class={cardItemClasses} onClick={props.triggerUpload}>
<div
class={[
`${classPrefix.value}-upload__image-add`,
`${classPrefix.value}-upload__card-container`,
`${classPrefix.value}-upload__card-box`,
{
[`${classPrefix.value}-is-disabled`]: props.disabled,
},
]}
>
<AddIcon />
<p class={`${classPrefix.value}-size-s`}>{locale.value?.triggerUploadText?.image}</p>
<p class={[`${classPrefix.value}-size-s`, `${classPrefix.value}-upload__add-text`]}>
{locale.value?.triggerUploadText?.image}
</p>
</div>
</li>
)}
Expand Down
8 changes: 7 additions & 1 deletion src/upload/themes/multiple-flow-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,13 @@ export default defineComponent({
const renderImageList = () => {
const customList = renderTNodeJSX('fileListDisplay', {
params: {
...props,
cancelUpload: props.cancelUpload,
uploadFiles: props.uploadFiles,
onRemove: props.onRemove,
onPreview: props.onPreview,
toUploadFiles: props.toUploadFiles,
sizeOverLimitMessage: props.sizeOverLimitMessage,
locale: props.locale,
files: props.displayFiles,
dragEvents: innerDragEvents.value,
},
Expand Down
8 changes: 6 additions & 2 deletions src/upload/themes/normal-file.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const NormalFile = defineComponent({

return () => {
const classes = [`${uploadPrefix}__single`, `${uploadPrefix}__single-${theme.value}`];
const fileListDisplay = renderTNodeJSX('fileListDisplay', {
let fileListDisplay = renderTNodeJSX('fileListDisplay', {
params: {
onRemove: props.onRemove,
toUploadFiles: props.toUploadFiles,
Expand All @@ -147,6 +147,10 @@ const NormalFile = defineComponent({
files: props.displayFiles,
},
});
if (props.fileListDisplay === null || fileListDisplay === null) {
fileListDisplay = null;
}

const { displayFiles } = props;

return (
Expand All @@ -159,7 +163,7 @@ const NormalFile = defineComponent({
<small class={[props.tipsClasses, props.placeholderClass]}>{props.placeholder}</small>
)}

{fileListDisplay || renderFilePreviewAsText(displayFiles)}
{fileListDisplay === null ? null : fileListDisplay || renderFilePreviewAsText(displayFiles)}

{/* 单文件上传失败要显示失败的原因 */}
{!props.multiple && displayFiles[0]?.status === 'fail' && theme.value === 'file' ? (
Expand Down
4 changes: 4 additions & 0 deletions src/upload/upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ export default defineComponent({
v-slots={{
fileListDisplay: slots.fileListDisplay,
'file-list-display': slots['file-list-display'],
uploadButton: slots.uploadButton,
'upload-button': slots['upload-button'],
cancelUploadButton: slots.cancelUploadButton,
'cancel-upload-button': slots['cancel-upload-button'],
}}
>
<div class={`${classPrefix.value}-upload__trigger`} onClick={triggerUpload}>
Expand Down
6 changes: 3 additions & 3 deletions test/unit/snap/__snapshots__/csr.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -200439,7 +200439,7 @@ exports[`csr snapshot test > csr test ./src/upload/_example/image.vue 1`] = `
/>
</svg>
<p
class="t-size-s"
class="t-size-s t-upload__add-text"
>
请选择图片
</p>
Expand Down Expand Up @@ -200498,7 +200498,7 @@ exports[`csr snapshot test > csr test ./src/upload/_example/image.vue 1`] = `
/>
</svg>
<p
class="t-size-s"
class="t-size-s t-upload__add-text"
>
点击上传图片
</p>
Expand Down Expand Up @@ -200720,7 +200720,7 @@ exports[`csr snapshot test > csr test ./src/upload/_example/image.vue 1`] = `
/>
</svg>
<p
class="t-size-s"
class="t-size-s t-upload__add-text"
>
点击上传图片
</p>
Expand Down
2 changes: 1 addition & 1 deletion test/unit/snap/__snapshots__/ssr.test.js.snap

Large diffs are not rendered by default.

Loading