diff --git a/src/upload/hooks/useUpload.ts b/src/upload/hooks/useUpload.ts index 077dc1a1e..5241b5972 100644 --- a/src/upload/hooks/useUpload.ts +++ b/src/upload/hooks/useUpload.ts @@ -1,7 +1,7 @@ import { computed, h, ref, toRefs, ComputedRef } from 'vue'; import isFunction from 'lodash/isFunction'; import isString from 'lodash/isString'; -import type { SizeLimitObj, TdUploadProps, UploadChangeContext, UploadFile, UploadRemoveContext } from '../type'; +import { SizeLimitObj, TdUploadProps, UploadChangeContext, UploadFile, UploadRemoveContext } from '../type'; import { useVModel } from '../../shared'; import { formatToUploadFile, diff --git a/src/upload/upload.tsx b/src/upload/upload.tsx index 4aad342b5..1feda9a9c 100644 --- a/src/upload/upload.tsx +++ b/src/upload/upload.tsx @@ -2,8 +2,8 @@ import { defineComponent, ref, computed, toRefs } from 'vue'; import { AddIcon, LoadingIcon, CloseIcon, CloseCircleIcon } from 'tdesign-icons-vue-next'; import TImage from '../image'; import TImageViewer from '../image-viewer'; -import { TdUploadProps, UploadFile } from './type'; -import props from './props'; +import { UploadFile } from './type'; +import UploadProps from './props'; import config from '../config'; import useUpload from './hooks/useUpload'; import { useTNodeJSX, useContent } from '../hooks/tnode'; @@ -13,7 +13,15 @@ const { prefix } = config; export default defineComponent({ name: `${prefix}-upload`, - props, + components: { + AddIcon, + LoadingIcon, + CloseCircleIcon, + CloseIcon, + TImage, + TImageViewer, + }, + props: UploadProps, emits: [ 'update:files', 'update:modelValue', @@ -87,13 +95,13 @@ export default defineComponent({
{file.status === 'progress' ? ( <> - +
{file.percent ? `${file.percent}%` : globalConfig.value.progress.uploadingText}
) : ( - + )} {file.status === 'fail' && (
{globalConfig.value.progress.failText}
@@ -112,79 +120,80 @@ export default defineComponent({ } return (
-
{addContent || }
+
{addContent || }
); } }; + + return { + ...toRefs(props), + uploadClass, + globalConfig, + initialIndex, + showViewer, + previewImgs, + toUploadFiles, + uploadValue, + displayFiles, + sizeOverLimitMessage, + uploading, + inputRef, + disabled, + xhrReq, + handlePreview, + triggerUpload, + uploadFilePercent, + uploadFiles, + onFileChange, + onNormalFileChange, + onInnerRemove, + cancelUpload, + handleImageClose, + renderStatus, + content, + }; + }, + + render() { return ( -
- {displayFiles.value.map((file, index) => ( -
handlePreview(e, file, index)} - > +
+ {this.displayFiles.map((file, index) => ( +
{file.url && ( - this.handlePreview(e, file, index)} /> )} - {renderStatus(file)} - onInnerRemove({ e, file, index })} + {this.renderStatus(file)} + this.onInnerRemove({ e, file, index })} />
))} - {content()} + {this.content()} -
); - // return { - // ...toRefs(props), - // uploadClass, - // globalConfig, - // initialIndex, - // showViewer, - // previewImgs, - // toUploadFiles, - // uploadValue, - // displayFiles, - // sizeOverLimitMessage, - // uploading, - // inputRef, - // disabled, - // // xhrReq, - // handlePreview, - // triggerUpload, - // uploadFilePercent, - // uploadFiles, - // onFileChange, - // onNormalFileChange, - // onInnerRemove, - // cancelUpload, - // handleImageClose, - // renderStatus, - // content, - // }; }, });