1.0.5 • Published 5 years ago

log-progress v1.0.5

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

log-progress

theajack

一个简单,灵活且高度可配置的进度条插件。

A simple, flexible, and highly configurable progress bar plugin.

可以选择进度自动走动或手动走动

You can choose to move automatically or manually.

1.安装 Install
2.使用 Usage
2.1.引入 Import(#2.1 引入-Import)
2.2.配置 Configuration(#2.2 配置-Configuration)
2.3.自动 Automatically(#2.3 使用进度自动走动)
2.4.手动 Manually(#2.4 手动调整进度条)
2.5.complete & fail(#2.5 使用complete和fail方法)
2.6.oncomplete(#2.6 使用oncomplete属性)
3.API 列表 API List
3.1.方法 method(#3.1 方法列表:)
3.2.配置属性 Configuration(#3.2 配置属性列表:)

1.安装-Install

npm install log-progress

2.使用-Usage

2.1 引入-Import

2.2 配置-Configuration

2.3 使用进度自动走动

当使用默认配置,或设置 auto=true时,会启动一个自己走动的进度条
当使用auto=true时,参数time表示走动的间隔时间,参数add表示每次走动的值

2.3 Using the progress automatically

When using the default configuration, or setting auto=true, a self-propelled progress bar will be launched.
When using auto=true, the parameter time indicates the interval between moves, and the parameter add indicates the value of each walk.
效果图如下
The effect chart is as follows

progress

2.4 手动调整进度条

当设置 auto=false 时,进入手动模式,进度条不会自己走动,需要调用setValue() 方法手动调整进度条
当设置 auto=false 时,time参数和add参数不起作用。

2.4 Manually adjusting the progress bar

When setting auto=false, enter manual mode, the progress bar will not move by itself, you need to call the setValue() method to manually adjust the progress bar.
When setting auto=false, the time parameter and the add parameter do not work.
效果图如下
The effect chart is as follows

progress

2.5 使用complete和fail方法

使用complete方法可以提前成功完成进度
使用fail方法当进度无法完成时以失败的结果结束进度

2.5 Using the complete and fail methods

Using the complete method, you can successfully complete the progress in advance.
Using the fail method to end the progress with a failed result when the progress cannot be completed
complete 效果
complete effect

progress

fail 效果
fail effect

progress

2.6 使用oncomplete属性

使用oncomplete可以在进度条完成后触发一些操作

2.6 Using the oncomplete attribute

Use oncomplete to trigger some actions after the progress bar is completed.
oncomplete 效果
oncomplete effect

progress

3.Api 列表

3.1 方法列表:

3.Api list

3.1 method list:

中文:

方法参数返回值描述
config()object--配置一些基础信息
start()object--初始化或启动progress
pause()----初始化或启动progress
complete()string--完成一个进度
fail()string--以失败结束一个进度
setTitle()string--设置标题
setTime()number--设置进度条走动的间隔时间
setValue()number,stringnumber设置进度条的值,返回进度条的值第二个参数是info,详情见3.2
getValue()--number获取进度条的值
addValue()number,stringnumber增加进度条的值,返回进度条的值第二个参数是info,详情见3.2
setTotal()number--设置进度条的最大值
getTotal()--number获取进度条的最大值
getPercent()--number获取进度条百分比
setInfo()string--设置进度条的显示信息
isInit()--boolean获取进度条是否已经初始化
isPause()--boolean获取进度条是否处于暂停状态
isCompleted()--boolean获取进度是否已经完成

English:

methodargumentsreturndescription
config()object--Configure some basic information
start()object--Initialize or start progress
pause()----Initialize or start progress
complete()string--Complete a progress
fail()string--End a progress with failure
setTitle()string--Set Title
setTime()number--Set the interval at which the progress bar moves
setValue()number,stringnumberSet the value of the progress bar, return the value of the progress barThe second parameter is info, see 3.2
getValue()--numberGet the value of the progress bar
addValue()number,stringnumberIncrease the value of the progress bar, return the value of the progress barThe second parameter is info, see 3.2 for details.
setTotal()number--Set the maximum value of the progress bar
getTotal()--numberGet the maximum value of the progress bar
getPercent()--numberGet progress bar percentage
setInfo()string--Set the display information of the progress bar
isInit()--booleanGet the progress bar initialized
isPause()--booleanGet the progress bar in pause state
isCompleted()--booleanGet progress has been completed

3.2 配置属性列表:

3.2 Configuration attributes list:

中文:

属性类型缺省值描述
titlestring'Progress'进度条前面的标题
lengthnumber50进度条的长度
valuenumber0进度条起始值
totalnumber100进度条总值
autobooleantrue进度条是否自己走动
timenumber200进度条自己走动的间隔时间
ontickfunctionnull每次进度条走动的回调函数this:progress参数1:value,参数2:percent
oncompletefunctionnull进度条完成之后的回调函数this:progress
addnumber1进度条每次自己走动的值
showSpinbooleantrue是否在进度条前面加上一个旋转的动画和成功或失败的头部字符
filledCharstring'∎'已经完成的进度的字符
emptyCharstring'-'未完成的进度的字符
completeTitlestring'Progress Completed'进度完成的提示文字
failTitlestring'Progress Failed'进度失败的提示文字
infostring''在进度条下一行显示一些信息

English

attributetypedefaultdescription
titlestring'Progress'Title in front of the progress bar
lengthnumber50The length of the progress bar
valuenumber0progress bar start value
totalnumber100progress bar total value
autobooleantrueWhether the progress bar walks by itself
timenumber200Interval time of the progress bar itself
ontickfunctionnullCallback function for each progress barthis:progressParameter 1:value, parameter 2:percent
oncompletefunctionnullcallback function after progress bar completionthis:progress
addnumber1The value of the progress bar each time you walk around
showSpinbooleantrueIs there a rotating animation and a successful or failed header character in front of the progress bar
filledCharstring'∎'Character of completed progress
emptyCharstring'-'Unfinished progress characters
completeTitlestring'Progress Completed'Tips for progress completion
failTitlestring'Progress Failed'Tips for progress failure
infostring''Show some information in the next line of the progress bar