Skip to content

Commit

Permalink
style: 全局格式化
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyh2001 committed Mar 1, 2024
1 parent 5379202 commit 9204684
Show file tree
Hide file tree
Showing 22 changed files with 57 additions and 53 deletions.
2 changes: 1 addition & 1 deletion 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
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export interface UseCollapseAnimationReturn {
/**
* 对于 Collapse Animation 折叠动画样式处理
*
* @param prop prop 参数
* @returns
* @param { Object } prop prop 参数
*/
export const useCollapseAnimation = (
prop: CollapseAnimationProps
Expand Down
4 changes: 1 addition & 3 deletions packages/fighting-design/_hooks/use-confirm-box/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ export interface UseConfirmBoxReturn {
*
* @author Tyh2001 <https://github.com/Tyh2001>
* @param { Object } component 组件实例
* @returns
*/
export const useConfirmBox = (component: Component): UseConfirmBoxReturn => {
/**
* 创建组件
*
* @param { Object } options 配置参数
* @returns
*/
const create = (options: Partial<ConfirmBoxProps>): ComponentInternalInstance => {
const vNode = h(component, options)
Expand All @@ -39,7 +37,7 @@ export const useConfirmBox = (component: Component): UseConfirmBoxReturn => {
* 暴露出去的方法
*
* @param { Object } options 配置对象
* @returns
*/
const confirmBox = (options: Partial<ConfirmBoxProps>): ComponentInternalInstance => {
return create(reactive({ ...options, show: true }))
Expand Down
8 changes: 4 additions & 4 deletions packages/fighting-design/_hooks/use-count-down/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,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 => {
return Math.floor(time1 / interval) === Math.floor(time2 / interval)
Expand Down Expand Up @@ -203,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 @@ -215,7 +215,7 @@ export const useCountDown = (options: UseCountDownOptions): UseCountDownReturn =
}
})

// keep-alive时,deactive 状态下: 暂停倒计时
// keep-alive时,deactive 状态下: 暂停倒计时
onDeactivated(() => {
if (isCounting) {
pause()
Expand Down
36 changes: 24 additions & 12 deletions packages/fighting-design/_hooks/use-form-check/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { reactive, computed, useSlots } from 'vue'
import { getChildren, isArray, isString, isObject, warning, splitString, isTrue, isNumber, toString } from '../../_utils'
import {
getChildren,
isArray,
isString,
isObject,
warning,
splitString,
isNumber
} from '../../_utils'
import type { FormProps } from '../../form'
import type { VNode, Slots } from 'vue'
import type { FormItemRules, FormItemRulesItem, FormItemProps } from '../../form-item'
Expand All @@ -19,7 +27,6 @@ export interface UseFormCheckReturn {
* form 表单校验方法
*
* @param { Object } prop prop 参数
* @returns
*/
export const useFormCheck = (prop: FormProps): UseFormCheckReturn => {
/** 子节点校验结果 */
Expand Down Expand Up @@ -80,15 +87,17 @@ export const useFormCheck = (prop: FormProps): UseFormCheckReturn => {

return !(
// 必填项
(ruleItem.required && !value) ||
// 设置最大输入长度
(ruleItem.max && length > ruleItem.max) ||
// 设置最小输入长度
(ruleItem.min && length < ruleItem.min) ||
// 设置正则校验
(ruleItem.regExp && !ruleItem.regExp.test(value)) ||
// 自定义校验方法
(ruleItem.validator && !ruleItem.validator())
(
(ruleItem.required && !value) ||
// 设置最大输入长度
(ruleItem.max && length > ruleItem.max) ||
// 设置最小输入长度
(ruleItem.min && length < ruleItem.min) ||
// 设置正则校验
(ruleItem.regExp && !ruleItem.regExp.test(value)) ||
// 自定义校验方法
(ruleItem.validator && !ruleItem.validator())
)
)
}

Expand Down Expand Up @@ -144,7 +153,10 @@ export const useFormCheck = (prop: FormProps): UseFormCheckReturn => {
}

/** 获取到规则校验的信息 */
const msg: string | boolean = checkRuleMassage(modelKeyVal as unknown as string, _rules)
const msg: string | boolean = checkRuleMassage(
modelKeyVal as unknown as string,
_rules
)

childrenCheckResult[_name] = msg
}
Expand Down
1 change: 0 additions & 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,6 @@ export interface UseInputReturn {
* @author Tyh2001 <https://github.com/Tyh2001>
* @param { Object } prop 组件的 props 参数
* @param { Function } emit 回调参数
* @returns
*/
export const useInput = (
prop: Partial<UseInputProps>,
Expand Down
3 changes: 1 addition & 2 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,6 @@ export const useLoadImg = (
/** 创建一个新的 img 元素 */
const el: HTMLImageElement = new Image()

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

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

// 监视 src 的变化重新加载图片
// 监视 src 的变化重新加载图片
watch(
(): string => prop.src,
(): void => {
Expand Down
1 change: 0 additions & 1 deletion packages/fighting-design/_hooks/use-lunar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export type UseLunarReturn = (
* 农历方法
*
* @author Tyh2001 <https://github.com/Tyh2001>
* @returns
*/
export const useLunar = (): UseLunarReturn => {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/fighting-design/_hooks/use-message/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const getNextElementInterval = (instance: ComponentInternalInstance): number =>
* 更新组件偏移量
*
* @param { Object } closeInstance 组件实例
* @returns
*/
const updatePosition = (closeInstance: ComponentInternalInstance): void => {
/** 获取当前组件实例索引值 */
Expand Down
2 changes: 1 addition & 1 deletion packages/fighting-design/_hooks/use-page/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const usePage = (
/** 结果数组 */
const pageList: number[] = []

// 如果最大页码数 > 当前页码超过多少需要展示省略号
// 如果最大页码数 > 当前页码超过多少需要展示省略号
if (maxCount.value > pagerCount) {
if (prop.current > pagerCount - halfPagerCount) {
showPrevMore = true
Expand Down
1 change: 0 additions & 1 deletion packages/fighting-design/_hooks/use-watermark/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export interface UseWatermarkReturn {
* 生成水印图片
*
* @param { Object } prop prop 参数
* @returns
*/
export const useWatermark = (prop: WatermarkProps): ComputedRef<UseWatermarkReturn> => {
return computed((): UseWatermarkReturn => {
Expand Down
9 changes: 4 additions & 5 deletions packages/fighting-design/_utils/is/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ export const isObject = is('Object')
* @param { * } value 要检测的值
* @returns { boolean }
*/
export const isFunction = (value: any): value is Function =>
typeof value === 'function'
export const isFunction = (value: any): value is Function => typeof value === 'function'

/**
* 判断一个值是否为 array 类型
Expand All @@ -67,8 +66,8 @@ export const isBrowser: boolean = typeof window !== 'undefined'

/**
* 是否为真值
*
* @param { * } value 检测的值
*
* @param { * } value 检测的值
* @returns { boolean }
*/
export const isTrue = (value: any): boolean => {
Expand All @@ -77,4 +76,4 @@ export const isTrue = (value: any): boolean => {
}

return true
}
}
2 changes: 1 addition & 1 deletion packages/fighting-design/_utils/type/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { toString: _toString } = Object.prototype

/**
* 转换为字符串
*
*
* @param { * } value 数据
* @returns { string }
*/
Expand Down
4 changes: 2 additions & 2 deletions packages/fighting-design/_utils/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ export const convertFormat = (str: string): string => {

/**
* 将字符串通过指定规则分隔
*
*
* @param { string } str 字符串
* @param { string } rule 规则字符串
* @returns { Array }
*/
export const splitString = (str: string, rule: string): string[] => {
return str.split(rule)
}
}
1 change: 0 additions & 1 deletion packages/fighting-design/calendar/src/calendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@
*
* @param { number } month 月份
* @param { number } date 日期
* @returns
*/
const currentDataClass = (month: number, date: number): string => {
/** 如果当前的月份和日期和绑定的日期相同,则高亮显示 */
Expand Down
2 changes: 1 addition & 1 deletion packages/fighting-design/form/src/form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
})
)
// 向外界导出一些方法
// 向外界导出一些方法
defineExpose({ submit, validate })
</script>

Expand Down
2 changes: 1 addition & 1 deletion packages/fighting-design/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@
},
"homepage": "https://fighting.tianyuhao.cn",
"repository": "https://github.com/FightingDesign/fighting-design"
}
}
16 changes: 8 additions & 8 deletions packages/fighting-design/table/src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ export type TableRenderReturn = VNode<RendererNode, RendererElement, Record<stri

/**
* 自定义模板函数渲染类型
*
*
* 详情参考
*
*
* @see h() https://cn.vuejs.org/api/render-function.html
*
*
* @param { string | Object } type 类型
* @param { Object } props props 传参数
* @param { Object } children 子节点
Expand All @@ -35,7 +35,7 @@ export type TableRender = (

/**
* 渲染内容自定义模板方法类型
*
*
* @param { Function } h 渲染函数
* @param { Object } row 行的每一项
* @param { Object } column 列的每一项
Expand All @@ -50,7 +50,7 @@ export type TableRenderData = (

/**
* 渲染标题自定义模板方法类型
*
*
* @param { Function } h 渲染函数
* @param { Object } item 每一项
* @param { number } index 当前行的索引
Expand All @@ -61,9 +61,9 @@ export type TableRenderTitle = (
index: number
) => TableRenderReturn

/**
/**
* 表格表头配置类型
*
*
* @param { string | Function } 标题
* @param { string } [key] 唯一值
* @param { number | string } [width] 宽度
Expand All @@ -78,7 +78,7 @@ export interface TableColumns {

/**
* 选择器改变触发的回调类型
*
*
* @param { Array } values 选中的数据集合
*/
export type TableSelect = (value: TableData) => void
2 changes: 1 addition & 1 deletion packages/fighting-playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"fflate": "^0.7.3"
},
"license": "MIT"
}
}
2 changes: 1 addition & 1 deletion vite.config.icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default (): UserConfigExport => {
cleanVueFileName: true, // 是否将 '.vue.d.ts' 文件名转换为 '.d.ts'
copyDtsFiles: false, // 是否将源码里的 .d.ts 文件复制到 outputDir
include: ['./packages/fighting-icon'], // 手动设置包含路径的 glob
/**
/**
* 构建后回调钩子
*/
afterBuild: (): void => {
Expand Down
4 changes: 2 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default (): UserConfigExport => {
cleanVueFileName: true, // 是否将 '.vue.d.ts' 文件名转换为 '.d.ts'
copyDtsFiles: true, // 是否将源码里的 .d.ts 文件复制到 outputDir
include: ['./packages/fighting-design'], // 手动设置包含路径的 glob
/**
/**
* 构建后回调钩子
*/
afterBuild: (): void => {
Expand Down Expand Up @@ -197,7 +197,7 @@ export default (): UserConfigExport => {
}
}

/**
/**
* 打包结束之后将一些静态文件进行移入
*/
const move = (): void => {
Expand Down
2 changes: 1 addition & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { UserConfigExport } from 'vite'
*/
export default (): UserConfigExport => {
return {
/**
/**
* 配置插件 vue,如果不配置则识别不了 vue 文件
*/
plugins: [
Expand Down

0 comments on commit 9204684

Please sign in to comment.