-
Notifications
You must be signed in to change notification settings - Fork 0
/
system.battery.d.ts
63 lines (58 loc) · 1.5 KB
/
system.battery.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/// <reference path="./types.d.ts"/>
/**
* 电量信息 battery
* @后台运行限制 无限制。后台运行详细用法参见后台运行 脚本。
* @see https://doc.quickapp.cn/features/system/battery.html
*/
declare module '@system.battery' {
interface Battery {
/**
* 获取当前设备的电量信息。
* @example
* ```js
* battery.getStatus({
* success: function(data) {
* console.log(`handling success: ${data.level}`)
* },
* fail: function(data, code) {
* console.log(`handling fail, code = ${code}`)
* }
* })
* ```
*/
getStatus(OBJECT: GetStatusOBJECT): any;
}
/**
*
* @param success 成功回调[可选]
* @param fail 失败回调[可选]
* @param complete 执行结束后的回调[可选]
*/
interface GetStatusOBJECT {
success?: GetStatusOBJECTSuccessCB;
fail?: Function;
complete?: Function;
}
/**
* 成功回调
*/
type GetStatusOBJECTSuccessCB = (
successArg: GetStatusSuccessSuccessArg
) => any;
/**
* 成功回调
* @param charging 是否正在充电[可选]
* @param level 当前电量,0.0 - 1.0 之间[可选]
*/
interface GetStatusSuccessSuccessArg {
charging?: Boolean;
level?: Number;
}
/**
* 电量信息 battery
* @后台运行限制 无限制。后台运行详细用法参见后台运行 脚本。
* @see https://doc.quickapp.cn/features/system/battery.html
*/
const battery: Battery;
export default battery;
}