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

feat(upload): add custom button slot #3337

Closed
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
45 changes: 30 additions & 15 deletions src/upload/themes/multiple-flow-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -369,21 +369,36 @@ export default defineComponent({

{!props.autoUpload && (
<div class={`${uploadPrefix.value}__flow-bottom`}>
<TButton
theme="default"
disabled={disabled.value || !uploading.value}
content={locale.value?.cancelUploadText}
class={`${uploadPrefix.value}__cancel`}
onClick={(e) => props.cancelUpload?.({ e })}
></TButton>
<TButton
disabled={disabled.value || uploading.value || !displayFiles.value.length}
theme="primary"
loading={uploading.value}
class={`${uploadPrefix.value}__continue`}
content={uploadText.value}
onClick={() => props.uploadFiles?.()}
></TButton>
{slots.cancelUploadButton ? (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

新增插槽,需要参考其他组件使用通用方法 renderTNodeJSX 渲染

slots.cancelUploadButton?.({
disabled: disabled.value || !uploading.value,
cancelUpload: props.cancelUpload,
})
) : (
<TButton
theme="default"
disabled={disabled.value || !uploading.value}
content={locale.value?.cancelUploadText}
class={`${uploadPrefix.value}__cancel`}
onClick={(e) => props.cancelUpload?.({ e })}
></TButton>
)}
{slots.uploadButton ? (
slots.uploadButton?.({
disabled: disabled.value || uploading.value || !displayFiles.value.length,
loading: uploading.value,
upload: props.uploadFiles,
})
) : (
<TButton
disabled={disabled.value || uploading.value || !displayFiles.value.length}
theme="primary"
loading={uploading.value}
class={`${uploadPrefix.value}__continue`}
content={uploadText.value}
onClick={() => props.uploadFiles?.()}
></TButton>
)}
</div>
)}

Expand Down
Loading