Skip to content

Commit

Permalink
fix(Upload): fix global icon replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
uyarn committed Jul 24, 2024
1 parent 160653a commit 1f66213
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 @@ -371,6 +377,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,5 +1,5 @@
import { computed, defineComponent, SetupContext } from '@vue/composition-api';
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 @@ -13,6 +13,8 @@ import { UploadDragEvents } from './hooks/useDrag';
import CustomFile from './themes/custom-file';
import { renderContent, renderTNodeJSX } from '../utils/render-tnode';

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

export default defineComponent({
name: 'TUpload',

Expand Down Expand Up @@ -40,6 +42,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 @@ -97,11 +102,13 @@ export default defineComponent({
uploadClasses,
sizeOverLimitMessage,
tDisabled,
icons,
};
},

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

0 comments on commit 1f66213

Please sign in to comment.