diff --git a/zh-cn/application-dev/reference/apis/js-apis-batteryStatistics.md b/zh-cn/application-dev/reference/apis/js-apis-batteryStatistics.md index a91de5d9d68aa7659d7d85f24062f78300449ffc..04bc3142fc509ec4385373a29fedfd6dcba79183 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-batteryStatistics.md +++ b/zh-cn/application-dev/reference/apis/js-apis-batteryStatistics.md @@ -42,10 +42,10 @@ getBatteryStats(): Promise ```js batteryStats.getBatteryStats() -.then(data => { +.then((data: batteryStats.BatteryStatsInfo[]) => { console.info('battery statistics info: ' + data); }) -.catch(err => { +.catch((err: { code: number, message: string }) => { console.error('get battery statistics failed, err: ' + err); }); ``` @@ -77,7 +77,7 @@ getBatteryStats(callback: AsyncCallback): void **示例:** ```js -batteryStats.getBatteryStats((err, data) => { +batteryStats.getBatteryStats((err: BusinessError, data: batteryStats.BatteryStatsInfo[]) => { if (typeof err === 'undefined') { console.info('battery statistics info: ' + data); } else { @@ -120,7 +120,7 @@ getAppPowerValue(uid: number): number ```js try { - var value = batteryStats.getAppPowerValue(10021); + let value = batteryStats.getAppPowerValue(10021); console.info('battery statistics value of app is: ' + value); } catch(err) { console.error('get battery statistics value of app failed, err: ' + err); @@ -161,7 +161,7 @@ getAppPowerPercent(uid: number): number ```js try { - var percent = batteryStats.getAppPowerPercent(10021); + let percent = batteryStats.getAppPowerPercent(10021); console.info('battery statistics percent of app is: ' + percent); } catch(err) { console.error('get battery statistics percent of app failed, err: ' + err); @@ -202,7 +202,7 @@ getHardwareUnitPowerValue(type: ConsumptionType): number ```js try { - var value = batteryStats.getHardwareUnitPowerValue(batteryStats.ConsumptionType.CONSUMPTION_TYPE_SCREEN); + let value = batteryStats.getHardwareUnitPowerValue(batteryStats.ConsumptionType.CONSUMPTION_TYPE_SCREEN); console.info('battery statistics value of hardware is: ' + value); } catch(err) { console.error('get battery statistics percent of hardware failed, err: ' + err); @@ -243,7 +243,7 @@ getHardwareUnitPowerPercent(type: ConsumptionType): number ```js try { - var percent = batteryStats.getHardwareUnitPowerPercent(batteryStats.ConsumptionType.CONSUMPTION_TYPE_SCREEN); + let percent = batteryStats.getHardwareUnitPowerPercent(batteryStats.ConsumptionType.CONSUMPTION_TYPE_SCREEN); console.info('battery statistics percent of hardware is: ' + percent); } catch(err) { console.error('get battery statistics percent of hardware failed, err: ' + err); diff --git a/zh-cn/application-dev/reference/apis/js-apis-power.md b/zh-cn/application-dev/reference/apis/js-apis-power.md index 176a4548a2d3fb281d3381a413a19a225f45dc05..eeef1d1f6f8d955e8c9690f497f13f7e998ca339 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-power.md +++ b/zh-cn/application-dev/reference/apis/js-apis-power.md @@ -104,7 +104,7 @@ isActive(): boolean ```js try { - var isActive = power.isActive(); + let isActive = power.isActive(); console.info('power is active: ' + isActive); } catch(err) { console.error('check active status failed, err: ' + err); @@ -206,7 +206,7 @@ getPowerMode(): DevicePowerMode ```js try { - var mode = power.getPowerMode(); + let mode = power.getPowerMode(); console.info('power mode: ' + mode); } catch(err) { console.error('get power mode failed, err: ' + err); @@ -243,7 +243,7 @@ setPowerMode(mode: DevicePowerMode, callback: AsyncCallback<void>): void **示例:** ```js -power.setPowerMode(power.DevicePowerMode.MODE_PERFORMANCE, err => { +power.setPowerMode(power.DevicePowerMode.MODE_PERFORMANCE, (err: BusinessError) => { if (typeof err === 'undefined') { console.info('set power mode to MODE_PERFORMANCE'); } else { @@ -322,7 +322,7 @@ isStandby(): boolean ```js try { - var isStandby = power.isStandby(); + let isStandby = power.isStandby(); console.info('device is in standby: ' + isStandby); } catch(err) { console.error('check isStandby failed, err: ' + err); @@ -372,7 +372,7 @@ isScreenOn(callback: AsyncCallback<boolean>): void **示例:** ```js -power.isScreenOn((err, data) => { +power.isScreenOn((err: BusinessError, data: boolean) => { if (typeof err === 'undefined') { console.info('screen on status is ' + data); } else { @@ -400,10 +400,10 @@ isScreenOn(): Promise<boolean> ```js power.isScreenOn() -.then(data => { +.then((data: boolean) => { console.info('screen on status is ' + data); }) -.catch(err => { +.catch((err: { code: number, message: string }) => { console.error('check screen status failed, err: ' + err); }) ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-runninglock.md b/zh-cn/application-dev/reference/apis/js-apis-runninglock.md index 4c36b19d5855864abae10b690b643e3dd905e690..a8f0bf0788344273bc0ea208715d846bb084a334 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-runninglock.md +++ b/zh-cn/application-dev/reference/apis/js-apis-runninglock.md @@ -44,7 +44,7 @@ isSupported(type: RunningLockType): boolean; ```js try { - var isSupported = runningLock.isSupported(runningLock.RunningLockType.BACKGROUND); + let isSupported = runningLock.isSupported(runningLock.RunningLockType.BACKGROUND); console.info('BACKGROUND type supported: ' + isSupported); } catch(err) { console.error('check supported failed, err: ' + err); @@ -72,7 +72,7 @@ create(name: string, type: RunningLockType, callback: AsyncCallback<RunningLo **示例:** ```js -runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND, (err, lock) => { +runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND, (err: BusinessError, lock: runningLock.RunningLock) => { if (typeof err === 'undefined') { console.info('created running lock: ' + lock); } else { @@ -108,10 +108,10 @@ create(name: string, type: RunningLockType): Promise<RunningLock> ```js runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND) -.then(lock => { +.then((lock: runningLock.RunningLock) => { console.info('created running lock: ' + lock); }) -.catch(err => { +.catch((err: { code: number, message: string }) => { console.error('create running lock failed, error: ' + err); }); ``` @@ -136,7 +136,7 @@ isRunningLockTypeSupported(type: RunningLockType, callback: AsyncCallback<boo **示例:** ```js -runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.BACKGROUND, (err, data) => { +runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.BACKGROUND, (err: BusinessError, data: boolean) => { if (typeof err === 'undefined') { console.info('BACKGROUND lock support status: ' + data); } else { @@ -171,10 +171,10 @@ isRunningLockTypeSupported(type: RunningLockType): Promise<boolean> ```js runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.BACKGROUND) -.then(data => { +.then((data: boolean) => { console.info('BACKGROUND lock support status: ' + data); }) -.catch(err => { +.catch((err: { code: number, message: string }) => { console.log('check BACKGROUND lock support status failed, err: ' + err); }); ``` @@ -202,7 +202,7 @@ createRunningLock(name: string, type: RunningLockType, callback: AsyncCallback&l **示例:** ```js -runningLock.createRunningLock('running_lock_test', runningLock.RunningLockType.BACKGROUND, (err, lock) => { +runningLock.createRunningLock('running_lock_test', runningLock.RunningLockType.BACKGROUND, (err: BusinessError, lock: runningLock.RunningLock) => { if (typeof err === 'undefined') { console.info('created running lock: ' + lock); } else { @@ -240,10 +240,10 @@ createRunningLock(name: string, type: RunningLockType): Promise<RunningLock&g ```js runningLock.createRunningLock('running_lock_test', runningLock.RunningLockType.BACKGROUND) -.then(lock => { +.then((lock: runningLock.RunningLock) => { console.info('created running lock: ' + lock); }) -.catch(err => { +.catch((err: { code: number, message: string }) => { console.log('create running lock failed, err: ' + err); }); ``` @@ -280,7 +280,7 @@ hold(timeout: number): void ```js runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND) -.then(lock => { +.then((lock: runningLock.RunningLock) => { console.info('create running lock success'); try { lock.hold(500); @@ -289,7 +289,7 @@ runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND) console.error('hold running lock failed, err: ' + err); } }) -.catch(err => { +.catch((err: { code: number, message: string }) => { console.error('create running lock failed, err: ' + err); }); ``` @@ -316,7 +316,7 @@ unhold(): void ```js runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND) -.then(lock => { +.then((lock: runningLock.RunningLock) => { console.info('create running lock success'); try { lock.unhold(); @@ -325,7 +325,7 @@ runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND) console.error('unhold running lock failed, err: ' + err); } }) -.catch(err => { +.catch((err: { code: number, message: string }) => { console.error('create running lock failed, err: ' + err); }); ``` @@ -356,16 +356,16 @@ isHolding(): boolean ```js runningLock.create('running_lock_test', runningLock.RunningLockType.BACKGROUND) -.then(lock => { +.then((lock: runningLock.RunningLock) => { console.info('create running lock success'); try { - var isHolding = lock.isHolding(); + let isHolding = lock.isHolding(); console.info('check running lock holding status: ' + isHolding); } catch(err) { console.error('check running lock holding status failed, err: ' + err); } }) -.catch(err => { +.catch((err: { code: number, message: string }) => { console.error('create running lock failed, err: ' + err); }); ``` @@ -392,11 +392,11 @@ lock(timeout: number): void ```js runningLock.createRunningLock('running_lock_test', runningLock.RunningLockType.BACKGROUND) -.then(lock => { +.then((lock: runningLock.RunningLock) => { lock.lock(500); console.info('create running lock and lock success'); }) -.catch(err => { +.catch((err: { code: number, message: string }) => { console.error('create running lock failed, err: ' + err); }); ``` @@ -417,11 +417,11 @@ unlock(): void ```js runningLock.createRunningLock('running_lock_test', runningLock.RunningLockType.BACKGROUND) -.then(lock => { +.then((lock: runningLock.RunningLock) => { lock.unlock(); console.info('create running lock and unlock success'); }) -.catch(err => { +.catch((err: { code: number, message: string }) => { console.error('create running lock failed, err: ' + err); }); ``` @@ -445,11 +445,11 @@ isUsed(): boolean ```js runningLock.createRunningLock('running_lock_test', runningLock.RunningLockType.BACKGROUND) -.then(lock => { - var isUsed = lock.isUsed(); +.then((lock: runningLock.RunningLock) => { + let isUsed = lock.isUsed(); console.info('check running lock used status: ' + isUsed); }) -.catch(err => { +.catch((err: { code: number, message: string }) => { console.error('check running lock used status failed, err: ' + err); }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-battery.md b/zh-cn/application-dev/reference/apis/js-apis-system-battery.md index 73ea1bcd742e74becc93e926b300cc28ceb172ec..2f7408e1014b373c7f7036ef017e003387c8ce3d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-battery.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-battery.md @@ -33,10 +33,10 @@ getStatus(options?: GetStatusOptions): void; ```js battery.getStatus({ - success: function(data) { + success: (data: BatteryResponse) => { console.log('success get battery level:' + data.level); }, - fail: function(data, code) { + fail: (data: string, code: number) => { console.error('fail to get battery level code:' + code + ', data: ' + data); } }); diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-brightness.md b/zh-cn/application-dev/reference/apis/js-apis-system-brightness.md index 107005a04cff5e4087dbb1f2197d1bae7dc99655..b9cbd193e208ce61720e0184a5dc82bf666c96cb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-brightness.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-brightness.md @@ -34,11 +34,11 @@ getValue(options?: GetBrightnessOptions): void ```js brightness.getValue({ - success: function(data) { - console.log('success get brightness value:' + data.value); + success: (data: BrightnessResponse) => { + console.log('success get brightness value:' + data.value); }, - fail: function(data, code) { - console.error('get brightness fail, code: ' + code + ', data: ' + data); + fail: (data: string, code: number) => { + console.error('get brightness fail, code: ' + code + ', data: ' + data); } }); ``` @@ -63,11 +63,11 @@ setValue(options?: SetBrightnessOptions): void ```js brightness.setValue({ value: 100, - success: function() { - console.log('handling set brightness success.'); + success: () => { + console.log('handling set brightness success.'); }, - fail: function(data, code) { - console.error('handling set brightness value fail, code:' + code + ', data: ' + data); + fail: (data: string, code: number) => { + console.error('handling set brightness value fail, code:' + code + ', data: ' + data); } }); ``` @@ -91,11 +91,11 @@ getMode(options?: GetBrightnessModeOptions): void ```js brightness.getMode({ - success: function(data) { - console.log('success get mode:' + data.mode); + success: (data: BrightnessModeResponse) => { + console.log('success get mode:' + data.mode); }, - fail: function(data, code){ - console.error('handling get mode fail, code:' + code + ', data: ' + data); + fail: (data: string, code: number) => { + console.error('handling get mode fail, code:' + code + ', data: ' + data); } }); ``` @@ -119,11 +119,11 @@ setMode(options?: SetBrightnessModeOptions): void ```js brightness.setMode({ mode: 1, - success: function() { - console.log('handling set mode success.'); + success: () => { + console.log('handling set mode success.'); }, - fail: function(data, code) { - console.error('handling set mode fail, code:' + code + ', data: ' + data); + fail: (data: string, code: number) => { + console.error('handling set mode fail, code:' + code + ', data: ' + data); } }); ``` @@ -150,11 +150,11 @@ setKeepScreenOn(options?: SetKeepScreenOnOptions): void ```js brightness.setKeepScreenOn({ keepScreenOn: true, - success: function () { - console.log('handling set keep screen on success.'); + success: () => { + console.log('handling set keep screen on success.'); }, - fail: function (data, code) { - console.error('handling set keep screen on fail, code:' + code + ', data: ' + data); + fail: (data: string, code: number) => { + console.error('handling set keep screen on fail, code:' + code + ', data: ' + data); } }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-thermal.md b/zh-cn/application-dev/reference/apis/js-apis-thermal.md index 21027cf5284dc2a203f47f92191e36a128e66c21..5649a6a2cf6c48157abb05e144a7300ca5cc5a95 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-thermal.md +++ b/zh-cn/application-dev/reference/apis/js-apis-thermal.md @@ -38,7 +38,7 @@ registerThermalLevelCallback(callback: Callback<ThermalLevel>): void ```js try { - thermal.registerThermalLevelCallback(level => { + thermal.registerThermalLevelCallback((level: thermal.ThermalLevel) => { console.info('thermal level is: ' + level); }); console.info('register thermal level callback success.'); @@ -108,7 +108,7 @@ getLevel(): ThermalLevel ```js try { - var level = thermal.getLevel(); + let level = thermal.getLevel(); console.info('thermal level is: ' + level); } catch(err) { console.error('get thermal level failed, err: ' + err); @@ -134,7 +134,7 @@ subscribeThermalLevel(callback: AsyncCallback<ThermalLevel>): void **示例:** ```js -thermal.subscribeThermalLevel((level) => { +thermal.subscribeThermalLevel((err: BusinessError, level: thermal.ThermalLevel) => { console.info('thermal level is: ' + level); }); ``` @@ -182,7 +182,7 @@ getThermalLevel(): ThermalLevel **示例:** ```js -var level = thermal.getThermalLevel(); +let level = thermal.getThermalLevel(); console.info('thermal level is: ' + level); ```