Skip to content

Commit

Permalink
fix(Upload): fix global icon replacement (#3244)
Browse files Browse the repository at this point in the history
  • Loading branch information
uyarn committed Aug 15, 2024
1 parent 74c34f7 commit 02cf2be
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
22 changes: 16 additions & 6 deletions src/upload/themes/multiple-flow-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import {
CheckCircleFilledIcon as TdCheckCircleFilledIcon,
ErrorCircleFilledIcon as TdErrorCircleFilledIcon,
TimeFilledIcon as TdTimeFilledIcon,
FileExcelIcon,
FilePdfIcon,
FileWordIcon,
FilePowerpointIcon,
FileIcon,
VideoIcon,
FileExcelIcon as TdFileExcelIcon,
FilePdfIcon as TdFilePdfIcon,
FileWordIcon as TdFileWordIcon,
FilePowerpointIcon as TdFilePowerpointIcon,
FileIcon as TdFileIcon,
VideoIcon as TdVideoIcon,
} from 'tdesign-icons-vue';
import isFunction from 'lodash/isFunction';
import isObject from 'lodash/isObject';
Expand Down Expand Up @@ -81,6 +81,12 @@ export default defineComponent({
CheckCircleFilledIcon: TdCheckCircleFilledIcon,
ErrorCircleFilledIcon: TdErrorCircleFilledIcon,
TimeFilledIcon: TdTimeFilledIcon,
FileExcelIcon: TdFileExcelIcon,
FilePdfIcon: TdFilePdfIcon,
FileWordIcon: TdFileWordIcon,
FilePowerpointIcon: TdFilePowerpointIcon,
FileIcon: TdFileIcon,
VideoIcon: TdVideoIcon,
});

const drag = useDrag(props.dragEvents, accept);
Expand Down Expand Up @@ -375,6 +381,10 @@ export default defineComponent({
);
},
getFileThumbnailIcon(fileType: string) {
const {
FilePdfIcon, FileExcelIcon, FileWordIcon, FilePowerpointIcon, VideoIcon, FileIcon,
} = this.icons;

if (FILE_PDF_REGEXP.test(fileType)) {
return <FilePdfIcon />;
}
Expand Down
9 changes: 8 additions & 1 deletion src/upload/upload.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
computed, defineComponent, Ref, SetupContext, toRef,
} from 'vue';
import { UploadIcon } from 'tdesign-icons-vue';
import { UploadIcon as TdUploadIcon } from 'tdesign-icons-vue';
import useFormDisabled from '../hooks/useFormDisabled';
import props from './props';
import NormalFile from './themes/normal-file';
Expand All @@ -18,6 +18,8 @@ import { getFileList } from '../_common/js/upload/utils';
import { formatToUploadFile } from '../_common/js/upload/main';
import { UploadFile } from './type';

import useGlobalIcon from '../hooks/useGlobalIcon';

export default defineComponent({
name: 'TUpload',

Expand Down Expand Up @@ -45,6 +47,9 @@ export default defineComponent({
} = uploadData;

const tDisabled = computed<boolean>(() => formDisabled.value || innerDisabled.value);
const icons = useGlobalIcon({
UploadIcon: TdUploadIcon,
});

const commonDisplayFileProps = computed<CommonDisplayFileProps>(() => ({
accept: props.accept,
Expand Down Expand Up @@ -115,11 +120,13 @@ export default defineComponent({
triggerButtonProps,
sizeOverLimitMessage,
tDisabled,
icons,
};
},

methods: {
renderTrigger() {
const { UploadIcon } = this.icons;
const getDefaultTrigger = () => {
if (this.theme === 'file-input') {
return (
Expand Down

0 comments on commit 02cf2be

Please sign in to comment.