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

fix(Upload): fix global icon replacement #3244

Merged
merged 1 commit into from
Jul 24, 2024
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
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
Loading