diff --git a/zh-cn/application-dev/reference/apis/js-apis-screen-lock.md b/zh-cn/application-dev/reference/apis/js-apis-screen-lock.md index 50c56fb4b526a3ffdd70bdc9f20b8a431dd1810a..135127890f755216c91187f4e9c81d5e8e1f3c4e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-screen-lock.md +++ b/zh-cn/application-dev/reference/apis/js-apis-screen-lock.md @@ -9,7 +9,7 @@ ## 导入模块 ```js -import screenlock from '@ohos.screenLock'; +import screenLock from '@ohos.screenLock'; ``` ## EventType9+ @@ -50,7 +50,7 @@ import screenlock from '@ohos.screenLock'; | eventType | [EventType](#eventtype9) | 是 | 系统事件类型。 | | params | string | 是 | 系统事件参数。 | -## screenlock.isLocked9+ +## screenLock.isLocked9+ isLocked(): boolean @@ -69,10 +69,10 @@ isLocked(): boolean **示例:** ```js -let isLocked = screenlock.isLocked(); +let isLocked = screenLock.isLocked(); ``` -## screenlock.unlock9+ +## screenLock.unlock9+ unlock(callback: AsyncCallback<boolean>): void @@ -98,17 +98,17 @@ unlock(callback: AsyncCallback<boolean>): void **示例:** -```js -screenlock.unlock((err, data) => { + ```js + screenLock.unlock((err, data) => { if (err) { - console.error(`Failed to unlock the screen, because: ${err.message}`); - return; + console.error(`Failed to unlock the screen, Code: ${err.code}, message: ${err.message}`); + return; } - console.info(`unlock the screen successfully. result: ${data}`); -}); -``` + console.info(`Succeeded in unlocking the screen. result: ${data}`); + }); + ``` -## screenlock.unlock9+ +## screenLock.unlock9+ unlock(): Promise<boolean> @@ -134,15 +134,15 @@ unlock(): Promise<boolean> **示例:** -```js -screenlock.unlock().then((data) => { - console.info(`unlock the screen successfully. result: ${data}`); -}).catch((err) => { - console.error(`Failed to unlock the screen, because: ${err.message}`); -}); -``` + ```js + screenLock.unlock().then((data) => { + console.info(`Succeeded in unlocking the screen. result: ${data}`); + }).catch((err) => { + console.error(`Failed to unlock the screen, Code: ${err.code}, message: ${err.message}`); + }); + ``` -## screenlock.lock9+ +## screenLock.lock9+ lock(callback: AsyncCallback<boolean>): void @@ -168,17 +168,17 @@ lock(callback: AsyncCallback<boolean>): void **示例:** -```js -screenlock.lock((err, data) => { + ```js + screenLock.lock((err, data) => { if (err) { - console.error(`Failed to lock the screen, because: ${err.message}`); - return; + console.error(`Failed to lock the screen, Code: ${err.code}, message: ${err.message}`); + return; } - console.info(`lock the screen successfully. result: ${data}`); -}); -``` + console.info(`Succeeded in locking the screen. result: ${data}`); + }); + ``` -## screenlock.lock9+ +## screenLock.lock9+ lock(): Promise<boolean> @@ -204,15 +204,15 @@ lock(): Promise<boolean> **示例:** -```js -screenlock.lock().then((data) => { - console.info(`lock the screen successfully. result: ${data}`); -}).catch((err) => { - console.error(`Failed to lock the screen, because: ${err.message}`); -}); -``` + ```js + screenLock.lock().then((data) => { + console.info(`Succeeded in locking the screen. result: ${data}`); + }).catch((err) => { + console.error(`Failed to lock the screen, Code: ${err.code}, message: ${err.message}`); + }); + ``` -## screenlock.onSystemEvent9+ +## screenLock.onSystemEvent9+ onSystemEvent(callback: Callback<SystemEvent>): boolean @@ -244,17 +244,17 @@ onSystemEvent(callback: Callback<SystemEvent>): boolean **示例:** -```js -try { - let isSuccess = screenlock.onSystemEvent((event) => { - console.log(`Register the system event which related to screenlock successfully. eventType: ${event.eventType}`) + ```js + try { + let isSuccess = screenLock.onSystemEvent((event) => { + console.log(`Succeeded in Registering the system event which related to screenlock. eventType: ${event.eventType}`) }); -} catch (err) { - console.error(`Failed to register the system event which related to screenlock, because: ${err.message}`) -} -``` + } catch (err) { + console.error(`Failed to register the system event which related to screenlock, Code: ${err.code}, message: ${err.message}`) + } + ``` -## screenlock.sendScreenLockEvent9+ +## screenLock.sendScreenLockEvent9+ sendScreenLockEvent(event: String, parameter: number, callback: AsyncCallback<boolean>): void @@ -282,17 +282,17 @@ sendScreenLockEvent(event: String, parameter: number, callback: AsyncCallback< **示例:** -```js -screenlock.sendScreenLockEvent('unlockScreenResult', 0, (err, result) => { + ```js + screenLock.sendScreenLockEvent('unlockScreenResult', 0, (err, result) => { if (err) { - console.error(`Failed to send screenlock event, because: ${err.message}`); - return; + console.error(`Failed to send screenlock event, Code: ${err.code}, message: ${err.message}`); + return; } - console.info(`Send screenlock event successfully. result: ${result}`); -}); -``` + console.info(`Succeeded in Sending screenlock event. result: ${result}`); + }); + ``` -## screenlock.sendScreenLockEvent9+ +## screenLock.sendScreenLockEvent9+ sendScreenLockEvent(event: String, parameter: number): Promise<boolean> @@ -325,15 +325,15 @@ sendScreenLockEvent(event: String, parameter: number): Promise<boolean> **示例:** -```js -screenlock.sendScreenLockEvent('unlockScreenResult', 0).then((result) => { - console.info(`Send screenlock event successfully. result: ${result}`); -}).catch((err) => { - console.error(`Failed to send screenlock event, because: ${err.message}`); -}); -``` + ```js + screenLock.sendScreenLockEvent('unlockScreenResult', 0).then((result) => { + console.info(`Succeeded in Sending screenlock event. result: ${result}`); + }).catch((err) => { + console.error(`Failed to send screenlock event, Code: ${err.code}, message: ${err.message}`); + }); + ``` -## screenlock.isScreenLocked(deprecated) +## screenLock.isScreenLocked(deprecated) isScreenLocked(callback: AsyncCallback<boolean>): void @@ -353,17 +353,17 @@ isScreenLocked(callback: AsyncCallback<boolean>): void **示例:** -```js -screenlock.isScreenLocked((err, data)=>{ + ```js + screenLock.isScreenLocked((err, data)=>{ if (err) { - console.error(`Failed to obtain whether the screen is locked, because: ${err.message}`); - return; + console.error(`Failed to obtain whether the screen is locked, Code: ${err.code}, message: ${err.message}`); + return; } - console.info(`Obtain whether the screen is locked successfully. result: ${data}`); -}); -``` + console.info(`Succeeded in Obtaining whether the screen is locked. result: ${data}`); + }); + ``` -## screenlock.isScreenLocked(deprecated) +## screenLock.isScreenLocked(deprecated) isScreenLocked(): Promise<boolean> @@ -383,15 +383,15 @@ isScreenLocked(): Promise<boolean> **示例:** -```js -screenlock.isScreenLocked().then((data) => { - console.info(`Obtain whether the screen is locked successfully. result: ${data}`); -}).catch((err) => { - console.error(`Failed to obtain whether the screen is locked, because: ${err.message}`); -}); -``` + ```js + screenLock.isScreenLocked().then((data) => { + console.info(`Succeeded in Obtaining whether the screen is locked. result: ${data}`); + }).catch((err) => { + console.error(`Failed to obtain whether the screen is locked, Code: ${err.code}, message: ${err.message}`); + }); + ``` -## screenlock.isSecureMode(deprecated) +## screenLock.isSecureMode(deprecated) isSecureMode(callback: AsyncCallback<boolean>): void @@ -411,17 +411,17 @@ isSecureMode(callback: AsyncCallback<boolean>): void **示例:** -```js -screenlock.isSecureMode((err, data)=>{ + ```js + screenLock.isSecureMode((err, data)=>{ if (err) { - console.error(`Failed to obtain whether the device is in secure mode, because: ${err.message}`); - return; + console.error(`Failed to obtain whether the device is in secure mode, Code: ${err.code}, message: ${err.message}`); + return; } - console.info(`Obtain whether the device is in secure mode successfully. result: ${data}`); -}); -``` + console.info(`Succeeded in Obtaining whether the device is in secure mode. result: ${data}`); + }); + ``` -## screenlock.isSecureMode(deprecated) +## screenLock.isSecureMode(deprecated) isSecureMode(): Promise<boolean> @@ -441,14 +441,15 @@ isSecureMode(): Promise<boolean> **示例:** -```js -screenlock.isSecureMode().then((data) => { - console.info(`Obtain whether the device is in secure mode successfully. result: ${data}`); -}).catch((err) => { - console.error(`Failed to obtain whether the device is in secure mode, because: ${err.message}`); -}); -``` -## screenlock.unlockScreen(deprecated) + ```js + screenLock.isSecureMode().then((data) => { + console.info(`Succeeded in Obtaining whether the device is in secure mode. result: ${data}`); + }).catch((err) => { + console.error(`Failed to obtain whether the device is in secure mode, Code: ${err.code}, message: ${err.message}`); + }); + ``` + +## screenLock.unlockScreen(deprecated) unlockScreen(callback: AsyncCallback<void>): void @@ -468,17 +469,17 @@ unlockScreen(callback: AsyncCallback<void>): void **示例:** -```js -screenlock.unlockScreen((err) => { + ```js + screenLock.unlockScreen((err) => { if (err) { - console.error(`Failed to unlock the screen, because: ${err.message}`); - return; + console.error(`Failed to unlock the screen, Code: ${err.code}, message: ${err.message}`); + return; } - console.info('unlock the screen successfully.'); -}); -``` + console.info(`Succeeded unlocking the screen.`); + }); + ``` -## screenlock.unlockScreen(deprecated) +## screenLock.unlockScreen(deprecated) unlockScreen(): Promise<void> @@ -498,10 +499,10 @@ unlockScreen(): Promise<void> **示例:** -```js -screenlock.unlockScreen().then(() => { - console.info('unlock the screen successfully.'); -}).catch((err) => { - console.error(`Failed to unlock the screen, because: ${err.message}`); -}); -``` + ```js + screenLock.unlockScreen().then(() => { + console.info('Succeeded unlocking the screen.'); + }).catch((err) => { + console.error(`Failed to unlock the screen, Code: ${err.code}, message: ${err.message}`); + }); + ```