Skip to content

Commit 38f8393

Browse files
refactor(upload): components optimization (#5205)
* refactor(upload): component optimization * refactor(menu): mv consts/index to types * chore(upload): up
1 parent a7a789e commit 38f8393

File tree

17 files changed

+24
-36
lines changed

17 files changed

+24
-36
lines changed

packages/components/menu/head-menu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { isArray } from 'lodash-es';
2020
import log from '@tdesign/common-js/log/log';
2121
import props from './head-menu-props';
2222
import { MenuValue } from './type';
23-
import { TdMenuInterface, TdOpenType } from './consts';
23+
import { TdMenuInterface, TdOpenType } from './types';
2424
import { Tabs, TabPanel } from '../tabs';
2525
import Submenu from './submenu';
2626
import { VMenu } from './utils';

packages/components/menu/menu-item.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { defineComponent, computed, inject, onMounted, ref, toRefs, getCurrentInstance } from 'vue';
22
import props from './menu-item-props';
3-
import { TdMenuInterface, TdSubMenuInterface } from './consts';
3+
import { TdMenuInterface, TdSubMenuInterface } from './types';
44
import { useTNodeJSX, useContent } from '../hooks/tnode';
55
import useRipple from '../hooks/useRipple';
66
import { usePrefixClass } from '../hooks/useConfig';

packages/components/menu/menu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { defineComponent, ref, computed, provide, watchEffect, watch, onMounted, toRefs } from 'vue';
22
import props from './props';
33
import { MenuValue } from './type';
4-
import { TdMenuInterface, TdOpenType } from './consts';
4+
import { TdMenuInterface, TdOpenType } from './types';
55
import { useTNodeJSX, useContent } from '../hooks/tnode';
66
import { VMenu } from './utils';
77
import log from '@tdesign/common-js/log/log';

packages/components/menu/submenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
Transition,
1515
} from 'vue';
1616
import props from './submenu-props';
17-
import { TdMenuInterface, TdSubMenuInterface, TdMenuItem } from './consts';
17+
import { TdMenuInterface, TdSubMenuInterface, TdMenuItem } from './types';
1818
import FakeArrow from '../common-components/fake-arrow';
1919
import useRipple from '../hooks/useRipple';
2020
import { usePrefixClass } from '../hooks/useConfig';

packages/components/menu/consts/index.ts renamed to packages/components/menu/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Ref, VNodeNormalizedChildren } from 'vue';
2-
import { MenuValue } from '../type';
3-
import { VMenu } from '../utils';
2+
import { MenuValue } from './type';
3+
import { VMenu } from './utils';
44

