Skip to content

Commit

Permalink
style: 全局格式化
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyh2001 committed Aug 25, 2023
1 parent d3c67dc commit e39ed35
Show file tree
Hide file tree
Showing 17 changed files with 96 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/.vitepress/dist
publish_branch: gh-pages # 将部署到 gh-pages 分支
publish_branch: gh-pages # 将部署到 gh-pages 分支
3 changes: 2 additions & 1 deletion docs/.vitepress/config/head.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export const head: HeadConfig[] = [
'meta',
{
property: 'og:image',
content: 'https://raw.githubusercontent.com/Tyh2001/images/4ad62a8f00aa2473deca61598f307430d8d4a4cf/fighting-design/FightingDesign.svg'
content:
'https://raw.githubusercontent.com/Tyh2001/images/4ad62a8f00aa2473deca61598f307430d8d4a4cf/fighting-design/FightingDesign.svg'
}
],
/** OG 描述 */
Expand Down
2 changes: 1 addition & 1 deletion docs/.vitepress/json/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -361,4 +361,4 @@
"url": "components/confirm-box"
}
]
}
}
10 changes: 8 additions & 2 deletions docs/components/demos/avatar/demo1.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
</div>
<div class="avatar-block">
<code>contain</code>
<f-avatar fit="contain" src="https://avatars.githubusercontent.com/u/73180970?v=4" />
<f-avatar
fit="contain"
src="https://avatars.githubusercontent.com/u/73180970?v=4"
/>
</div>
<div class="avatar-block">
<code>cover</code>
Expand All @@ -18,7 +21,10 @@
</div>
<div class="avatar-block">
<code>scale-down</code>
<f-avatar fit="scale-down" src="https://avatars.githubusercontent.com/u/73180970?v=4" />
<f-avatar
fit="scale-down"
src="https://avatars.githubusercontent.com/u/73180970?v=4"
/>
</div>
</f-space>
</template>
Expand Down
17 changes: 14 additions & 3 deletions docs/components/image.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
</template>

```html
<f-image width="200px" src="https://raw.githubusercontent.com/Tyh2001/images/master/auto/1.jpg" />
<f-image
width="200px"
src="https://raw.githubusercontent.com/Tyh2001/images/master/auto/1.jpg"
/>
```

:::
Expand Down Expand Up @@ -99,7 +102,11 @@
</template>
```html
<f-image round="30px" height="190px" src="https://raw.githubusercontent.com/Tyh2001/images/master/auto/2.jpg" />
<f-image
round="30px"
height="190px"
src="https://raw.githubusercontent.com/Tyh2001/images/master/auto/2.jpg"
/>
```
:::
Expand All @@ -115,7 +122,11 @@
</template>
```html
<f-image lazy width="200px" src="https://raw.githubusercontent.com/Tyh2001/images/master/auto/3.jpg" />
<f-image
lazy
width="200px"
src="https://raw.githubusercontent.com/Tyh2001/images/master/auto/3.jpg"
/>
```
:::
Expand Down
4 changes: 3 additions & 1 deletion docs/components/watermark.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@

