Skip to content

Commit

Permalink
style: 更新格式问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyh2001 committed Dec 12, 2023
1 parent 748e7bb commit f5970b9
Show file tree
Hide file tree
Showing 33 changed files with 83 additions and 85 deletions.
2 changes: 1 addition & 1 deletion packages/fighting-design/_hooks/use-alert-list/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const useAlertList = (node: HTMLElement): UseAlertListReturn => {
if (from >= to) {
clearInterval(timer)

/** 代表到达最后一项了 */
// 代表到达最后一项了
if (scrollIndex === nodeChildrenLength - 1) {
node.scrollTop = 0
scrollIndex = 0
Expand Down
6 changes: 3 additions & 3 deletions packages/fighting-design/_hooks/use-calendar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const useCalendar = (prop: CalendarProps): UseCalendarReturn => {
month = 12
}

/** 如果是闰年,二月份有29天 */
// 如果是闰年,二月份有29天
if (month === 2 && isLeapYear(year)) {
return 29
}
Expand Down Expand Up @@ -102,7 +102,7 @@ export const useCalendar = (prop: CalendarProps): UseCalendarReturn => {
/** 获取上个月天数 */
const lastMonthDays = getDaysInMonth(year, month - 1)

/** 填充上个月的剩余天数 */
// 填充上个月的剩余天数
for (let i = startDay - 1; i >= 0; i--) {
const _month = month - 1 === 0 ? 12 : month - 1
const _day = lastMonthDays - i
Expand All @@ -119,7 +119,7 @@ export const useCalendar = (prop: CalendarProps): UseCalendarReturn => {

let currentDay = 1

/** 填充当前月份的天数 */
// 填充当前月份的天数
while (currentDay <= getDaysInMonth(year, month)) {
const _lunar = prop.lunar ? lunar(year, month, currentDay) : {}

Expand Down
6 changes: 3 additions & 3 deletions packages/fighting-design/_hooks/use-color/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const useColor = (color: string): UseColorReturn => {
/** 十六进制色号正则检测条件 */
const r = /^\#?[0-9A-Fa-f]{6}$/

/** 检测是否为一个有效的十六进制色号 */
// 检测是否为一个有效的十六进制色号
if (!r.test(color)) {
throw new Error(
`Fighting Design - useColor: ${color} is not a valid hex color number`
Expand Down Expand Up @@ -93,7 +93,7 @@ export const useColor = (color: string): UseColorReturn => {
rgb[i] = Math.floor(Number(rgb[i]) * (1 - level)).toString(16)
}

/** 转换成 hex 返回 */
// 转换成 hex 返回
return toHex(...rgb)
}

Expand All @@ -111,7 +111,7 @@ export const useColor = (color: string): UseColorReturn => {
rgb[i] = Math.floor((255 - Number(rgb[i])) * level + Number(rgb[i])).toString(16)
}

/** 转换成 hex 返回 */
// 转换成 hex 返回
return toHex(...rgb)
}

Expand Down
9 changes: 5 additions & 4 deletions packages/fighting-design/_hooks/use-count-down/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ const parseTime = (time: number): CurrentTime => {
*
* @param { number } time1 时间(单位毫秒)
* @param { number } time2 时间(单位毫秒)
* @param { number } [interval = 1000] 间隔
* @returns
*/
const isSameTime = (time1: number, time2: number, interval: number = SECOND): boolean => {
Expand Down Expand Up @@ -186,7 +187,7 @@ export const useCountDown = (options: UseCountDownOptions): UseCountDownReturn =
/** 获取此次调用的剩余时间 */
const remainRemain = getCurrentRemain()

/** 同一个间隔才渲染 */
// 同一个间隔才渲染
if (
!isSameTime(remainRemain, remain.value, options.interval) ||
remainRemain === 0
Expand All @@ -202,10 +203,10 @@ export const useCountDown = (options: UseCountDownOptions): UseCountDownReturn =
})
}

/* 组件即将被卸载时,暂停倒计时 */
// 组件即将被卸载时,暂停倒计时
onBeforeUnmount(pause)

/* keep-alive时,从 deactive 到active状态下: 继续倒计时 */
// keep-alive时,从 deactive 到active状态下: 继续倒计时
onActivated(() => {
if (deactivated) {
isCounting = true
Expand All @@ -214,7 +215,7 @@ export const useCountDown = (options: UseCountDownOptions): UseCountDownReturn =
}
})

/* keep-alive时,deactive 状态下: 暂停倒计时 */
// keep-alive时,deactive 状态下: 暂停倒计时
onDeactivated(() => {
if (isCounting) {
pause()
Expand Down
12 changes: 6 additions & 6 deletions packages/fighting-design/_hooks/use-form-check/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ export const useFormCheck = (prop: FormProps): UseFormCheckReturn => {

/** 获取到所有子节点 vNode */
const getChildrenList = computed((): VNode[] => {
/** 如果没有插槽内容,返回空数组 */
// 如果没有插槽内容,返回空数组
if (!slot.default) return []

/** 获取到所有子节点元素 */
const children = getChildren(slot.default(), 'FFormItem')

/** 遍历添每个节点判断是否验证通过 */
// 遍历添每个节点判断是否验证通过
children.forEach((item: VNode): void => {
/** 必须有 name 和 rules 才能触发表单校验 */
// 必须有 name 和 rules 才能触发表单校验
if (item.props && item.props.name && item.props.rules) {
/** 初始状态下默认设置全部没有通过校验 */
// 初始状态下默认设置全部没有通过校验
childrenCheckResult[item.props.name] = false
}
})
Expand Down Expand Up @@ -109,7 +109,7 @@ export const useFormCheck = (prop: FormProps): UseFormCheckReturn => {
/** 子组件名字 */
const _name: FormItemProps['name'] = item.props && item.props.name

/** 判断的每个自组件必须有 rules 和 name 参数 */
// 判断的每个自组件必须有 rules 和 name 参数
if (item.props && _rules && _name && prop.model) {
/** 检测父组件绑定的对象上是否存在子组件绑定的 name 属性 */
if (_name in prop.model) {
Expand All @@ -121,7 +121,7 @@ export const useFormCheck = (prop: FormProps): UseFormCheckReturn => {

childrenCheckResult[_name] = msg
} else {
/** xxx 不是有效的 `name` 参数 */
// xxx 不是有效的 `name` 参数
warning('f-form-item', `${_name} is not a valid \`name\` parameter`)
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/fighting-design/_hooks/use-global/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const useGlobal = (prop?: Partial<UseGlobalProp>): UseGlobalReturn => {
return def as FightingType
}

/** 如果校验不通过则返回默认值 */
// 如果校验不通过则返回默认值
if (prop.type && !FIGHTING_TYPE.includes(prop.type)) {
return def as FightingType
}
Expand Down Expand Up @@ -115,7 +115,7 @@ export const useGlobal = (prop?: Partial<UseGlobalProp>): UseGlobalReturn => {
const lang: FightingLang = (global && global.lang) || 'zh-CN'
/** 获取当前的语音对象 */
const langList = LANG[lang]
/** 返回指定组件的语言内容 */
// 返回指定组件的语言内容
return langList[componentName]
})
}
Expand Down
2 changes: 1 addition & 1 deletion packages/fighting-design/_hooks/use-input/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export interface UseInputReturn {
* @author Tyh2001 <https://github.com/Tyh2001>
* @param { Object } prop 组件的 props 参数
* @param { Function } emit 回调参数
* @returns { Object }
* @returns
*/
export const useInput = (
prop: Partial<UseInputProps>,
Expand Down
10 changes: 5 additions & 5 deletions packages/fighting-design/_hooks/use-list/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const useList = <T extends object>(prop: T, name: string): UseListReturn
/** 过滤得到 prop 集合 */
const propList: Record<string, unknown> = filter(list)

/** 是否存在其它需要直接加入的类名 */
// 是否存在其它需要直接加入的类名
className && classList.value.push(className)

for (const key in propList) {
Expand Down Expand Up @@ -93,20 +93,20 @@ export const useList = <T extends object>(prop: T, name: string): UseListReturn
key: string,
pixel: boolean | string | string[] = true
): string | number => {
/** 如果需要添加单位,则所有的数字都添加单位 */
// 如果需要添加单位,则所有的数字都添加单位
if (isBoolean(pixel)) {
return (isNumber(val) ? (pixel ? sizeChange(val) : val) : val) as string | number
} else if (isString(pixel)) {
/** 如果为字符串类型,则代表仅仅有一个不需要添加单位 */
// 如果为字符串类型,则代表仅仅有一个不需要添加单位
if (pixel === key) return val
} else if (isArray(pixel)) {
/** 如果为数组类型,则代表有些值不需要添加单位,循环遍历处理 */
// 如果为数组类型,则代表有些值不需要添加单位,循环遍历处理
for (const item of pixel) {
if (item === key) return val
}
}

/** 没有进入判断则默认添加 */
// 没有进入判断则默认添加
return sizeChange(val)
}

Expand Down
14 changes: 7 additions & 7 deletions packages/fighting-design/_hooks/use-load-img/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const useLoadImg = (
/** 创建一个新的 img 元素 */
const el: HTMLImageElement = new Image()

/** 待优化,Promise 可能会有不兼容 */
// 待优化,Promise 可能会有不兼容
new Promise((resolve, reject): void => {
el.src = errSrc || prop.src

Expand All @@ -113,19 +113,19 @@ export const useLoadImg = (
reject(evt)
})
})
/** 加载成功 */
// 加载成功
.then(evt => {
evt && success(node, evt as Event, el.src)
})
/** 加载失败 */
// 加载失败
.catch(evt => {
/** 如果没有加载过 errSrc,并且 errSrc 存在,则继续加载 */
// 如果没有加载过 errSrc,并且 errSrc 存在,则继续加载
if (!isLoadErrSrc && prop.errSrc) {
load(node, prop.errSrc)
isLoadErrSrc = true
return
}
/** 否则调用失败方法 */
// 否则调用失败方法
failure(evt)
})
}
Expand Down Expand Up @@ -220,7 +220,7 @@ export const useLoadImg = (
}
}

/** 开始监听滚动事件 */
// 开始监听滚动事件
window && window.addEventListener('scroll', listerScroll)
}

Expand Down Expand Up @@ -266,7 +266,7 @@ export const useLoadImg = (
startLoad()
})

/** 监视 src 的变化重新加载图片 */
// 监视 src 的变化重新加载图片
watch(
(): string => prop.src,
(): void => {
Expand Down
4 changes: 2 additions & 2 deletions packages/fighting-design/_hooks/use-offset/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ export const useOffset = (
let parent: Element | null = el.offsetParent

while (parent !== null) {
/** 累加左边距 */
// 累加左边距
left += (parent as HTMLElement).offsetLeft
/** 依次获取父元素 */
// 依次获取父元素
parent = (parent as HTMLElement).offsetParent
}

Expand Down
4 changes: 2 additions & 2 deletions packages/fighting-design/_hooks/use-page/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const usePage = (
/** 结果数组 */
const pageList: number[] = []

/** 如果最大页码数 > 当前页码超过多少需要展示省略号 */
// 如果最大页码数 > 当前页码超过多少需要展示省略号
if (maxCount.value > pagerCount) {
if (prop.current > pagerCount - halfPagerCount) {
showPrevMore = true
Expand All @@ -80,7 +80,7 @@ export const usePage = (
showNextMore = true
}
} else {
// 如果最大页码数小于 当前输入的pagerCount.
// 如果最大页码数小于 当前输入的pagerCount
for (let i = 2; i < maxCount.value; i++) {
pageList.push(i)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/fighting-design/_hooks/use-ripples/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const useRipples = (
ripples.style.background = ripplesColor.value
ripples.style.left = `${x}px`

/** 如果是按钮,则需要添加容器 */
// 如果是按钮,则需要添加容器
if (options.component === 'f-button') {
/** 创建一个容器元素 */
const box: HTMLDivElement = document.createElement('div')
Expand Down
8 changes: 4 additions & 4 deletions packages/fighting-design/_hooks/use-trigger/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ export const useTrigger = (
}
}

/** 挂载之后给元素添加事件监听器 */
// 挂载之后给元素添加事件监听器
onMounted(addEventListener)

/** 状态改变时重新添加事件监听器 */
// 状态改变时重新添加事件监听器
watch((): TriggerTrigger => prop.trigger, addEventListener)

/**
Expand All @@ -196,10 +196,10 @@ export const useTrigger = (
return
}

/** 否则关闭触发器 */
// 否则关闭触发器
close(evt)

/** 关闭之后移除事件监听 */
// 关闭之后移除事件监听
window.removeEventListener('click', documentListen, true)
window.removeEventListener('resize', setPosition)
}
Expand Down
8 changes: 4 additions & 4 deletions packages/fighting-design/_hooks/use-turn-page/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const useTurnPage = (
const selectChange = (newValue: SelectModelValue): void => {
const maxValue: number = Math.ceil(prop.total / Number(newValue))

/** 如果当前用户选择的值是大于总页数的,那么直接将总页数的最大值赋值给 current */
// 如果当前用户选择的值是大于总页数的,那么直接将总页数的最大值赋值给 current
if (prop.current > maxValue) {
modelValue.currentModelValue.value = maxValue
}
Expand All @@ -78,7 +78,7 @@ export const useTurnPage = (
const handleInput = (): void => {
if (prop.disabled) return

/** 如果输入的值大于最大值 */
// 如果输入的值大于最大值
if (Number(jumpCurrent.value) > pages.value.length) {
jumpCurrent.value = String(pages.value.length)
}
Expand All @@ -94,13 +94,13 @@ export const useTurnPage = (
* @param { Object } evt 事件对象
*/
const handelClick = (evt: MouseEvent): void => {
/** 禁用状态直接返回 */
// 禁用状态直接返回
if (prop.disabled) return

/** 当前点击的元素节点 */
const target: HTMLElement = evt.target as HTMLElement

/** 判断点击的是否为子节点 */
// 判断点击的是否为子节点
if (target.className.includes(PAGINATION_ITEM)) {
/** 最新的页数 */
let newPage = Number(target.textContent)
Expand Down
4 changes: 2 additions & 2 deletions packages/fighting-design/_utils/compatible/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ export const objectEntries = <T extends object>(obj: T): [keyof T, T[keyof T]][]
if (typeof obj !== 'object' || obj === null) {
warning('objectEntries', 'Parameter is not an object type.')

/** 如果不是对象类型 返回空数组 */
// 如果不是对象类型 返回空数组
return []
}

/** 如果 Object.entries 存在则直接使用 */
// 如果 Object.entries 存在则直接使用
if (Object.entries && Object.entries !== undefined) {
return Object.entries(obj) as [keyof T, T[keyof T]][]
}
Expand Down
2 changes: 1 addition & 1 deletion packages/fighting-design/_utils/get-children/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { Component, VNode } from 'vue'
export const getChildren = (children: VNode[], componentName: string): VNode[] => {
let components: VNode[] = []

/** 传入的子节点必须是一个有效数组 */
// 传入的子节点必须是一个有效数组
if (isArray(children) && children.length) {
children.forEach((child: VNode): void => {
/** 获取到每个组件的 name */
Expand Down
2 changes: 1 addition & 1 deletion packages/fighting-design/avatar-group/src/avatar-group.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
}
}
/** dom 挂载之后设置样式 */
// dom 挂载之后设置样式
onMounted(setZIndexStyle)
/** 样式列表 */
Expand Down
Loading

0 comments on commit f5970b9

Please sign in to comment.