55
export interface TdMenuItem {
66
value: MenuValue;
File renamed without changes.

packages/components/upload/themes/custom-file.tsx renamed to packages/components/upload/components/custom-file.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { defineComponent, PropType, toRefs } from 'vue';
22
import useDrag, { UploadDragEvents } from '../hooks/useDrag';
3-
import { CommonDisplayFileProps } from '../interface';
4-
import { commonProps } from '../constants';
3+
import { CommonDisplayFileProps } from '../types';
4+
import { commonProps } from '../consts';
55
import { useContent } from '../../hooks/tnode';
66
import { TdUploadProps } from '../type';
77

@@ -17,7 +17,6 @@ export interface CustomFileProps extends CommonDisplayFileProps {
1717

1818
export default defineComponent({
1919
name: 'UploadCustomFile',
20-
2120
props: {
2221
...commonProps,
2322
dragEvents: Object as PropType<CustomFileProps['dragEvents']>,
@@ -28,7 +27,6 @@ export default defineComponent({
2827
triggerUpload: Function as PropType<CustomFileProps['triggerUpload']>,
2928
childrenNode: [String, Function] as PropType<CustomFileProps['childrenNode']>,
3029
},
31-
3230
setup(props, { slots }) {
3331
const { classPrefix, displayFiles, accept } = toRefs(props);
3432
const drag = useDrag(props.dragEvents, accept);

packages/components/upload/themes/dragger-file.tsx renamed to packages/components/upload/components/dragger-file.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import {
66
import { abridgeName, getFileSizeText } from '@tdesign/common-js/upload/utils';
77
import { TdUploadProps, UploadFile } from '../type';
88
import Button from '../../button';
9-
import { CommonDisplayFileProps } from '../interface';
10-
import { commonProps } from '../constants';
9+
import { CommonDisplayFileProps } from '../types';
10+
import { commonProps } from '../consts';
1111
import useCommonClassName from '../../hooks/useCommonClassName';
1212
import TLoading from '../../loading';
1313
import useDrag, { UploadDragEvents } from '../hooks/useDrag';
@@ -27,7 +27,6 @@ export interface DraggerProps extends CommonDisplayFileProps {
2727

2828
export default defineComponent({
2929
name: 'UploadDraggerFile',
30-
3130
props: {
3231
...commonProps,
3332
trigger: Function as PropType<DraggerProps['trigger']>,
@@ -36,7 +35,6 @@ export default defineComponent({
3635
cancelUpload: Function as PropType<DraggerProps['cancelUpload']>,
3736
dragEvents: Object as PropType<DraggerProps['dragEvents']>,
3837
},
39-
4038
setup(props, { slots }) {
4139
const { displayFiles, disabled, accept } = toRefs(props);
4240
const locale = computed(() => props.locale as UploadConfig);

packages/components/upload/themes/image-card.tsx renamed to packages/components/upload/components/image-card.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import {
88
import Loading from '../../loading';
99
import useGlobalIcon from '../../hooks/useGlobalIcon';
1010
import ImageViewer, { ImageViewerProps } from '../../image-viewer';
11-
import { CommonDisplayFileProps } from '../interface';
12-
import { commonProps } from '../constants';
11+
import { CommonDisplayFileProps } from '../types';
12+
import { commonProps } from '../consts';
1313
import { TdUploadProps, UploadFile } from '../type';
1414
import { abridgeName } from '@tdesign/common-js/upload/utils';
1515
import { UploadConfig } from '../../config-provider';
@@ -30,7 +30,6 @@ export interface ImageCardUploadProps extends CommonDisplayFileProps {
3030

3131
export default defineComponent({
3232
name: 'UploadImageCard',
33-
3433
props: {
3534
...commonProps,
3635
multiple: Boolean,
@@ -43,7 +42,6 @@ export default defineComponent({
4342
onPreview: Function as PropType<ImageCardUploadProps['onPreview']>,
4443
showImageFileName: Boolean,
4544
},
46-
4745
setup(props) {
4846
const { displayFiles, classPrefix, multiple, max } = toRefs(props);
4947
const locale = computed(() => props.locale as UploadConfig);

packages/components/upload/themes/multiple-flow-list.tsx renamed to packages/components/upload/components/multiple-flow-list.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import { isFunction } from 'lodash-es';
1616
import { isObject } from 'lodash-es';
1717
import useGlobalIcon from '../../hooks/useGlobalIcon';
1818
import ImageViewer, { ImageViewerProps } from '../../image-viewer';
19-
import { CommonDisplayFileProps } from '../interface';
20-
import { commonProps } from '../constants';
19+
import { CommonDisplayFileProps } from '../types';
20+
import { commonProps } from '../consts';
2121
import TButton from '../../button';
2222
import { UploadFile, TdUploadProps } from '../type';
2323
import useDrag, { UploadDragEvents } from '../hooks/useDrag';
@@ -51,7 +51,6 @@ export interface ImageFlowListProps extends CommonDisplayFileProps {
5151

5252
export default defineComponent({
5353
name: 'UploadMultipleFlowList',
54-
5554
props: {
5655
...commonProps,
5756
showThumbnail: Boolean,
@@ -66,7 +65,6 @@ export default defineComponent({
6665
cancelUploadButton: Object as PropType<ImageFlowListProps['cancelUploadButton']>,
6766
onPreview: Function as PropType<ImageFlowListProps['onPreview']>,
6867
},
69-
7068
setup(props, { slots }) {
7169
// locale 已经在 useUpload 中统一处理优先级
7270
const { uploading, disabled, displayFiles, classPrefix, accept } = toRefs(props);

0 commit comments

Comments
 (0)