From ba560a37fe24ab0c9c06d009f1d5e9e9e584de92 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Sat, 25 Sep 2021 18:17:41 +0800 Subject: [PATCH] style: remove not use mixins --- components/_util/BaseMixin2.js | 44 ------------------------------- components/form/FormItem.tsx | 2 -- components/slider/index.tsx | 2 -- components/vc-image/src/Image.tsx | 3 --- components/vc-steps/Steps.tsx | 2 -- 5 files changed, 53 deletions(-) delete mode 100644 components/_util/BaseMixin2.js diff --git a/components/_util/BaseMixin2.js b/components/_util/BaseMixin2.js deleted file mode 100644 index 00446ed20..000000000 --- a/components/_util/BaseMixin2.js +++ /dev/null @@ -1,44 +0,0 @@ -import { nextTick } from 'vue'; -import { getOptionProps } from './props-util'; - -export default { - methods: { - setState(state = {}, callback) { - let newState = typeof state === 'function' ? state(this, this.$props) : state; - if (this.getDerivedStateFromProps) { - const s = this.getDerivedStateFromProps(getOptionProps(this), { - ...this, - ...newState, - }); - if (s === null) { - return; - } else { - newState = { ...newState, ...(s || {}) }; - } - } - Object.assign(this, newState); - if (this._.isMounted) { - this.$forceUpdate(); - } - nextTick(() => { - callback && callback(); - }); - }, - __emit() { - // 直接调用事件,底层组件不需要vueTool记录events - const args = [].slice.call(arguments, 0); - let eventName = args[0]; - eventName = `on${eventName[0].toUpperCase()}${eventName.substring(1)}`; - const event = this.$props[eventName] || this.$attrs[eventName]; - if (args.length && event) { - if (Array.isArray(event)) { - for (let i = 0, l = event.length; i < l; i++) { - event[i](...args.slice(1)); - } - } else { - event(...args.slice(1)); - } - } - }, - }, -}; diff --git a/components/form/FormItem.tsx b/components/form/FormItem.tsx index 5e6b7faee..a715d7e8d 100644 --- a/components/form/FormItem.tsx +++ b/components/form/FormItem.tsx @@ -5,7 +5,6 @@ import PropTypes from '../_util/vue-types'; import Row from '../grid/Row'; import type { ColProps } from '../grid/Col'; import { filterEmpty } from '../_util/props-util'; -import BaseMixin from '../_util/BaseMixin'; import { validateRules as validateRulesUtil } from './utils/validateUtil'; import { getNamePath } from './utils/valueUtil'; import { toArray } from './utils/typeUtil'; @@ -97,7 +96,6 @@ const defaultItemNamePrefixCls = 'form_item'; export default defineComponent({ name: 'AFormItem', - mixins: [BaseMixin], inheritAttrs: false, __ANT_NEW_FORM_ITEM: true, props: formItemProps, diff --git a/components/slider/index.tsx b/components/slider/index.tsx index 613a139f2..47035ffa4 100644 --- a/components/slider/index.tsx +++ b/components/slider/index.tsx @@ -1,6 +1,5 @@ import type { CSSProperties, VNodeTypes, PropType } from 'vue'; import { computed, ref, defineComponent } from 'vue'; -import BaseMixin from '../_util/BaseMixin'; import VcSlider from '../vc-slider/src/Slider'; import VcRange from '../vc-slider/src/Range'; import VcHandle from '../vc-slider/src/Handle'; @@ -75,7 +74,6 @@ export type Visibles = { [index: number]: boolean }; const Slider = defineComponent({ name: 'ASlider', - mixins: [BaseMixin], inheritAttrs: false, props: { ...sliderProps(), diff --git a/components/vc-image/src/Image.tsx b/components/vc-image/src/Image.tsx index 036c104e5..ef1e43d5c 100644 --- a/components/vc-image/src/Image.tsx +++ b/components/vc-image/src/Image.tsx @@ -1,8 +1,6 @@ import type { ImgHTMLAttributes, CSSProperties } from 'vue'; import { ref, watch, defineComponent, computed, onMounted } from 'vue'; import isNumber from 'lodash-es/isNumber'; - -import BaseMixin from '../../_util/BaseMixin'; import cn from '../../_util/classNames'; import PropTypes from '../../_util/vue-types'; import { getOffset } from '../../vc-util/Dom/css'; @@ -61,7 +59,6 @@ const mergeDefaultValue = (obj: T, defaultValues: object): T = let uuid = 0; const ImageInternal = defineComponent({ name: 'Image', - mixins: [BaseMixin], inheritAttrs: false, props: imageProps, emits: ['click'], diff --git a/components/vc-steps/Steps.tsx b/components/vc-steps/Steps.tsx index 92135554a..01a0b58c8 100644 --- a/components/vc-steps/Steps.tsx +++ b/components/vc-steps/Steps.tsx @@ -1,5 +1,4 @@ import PropTypes from '../_util/vue-types'; -import BaseMixin from '../_util/BaseMixin'; import { filterEmpty } from '../_util/props-util'; import { cloneElement } from '../_util/vnode'; import { defineComponent } from 'vue'; @@ -24,7 +23,6 @@ export type ProgressDotRender = (info: { export default defineComponent({ name: 'Steps', - mixins: [BaseMixin], props: { type: PropTypes.string.def('default'), prefixCls: PropTypes.string.def('vc-steps'),