diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md b/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md index bb48bd9a80cdd3f829d3b3e68736edc22dbbb909..5d1e6d2c4a619eee379b47ffc08e15c89ed1bec1 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md @@ -47,7 +47,7 @@ getInputMethodController(): InputMethodController | [InputMethodController](#InputMethodController) | 回调返回当前客户端实例。 | - 示例 - ``` + ```js var InputMethodController = inputMethod.getInputMethodController(); ``` ## inputMethod.getInputMethodSetting8+ @@ -66,7 +66,7 @@ getInputMethodSetting(): InputMethodSetting - 示例 - ``` + ```js var InputMethodSetting = inputMethod.getInputMethodSetting(); ``` @@ -90,7 +90,7 @@ stopInput(callback: AsyncCallback<boolean>): void - 示例 -``` +```js InputMethodController.stopInput((error)=>{ console.info('stopInput'); }); @@ -113,7 +113,7 @@ stopInput(): Promise<boolean> - 示例 -``` +```js var isSuccess = InputMethodController.stopInput(); console.info('stopInput isSuccess = ' + isSuccess); ``` @@ -136,7 +136,7 @@ listInputMethod(callback: AsyncCallback<Array<InputMethodProperty>>) | callback | Array<[InputMethodProperty](#InputMethodProperty)> | 是 | 返回已安装输入法列表。 | - 示例 - ``` + ```js InputMethodSetting.listInputMethod((properties)=>{ for (var i = 0;i < properties.length; i++) { var property = properties[i]; @@ -159,7 +159,7 @@ listInputMethod(): Promise<Array<InputMethodProperty>> | Promise> | 返回已安装输入法列表。 | - 示例 - ``` + ```js var properties = InputMethodSetting.listInputMethod(); for (var i = 0;i < properties.length; i++) { var property = properties[i]; @@ -182,7 +182,7 @@ displayOptionalInputMethod(callback: AsyncCallback<void>): void | callback | AsyncCallback<void> | 是 | 回调函数。 | - 示例 - ``` + ```js InputMethodSetting.displayOptionalInputMethod(()=>{ console.info('displayOptionalInputMethod is called'); }); @@ -203,6 +203,6 @@ displayOptionalInputMethod(callback: AsyncCallback<void>): void | Promise<void> | 回调函数。 | - 示例 - ``` + ```js InputMethodSetting.displayOptionalInputMethod(); ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md b/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md index 0ecd9b3257546692b81781d2d41ee55897e7ae56..74c5220408b55b74764a8198c49cd4b8deb26b22 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md @@ -60,7 +60,7 @@ getInputMethodEngine(): InputMethodEngine - 示例 - ``` + ```js var InputMethodEngine = inputMethodEngine.getInputMethodEngine(); ``` @@ -80,7 +80,7 @@ createKeyboardDelegate(): KeyboardDelegate - 示例 - ``` + ```js var KeyboardDelegate = inputMethodEngine.createKeyboardDelegate(); ``` @@ -105,7 +105,7 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, textInputCli - 示例: - ``` + ```js InputMethodEngine.on('inputStart', (kbController, textInputClient) => { KeyboardController = kbController; TextInputClient = textInputClient; @@ -131,7 +131,7 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, textInputC - 示例: - ``` + ```js InputMethodEngine.off('inputStart'); ``` @@ -152,7 +152,7 @@ on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void - 示例: - ``` + ```js InputMethodEngine.on('keyboardShow', (err) => { console.info('keyboardShow'); }); @@ -175,7 +175,7 @@ off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void - 示例: - ``` + ```js InputMethodEngine.off('keyboardShow'); ``` @@ -203,7 +203,7 @@ on(type: 'keyDown'|'keyUp', callback: (event: KeyEvent) => boolean): void - 示例: - ``` + ```js KeyboardDelegate.on('keyDown', (event) => { console.info('keyDown'); }); @@ -226,7 +226,7 @@ off(type: 'keyDown'|'keyUp', callback?: (event: KeyEvent) => boolean): void - 示例: - ``` + ```js KeyboardDelegate.off('keyDown'); ``` @@ -249,7 +249,7 @@ on(type: 'cursorContextChange', callback: (x: number, y:number, height:number) = - 示例: - ``` + ```js KeyboardDelegate.on('cursorContextChange', (x, y, height) => { console.info('cursorContextChange'); }); @@ -273,7 +273,7 @@ off(type: 'cursorContextChange', callback?: (x: number, y:number, height:number) - 示例: - ``` + ```js KeyboardDelegate.off('cursorContextChange'); ``` ### on('selectionChange') @@ -293,7 +293,7 @@ on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegi - 示例: - ``` + ```js KeyboardDelegate.on('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => { console.info('selectionChange'); }); @@ -316,7 +316,7 @@ off(type: 'selectionChange', callback?: (oldBegin: number, oldEnd: number, newBe - 示例: - ``` + ```js KeyboardDelegate.off('selectionChange'); ``` @@ -338,7 +338,7 @@ on(type: 'textChange', callback: (text: string) => void): void - 示例: - ``` + ```js KeyboardDelegate.on('textChange', (text) => { console.info('textChange'); }); @@ -361,7 +361,7 @@ off(type: 'textChange', callback?: (text: string) => void): void - 示例: - ``` + ```js KeyboardDelegate.off('textChange'); ``` @@ -386,7 +386,7 @@ hideKeyboard(callback: AsyncCallback<void>): void - 示例 -``` +```js KeyboardController.hideKeyboard(()=>{ }); ``` @@ -408,7 +408,7 @@ hideKeyboard(): Promise<void> - 示例 -``` +```js KeyboardController.hideKeyboard(); ``` @@ -432,7 +432,7 @@ getForward(length:number, callback: AsyncCallback<string>): void | callback | AsyncCallback<string> | 是 | 返回文本。 | - 示例 - ``` + ```js TextInputClient.getForward(5,(text) =>{ console.info("text = " + text); }); @@ -458,7 +458,7 @@ getForward(length:number): Promise<string> | Promise<string> | 返回文本。 | - 示例 - ``` + ```js var text = TextInputClient.getForward(5); console.info("text = " + text); ``` @@ -479,7 +479,7 @@ getBackward(length:number, callback: AsyncCallback<string>): void | callback | AsyncCallback<string> | 是 | 返回文本。 | - 示例 - ``` + ```js TextInputClient.getBackward(5,(text)=>{ console.info("text = " + text); }); @@ -505,7 +505,7 @@ getBackward(length:number): Promise<string> | Promise<string> | 返回文本。 | - 示例 - ``` + ```js var text = TextInputClient.getBackward(5); console.info("text = " + text); ``` @@ -526,7 +526,7 @@ deleteForward(length:number, callback: AsyncCallback<boolean>): void | callback | AsyncCallback<boolean> | 是 | 操作成功与否。 | - 示例 - ``` + ```js TextInputClient.deleteForward(5,(isSuccess)=>{ console.info("isSuccess = " + isSuccess); }); @@ -551,7 +551,7 @@ deleteForward(length:number): Promise<boolean> | Promise<boolean> | 操作成功与否。 | - 示例 - ``` + ```js var isSuccess = TextInputClient.deleteForward(5); console.info("isSuccess = " + isSuccess); ``` @@ -572,7 +572,7 @@ deleteBackward(length:number, callback: AsyncCallback<boolean>): void | callback | AsyncCallback<boolean> | 是 | 操作成功与否。 | - 示例 - ``` + ```js TextInputClient.deleteBackward(5, (isSuccess)=>{ console.info("isSuccess = " + isSuccess); }); @@ -598,7 +598,7 @@ deleteBackward(length:number): Promise<boolean> - 示例 - ``` + ```js var isSuccess = TextInputClient.deleteBackward(5); console.info("isSuccess = " + isSuccess); ``` @@ -618,7 +618,7 @@ sendKeyFunction(action:number, callback: AsyncCallback<boolean>): void | callback | AsyncCallback<boolean> | 是 | 操作成功与否。 | - 示例 - ``` + ```js TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT,(isSuccess)=>{ console.info("isSuccess = " + isSuccess); }); @@ -644,7 +644,7 @@ sendKeyFunction(action:number): Promise<boolean> - 示例 - ``` + ```js var isSuccess = TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT); console.info("isSuccess = " + isSuccess); ``` @@ -665,7 +665,7 @@ insertText(text:string, callback: AsyncCallback<boolean>): void | callback | AsyncCallback<boolean> | 是 | 操作成功与否。 | - 示例 - ``` + ```js TextInputClient.insertText("test", (isSuccess)=>{ console.info("isSuccess = " + isSuccess); }); @@ -691,7 +691,7 @@ insertText(text:string): Promise<boolean> - 示例 - ``` + ```js var isSuccess = TextInputClient.insertText("test"); console.info("isSuccess = " + isSuccess); ``` @@ -710,7 +710,7 @@ getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void | callback | AsyncCallback<[EditorAttribute](#EditorAttribute)> | 是 | 编辑框属性值。 | - 示例 - ``` + ```js TextInputClient.getEditorAttribute((EditorAttribute)=>{ }); ``` @@ -729,7 +729,7 @@ getEditorAttribute(): Promise<EditorAttribute> | Promise<[EditorAttribute](#EditorAttribute)> | 返回编辑框属性值。 | - 示例 - ``` + ```js var EditorAttribute = TextInputClient.getEditorAttribute(); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md b/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md index 6ab245ab6d63080d976577ee9a2ddaa44541eae1..ce2e8f8c264eaec822e89098ed321c475041cad4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md +++ b/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md @@ -46,7 +46,7 @@ createPlainTextData(text:string): PasteData **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("content"); ``` @@ -71,7 +71,7 @@ createHtmlData(htmlText:string): PasteData **示例** - ``` + ```js var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; var pasteData = pasteboard.createHtmlData(html); ``` @@ -97,7 +97,7 @@ createWantData(want:Want): PasteData **示例** - ``` + ```js var object = { bundleName: "com.example.aafwk.test", abilityName: "com.example.aafwk.test.TwoAbility" @@ -126,7 +126,7 @@ createUriData(uri:string): PasteData **示例** - ``` + ```js var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); ``` @@ -151,7 +151,7 @@ createPlainTextRecord(text:string): PasteDataRecord **示例** - ``` + ```js var record = pasteboard.createPlainTextRecord("hello"); ``` @@ -176,7 +176,7 @@ createHtmlTextRecord(htmlText:string): PasteDataRecord **示例** - ``` + ```js var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; var record = pasteboard.createHtmlTextRecord(html); ``` @@ -202,7 +202,7 @@ createWantRecord(want:Want): PasteDataRecord **示例** - ``` + ```js var object = { bundleName: "com.example.aafwk.test", abilityName: "com.example.aafwk.test.TwoAbility" @@ -231,7 +231,7 @@ createUriRecord(uri:string): PasteDataRecord **示例** - ``` + ```js var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); ``` @@ -284,7 +284,7 @@ convertToText(): Promise<string> **示例** - ``` + ```js var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); record.convertToText().then((data) => { console.info('convertToText success data : ' + JSON.stringify(data)); @@ -309,7 +309,7 @@ convertToText(callback: AsyncCallback<string>): void **示例** - ``` + ```js var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); record.convertToText((err, data) => { if (err) { @@ -346,7 +346,7 @@ getPrimaryText(): string **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("hello"); var plainText = pasteData.getPrimaryText(); ``` @@ -367,7 +367,7 @@ getPrimaryHtml(): string **示例** - ``` + ```js var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; var pasteData = pasteboard.createHtmlData(html); var htmlText = pasteData.getPrimaryHtml(); @@ -389,7 +389,7 @@ getPrimaryWant(): Want **示例** - ``` + ```js var object = { bundleName: "com.example.aafwk.test", abilityName: "com.example.aafwk.test.TwoAbility" @@ -414,7 +414,7 @@ getPrimaryUri(): string **示例** - ``` + ```js var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); var uri = pasteData.getPrimaryUri(); ``` @@ -437,7 +437,7 @@ addTextRecord(text: string): void **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("hello"); pasteData.addTextRecord("good"); ``` @@ -460,7 +460,7 @@ addHtmlRecord(htmlText: string): void **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("hello"); var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; pasteData.addHtmlRecord(html); @@ -484,7 +484,7 @@ addWantRecord(want: Want): void **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("hello"); var object = { bundleName: "com.example.aafwk.test", @@ -511,7 +511,7 @@ addUriRecord(uri: string): void **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("hello"); pasteData.addUriRecord("dataability:///com.example.myapplication1?user.txt"); ``` @@ -534,7 +534,7 @@ addRecord(record: PasteDataRecord): void **示例** - ``` + ```js var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); var textRecord = pasteboard.createPlainTextRecord("hello"); var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; @@ -559,7 +559,7 @@ getMimeTypes(): Array<string> **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("hello"); var types = pasteData.getMimeTypes(); ``` @@ -580,7 +580,7 @@ getPrimaryMimeType(): string **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("hello"); var type = pasteData.getPrimaryMimeType(); ``` @@ -601,7 +601,7 @@ getProperty(): PasteDataProperty **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("hello"); var property = pasteData.getProperty(); ``` @@ -627,7 +627,7 @@ getRecordAt(index: number): PasteDataRecord **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("hello"); var record = pasteData.getRecordAt(0); ``` @@ -648,7 +648,7 @@ getRecordCount(): number **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("hello"); var count = pasteData.getRecordCount(); ``` @@ -669,7 +669,7 @@ getTag(): string **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("hello"); var tag = pasteData.getTag(); ``` @@ -695,7 +695,7 @@ hasMimeType(mimeType: string): boolean **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("hello"); var hasType = pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_PLAIN); ``` @@ -721,7 +721,7 @@ removeRecordAt(index: number): boolean **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("hello"); var isRemove = pasteData.removeRecordAt(0); ``` @@ -748,7 +748,7 @@ replaceRecordAt(index: number, record: PasteDataRecord): boolean **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("hello"); var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); var isReplace = pasteData.replaceRecordAt(0, record); @@ -770,7 +770,7 @@ getSystemPasteboard(): SystemPasteboard **示例** - ``` + ```js var systemPasteboard = pasteboard.getSystemPasteboard(); ``` @@ -800,7 +800,7 @@ setPasteData(data:PasteData, callback:AsyncCallback<void>): void **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("content"); var systemPasteboard = pasteboard.getSystemPasteboard(); systemPasteboard.setPasteData(pasteData, (error, data) => { @@ -833,7 +833,7 @@ setPasteData(data:PasteData): Promise<void> **示例** - ``` + ```js var pasteData = pasteboard.createPlainTextData("content"); var systemPasteboard = pasteboard.getSystemPasteboard(); systemPasteboard.setPasteData(pasteData).then((data) => { @@ -859,7 +859,7 @@ getPasteData( callback:AsyncCallback<PasteData>): void **示例** - ``` + ```js var systemPasteboard = pasteboard.getSystemPasteboard(); systemPasteboard.getPasteData((error, pasteData) => { if (error) { @@ -886,7 +886,7 @@ getPasteData(): Promise<PasteData> **示例** - ``` + ```js var systemPasteboard = pasteboard.getSystemPasteboard(); systemPasteboard.getPasteData().then((pasteData) => { var text = pasteData.getPrimaryText(); @@ -912,7 +912,7 @@ on(type: 'update', callback: () =>void ): void **示例** - ``` + ```js var systemPasteboard = pasteboard.getSystemPasteboard(); var listener = ()=>{ console.info('The system pasteboard has changed'); @@ -937,7 +937,7 @@ off(type: 'update', callback?: () =>void ): void **示例** - ``` + ```js systemPasteboard.off('update', listener); ``` @@ -957,7 +957,7 @@ hasPasteData(callback: AsyncCallback<boolean>): void **示例** - ``` + ```js systemPasteboard.hasPasteData((err, data) => { if (err) { console.error('failed to hasPasteData because ' + JSON.stringify(err)); @@ -983,7 +983,7 @@ hasPasteData(): Promise<boolean> **示例** - ``` + ```js systemPasteboard.hasPasteData().then((data) => { console.info('success hasPasteData : ' + JSON.stringify(data)); }).catch((error) => { @@ -1007,7 +1007,7 @@ clear(callback: AsyncCallback<void>): void **示例** - ``` + ```js systemPasteboard.clear((err, data) => { if (err) { console.error('failed to clear because ' + JSON.stringify(err)); @@ -1034,7 +1034,7 @@ clear(): Promise<void> **示例** - ``` + ```js systemPasteboard.clear().then((data) => { console.info('success clear'); }).catch((error) => { diff --git a/zh-cn/application-dev/reference/apis/js-apis-request.md b/zh-cn/application-dev/reference/apis/js-apis-request.md index 8d7ed2246a63c497b40605392468340e45282c30..4be83b781fc43b2d3dfbb5b350289bc4482c1794 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-request.md +++ b/zh-cn/application-dev/reference/apis/js-apis-request.md @@ -81,7 +81,7 @@ upload(config: UploadConfig): Promise<UploadTask> - 示例: - ``` + ```js request.upload({ url: 'https://patch' }).then((data) => { uploadTask = data; }).catch((err) => { @@ -108,7 +108,7 @@ upload(config: UploadConfig, callback: AsyncCallback<UploadTask>): void - 示例: - ``` + ```js request.upload({ url: 'https://patch' }, (err, data) => { if (err) { console.error('Failed to request the upload. Cause: ' + JSON.stringify(err)); @@ -142,14 +142,14 @@ on(type: 'progress', callback:(uploadedSize: number, totalSize: number) => vo 回调函数的参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | uploadedSize | number | 是 | 当前已上传文件大小,单位为KB。 | - | totalSize | number | 是 | 上传文件的总大小,单位为KB。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| uploadedSize | number | 是 | 当前已上传文件大小,单位为KB。 | +| totalSize | number | 是 | 上传文件的总大小,单位为KB。 | - 示例: - ``` + ```js uploadTask.on('progress', function callback(uploadedSize, totalSize) { console.info("upload totalSize:" + totalSize + " uploadedSize:" + uploadedSize); } @@ -175,13 +175,13 @@ on(type: 'headerReceive', callback: (header: object) => void): void 回调函数的参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | header | object | 是 | HTTP Response Header。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| header | object | 是 | HTTP Response Header。 | - 示例: - ``` + ```js uploadTask.on('headerReceive', function callback(headers){ console.info("upOnHeader headers:" + JSON.stringify(headers)); } @@ -207,14 +207,14 @@ off(type: 'progress', callback?: (uploadedSize: number, totalSize: number) =&g 回调函数的参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | uploadedSize | number | 是 | 当前已上传文件的大小,单位为KB。 | - | totalSize | number | 是 | 上传文件的总大小,单位为KB。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| uploadedSize | number | 是 | 当前已上传文件的大小,单位为KB。 | +| totalSize | number | 是 | 上传文件的总大小,单位为KB。 | - 示例: - ``` + ```js uploadTask.off('progress', function callback(uploadedSize, totalSize) { console.info('uploadedSize: ' + uploadedSize, 'totalSize: ' + totalSize); } @@ -240,13 +240,13 @@ off(type: 'headerReceive', callback?: (header: object) => void): void 回调函数的参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | header | object | 是 | HTTP Response Header。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| header | object | 是 | HTTP Response Header。 | - 示例: - ``` + ```js uploadTask.off('headerReceive', function callback(headers) { console.info("upOnHeader headers:" + JSON.stringify(headers)); } @@ -271,7 +271,7 @@ remove(): Promise<boolean> - 示例 - ``` + ```js uploadTask.remove().then((result) => { if (result) { console.info('Upload task removed successfully. '); @@ -301,7 +301,7 @@ remove(callback: AsyncCallback<boolean>): void - 示例 - ``` + ```js uploadTask.remove((err, result) => { if (err) { console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err)); @@ -373,7 +373,7 @@ download(config: DownloadConfig): Promise<DownloadTask> - 示例 - ``` + ```js request.download({ url: 'https://xxxx/xxxx.hap' }).then((data) => { downloadTask = data; }).catch((err) => { @@ -400,7 +400,7 @@ download(config: DownloadConfig, callback: AsyncCallback<DownloadTask>): v - 示例 - ``` + ```js request.download({ url: 'https://xxxx/xxxxx.hap', filePath: 'xxx/xxxxx.hap'}, (err, data) => { if (err) { @@ -435,14 +435,14 @@ on(type: 'progress', callback:(receivedSize: number, totalSize: number) => vo 回调函数的参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | receivedSize | number | 是 | 当前下载的进度,单位为KB。 | - | totalSize | number | 是 | 下载文件的总大小,单位为KB。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| receivedSize | number | 是 | 当前下载的进度,单位为KB。 | +| totalSize | number | 是 | 下载文件的总大小,单位为KB。 | - 示例: - ``` + ```js request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { if (err) { console.error('Failed to request download. Cause:' + err); @@ -475,14 +475,14 @@ off(type: 'progress', callback?: (receivedSize: number, totalSize: number) => 回调函数的参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | receivedSize | number | 是 | 当前下载的进度。 | - | totalSize | number | 是 | 下载文件的总大小。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| receivedSize | number | 是 | 当前下载的进度。 | +| totalSize | number | 是 | 下载文件的总大小。 | - 示例: - ``` + ```js request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { if (err) { console.error('Failed to request download. Cause:' + err); @@ -515,7 +515,7 @@ on(type: 'complete'|'pause'|'remove', callback:() => void): void - 示例: - ``` + ```js request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { if (err) { console.error('Failed to request download. Cause:' + err); @@ -548,7 +548,7 @@ off(type: 'complete'|'pause'|'remove', callback?:() => void): void - 示例: - ``` + ```js request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { if (err) { console.error('Failed to request download. Cause:' + JSON.stringify(err)); @@ -581,13 +581,13 @@ on(type: 'fail', callback: (err: number) => void): void 回调函数的参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | err | number | 是 | 下载失败的错误码,错误原因见[ERROR.*](#常量)。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| err | number | 是 | 下载失败的错误码,错误原因见[ERROR.*](#常量)。 | - 示例 - ``` + ```js request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { if (err) { console.error('Failed to request download. Cause:' + err); @@ -620,13 +620,13 @@ off(type: 'fail', callback?: (err: number) => void): void 回调函数的参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | err | number | 是 | 下载失败的错误码。错误原因见[ERROR_*](#常量)。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| err | number | 是 | 下载失败的错误码。错误原因见[ERROR_*](#常量)。 | - 示例 - ``` + ```js request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { if (err) { console.error('Failed to request download. Cause:' + err); @@ -658,7 +658,7 @@ remove(): Promise<boolean> - 示例 - ``` + ```js downloadTask.remove().then((result) => { if (result) { console.info('Download task removed.'); @@ -688,7 +688,7 @@ remove(callback: AsyncCallback<boolean>): void - 示例 - ``` + ```js downloadTask.remove((err, result)=>{ if(err) { console.error('Failed to remove the download task.'); @@ -720,7 +720,7 @@ query(): Promise<DownloadInfo> - 示例 - ``` + ```js downloadTask.query().then((downloadInfo) => { console.info('Download task queried. Data:' + JSON.stringify(downloadInfo)) }) .catch((err) => { @@ -746,7 +746,7 @@ query(callback: AsyncCallback<DownloadInfo>): void - 示例: - ``` + ```js downloadTask.query((err, downloadInfo)=>{ if(err) { console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err)); @@ -774,7 +774,7 @@ queryMimeType(): Promise<string> - 示例 - ``` + ```js downloadTask.queryMimeType().then((data) => { console.info('Download task queried. Data:' + JSON.stringify(data)); }).catch((err) => { @@ -800,7 +800,7 @@ queryMimeType(callback: AsyncCallback<string>): void; - 示例 - ``` + ```js downloadTask.queryMimeType((err, data)=>{ if(err) { console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err)); @@ -828,7 +828,7 @@ pause(): Promise<void> - 示例 - ``` + ```js downloadTask.pause().then((result) => { if (result) { console.info('Download task paused. '); @@ -858,7 +858,7 @@ pause(callback: AsyncCallback<void>): void - 示例 - ``` + ```js downloadTask.pause((err, result)=>{ if(err) { console.error('Failed to pause the download task. Cause:' + JSON.stringify(err)); @@ -890,7 +890,7 @@ resume(): Promise<void> - 示例 - ``` + ```js downloadTask.resume().then((result) => { if (result) { console.info('Download task resumed.') @@ -921,7 +921,7 @@ resume(callback: AsyncCallback<void>): void - 示例 - ``` + ```js downloadTask.resume((err, result)=>{ if (err) { console.error('Failed to resume the download task. Cause:' + err); diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-time.md b/zh-cn/application-dev/reference/apis/js-apis-system-time.md index c0a9861a987249b7bae87d88188168b988eb9493..fed9e6b00426546f2ca02159afaf2fbc170c73c5 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-time.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-time.md @@ -6,7 +6,7 @@ ## 导入模块 - + ``` import systemTime from '@ohos.systemTime'; ``` @@ -23,14 +23,14 @@ setTime(time : number, callback : AsyncCallback<void>) : void **系统能力:** SystemCapability.Miscservices.Time - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | time | number | 是 | 目标时间戳(毫秒)。 | - | callback | AsyncCallback<void> | 是 | 回调函数,可以在回调函数中处理接口返回值。 | + | time | number | 是 | 目标时间戳(毫秒)。 | + | callback | AsyncCallback<void> | 是 | 回调函数,可以在回调函数中处理接口返回值。 | - 示例: - - ``` + + ```js // time对应的时间为2021-01-20 02:36:25 var time = 1611081385000; systemTime.setTime(time, (error, data) => { @@ -54,18 +54,18 @@ setTime(time : number) : Promise<void> **系统能力:** SystemCapability.MiscServices.Time - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | time | number | 是 | 目标时间戳(毫秒)。 | + | time | number | 是 | 目标时间戳(毫秒)。 | - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<void> | 返回的异步回调函数。 | + | Promise<void> | 返回的异步回调函数。 | - 示例: - - ``` + + ```js // time对应的时间为2021-01-20 02:36:25 var time = 1611081385000; systemTime.setTime(time).then((data) => { @@ -85,14 +85,14 @@ getCurrentTime(isNano?: boolean, callback: AsyncCallback<number>): void **系统能力:** SystemCapability.MiscServices.Time - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | - | callback | AsyncCallback<number> | 是 | 回调函数,返回自 Unix 纪元以来经过的时间。 | + | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | + | callback | AsyncCallback<number> | 是 | 回调函数,返回自 Unix 纪元以来经过的时间。 | - 示例: - - ``` + + ```js systemTime.getCurrentTime(true, (error, data) => { if (error) { console.error(`failed to systemTime.getCurrentTime because ` + JSON.stringify(error)); @@ -112,18 +112,18 @@ getCurrentTime(isNano?: boolean): Promise<number> **系统能力:** SystemCapability.MiscServices.Time - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | + | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<number> | 以Promise形式返回结果,返回自 Unix 纪元以来经过的时间。 | + | Promise<number> | 以Promise形式返回结果,返回自 Unix 纪元以来经过的时间。 | - 示例: - - ``` + + ```js systemTime.getCurrentTime().then((data) => { console.log(`systemTime.getCurrentTime success data : ` + JSON.stringify(data)); }).catch((error) => { @@ -141,14 +141,14 @@ getRealActiveTime(isNano?: boolean, callback: AsyncCallback<number>): void **系统能力:** SystemCapability.MiscServices.Time - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | - | callback | AsyncCallback<number> | 是 | 回调函数,返回自系统启动以来但不包括度睡眠时间经过的时间。 | + | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | + | callback | AsyncCallback<number> | 是 | 回调函数,返回自系统启动以来但不包括度睡眠时间经过的时间。 | - 示例: - - ``` + + ```js systemTime.getRealActiveTime(true, (error, data) => { if (error) { console.error(`failed to systemTime.getRealActiveTimebecause ` + JSON.stringify(error)); @@ -168,18 +168,18 @@ getRealActiveTime(isNano?: boolean): Promise<number> **系统能力:** SystemCapability.MiscServices.Time - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | + | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<number> | 以Promise形式返回结果,返回自系统启动以来但不包括度睡眠时间经过的时间。 | + | Promise<number> | 以Promise形式返回结果,返回自系统启动以来但不包括度睡眠时间经过的时间。 | - 示例: - - ``` + + ```js systemTime.getCurrentTime().then((data) => { console.log(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data)); }).catch((error) => { @@ -197,14 +197,14 @@ getRealTime(callback: AsyncCallback<number>): void **系统能力:** SystemCapability.MiscServices.Time - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | - | callback | AsyncCallback<number> | 是 | 回调函数,返回自系统启动以来包括深度睡眠时间经过的毫秒数。 | + | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | + | callback | AsyncCallback<number> | 是 | 回调函数,返回自系统启动以来包括深度睡眠时间经过的毫秒数。 | - 示例: - - ``` + + ```js systemTime.getRealTime(true, (error, data) => { if (error) { console.error(`failed to systemTime.getRealTime because ` + JSON.stringify(error)); @@ -224,18 +224,18 @@ getRealTime(): Promise<number> **系统能力:** SystemCapability.MiscServices.Time - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | + | isNano | boolean | 否 | 如果是true,返回纳秒数;否则返回毫秒数。 | - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<number> | 以Promise形式返回结果,返回自系统启动以来包括深度睡眠时间经过的时间。 | + | Promise<number> | 以Promise形式返回结果,返回自系统启动以来包括深度睡眠时间经过的时间。 | - 示例: - - ``` + + ```js systemTime.getRealTime().then((data) => { console.log(`systemTime.getRealTime success data: ` + JSON.stringify(data)); }).catch((error) => { @@ -255,14 +255,14 @@ setDate(date: Date, callback: AsyncCallback<void>): void **系统能力:** SystemCapability.MiscServices.Time - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | date | Date | 是 | 目标日期。 | - | callback | AsyncCallback<void> | 是 | 回调函数,可以在回调函数中处理接口返回值。 | + | date | Date | 是 | 目标日期。 | + | callback | AsyncCallback<void> | 是 | 回调函数,可以在回调函数中处理接口返回值。 | - 示例: - - ``` + + ```js var data = new Date("October 13, 2020 11:13:00"); systemTime.setDate(data,(error, data) => { if (error) { @@ -285,18 +285,18 @@ setDate(date: Date): Promise<void> **系统能力:** SystemCapability.MiscServices.Time - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | date | Date | 是 | 目标日期。 | + | date | Date | 是 | 目标日期。 | - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<void> | 返回的异步回调函数。 | + | Promise<void> | 返回的异步回调函数。 | - 示例: - - ``` + + ```js var data = new Date("October 13, 2020 11:13:00"); systemTime.setDate(data).then((value) => { console.log(`systemTime.setDate success data : ` + JSON.stringify(value)); @@ -315,13 +315,13 @@ getDate(callback: AsyncCallback<Date>): void **系统能力:** SystemCapability.MiscServices.Time - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<Date> | 是 | 回调函数,返回当前系统日期。 | + | callback | AsyncCallback<Date> | 是 | 回调函数,返回当前系统日期。 | - 示例: - - ``` + + ```js systemTime.getDate((error, data) => { if (error) { console.error(`failed to systemTime.getDate because ` + JSON.stringify(error)); @@ -341,13 +341,13 @@ getDate(): Promise<Date> **系统能力:** SystemCapability.MiscServices.Time - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<Date> | 以Promise形式返回结果,返回当前系统日期。 | + | Promise<Date> | 以Promise形式返回结果,返回当前系统日期。 | - 示例: - - ``` + + ```js systemTime.getDate().then((data) => { console.log(`systemTime.getDate success data : ` + JSON.stringify(data)); }).catch((error) => { @@ -367,14 +367,14 @@ setTimezone(timezone: string, callback: AsyncCallback<void>): void **系统能力:** SystemCapability.MiscServices.Time - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | timezone | string | 是 | 系统时区。 | - | callback | AsyncCallback<void> | 是 | 回调函数,可以在回调函数中处理接口返回值。 | + | timezone | string | 是 | 系统时区。 | + | callback | AsyncCallback<void> | 是 | 回调函数,可以在回调函数中处理接口返回值。 | - 示例: - - ``` + + ```js systemTime.setTimezone('Asia/Shanghai', (error, data) => { if (error) { console.error('failed to systemTime.setTimezone because ' + JSON.stringify(error)); @@ -396,18 +396,18 @@ setTimezone(timezone: string): Promise<void> **系统能力:** SystemCapability.MiscServices.Time - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | timezone | string | 是 | 系统时区。 | + | timezone | string | 是 | 系统时区。 | - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<void> | 返回的异步回调函数。 | + | Promise<void> | 返回的异步回调函数。 | - 示例: - - ``` + + ```js systemTime.setTimezone('Asia/Shanghai').then((data) => { console.log(`systemTime.setTimezone success data : ` + JSON.stringify(data)); }).catch((error) => { @@ -425,13 +425,13 @@ getTimezone(callback: AsyncCallback<string>): void **系统能力:** SystemCapability.MiscServices.Time - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<string> | 是 | 回调函数,返回系统时区。 | + | callback | AsyncCallback<string> | 是 | 回调函数,返回系统时区。 | - 示例: - - ``` + + ```js systemTime.getTimezone((error, data) => { if (error) { console.error(`failed to systemTime.getTimezone because ` + JSON.stringify(error)); @@ -451,13 +451,13 @@ getTimezone(): Promise<string> **系统能力:** SystemCapability.MiscServices.Time - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<string> | 以Promise形式返回结果,返回系统时区。 | + | Promise<string> | 以Promise形式返回结果,返回系统时区。 | - 示例: - - ``` + + ```js systemTime.getTimezone().then((data) => { console.log(`systemTime.getTimezone success data : ` + JSON.stringify(data)); }).catch((error) => { diff --git a/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md b/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md index b542ff5ff6493bb84fea27b73a81783ea05d1a1c..372ca96ad2be5c343d39b875e291607bddbd737b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md +++ b/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md @@ -18,10 +18,10 @@ import wallpaper from '@ohos.wallpaper'; **系统能力**: 以下各项对应的系统能力均为SystemCapability.MiscServices.Wallpaper。 - | 名称 | 说明 | +| 名称 | 说明 | | -------- | -------- | -| WALLPAPER_LOCKSCREEN | 锁屏壁纸标识。 | -| WALLPAPER_SYSTEM | 主屏幕壁纸标识。 | +| WALLPAPER_LOCKSCREEN | 锁屏壁纸标识。 | +| WALLPAPER_SYSTEM | 主屏幕壁纸标识。 | ## wallpaper.getColors @@ -33,14 +33,14 @@ getColors(wallpaperType: WallpaperType, callback: AsyncCallback<Array<Rgba **系统能力**: SystemCapability.MiscServices.Wallpaper - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | - | callback | AsyncCallback<Array<[RgbaColor](#rgbacolor)>> | 是 | 回调函数,返回壁纸的主要颜色信息。 | + | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | + | callback | AsyncCallback<Array<[RgbaColor](#rgbacolor)>> | 是 | 回调函数,返回壁纸的主要颜色信息。 | - 示例: - ``` + ```js wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { if (error) { console.error(`failed to getColors because: ` + JSON.stringify(error)); @@ -60,18 +60,18 @@ getColors(wallpaperType: WallpaperType): Promise<Array<RgbaColor>> **系统能力**: SystemCapability.MiscServices.Wallpaper - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | + | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<Array<[RgbaColor](#rgbacolor)>> | 返回壁纸的主要颜色信息。 | + | Promise<Array<[RgbaColor](#rgbacolor)>> | 返回壁纸的主要颜色信息。 | - 示例: - ``` + ```js wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { console.log(`success to getColors.`); }).catch((error) => { @@ -89,14 +89,14 @@ getId(wallpaperType: WallpaperType, callback: AsyncCallback<number>): void **系统能力**: SystemCapability.MiscServices.Wallpaper - 参数 - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | - | callback | AsyncCallback<number> | 是 | 回调函数,返回壁纸的ID。如果配置了指定类型的壁纸就返回一个大于等于0的数,否则返回-1。取值范围是-1~2^31-1。 | + | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | + | callback | AsyncCallback<number> | 是 | 回调函数,返回壁纸的ID。如果配置了指定类型的壁纸就返回一个大于等于0的数,否则返回-1。取值范围是-1~2^31-1。 | - 示例: - ``` + ```js wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { if (error) { console.error(`failed to getId because: ` + JSON.stringify(error)); @@ -117,18 +117,18 @@ getId(wallpaperType: WallpaperType): Promise<number> - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | + | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<number> | 壁纸的ID。如果配置了这种壁纸类型的壁纸就返回一个大于等于0的数,否则返回-1。取值范围是-1~2^31-1。 | + | Promise<number> | 壁纸的ID。如果配置了这种壁纸类型的壁纸就返回一个大于等于0的数,否则返回-1。取值范围是-1~2^31-1。 | - 示例: - ``` + ```js wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { console.log(`success to getId: ` + JSON.stringify(data)); }).catch((error) => { @@ -146,13 +146,13 @@ getMinHeight(callback: AsyncCallback<number>): void **系统能力**: SystemCapability.MiscServices.Wallpaper - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<number> | 是 | 回调函数,返回壁纸的最小高度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的高度值代替。 | + | callback | AsyncCallback<number> | 是 | 回调函数,返回壁纸的最小高度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的高度值代替。 | - 示例: - ``` + ```js wallpaper.getMinHeight((error, data) => { if (error) { console.error(`failed to getMinHeight because: ` + JSON.stringify(error)); @@ -173,13 +173,13 @@ getMinHeight(): Promise<number> - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<number> | 返回壁纸的最小高度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的高度值代替。 | + | Promise<number> | 返回壁纸的最小高度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的高度值代替。 | - 示例: - ``` + ```js wallpaper.getMinHeight().then((data) => { console.log(`success to getMinHeight: ` + JSON.stringify(data)); }).catch((error) => { @@ -198,13 +198,13 @@ getMinWidth(callback: AsyncCallback<number>): void - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<number> | 是 | 回调函数,壁纸的最小宽度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的宽度值代替。 | + | callback | AsyncCallback<number> | 是 | 回调函数,壁纸的最小宽度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的宽度值代替。 | - 示例: - ``` + ```js wallpaper.getMinWidth((error, data) => { if (error) { console.error(`failed to getMinWidth because: ` + JSON.stringify(error)); @@ -224,13 +224,13 @@ getMinWidth(): Promise<number> **系统能力**: SystemCapability.MiscServices.Wallpaper - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<number> | 壁纸的最小宽度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的宽度值代替。 | + | Promise<number> | 壁纸的最小宽度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的宽度值代替。 | - 示例: - ``` + ```js wallpaper.getMinWidth().then((data) => { console.log(`success to getMinWidth: ` + JSON.stringify(data)); }).catch((error) => { @@ -248,13 +248,13 @@ isChangePermitted(callback: AsyncCallback<boolean>): void **系统能力**: SystemCapability.MiscServices.Wallpaper - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<boolean> | 是 | 回调函数,返回是否允许应用改变当前用户的壁纸。如果允许返回true,否则返回false。 | + | callback | AsyncCallback<boolean> | 是 | 回调函数,返回是否允许应用改变当前用户的壁纸。如果允许返回true,否则返回false。 | - 示例: - ``` + ```js wallpaper.isChangePermitted((error, data) => { if (error) { console.error(`failed to isChangePermitted because: ` + JSON.stringify(error)); @@ -274,13 +274,13 @@ isChangePermitted(): Promise<boolean> **系统能力**: SystemCapability.MiscServices.Wallpaper - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<boolean> | 返回是否允许应用改变当前用户的壁纸。如果允许返回true,否则返回false。 | + | Promise<boolean> | 返回是否允许应用改变当前用户的壁纸。如果允许返回true,否则返回false。 | - 示例: - ``` + ```js wallpaper.isChangePermitted().then((data) => { console.log(`success to isChangePermitted: ` + JSON.stringify(data)); }).catch((error) => { @@ -298,13 +298,13 @@ isOperationAllowed(callback: AsyncCallback<boolean>): void **系统能力**: SystemCapability.MiscServices.Wallpaper - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<boolean> | 是 | 回调函数,返回是否允许用户设置壁纸。如果允许返回true,否则返回false。 | + | callback | AsyncCallback<boolean> | 是 | 回调函数,返回是否允许用户设置壁纸。如果允许返回true,否则返回false。 | - 示例: - ``` + ```js wallpaper.isOperationAllowed((error, data) => { if (error) { console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error)); @@ -324,13 +324,13 @@ isOperationAllowed(): Promise<boolean> **系统能力**: SystemCapability.MiscServices.Wallpaper - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<boolean> | 异步回调函数,返回是否允许用户设置壁纸。如果允许返回true,否则返回false。 | + | Promise<boolean> | 异步回调函数,返回是否允许用户设置壁纸。如果允许返回true,否则返回false。 | - 示例: - ``` + ```js wallpaper.isOperationAllowed().then((data) => { console.log(`success to isOperationAllowed: ` + JSON.stringify(data)); }).catch((error) => { @@ -350,14 +350,14 @@ reset(wallpaperType: WallpaperType, callback: AsyncCallback<void>): void **系统能力**: SystemCapability.MiscServices.Wallpaper - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | - | callback | AsyncCallback<void> | 是 | 回调函数,调用成功则返回是否移除成功的结果,调用失败则返回error信息。 | + | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | + | callback | AsyncCallback<void> | 是 | 回调函数,调用成功则返回是否移除成功的结果,调用失败则返回error信息。 | - 示例: - ``` + ```js wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { if (error) { console.error(`failed to reset because: ` + JSON.stringify(error)); @@ -379,18 +379,18 @@ reset(wallpaperType: WallpaperType): Promise<void> **系统能力**: SystemCapability.MiscServices.Wallpaper - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | + | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<void> | 调用成功则返回是否移除成功的结果,调用失败则返回error信息。 | + | Promise<void> | 调用成功则返回是否移除成功的结果,调用失败则返回error信息。 | - 示例: - ``` + ```js wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { console.log(`success to reset.`); }).catch((error) => { @@ -418,7 +418,7 @@ setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType, call - 示例: - ``` + ```js // source类型为string let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { @@ -469,13 +469,13 @@ setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType): Pro | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<void> | 调用成功则返回是返回设置的结果,调用失败则返回error信息。 | + | Promise<void> | 调用成功则返回是返回设置的结果,调用失败则返回error信息。 | - 示例: - ``` + ```js // source类型为string let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { @@ -515,14 +515,14 @@ getFile(wallpaperType: WallpaperType, callback: AsyncCallback<number>): vo **系统能力**: SystemCapability.MiscServices.Wallpaper - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | - | callback | AsyncCallback<number> | 是 | 回调函数,调用成功则返回壁纸文件描述符ID,调用失败则返回error信息。 | + | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | + | callback | AsyncCallback<number> | 是 | 回调函数,调用成功则返回壁纸文件描述符ID,调用失败则返回error信息。 | - 示例: - ``` + ```js wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { if (error) { console.error(`failed to getFile because: ` + JSON.stringify(error)); @@ -543,18 +543,18 @@ getFile(wallpaperType: WallpaperType): Promise<number> **系统能力**: SystemCapability.MiscServices.Wallpaper - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | + | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | - 返回值: - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | Promise<number> | 调用成功则返回壁纸文件描述符ID,调用失败则返回error信息。 | + | Promise<number> | 调用成功则返回壁纸文件描述符ID,调用失败则返回error信息。 | - 示例: - ``` + ```js wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { console.log(`success to getFile: ` + JSON.stringify(data)); }).catch((error) => { @@ -579,7 +579,7 @@ on(type: 'colorChange', callback: (colors: Array<RgbaColor>, wallpaperType - 示例: - ``` + ```js let listener = (colors, wallpaperType) => { console.log(`wallpaper color changed.`); }; @@ -596,14 +596,14 @@ off(type: 'colorChange', callback?: (colors: Array<RgbaColor>, wallpaperTy **系统能力**: SystemCapability.MiscServices.Wallpaper - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | type | string | 是 | 取值为'colorChange',表示取消订阅壁纸颜色变化结果上报事件。 | - | callback | function | 否 |   表示取消壁纸颜色变化结果上报,不填写该参数则取消订阅该type对应的所有回调。
- colors
  壁纸的主要颜色信息,其类型见[RgbaColor](#rgbacolor)。
- wallpaperType
  壁纸类型。 | + | type | string | 是 | 取值为'colorChange',表示取消订阅壁纸颜色变化结果上报事件。 | + | callback | function | 否 |   表示取消壁纸颜色变化结果上报,不填写该参数则取消订阅该type对应的所有回调。
- colors
  壁纸的主要颜色信息,其类型见[RgbaColor](#rgbacolor)。
- wallpaperType
  壁纸类型。 | - 示例: - ``` + ```js let listener = (colors, wallpaperType) => { console.log(`wallpaper color changed.`); }; @@ -619,9 +619,9 @@ off(type: 'colorChange', callback?: (colors: Array<RgbaColor>, wallpaperTy **系统能力**: 以下各项对应的系统能力均为SystemCapability.MiscServices.Wallpaper。 - | 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| red | number | 是 | 是 | 表示红色值,范围为 0 到 255。 | -| green | number | 是 | 是 | 表示绿色值,范围为 0 到 255。 | -| blue | number | 是 | 是 | 表示蓝色值,范围为 0 到 255。 | -| alpha | number | 是 | 是 | 表示 alpha 值,范围为 0 到 255。 | +| red | number | 是 | 是 | 表示红色值,范围为 0 到 255。 | +| green | number | 是 | 是 | 表示绿色值,范围为 0 到 255。 | +| blue | number | 是 | 是 | 表示蓝色值,范围为 0 到 255。 | +| alpha | number | 是 | 是 | 表示 alpha 值,范围为 0 到 255。 |