Skip to content

Commit

Permalink
docs: update
Browse files Browse the repository at this point in the history
  • Loading branch information
hemengke1997 committed Apr 18, 2024
1 parent 14754ea commit 5e80e5f
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions packages/istanbul-widget/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ import { IstanbulWidget } from 'istanbul-widget'

const istanbulWidget = new IstanbulWidget({
report: {
onAction: async (coverage) => {
console.log('上报', coverage)
onAction: async (coverage, config) => {
console.log('上报', coverage, config)
// 在这里你可以调用上报接口
// 如果接口报错,请在此抛出错误: throw new Error("你的错误信息")
},
},
})
Expand All @@ -37,6 +38,23 @@ interface IstanbulWidgetOptions {
* 挂载DOM,默认挂载到 body 上
*/
target?: string | HTMLElement
/**
* 按钮悬浮
*/
float?: {
offsetX?: number
}
/**
* 按钮默认位置
* @default
* ```js
* { x: 0, y: 0 }
* ```
*/
defaultPosition?: {
x?: number
y?: number
}
/**
* 插件就绪时回调
*/
Expand All @@ -48,36 +66,40 @@ interface IstanbulWidgetOptions {
/**
* 上报前触发
*/
beforeAction?: () => Promise<void> | void
beforeAction?: (coverage: any, config: Config) => Promise<void> | void
/**
* 上报方法
*/
onAction: (coverage: any) => Promise<void> | void
onAction: (coverage: any, config: Config) => Promise<void> | void
/**
* 上报后触发
*/
afterAction?: () => Promise<void> | void
afterAction?: (coverage: any, config: Config) => Promise<void> | void
/**
* 自动上报
*/
auto?:
| {
/**
* 自动上报间隔
* @default 60
*/
interval?: number
/**
* 最小间隔时间
* @default 60
*/
minInterval?: number
}
| boolean
/**
* 离开页面时是否提交一次上报
* @default true
*/
onLeavePage?: boolean
/**
* 是否需要填写上报人
* @default false
*/
requireReporter?: boolean
}
Expand Down

0 comments on commit 5e80e5f

Please sign in to comment.