未验证 提交 e79f03ad 编写于 作者: O openharmony_ci 提交者: Gitee

!23153 monthly_0815 arkts告警修改

Merge pull request !23153 from Wangkai/cherry-pick-1693040236
...@@ -97,10 +97,10 @@ let records = unifiedData.getRecords(); ...@@ -97,10 +97,10 @@ let records = unifiedData.getRecords();
for (let i = 0; i < records.length; i++) { for (let i = 0; i < records.length; i++) {
let record = records[i]; let record = records[i];
if (record.getType() == uniformTypeDescriptor.UniformDataType.PLAIN_TEXT) { if (record.getType() == uniformTypeDescriptor.UniformDataType.PLAIN_TEXT) {
let plainText = <unifiedDataChannel.PlainText> (record); let plainText = record as unifiedDataChannel.PlainText;
console.info(`textContent: ${plainText.textContent}`); console.info(`textContent: ${plainText.textContent}`);
} else if (record.getType() == uniformTypeDescriptor.UniformDataType.HYPERLINK) { } else if (record.getType() == uniformTypeDescriptor.UniformDataType.HYPERLINK) {
let hyperlink = <unifiedDataChannel.Hyperlink> (record); let hyperlink = record as unifiedDataChannel.Hyperlink;
console.info(`linkUrl: ${hyperlink.url}`); console.info(`linkUrl: ${hyperlink.url}`);
} }
} }
...@@ -148,7 +148,7 @@ let unifiedData = new unifiedDataChannel.UnifiedData(text); ...@@ -148,7 +148,7 @@ let unifiedData = new unifiedDataChannel.UnifiedData(text);
let records = unifiedData.getRecords(); let records = unifiedData.getRecords();
if (records[0].getType() == uniformTypeDescriptor.UniformDataType.PLAIN_TEXT) { if (records[0].getType() == uniformTypeDescriptor.UniformDataType.PLAIN_TEXT) {
let plainText = <unifiedDataChannel.PlainText> (records[0]); let plainText = records[0] as unifiedDataChannel.PlainText;
console.info(`textContent: ${plainText.textContent}`); console.info(`textContent: ${plainText.textContent}`);
} }
``` ```
...@@ -426,9 +426,13 @@ let unifiedData = new unifiedDataChannel.UnifiedData(appItem); ...@@ -426,9 +426,13 @@ let unifiedData = new unifiedDataChannel.UnifiedData(appItem);
import image from '@ohos.multimedia.image'; // PixelMap类定义所在模块 import image from '@ohos.multimedia.image'; // PixelMap类定义所在模块
const color = new ArrayBuffer(96); // 创建pixelmap对象 const color = new ArrayBuffer(96); // 创建pixelmap对象
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } let opts: image.InitializationOptions = {
editable: true, pixelFormat: 3, size: {
height: 4, width: 6
}
}
image.createPixelMap(color, opts, (error, pixelmap) => { image.createPixelMap(color, opts, (error, pixelmap) => {
if(error) { if (error) {
console.error('Failed to create pixelmap.'); console.error('Failed to create pixelmap.');
} else { } else {
console.info('Succeeded in creating pixelmap.'); console.info('Succeeded in creating pixelmap.');
...@@ -507,12 +511,13 @@ insertData(options: Options, data: UnifiedData, callback: AsyncCallback&lt;strin ...@@ -507,12 +511,13 @@ insertData(options: Options, data: UnifiedData, callback: AsyncCallback&lt;strin
```ts ```ts
import unifiedDataChannel from '@ohos.data.unifiedDataChannel'; import unifiedDataChannel from '@ohos.data.unifiedDataChannel';
import { BusinessError } from '@ohos.base';
let plainText = new unifiedDataChannel.PlainText(); let plainText = new unifiedDataChannel.PlainText();
plainText.textContent = 'hello world!'; plainText.textContent = 'hello world!';
let unifiedData = new unifiedDataChannel.UnifiedData(plainText); let unifiedData = new unifiedDataChannel.UnifiedData(plainText);
let options = { let options: unifiedDataChannel.Options = {
intention: unifiedDataChannel.Intention.DATA_HUB intention: unifiedDataChannel.Intention.DATA_HUB
} }
try { try {
...@@ -523,8 +528,9 @@ try { ...@@ -523,8 +528,9 @@ try {
console.error(`Failed to insert data. code is ${err.code},message is ${err.message} `); console.error(`Failed to insert data. code is ${err.code},message is ${err.message} `);
} }
}); });
} catch(e) { } catch (e) {
console.error(`Insert data throws an exception. code is ${e.code},message is ${e.message} `); let error: BusinessError = e as BusinessError;
console.error(`Insert data throws an exception. code is ${error.code},message is ${error.message} `);
} }
``` ```
...@@ -554,22 +560,24 @@ insertData(options: Options, data: UnifiedData): Promise&lt;string&gt; ...@@ -554,22 +560,24 @@ insertData(options: Options, data: UnifiedData): Promise&lt;string&gt;
```ts ```ts
import unifiedDataChannel from '@ohos.data.unifiedDataChannel'; import unifiedDataChannel from '@ohos.data.unifiedDataChannel';
import { BusinessError } from '@ohos.base';
let plainText = new unifiedDataChannel.PlainText(); let plainText = new unifiedDataChannel.PlainText();
plainText.textContent = 'hello world!'; plainText.textContent = 'hello world!';
let unifiedData = new unifiedDataChannel.UnifiedData(plainText); let unifiedData = new unifiedDataChannel.UnifiedData(plainText);
let options = { let options: unifiedDataChannel.Options = {
intention: unifiedDataChannel.Intention.DATA_HUB intention: unifiedDataChannel.Intention.DATA_HUB
} }
try { try {
unifiedDataChannel.insertData(options, unifiedData).then((data) => { unifiedDataChannel.insertData(options, unifiedData).then((data) => {
console.info(`Succeeded in inserting data. key = ${data}`); console.info(`Succeeded in inserting data. key = ${data}`);
}).catch((err) => { }).catch((err: BusinessError) => {
console.error(`Failed to insert data. code is ${err.code},message is ${err.message} `); console.error(`Failed to insert data. code is ${err.code},message is ${err.message} `);
}); });
} catch(e) { } catch (e) {
console.error(`Insert data throws an exception. code is ${e.code},message is ${e.message} `); let error: BusinessError = e as BusinessError;
console.error(`Insert data throws an exception. code is ${error.code},message is ${error.message} `);
} }
``` ```
...@@ -593,12 +601,13 @@ updateData(options: Options, data: UnifiedData, callback: AsyncCallback&lt;void& ...@@ -593,12 +601,13 @@ updateData(options: Options, data: UnifiedData, callback: AsyncCallback&lt;void&
```ts ```ts
import unifiedDataChannel from '@ohos.data.unifiedDataChannel'; import unifiedDataChannel from '@ohos.data.unifiedDataChannel';
import { BusinessError } from '@ohos.base';
let plainText = new unifiedDataChannel.PlainText(); let plainText = new unifiedDataChannel.PlainText();
plainText.textContent = 'hello world!'; plainText.textContent = 'hello world!';
let unifiedData = new unifiedDataChannel.UnifiedData(plainText); let unifiedData = new unifiedDataChannel.UnifiedData(plainText);
let options = { let options: unifiedDataChannel.Options = {
key: 'udmf://DataHub/com.ohos.test/0123456789' key: 'udmf://DataHub/com.ohos.test/0123456789'
}; };
...@@ -610,8 +619,9 @@ try { ...@@ -610,8 +619,9 @@ try {
console.error(`Failed to update data. code is ${err.code},message is ${err.message} `); console.error(`Failed to update data. code is ${err.code},message is ${err.message} `);
} }
}); });
} catch(e) { } catch (e) {
console.error(`Update data throws an exception. code is ${e.code},message is ${e.message} `); let error: BusinessError = e as BusinessError;
console.error(`Update data throws an exception. code is ${error.code},message is ${error.message} `);
} }
``` ```
...@@ -640,23 +650,25 @@ updateData(options: Options, data: UnifiedData): Promise&lt;void&gt; ...@@ -640,23 +650,25 @@ updateData(options: Options, data: UnifiedData): Promise&lt;void&gt;
```ts ```ts
import unifiedDataChannel from '@ohos.data.unifiedDataChannel'; import unifiedDataChannel from '@ohos.data.unifiedDataChannel';
import { BusinessError } from '@ohos.base';
let plainText = new unifiedDataChannel.PlainText(); let plainText = new unifiedDataChannel.PlainText();
plainText.textContent = 'hello world!'; plainText.textContent = 'hello world!';
let unifiedData = new unifiedDataChannel.UnifiedData(plainText); let unifiedData = new unifiedDataChannel.UnifiedData(plainText);
let options = { let options: unifiedDataChannel.Options = {
key: 'udmf://DataHub/com.ohos.test/0123456789' key: 'udmf://DataHub/com.ohos.test/0123456789'
}; };
try { try {
unifiedDataChannel.updateData(options, unifiedData).then(() => { unifiedDataChannel.updateData(options, unifiedData).then(() => {
console.info('Succeeded in updating data.'); console.info('Succeeded in updating data.');
}).catch((err) => { }).catch((err: BusinessError) => {
console.error(`Failed to update data. code is ${err.code},message is ${err.message} `); console.error(`Failed to update data. code is ${err.code},message is ${err.message} `);
}); });
} catch(e) { } catch (e) {
console.error(`Update data throws an exception. code is ${e.code},message is ${e.message} `); let error: BusinessError = e as BusinessError;
console.error(`Update data throws an exception. code is ${error.code},message is ${error.message} `);
} }
``` ```
...@@ -680,8 +692,9 @@ queryData(options: Options, callback: AsyncCallback&lt;Array&lt;UnifiedData&gt;& ...@@ -680,8 +692,9 @@ queryData(options: Options, callback: AsyncCallback&lt;Array&lt;UnifiedData&gt;&
```ts ```ts
import unifiedDataChannel from '@ohos.data.unifiedDataChannel'; import unifiedDataChannel from '@ohos.data.unifiedDataChannel';
import uniformTypeDescriptor from '@ohos.data.uniformTypeDescriptor'; import uniformTypeDescriptor from '@ohos.data.uniformTypeDescriptor';
import { BusinessError } from '@ohos.base';
let options = { let options: unifiedDataChannel.Options = {
intention: unifiedDataChannel.Intention.DATA_HUB intention: unifiedDataChannel.Intention.DATA_HUB
}; };
...@@ -693,7 +706,7 @@ try { ...@@ -693,7 +706,7 @@ try {
let records = data[i].getRecords(); let records = data[i].getRecords();
for (let j = 0; j < records.length; j++) { for (let j = 0; j < records.length; j++) {
if (records[j].getType() === uniformTypeDescriptor.UniformDataType.PLAIN_TEXT) { if (records[j].getType() === uniformTypeDescriptor.UniformDataType.PLAIN_TEXT) {
let text = <unifiedDataChannel.PlainText>(records[j]); let text = records[j] as unifiedDataChannel.PlainText;
console.info(`${i + 1}.${text.textContent}`); console.info(`${i + 1}.${text.textContent}`);
} }
} }
...@@ -702,8 +715,9 @@ try { ...@@ -702,8 +715,9 @@ try {
console.error(`Failed to query data. code is ${err.code},message is ${err.message} `); console.error(`Failed to query data. code is ${err.code},message is ${err.message} `);
} }
}); });
} catch(e) { } catch (e) {
console.error(`Query data throws an exception. code is ${e.code},message is ${e.message} `); let error: BusinessError = e as BusinessError;
console.error(`Query data throws an exception. code is ${error.code},message is ${error.message} `);
} }
``` ```
...@@ -732,8 +746,9 @@ queryData(options: Options): Promise&lt;Array&lt;UnifiedData&gt;&gt; ...@@ -732,8 +746,9 @@ queryData(options: Options): Promise&lt;Array&lt;UnifiedData&gt;&gt;
```ts ```ts
import unifiedDataChannel from '@ohos.data.unifiedDataChannel'; import unifiedDataChannel from '@ohos.data.unifiedDataChannel';
import uniformTypeDescriptor from '@ohos.data.uniformTypeDescriptor'; import uniformTypeDescriptor from '@ohos.data.uniformTypeDescriptor';
import { BusinessError } from '@ohos.base';
let options = { let options: unifiedDataChannel.Options = {
key: 'udmf://DataHub/com.ohos.test/0123456789' key: 'udmf://DataHub/com.ohos.test/0123456789'
}; };
...@@ -744,16 +759,17 @@ try { ...@@ -744,16 +759,17 @@ try {
let records = data[i].getRecords(); let records = data[i].getRecords();
for (let j = 0; j < records.length; j++) { for (let j = 0; j < records.length; j++) {
if (records[j].getType() === uniformTypeDescriptor.UniformDataType.PLAIN_TEXT) { if (records[j].getType() === uniformTypeDescriptor.UniformDataType.PLAIN_TEXT) {
let text = <unifiedDataChannel.PlainText>(records[j]); let text = records[j] as unifiedDataChannel.PlainText;
console.info(`${i + 1}.${text.textContent}`); console.info(`${i + 1}.${text.textContent}`);
} }
} }
} }
}).catch((err) => { }).catch((err: BusinessError) => {
console.error(`Failed to query data. code is ${err.code},message is ${err.message} `); console.error(`Failed to query data. code is ${err.code},message is ${err.message} `);
}); });
} catch(e) { } catch (e) {
console.error(`Query data throws an exception. code is ${e.code},message is ${e.message} `); let error: BusinessError = e as BusinessError;
console.error(`Query data throws an exception. code is ${error.code},message is ${error.message} `);
} }
``` ```
...@@ -777,8 +793,9 @@ deleteData(options: Options, callback: AsyncCallback&lt;Array&lt;UnifiedData&gt; ...@@ -777,8 +793,9 @@ deleteData(options: Options, callback: AsyncCallback&lt;Array&lt;UnifiedData&gt;
```ts ```ts
import unifiedDataChannel from '@ohos.data.unifiedDataChannel'; import unifiedDataChannel from '@ohos.data.unifiedDataChannel';
import uniformTypeDescriptor from '@ohos.data.uniformTypeDescriptor'; import uniformTypeDescriptor from '@ohos.data.uniformTypeDescriptor';
import { BusinessError } from '@ohos.base';
let options = { let options: unifiedDataChannel.Options = {
intention: unifiedDataChannel.Intention.DATA_HUB intention: unifiedDataChannel.Intention.DATA_HUB
}; };
...@@ -790,7 +807,7 @@ try { ...@@ -790,7 +807,7 @@ try {
let records = data[i].getRecords(); let records = data[i].getRecords();
for (let j = 0; j < records.length; j++) { for (let j = 0; j < records.length; j++) {
if (records[j].getType() === uniformTypeDescriptor.UniformDataType.PLAIN_TEXT) { if (records[j].getType() === uniformTypeDescriptor.UniformDataType.PLAIN_TEXT) {
let text = <unifiedDataChannel.PlainText>(records[j]); let text = records[j] as unifiedDataChannel.PlainText;
console.info(`${i + 1}.${text.textContent}`); console.info(`${i + 1}.${text.textContent}`);
} }
} }
...@@ -799,8 +816,9 @@ try { ...@@ -799,8 +816,9 @@ try {
console.error(`Failed to delete data. code is ${err.code},message is ${err.message} `); console.error(`Failed to delete data. code is ${err.code},message is ${err.message} `);
} }
}); });
} catch(e) { } catch (e) {
console.error(`Delete data throws an exception. code is ${e.code},message is ${e.message} `); let error: BusinessError = e as BusinessError;
console.error(`Delete data throws an exception. code is ${error.code},message is ${error.message} `);
} }
``` ```
...@@ -829,8 +847,9 @@ deleteData(options: Options): Promise&lt;Array&lt;UnifiedData&gt;&gt; ...@@ -829,8 +847,9 @@ deleteData(options: Options): Promise&lt;Array&lt;UnifiedData&gt;&gt;
```ts ```ts
import unifiedDataChannel from '@ohos.data.unifiedDataChannel'; import unifiedDataChannel from '@ohos.data.unifiedDataChannel';
import uniformTypeDescriptor from '@ohos.data.uniformTypeDescriptor'; import uniformTypeDescriptor from '@ohos.data.uniformTypeDescriptor';
import { BusinessError } from '@ohos.base';
let options = { let options: unifiedDataChannel.Options = {
key: 'udmf://DataHub/com.ohos.test/0123456789' key: 'udmf://DataHub/com.ohos.test/0123456789'
}; };
...@@ -841,15 +860,16 @@ try { ...@@ -841,15 +860,16 @@ try {
let records = data[i].getRecords(); let records = data[i].getRecords();
for (let j = 0; j < records.length; j++) { for (let j = 0; j < records.length; j++) {
if (records[j].getType() === uniformTypeDescriptor.UniformDataType.PLAIN_TEXT) { if (records[j].getType() === uniformTypeDescriptor.UniformDataType.PLAIN_TEXT) {
let text = <unifiedDataChannel.PlainText>(records[j]); let text = records[j] as unifiedDataChannel.PlainText;
console.info(`${i + 1}.${text.textContent}`); console.info(`${i + 1}.${text.textContent}`);
} }
} }
} }
}).catch((err) => { }).catch((err: BusinessError) => {
console.error(`Failed to delete data. code is ${err.code},message is ${err.message} `); console.error(`Failed to delete data. code is ${err.code},message is ${err.message} `);
}); });
} catch(e) { } catch (e) {
console.error(`Delete data throws an exception. code is ${e.code},message is ${e.message} `); let error: BusinessError = e as BusinessError;
console.error(`Query data throws an exception. code is ${error.code},message is ${error.message} `);
} }
``` ```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册