diff --git a/packages/fighting-design/_hooks/use-alert-list/index.ts b/packages/fighting-design/_hooks/use-alert-list/index.ts index cd7efb3b69..ef854f46f2 100644 --- a/packages/fighting-design/_hooks/use-alert-list/index.ts +++ b/packages/fighting-design/_hooks/use-alert-list/index.ts @@ -73,7 +73,7 @@ export const useAlertList = (node: HTMLElement): UseAlertListReturn => { * * 控制动画执行 */ - const timer: NodeJS.Timer = setInterval((): void => { + const timer: NodeJS.Timer = setInterval(() => { from += dis if (from >= to) { diff --git a/packages/fighting-design/_hooks/use-count-down/index.ts b/packages/fighting-design/_hooks/use-count-down/index.ts index d5eb5a60bf..eaea89bc8b 100644 --- a/packages/fighting-design/_hooks/use-count-down/index.ts +++ b/packages/fighting-design/_hooks/use-count-down/index.ts @@ -132,7 +132,7 @@ export const useCountDown = (options: UseCountDownOptions): UseCountDownReturn = /** 逐帧计算倒计时 */ const tick = (): void => { - /** 非浏览器环境,时间不走 */ + // 非浏览器环境,时间不走 if (!isBrowser) { return } @@ -167,7 +167,7 @@ export const useCountDown = (options: UseCountDownOptions): UseCountDownReturn = /** 毫秒级渲染 */ const microTick = (): void => { - rafId = raf((): void => { + rafId = raf(() => { if (isCounting) { /** 设置剩余时间为此次调用时的剩余时间 */ setRemain(getCurrentRemain()) @@ -182,7 +182,7 @@ export const useCountDown = (options: UseCountDownOptions): UseCountDownReturn = /** 秒级渲染 */ const macroTick = (): void => { - rafId = raf((): void => { + rafId = raf(() => { if (isCounting) { /** 获取此次调用的剩余时间 */ const remainRemain = getCurrentRemain() @@ -195,7 +195,7 @@ export const useCountDown = (options: UseCountDownOptions): UseCountDownReturn = setRemain(remainRemain) } - /** 当还有剩余时间时,继续 */ + // 当还有剩余时间时,继续 if (remain.value > 0) { macroTick() } diff --git a/packages/fighting-design/_hooks/use-form-check/index.ts b/packages/fighting-design/_hooks/use-form-check/index.ts index 5c983617c2..6badc7c45c 100644 --- a/packages/fighting-design/_hooks/use-form-check/index.ts +++ b/packages/fighting-design/_hooks/use-form-check/index.ts @@ -43,7 +43,7 @@ export const useFormCheck = (prop: FormProps): UseFormCheckReturn => { const children = getChildren(slot.default(), 'FFormItem') // 遍历添每个节点判断是否验证通过 - children.forEach((item: VNode): void => { + children.forEach((item: VNode) => { // 必须有 name 和 rules 才能触发表单校验 if (item.props && item.props.name && item.props.rules) { // 初始状态下默认设置全部没有通过校验 @@ -127,7 +127,7 @@ export const useFormCheck = (prop: FormProps): UseFormCheckReturn => { * 获取到每个子组件,检测输入的内容是否符合规则 */ const validate = (): boolean => { - getChildrenList.value.forEach((item: VNode): void => { + getChildrenList.value.forEach((item: VNode) => { /** 子组件规则 */ const _rules: FormItemProps['rules'] = item.props && item.props.rules /** 子组件名字 */ diff --git a/packages/fighting-design/_hooks/use-global/index.ts b/packages/fighting-design/_hooks/use-global/index.ts index a0db807620..7bfdfc4f6e 100644 --- a/packages/fighting-design/_hooks/use-global/index.ts +++ b/packages/fighting-design/_hooks/use-global/index.ts @@ -115,6 +115,7 @@ export const useGlobal = (prop?: Partial): UseGlobalReturn => { const lang: FightingLang = (global && global.lang) || 'zh-CN' /** 获取当前的语音对象 */ const langList = LANG[lang] + // 返回指定组件的语言内容 return langList[componentName] }) @@ -144,15 +145,15 @@ export const useGlobal = (prop?: Partial): UseGlobalReturn => { size?: ComputedRef } = {} - /** 必须是数组才遍历,提前拦截错误 */ + // 必须是数组才遍历,提前拦截错误 if (isArray(target)) { - target.forEach((item: 'type' | 'size', index: number): void => { - /** 检测映射对象中是否存在该属性 */ + target.forEach((item: 'type' | 'size', index: number) => { + // 检测映射对象中是否存在该属性 if (getPropMap[item]) { /** 获取默认值 */ const defaultValue: string | undefined = def && def[index] - /** 将需要更改的树形改为指定参数 */ + // 将需要更改的树形改为指定参数 prams[item] = getPropMap[item](defaultValue) } }) diff --git a/packages/fighting-design/_hooks/use-message/index.ts b/packages/fighting-design/_hooks/use-message/index.ts index f1c078b42f..01bbe454e8 100644 --- a/packages/fighting-design/_hooks/use-message/index.ts +++ b/packages/fighting-design/_hooks/use-message/index.ts @@ -120,9 +120,9 @@ const updatePosition = (closeInstance: ComponentInternalInstance): void => { instances[placement] as ComponentInternalInstance[] )[index] - /** 减少后面的组件实例偏移量 */ - ;(instance.exposed as Record>).offsetVal.value -= - getNextElementInterval(closeInstance) + // 减少后面的组件实例偏移量 + ; (instance.exposed as Record>).offsetVal.value -= + getNextElementInterval(closeInstance) } } @@ -137,13 +137,13 @@ export const removeInstance = (instance: ComponentInternalInstance): void => { /** 当前组件的方位 */ const placement: MessagePlacement | NotificationPlacement = getPlacement(instance) - /** - * @see Array.prototype.splice() https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/splice - */ - ;(instances[placement] as ComponentInternalInstance[]).splice( - getIndexByInstance(instance), - 1 - ) + /** + * @see Array.prototype.splice() https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/splice + */ + ; (instances[placement] as ComponentInternalInstance[]).splice( + getIndexByInstance(instance), + 1 + ) } /** @@ -170,10 +170,10 @@ export const useMessage = ( const placement: MessagePlacement | NotificationPlacement = getPlacement(instance) if (instances[placement]) { - /** 如果对象中存在当前方位数组,则往数组中追加组件实例 */ + // 如果对象中存在当前方位数组,则往数组中追加组件实例 (instances[placement] as ComponentInternalInstance[]).push(instance) } else { - /** 否则新建一个数组存储当前组件实例 */ + // 否则新建一个数组存储当前组件实例 instances[placement] = [instance] } } @@ -192,11 +192,11 @@ export const useMessage = ( /** 获取到当前方位的组件实例集合 */ const placementInstance: ComponentInternalInstance[] | undefined = instances[ - options.placement ? options.placement : name === 'message' ? 'top' : 'top-right' + options.placement ? options.placement : name === 'message' ? 'top' : 'top-right' ] if (placementInstance) { - placementInstance.forEach((instance: ComponentInternalInstance): void => { + placementInstance.forEach((instance: ComponentInternalInstance) => { result += getNextElementInterval(instance) }) } @@ -267,7 +267,7 @@ export const useMessage = ( ...options } - /** 如何传入的时间不是一个数字,则强制修改成为数字类型 */ + // 如果传入的时间不是一个数字,则强制修改成为数字类型 if (!isNumber(defaultOptions.duration)) { defaultOptions.duration = 2500 diff --git a/packages/fighting-design/_hooks/use-page/index.ts b/packages/fighting-design/_hooks/use-page/index.ts index a24b3461d5..8ec82081d8 100644 --- a/packages/fighting-design/_hooks/use-page/index.ts +++ b/packages/fighting-design/_hooks/use-page/index.ts @@ -122,8 +122,10 @@ export const usePage = ( /** 翻页映射方法 */ const changeMap = { - /** 下一页切换 */ - next: (): void => { + /** + * 下一页切换 + */ + next: () => { const newCurrent: number = prop.current === maxCount.value ? maxCount.value : prop.current + 1 @@ -131,8 +133,10 @@ export const usePage = ( run(prop.onNext, newCurrent, prop.pageSize) run(prop.onChange, newCurrent, prop.pageSize) }, - /**上一页切换 */ - prev: (): void => { + /** + * 上一页切换 + */ + prev: () => { newCurrent = prop.current === 1 ? 1 : prop.current - 1 modelValue.currentModelValue.value = newCurrent run(prop.onPrev, newCurrent, prop.pageSize) diff --git a/packages/fighting-design/_hooks/use-props/index.ts b/packages/fighting-design/_hooks/use-props/index.ts index 2af01d606f..5ae949a2f3 100644 --- a/packages/fighting-design/_hooks/use-props/index.ts +++ b/packages/fighting-design/_hooks/use-props/index.ts @@ -53,7 +53,7 @@ export const useProps = (prop: T): UsePropsReturn => { /** 过滤的 prop 结果 */ const result: Record = reactive({}) - list.forEach((item: string | FilterParamsList): void => { + list.forEach((item: string | FilterParamsList) => { /** * 判断如果是字符串参数 * diff --git a/packages/fighting-design/_hooks/use-ripples/index.ts b/packages/fighting-design/_hooks/use-ripples/index.ts index e87d52c493..194dd9e31b 100644 --- a/packages/fighting-design/_hooks/use-ripples/index.ts +++ b/packages/fighting-design/_hooks/use-ripples/index.ts @@ -100,7 +100,7 @@ export const useRipples = ( * @param { Object } node dom 元素 */ const removeElement = (node: HTMLElement): void => { - setTimeout((): void => { + setTimeout(() => { /** * @see Element.remove() https://developer.mozilla.org/zh-CN/docs/Web/API/Element/remove */ diff --git a/packages/fighting-design/_hooks/use-trigger/index.ts b/packages/fighting-design/_hooks/use-trigger/index.ts index 822075d857..0458976916 100644 --- a/packages/fighting-design/_hooks/use-trigger/index.ts +++ b/packages/fighting-design/_hooks/use-trigger/index.ts @@ -112,7 +112,7 @@ export const useTrigger = ( return } - setPosition() + setPosition() // 设置内容位置 visible.value = true contentVisible = true @@ -143,7 +143,7 @@ export const useTrigger = ( return } - setTimeout((): void => { + setTimeout(() => { if (!contentVisible) { _() } diff --git a/packages/fighting-design/_hooks/use-turn-page/index.ts b/packages/fighting-design/_hooks/use-turn-page/index.ts index 26f43d7075..f39326beb2 100644 --- a/packages/fighting-design/_hooks/use-turn-page/index.ts +++ b/packages/fighting-design/_hooks/use-turn-page/index.ts @@ -56,6 +56,7 @@ export const useTurnPage = ( if (prop.current > maxValue) { modelValue.currentModelValue.value = maxValue } + modelValue.pageSizeModelValue.value = Number(newValue) } diff --git a/packages/fighting-design/_utils/install/index.ts b/packages/fighting-design/_utils/install/index.ts index 9ea3ce5f64..9acc7fbb5c 100644 --- a/packages/fighting-design/_utils/install/index.ts +++ b/packages/fighting-design/_utils/install/index.ts @@ -11,7 +11,7 @@ export type Install = T & { * @returns { Object } 组件实例 */ export const install = (main: T): Install => { - (main as Record).install = (app: App): void => { + (main as Record).install = (app: App) => { const { name } = main name && app.component(name, main) } @@ -26,7 +26,7 @@ export const install = (main: T): Install => { * @returns { Object } 组件实例 */ export const installFn = (main: T, name: string): Install => { - (main as Install).install = (app: App): void => { + (main as Install).install = (app: App) => { app.config.globalProperties[name] = main as Install } return main as Install @@ -43,7 +43,7 @@ export const installDirective = ( main: T, name: string ): Install => { - (main as Install).install = (app: App): void => { + (main as Install).install = (app: App) => { app.directive(name, main as Install) } return main as Install diff --git a/packages/fighting-design/_utils/tips/index.ts b/packages/fighting-design/_utils/tips/index.ts index de767e11da..0816f8fce4 100644 --- a/packages/fighting-design/_utils/tips/index.ts +++ b/packages/fighting-design/_utils/tips/index.ts @@ -5,7 +5,7 @@ * @param { string } location 位置 * @param { string } message 警告信息 */ -export const warning = (location: string, message: string): void => { +export const warning = (location: string, message: string) => { console.warn(`[fighting-design/${location}]: ${message}`) } @@ -16,7 +16,7 @@ export const warning = (location: string, message: string): void => { * @param { string } location 位置 * @param { string } message 警告信息 */ -export const error = (location: string, message: string): void => { +export const error = (location: string, message: string) => { console.error(`[fighting-design/${location}]: ${message}`) } @@ -28,6 +28,6 @@ export const error = (location: string, message: string): void => { * @param { string } location 位置 * @param { string } message 警告信息 */ -export const throwError = (location: string, message: string): never => { +export const throwError = (location: string, message: string) => { throw new Error(`[fighting-design/${location}]: ${message}`) } diff --git a/packages/fighting-design/_utils/utils/index.ts b/packages/fighting-design/_utils/utils/index.ts index 7d5448e4a0..c1322296aa 100644 --- a/packages/fighting-design/_utils/utils/index.ts +++ b/packages/fighting-design/_utils/utils/index.ts @@ -33,12 +33,12 @@ export const debounce = void>( /** 计时器实例 */ let timeout: ReturnType | undefined - return (...args: Parameters): void => { + return (...args: Parameters) => { if (timeout) { clearTimeout(timeout) } - timeout = setTimeout((): void => { + timeout = setTimeout(() => { func(...args) }, delay) } diff --git a/packages/fighting-design/alert/__test__/alert.spec.ts b/packages/fighting-design/alert/__test__/alert.spec.ts index 6800576ad1..77d02f78b1 100644 --- a/packages/fighting-design/alert/__test__/alert.spec.ts +++ b/packages/fighting-design/alert/__test__/alert.spec.ts @@ -13,7 +13,7 @@ describe('FAlert', () => { }) test('type', () => { - FIGHTING_TYPE.forEach((item: FightingType): void => { + FIGHTING_TYPE.forEach((item: FightingType) => { const wrapper = mount(FAlert, { props: { type: item } }) diff --git a/packages/fighting-design/avatar-group/src/avatar-group.vue b/packages/fighting-design/avatar-group/src/avatar-group.vue index 4e0c643abc..b8cd4552cd 100644 --- a/packages/fighting-design/avatar-group/src/avatar-group.vue +++ b/packages/fighting-design/avatar-group/src/avatar-group.vue @@ -24,7 +24,7 @@ // 必须在子元素存在的时候,设置 zIndex 层级样式 if (avatars && avatars.length) { - avatars.forEach((item: HTMLDivElement, i: number): void => { + avatars.forEach((item: HTMLDivElement, i: number) => { item.style.zIndex = (avatars.length - i).toString() }) } diff --git a/packages/fighting-design/avatar/__test__/avatar.spec.ts b/packages/fighting-design/avatar/__test__/avatar.spec.ts index 962dfa7699..0bf067aa7d 100644 --- a/packages/fighting-design/avatar/__test__/avatar.spec.ts +++ b/packages/fighting-design/avatar/__test__/avatar.spec.ts @@ -26,7 +26,7 @@ describe('FAvatar', () => { }) test('fit', () => { - FIGHTING_FIT.forEach((item: FightingFit): void => { + FIGHTING_FIT.forEach((item: FightingFit) => { const wrapper = mount(FAvatar, { props: { fit: item } }) @@ -35,7 +35,7 @@ describe('FAvatar', () => { }) test('size', () => { - FIGHTING_SIZE.forEach((item: FightingSize): void => { + FIGHTING_SIZE.forEach((item: FightingSize) => { const wrapper = mount(FAvatar, { props: { size: item } }) diff --git a/packages/fighting-design/back-top/src/back-top.vue b/packages/fighting-design/back-top/src/back-top.vue index 36db1fe185..64143c6213 100644 --- a/packages/fighting-design/back-top/src/back-top.vue +++ b/packages/fighting-design/back-top/src/back-top.vue @@ -24,7 +24,7 @@ * @returns { Function } 防抖函数 */ const handleScroll = (node?: HTMLElement): (() => void) => { - return debounce((): void => { + return debounce(() => { /** * 当前滚动的距离 * @@ -122,7 +122,7 @@ }) // 卸载组件移除监听 - onUnmounted((): void => { + onUnmounted(() => { document.removeEventListener('scroll', cachedHandleScroll) }) diff --git a/packages/fighting-design/badge/__test__/badge.spec.ts b/packages/fighting-design/badge/__test__/badge.spec.ts index 0fea3a72fe..52447bee37 100644 --- a/packages/fighting-design/badge/__test__/badge.spec.ts +++ b/packages/fighting-design/badge/__test__/badge.spec.ts @@ -12,7 +12,7 @@ describe('FBadge', () => { }) test('type', () => { - FIGHTING_TYPE.forEach((item: FightingType): void => { + FIGHTING_TYPE.forEach((item: FightingType) => { const wrapper = mount(FBadge, { props: { type: item } }) diff --git a/packages/fighting-design/button/__test__/button.spec.ts b/packages/fighting-design/button/__test__/button.spec.ts index 582bda445e..98f29067c5 100644 --- a/packages/fighting-design/button/__test__/button.spec.ts +++ b/packages/fighting-design/button/__test__/button.spec.ts @@ -67,7 +67,7 @@ describe('FButton', () => { }) test('size', () => { - FIGHTING_SIZE.forEach((item: FightingSize): void => { + FIGHTING_SIZE.forEach((item: FightingSize) => { const wrapper = mount(FButton, { props: { size: item } }) @@ -90,7 +90,7 @@ describe('FButton', () => { }) test('target', () => { - FIGHTING_TARGET.forEach((item: ButtonTarget): void => { + FIGHTING_TARGET.forEach((item: ButtonTarget) => { const wrapper = mount(FButton, { props: { href: 'https://tianyuhao.cn', target: item } }) @@ -120,7 +120,7 @@ describe('FButton', () => { }) test('type', () => { - FIGHTING_TYPE.forEach((item: FightingType): void => { + FIGHTING_TYPE.forEach((item: FightingType) => { const wrapper = mount(FButton, { props: { type: item } }) @@ -197,7 +197,7 @@ describe('FButton', () => { test('nativeType', () => { const nativeTypes: ButtonNative[] = ['button', 'submit', 'reset'] - nativeTypes.forEach((item: ButtonNative): void => { + nativeTypes.forEach((item: ButtonNative) => { const wrapper = mount(FButton, { props: { nativeType: item } }) diff --git a/packages/fighting-design/calendar/src/calendar.vue b/packages/fighting-design/calendar/src/calendar.vue index 0febfc3e92..bbf43a7d36 100644 --- a/packages/fighting-design/calendar/src/calendar.vue +++ b/packages/fighting-design/calendar/src/calendar.vue @@ -69,9 +69,9 @@ * @param { Function } now 点击今天执行的方法 */ const option = { - prev: (): void => changeLastMonth(), - next: (): void => changeNextMonth(), - current: (): void => { + prev: changeLastMonth, + next: changeNextMonth, + current: () => { dates.year = prop.date.getFullYear() dates.month = prop.date.getMonth() + 1 dates.date = prop.date.getDate() @@ -84,7 +84,7 @@ * @param { 'last' | 'current' | 'next' } target 不同类型用于切换当前时间、下个月、上个月 */ const optionClick = (target: 'prev' | 'current' | 'next'): void => { - /** 如果存在则执行指定方法 */ + // 如果存在则执行指定方法 option[target] && option[target]() } @@ -119,7 +119,7 @@ /** * @param { number } month 最新的月份 */ - (month: number): void => { + (month: number) => { run(prop.onChangeMonth, dates.year, month, dates.date) } ) @@ -127,7 +127,7 @@ /** 改变日期的监听器 */ const watchChange = watch( () => dates, - (): void => { + () => { run(prop.onChange, dates.year, dates.month, dates.date) }, { deep: true } @@ -140,7 +140,7 @@ * @param { number } date 日期 */ const currentDataClass = (month: number, date: number): string => { - /** 如果当前的月份和日期和绑定的日期相同,则高亮显示 */ + // 如果当前的月份和日期和绑定的日期相同,则高亮显示 if (date === dates.date && month === dates.month) { return 'f-calendar__day-today' } diff --git a/packages/fighting-design/card/__test__/card.spec.ts b/packages/fighting-design/card/__test__/card.spec.ts index 770043faf4..1fb4e59b8b 100644 --- a/packages/fighting-design/card/__test__/card.spec.ts +++ b/packages/fighting-design/card/__test__/card.spec.ts @@ -26,7 +26,7 @@ describe('FCard', () => { test('shadow', () => { const shadows: CardShadow[] = ['hover', 'always'] - shadows.forEach((item: CardShadow): void => { + shadows.forEach((item: CardShadow) => { const wrapper = mount(FCard, { props: { shadow: item } }) diff --git a/packages/fighting-design/checkbox-group/__test__/checkbox-group.spec.ts b/packages/fighting-design/checkbox-group/__test__/checkbox-group.spec.ts index 225b84f815..68f6d52e2d 100644 --- a/packages/fighting-design/checkbox-group/__test__/checkbox-group.spec.ts +++ b/packages/fighting-design/checkbox-group/__test__/checkbox-group.spec.ts @@ -29,7 +29,7 @@ describe('FCheckboxGroup', () => { }) test('size', () => { - FIGHTING_SIZE.forEach((size: FightingSize): void => { + FIGHTING_SIZE.forEach((size: FightingSize) => { const wrapper = mount(FCheckboxGroup, { props: { background: true, size } }) diff --git a/packages/fighting-design/count-down/src/count-down.vue b/packages/fighting-design/count-down/src/count-down.vue index 3e3c8db7b7..d719bce631 100644 --- a/packages/fighting-design/count-down/src/count-down.vue +++ b/packages/fighting-design/count-down/src/count-down.vue @@ -14,7 +14,7 @@ time: +prop.time, millisecond: prop.millisecond, interval: +prop.interval, - onFinish: (): void => { + onFinish: () => { run(prop.onFinish) } }) @@ -81,10 +81,10 @@ /** 生成时间字符串 */ const timeText = computed((): string => formatTimeStr(prop.format, current.value)) - /** 监听传入的 time 改变,则重新开始倒计时 */ + // 监听传入的 time 改变,则重新开始倒计时 watch( (): string | number => prop.time, - (): void => { + () => { reset(+prop.time) if (prop.autoStart) { diff --git a/packages/fighting-design/defaults.ts b/packages/fighting-design/defaults.ts index 3aaf0c1e2c..51c51462f2 100644 --- a/packages/fighting-design/defaults.ts +++ b/packages/fighting-design/defaults.ts @@ -17,7 +17,7 @@ const install = (app: App): App => { * @see registration https://cn.vuejs.org/guide/components/registration.html * @see Array.prototype.forEach() https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach */ - objectEntries(components).forEach(([key, value]): void => { + objectEntries(components).forEach(([key, value]) => { app.component(key, value) }) diff --git a/packages/fighting-design/divider/__test__/divider.spec.ts b/packages/fighting-design/divider/__test__/divider.spec.ts index 9460d987d8..6169b16346 100644 --- a/packages/fighting-design/divider/__test__/divider.spec.ts +++ b/packages/fighting-design/divider/__test__/divider.spec.ts @@ -27,7 +27,7 @@ describe('FDivider', () => { test('position', () => { const positions: DividerPosition[] = ['left', 'center', 'right'] - positions.forEach((item: DividerPosition): void => { + positions.forEach((item: DividerPosition) => { const wrapper = mount(FDivider, { props: { position: item } }) @@ -67,7 +67,7 @@ describe('FDivider', () => { test('type', () => { const types: DividerType[] = ['dashed', 'dotted', 'double', 'solid'] - types.forEach((item: DividerType): void => { + types.forEach((item: DividerType) => { const wrapper = mount(FDivider, { props: { type: item } }) diff --git a/packages/fighting-design/image-preview/src/image-preview.vue b/packages/fighting-design/image-preview/src/image-preview.vue index 201797499d..6b6c036717 100644 --- a/packages/fighting-design/image-preview/src/image-preview.vue +++ b/packages/fighting-design/image-preview/src/image-preview.vue @@ -59,16 +59,20 @@ /** 左右切换映射对象 */ const switchMap = { - /** 下一张切换 */ - next: (): void => { + /** + * 下一张切换 + */ + next: () => { if (previewShowIndex.value < prop.imgList.length - 1) { previewShowIndex.value++ return } previewShowIndex.value = 0 }, - /** 上一张切换 */ - prev: (): void => { + /** + * 上一张切换 + */ + prev: () => { if (previewShowIndex.value > 0) { previewShowIndex.value-- return @@ -89,11 +93,11 @@ /** 点击操作栏映射对象 */ const optionMap: Record void> = { - '1': (): void => smaller(), - '2': (): void => bigger(), - '3': (): void => recovery(), - '4': (): void => rotateClockwise(), - '5': (): void => rotateCounterClock() + '1': smaller, + '2': bigger, + '3': recovery, + '4': rotateClockwise, + '5': rotateCounterClock } as const /** diff --git a/packages/fighting-design/image/__test__/image.spec.ts b/packages/fighting-design/image/__test__/image.spec.ts index e32765de1e..9b9c0f1e18 100644 --- a/packages/fighting-design/image/__test__/image.spec.ts +++ b/packages/fighting-design/image/__test__/image.spec.ts @@ -18,12 +18,12 @@ describe('FImage', () => { expect(wrapper.find('img').attributes('alt')).toContain('图片') }) - // test('draggable', () => { - // const wrapper = mount(FImage, { - // props: { draggable: false } - // }) - // expect(wrapper.find('img').attributes('draggable')).toContain('false') - // }) + test('draggable', () => { + const wrapper = mount(FImage, { + props: { draggable: false } + }) + expect(wrapper.find('img').attributes('draggable')).toContain('false') + }) test('block', () => { const wrapper = mount(FImage, { @@ -33,7 +33,7 @@ describe('FImage', () => { }) test('fit', () => { - FIGHTING_FIT.forEach((item: ImageFit): void => { + FIGHTING_FIT.forEach((item: ImageFit) => { const wrapper = mount(FImage, { props: { fit: item } }) diff --git a/packages/fighting-design/input-number/src/input-number.vue b/packages/fighting-design/input-number/src/input-number.vue index 16876f4d27..49fd16d4a7 100644 --- a/packages/fighting-design/input-number/src/input-number.vue +++ b/packages/fighting-design/input-number/src/input-number.vue @@ -52,16 +52,20 @@ const handleChangeVal = (target: 'minus' | 'plus'): void => { const { disabled, readonly, step } = prop - /** 禁用或只读 */ + // 禁用或只读 if (disabled || readonly) return const map = { - /** 减少 */ - minus: (): void => { + /** + * 减少 + */ + minus: () => { modelValue.value -= step }, - /** 增加 */ - plus: (): void => { + /** + * 增加 + */ + plus: () => { modelValue.value += step } } diff --git a/packages/fighting-design/input/__test__/input.spec.ts b/packages/fighting-design/input/__test__/input.spec.ts index 92925e33f5..8153daf767 100644 --- a/packages/fighting-design/input/__test__/input.spec.ts +++ b/packages/fighting-design/input/__test__/input.spec.ts @@ -14,7 +14,7 @@ describe('Input', () => { test('type', () => { const types: InputType[] = ['text', 'password', 'number'] - types.forEach((item: InputType): void => { + types.forEach((item: InputType) => { const wrapper = mount(FInput, { props: { type: item } }) @@ -23,7 +23,7 @@ describe('Input', () => { }) test('size', () => { - FIGHTING_SIZE.forEach((item: FightingSize): void => { + FIGHTING_SIZE.forEach((item: FightingSize) => { const wrapper = mount(FInput, { props: { size: item } }) diff --git a/packages/fighting-design/link/__test__/link.spec.ts b/packages/fighting-design/link/__test__/link.spec.ts index 70b75c18e1..b1cf3bc9dc 100644 --- a/packages/fighting-design/link/__test__/link.spec.ts +++ b/packages/fighting-design/link/__test__/link.spec.ts @@ -55,7 +55,7 @@ describe('FLink', () => { test('state', () => { const state: LinkState[] = ['line', 'background'] - state.forEach((item: LinkState): void => { + state.forEach((item: LinkState) => { const wrapper = mount(FLink, { props: { state: item } }) @@ -73,7 +73,7 @@ describe('FLink', () => { }) test('target', () => { - FIGHTING_TARGET.forEach((item: LinkTarget): void => { + FIGHTING_TARGET.forEach((item: LinkTarget) => { const wrapper = mount(FLink, { props: { target: item } }) diff --git a/packages/fighting-design/list/__test__/list.spec.ts b/packages/fighting-design/list/__test__/list.spec.ts index e8201bd7e4..946aa6eb21 100644 --- a/packages/fighting-design/list/__test__/list.spec.ts +++ b/packages/fighting-design/list/__test__/list.spec.ts @@ -33,7 +33,7 @@ describe('FList', () => { }) test('size', () => { - FIGHTING_SIZE.forEach((item: FightingSize): void => { + FIGHTING_SIZE.forEach((item: FightingSize) => { const wrapper = mount(FList, { props: { size: item } }) diff --git a/packages/fighting-design/radio/src/radio.vue b/packages/fighting-design/radio/src/radio.vue index 5de97e2602..45003ad12d 100644 --- a/packages/fighting-design/radio/src/radio.vue +++ b/packages/fighting-design/radio/src/radio.vue @@ -20,8 +20,8 @@ get: (): RadioModelValue => { return (parentInject && parentInject.modelValue) || prop.modelValue }, - set: (val: RadioModelValue): void => { - /** 判断如果注入的依赖项存在,并且没有禁用,则将最新值传递给父组件 */ + set: (val: RadioModelValue) => { + // 判断如果注入的依赖项存在,并且没有禁用,则将最新值传递给父组件 if (parentInject && !isParentDisabled.value) { run(parentInject.changeEvent, val) return @@ -39,9 +39,9 @@ const isChecked = computed((): boolean => keyword.value === prop.label) /** 父级是否带有禁用 */ - const isParentDisabled = computed( - (): boolean => !!(parentInject && parentInject.disabled) - ) + const isParentDisabled = computed((): boolean => { + return !!(parentInject && parentInject.disabled) + }) /** 判断是否被禁用 */ const isDisabled = computed((): boolean => prop.disabled || isParentDisabled.value) diff --git a/packages/fighting-design/rate/src/rate.vue b/packages/fighting-design/rate/src/rate.vue index 14a5ce9d86..fc2873abad 100644 --- a/packages/fighting-design/rate/src/rate.vue +++ b/packages/fighting-design/rate/src/rate.vue @@ -48,7 +48,7 @@ // 监视如何绑定值发生变化的时候同步数据 watch( (): number => prop.modelValue, - (): void => { + () => { starValue.value = prop.modelValue } ) diff --git a/packages/fighting-design/select/src/select.vue b/packages/fighting-design/select/src/select.vue index bdc341dc61..25651921f8 100644 --- a/packages/fighting-design/select/src/select.vue +++ b/packages/fighting-design/select/src/select.vue @@ -126,7 +126,7 @@ // 设置文本框展示的内容 keyword.value = currentValue.toString() - // 如果最新的 value 和绑定的 value 不一致时,才触发 change 事件 + // 如果最新的 value 和绑定的 value 不一致时,才触发 change 事件 if (currentLabel !== prop.modelValue) { run(prop.onChange, currentValue, currentLabel, evt) } diff --git a/packages/fighting-design/swap/__test__/swap.spec.ts b/packages/fighting-design/swap/__test__/swap.spec.ts index 24d8be6271..8cb1df4928 100644 --- a/packages/fighting-design/swap/__test__/swap.spec.ts +++ b/packages/fighting-design/swap/__test__/swap.spec.ts @@ -18,7 +18,7 @@ describe('Swap', () => { test('type', () => { const types: SwapType[] = ['sound', 'swap'] - types.forEach((item: SwapType): void => { + types.forEach((item: SwapType) => { const wrapper = mount(FSwap, { props: { modelValue: false, type: item } }) diff --git a/packages/fighting-design/switch/__test__/switch.spec.ts b/packages/fighting-design/switch/__test__/switch.spec.ts index b755954471..c9c7ff4c87 100644 --- a/packages/fighting-design/switch/__test__/switch.spec.ts +++ b/packages/fighting-design/switch/__test__/switch.spec.ts @@ -25,7 +25,7 @@ describe('FSwitch', () => { }) test('size', () => { - FIGHTING_SIZE.forEach((item: FightingSize): void => { + FIGHTING_SIZE.forEach((item: FightingSize) => { const wrapper = mount(FSwitch, { props: { size: item } }) diff --git a/packages/fighting-design/tabs/src/tabs.vue b/packages/fighting-design/tabs/src/tabs.vue index 0001906e5a..b3d9622485 100644 --- a/packages/fighting-design/tabs/src/tabs.vue +++ b/packages/fighting-design/tabs/src/tabs.vue @@ -32,7 +32,7 @@ const vNodes = isArray(children) ? children : [children] const result: VNode[] = [] - vNodes.forEach((child): void => { + vNodes.forEach(child => { if (isArray(child)) { result.push(...flattedChildren(child)) } else if (isVNode(child) && isArray(child.children)) { diff --git a/packages/fighting-design/tag/__test__/tag.spec.ts b/packages/fighting-design/tag/__test__/tag.spec.ts index 5f184c4216..06210ae734 100644 --- a/packages/fighting-design/tag/__test__/tag.spec.ts +++ b/packages/fighting-design/tag/__test__/tag.spec.ts @@ -20,7 +20,7 @@ describe('FTag', () => { }) test('type', () => { - FIGHTING_TYPE.forEach((item: FightingType): void => { + FIGHTING_TYPE.forEach((item: FightingType) => { const wrapper = mount(FTag, { props: { type: item } }) @@ -96,9 +96,9 @@ describe('FTag', () => { test('close', async () => { const App = defineComponent({ components: { FTag }, - setup () { + setup() { const isShow = ref(true) - const onClose = (): void => { + const onClose = () => { isShow.value = false } return { diff --git a/packages/fighting-design/textarea/__test__/textarea.spec.ts b/packages/fighting-design/textarea/__test__/textarea.spec.ts index 48936b701d..06b608a9bf 100644 --- a/packages/fighting-design/textarea/__test__/textarea.spec.ts +++ b/packages/fighting-design/textarea/__test__/textarea.spec.ts @@ -59,7 +59,7 @@ describe('Textarea', () => { test('resize', () => { const resizes: TextareaResize[] = ['none', 'both', 'horizontal', 'vertical'] - resizes.forEach((item: TextareaResize): void => { + resizes.forEach((item: TextareaResize) => { const wrapper = mount(FTextarea, { props: { resize: item } }) diff --git a/packages/fighting-design/watermark/src/watermark.vue b/packages/fighting-design/watermark/src/watermark.vue index 6ef557b949..041fe784f2 100644 --- a/packages/fighting-design/watermark/src/watermark.vue +++ b/packages/fighting-design/watermark/src/watermark.vue @@ -36,11 +36,6 @@ watermarkRef.value.appendChild(div) } - /** - * 元素挂载之后生成水印元素 - */ - onMounted(renderWatermark) - /** * @see MutationObserver https://developer.mozilla.org/zh-CN/docs/Web/API/MutationObserver */ @@ -79,10 +74,12 @@ /** * 监控子节点 */ + // 监控子节点 childList: true, /** * 监控子树 */ + // 监控子树 subtree: true, /** * 监控属性 @@ -92,6 +89,9 @@ } }) + // 元素挂载之后生成水印元素 + onMounted(renderWatermark) + /** * 如何卸载之后停止监听 *