```html
<template>
<f-watermark image="https://raw.githubusercontent.com/Tyh2001/images/4ad62a8f00aa2473deca61598f307430d8d4a4cf/fighting-design/FightingDesign.svg">
<f-watermark
image="https://raw.githubusercontent.com/Tyh2001/images/4ad62a8f00aa2473deca61598f307430d8d4a4cf/fighting-design/FightingDesign.svg"
>
<f-card title="绝对机密">
<f-avatar round src="https://avatars.githubusercontent.com/u/73180970?v=4" />
<f-text block>这是一个重要的文件</f-text>
Expand Down
20 changes: 10 additions & 10 deletions packages/fighting-design/_hooks/use-calendar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ export const useCalendar = (prop: CalendarProps): UseCalendarReturn => {

/**
* 获取指定月份的天数
*
*
* @param { number } year 年份
* @param { number } month 月份
* @returns
* @returns
*/
const getDaysInMonth = (year: number, month: number): number => {
const daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
Expand All @@ -56,18 +56,18 @@ export const useCalendar = (prop: CalendarProps): UseCalendarReturn => {

/**
* 获取指定年份指定月份的 1号是星期几
*
*
* @param { number } year 年份
* @param { number } month 月份
* @returns
* @returns
*/
const getFirstDayOfWeek = (year: number, month: number): number => {
/**
* 创建一个表示给定年份和月份的 Date 对象
*
* 月份要减 1,因为月份是从 0 开始计数的
*/
const firstDay = new Date(year, month - 1, 1) //
const firstDay = new Date(year, month - 1, 1) //

/** 获取当前月份1号是星期几,0 表示星期日,1 表示星期一,以此类推 */
const dayOfWeek = firstDay.getDay()
Expand All @@ -77,20 +77,20 @@ export const useCalendar = (prop: CalendarProps): UseCalendarReturn => {

/**
* 判断是否为闰年
*
*
* @param { number } year 年份
* @returns
* @returns
*/
const isLeapYear = (year: number): boolean => {
return (year % 4 === 0 && year % 100 !== 0) || (year % 400 === 0)
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0
}

/**
* 生成日历数组
*
*
* @param { number } year 年份
* @param { number } month 月份
* @returns
* @returns
*/
const generateCalendar = (year: number, month: number): GenerateCalendarItem[] => {
/** 日历详情 */
Expand Down
32 changes: 16 additions & 16 deletions packages/fighting-design/_hooks/use-collapse-animation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import type { CollapseAnimationProps } from '../../collapse-animation'

/**
* useCollapseAnimation 返回值类型接口
*
* @param { Function } onBeforeEnter 在开启动画之前
*
* @param { Function } onBeforeEnter 在开启动画之前
* @param { Function } onEnter 开启过渡前插入 DOM
* @param { Function } onAfterEnter 开启过渡完成
* @param { Function } onBeforeLeave 关闭动画之前
Expand All @@ -24,9 +24,9 @@ export interface UseCollapseAnimationReturn {

/**
* 对于 Collapse Animation 折叠动画样式处理
*
*
* @param prop prop 参数
* @returns
* @returns
*/
export const useCollapseAnimation = (
prop: CollapseAnimationProps
Expand All @@ -43,9 +43,9 @@ export const useCollapseAnimation = (

/**
* 在开启动画之前
*
*
* 给元素设置动画样式和默认宽高
*
*
* @param { Object } el 元素节点
*/
const onBeforeEnter = (el: Element): void => {
Expand All @@ -66,7 +66,7 @@ export const useCollapseAnimation = (

/**
* 开启过渡前插入 DOM
*
*
* @param { Object } el 元素节点
*/
const onEnter = (el: Element): void => {
Expand All @@ -76,9 +76,9 @@ export const useCollapseAnimation = (

/**
* 将元素的高度设置为元素内容高度的度量
*
*
* @see Element.scrollHeight https://developer.mozilla.org/zh-CN/docs/Web/API/Element/scrollHeight
*
*
* 如果需要高度过渡动画,则将高度设置为滚动高度,否则不做动画处理,设置 auto
*/
if (prop.heightAnimation) {
Expand All @@ -87,15 +87,15 @@ export const useCollapseAnimation = (
node.style.height = 'auto'
}

/**
/**
* 如果需要宽度过渡
*/
if (prop.widthAnimation) {
node.style.width = 'auto'

/**
* 获取到宽度
*
*
* @see Element.getBoundingClientRect() https://developer.mozilla.org/zh-CN/docs/Web/API/Element/getBoundingClientRect
*/
const width: number = node.getBoundingClientRect().width
Expand All @@ -104,7 +104,7 @@ export const useCollapseAnimation = (

/**
* offsetWidth 的访问行为会触发浏览器的重排
*
*
* @see HTMLElement.offsetWidth https://developer.mozilla.org/zh-CN/docs/Web/API/HTMLElement/offsetWidth
*/
node.offsetWidth
Expand All @@ -117,7 +117,7 @@ export const useCollapseAnimation = (

/**
* 开启过渡完成
*
*
* @param { Object } el 元素节点
*/
const onAfterEnter = (el: Element): void => {
Expand All @@ -132,7 +132,7 @@ export const useCollapseAnimation = (

/**
* 关闭动画之前
*
*
* @param { Object } el 元素节点
*/
const onBeforeLeave = (el: Element): void => {
Expand All @@ -155,7 +155,7 @@ export const useCollapseAnimation = (

/**
* 关闭动画离开之前
*
*
* @param { Object } el 元素节点
*/
const onLeave = (el: Element): void => {
Expand All @@ -174,7 +174,7 @@ export const useCollapseAnimation = (

/**
* 关闭动画结束之后
*
*
* @param { Object } el 元素节点
*/
const onAfterLeave = (el: Element): void => {
Expand Down
15 changes: 7 additions & 8 deletions packages/fighting-design/_hooks/use-confirm-box/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@ export interface UseConfirmBoxReturn {

/**
* 确认框组件方法
*
*
* @author Tyh2001 <https://github.com/Tyh2001>
* @param { Object } component 组件实例
* @returns
* @returns
*/
export const useConfirmBox = (component: Component): UseConfirmBoxReturn => {

/**
* 创建组件
*
*
* @param { Object } options 配置参数
* @returns
* @returns
*/
const create = (options: Partial<ConfirmBoxProps>): ComponentInternalInstance => {
const vNode = h(component, options)
Expand All @@ -38,9 +37,9 @@ export const useConfirmBox = (component: Component): UseConfirmBoxReturn => {

/**
* 暴露出去的方法
*
* @param { Object } options 配置对象
* @returns
*
* @param { Object } options 配置对象
* @returns
*/
const confirmBox = (options: Partial<ConfirmBoxProps>): ComponentInternalInstance => {
return create(reactive({ ...options, show: true }))
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 @@ -170,7 +170,6 @@ export const useLunar = (): UseLunarReturn => {
mPara: number,
dPara: number
): -1 | GetLunarDetailReturn => {

/**
* @see parseInt https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/parseInt
*/
Expand Down
6 changes: 3 additions & 3 deletions packages/fighting-design/_utils/props/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import type { PropType } from 'vue'
* 设置组件的 prop 参数
*
* @see 为组件的props标注类型 https://cn.vuejs.org/guide/typescript/options-api.html#typing-component-props
*
*
* 注意:你需要了解 null 和 undefined 的区别
*
*
* null 表示无对象 表示 no object
* undefined 表示空值 表示 no value
*
*
* 如果一个值将来可能会是一个对象,但是目前还不是,则使用 null,也就是说 Object 类型的默认值都需要使用 null
* 基本类型都使用 undefined 默认值
*/
Expand Down
7 changes: 6 additions & 1 deletion packages/fighting-design/confirm-box/src/props.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { setBooleanProp, setFunctionProp, setStringNumberProp, setStringProp } from '../../_utils'
import {
setBooleanProp,
setFunctionProp,
setStringNumberProp,
setStringProp
} from '../../_utils'
import type { ExtractPropTypes } from 'vue'
import type { HandleMouse, HandleChange } from '../../_interface'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ import { FExpandCard } from '../index'
import type { ExpandCardImageList } from '../index'

const imageList: ExpandCardImageList = [
{ url: 'https://raw.githubusercontent.com/Tyh2001/images/master/fighting-design/1.jpg', text: '1' },
{ url: 'https://raw.githubusercontent.com/Tyh2001/images/master/fighting-design/2.jpg', text: '2' }
{
url: 'https://raw.githubusercontent.com/Tyh2001/images/master/fighting-design/1.jpg',
text: '1'
},
{
url: 'https://raw.githubusercontent.com/Tyh2001/images/master/fighting-design/2.jpg',
text: '2'
}
]

describe('FExpandCard', () => {
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 @@ -60,4 +60,4 @@
},
"homepage": "https://fighting.tianyuhao.cn",
"repository": "https://github.com/FightingDesign/fighting-design"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { FightingIcon } from '../../../_interface'

/**
* 子数每一项的类型接口
*
*
* @param { string } label 标签
* @param { number } __level 层级
* @param { number | string } value 多选 checkbox 绑定的值
Expand Down
Loading

0 comments on commit e39ed35

Please sign in to comment.