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

!23214 【udmf】指南arkts检查修改

Merge pull request !23214 from Wangkai/master
...@@ -54,12 +54,13 @@ UDMF针对多对多跨应用数据共享的不同业务场景提供了标准化 ...@@ -54,12 +54,13 @@ UDMF针对多对多跨应用数据共享的不同业务场景提供了标准化
2. 创建一个统一数据对象并插入到UDMF的公共数据通路中。 2. 创建一个统一数据对象并插入到UDMF的公共数据通路中。
```ts ```ts
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 {
...@@ -70,19 +71,21 @@ UDMF针对多对多跨应用数据共享的不同业务场景提供了标准化 ...@@ -70,19 +71,21 @@ UDMF针对多对多跨应用数据共享的不同业务场景提供了标准化
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} `);
} }
``` ```
3. 更新上一步骤插入的统一数据对象。 3. 更新上一步骤插入的统一数据对象。
```ts ```ts
import { BusinessError } from '@ohos.base';
let plainText = new unifiedDataChannel.PlainText(); let plainText = new unifiedDataChannel.PlainText();
plainText.textContent = 'How are you!'; plainText.textContent = 'How are you!';
let unifiedData = new unifiedDataChannel.UnifiedData(plainText); let unifiedData = new unifiedDataChannel.UnifiedData(plainText);
// 指定要更新的统一数据对象的URI // 指定要更新的统一数据对象的URI
let options = { let options: unifiedDataChannel.Options = {
key: 'udmf://DataHub/com.ohos.test/0123456789' key: 'udmf://DataHub/com.ohos.test/0123456789'
}; };
...@@ -94,15 +97,17 @@ UDMF针对多对多跨应用数据共享的不同业务场景提供了标准化 ...@@ -94,15 +97,17 @@ UDMF针对多对多跨应用数据共享的不同业务场景提供了标准化
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} `);
} }
``` ```
4. 删除存储在UDMF公共数据通路中的统一数据对象。 4. 删除存储在UDMF公共数据通路中的统一数据对象。
```ts ```ts
import { BusinessError } from '@ohos.base';
// 指定要删除数据的数据通路枚举类型 // 指定要删除数据的数据通路枚举类型
let options = { let options: unifiedDataChannel.Options = {
intention: unifiedDataChannel.Intention.DATA_HUB intention: unifiedDataChannel.Intention.DATA_HUB
}; };
...@@ -114,7 +119,7 @@ UDMF针对多对多跨应用数据共享的不同业务场景提供了标准化 ...@@ -114,7 +119,7 @@ UDMF针对多对多跨应用数据共享的不同业务场景提供了标准化
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}`);
} }
} }
...@@ -123,8 +128,9 @@ UDMF针对多对多跨应用数据共享的不同业务场景提供了标准化 ...@@ -123,8 +128,9 @@ UDMF针对多对多跨应用数据共享的不同业务场景提供了标准化
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} `);
} }
``` ```
...@@ -139,8 +145,9 @@ UDMF针对多对多跨应用数据共享的不同业务场景提供了标准化 ...@@ -139,8 +145,9 @@ UDMF针对多对多跨应用数据共享的不同业务场景提供了标准化
2. 查询存储在UDMF公共数据通路中的统一数据对象。 2. 查询存储在UDMF公共数据通路中的统一数据对象。
```ts ```ts
import { BusinessError } from '@ohos.base';
// 指定要查询数据的数据通路枚举类型 // 指定要查询数据的数据通路枚举类型
let options = { let options: unifiedDataChannel.Options = {
intention: unifiedDataChannel.Intention.DATA_HUB intention: unifiedDataChannel.Intention.DATA_HUB
}; };
...@@ -152,7 +159,7 @@ UDMF针对多对多跨应用数据共享的不同业务场景提供了标准化 ...@@ -152,7 +159,7 @@ UDMF针对多对多跨应用数据共享的不同业务场景提供了标准化
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}`);
} }
} }
...@@ -162,6 +169,7 @@ UDMF针对多对多跨应用数据共享的不同业务场景提供了标准化 ...@@ -162,6 +169,7 @@ UDMF针对多对多跨应用数据共享的不同业务场景提供了标准化
} }
}); });
} 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} `);
} }
``` ```
...@@ -114,11 +114,11 @@ UDMF提供了统一数据对象UnifiedData,用于封装一组数据记录Unifi ...@@ -114,11 +114,11 @@ UDMF提供了统一数据对象UnifiedData,用于封装一组数据记录Unifi
switch (type) { switch (type) {
case uniformTypeDescriptor.UniformDataType.IMAGE: case uniformTypeDescriptor.UniformDataType.IMAGE:
// 转换得到原图片数据记录 // 转换得到原图片数据记录
let image = <unifiedDataChannel.Image>(records[i]); let image = records[i] as unifiedDataChannel.Image;
break; break;
case uniformTypeDescriptor.UniformDataType.PLAIN_TEXT: case uniformTypeDescriptor.UniformDataType.PLAIN_TEXT:
// 转换得到原文本数据记录 // 转换得到原文本数据记录
let plainText = <unifiedDataChannel.PlainText>(records[i]); let plainText = records[i] as unifiedDataChannel.PlainText;
break; break;
default: default:
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册