mirror of
https://gitee.com/openharmony/applications_app_samples
synced 2024-11-24 09:00:13 +00:00
[Sample] LanguageBaseClassLibrary ArkTS语法整改
Signed-off-by: zwx1126739 <zhanghong121@huawei.com>
This commit is contained in:
parent
479c880f85
commit
cf41a3815d
@ -38,12 +38,12 @@
|
||||
2. 各个子模块界面中点击功能按钮完成各个功能。
|
||||
3. Util中有二级菜单,点击进入对应的二级界面,包含:
|
||||
|
||||
* StringCode:字符串编解码,点击功能按钮完成各个功能。
|
||||
* RationnalNumber:有理数比较,点击功能按钮完成各个功能。
|
||||
* LRUCache:LRU缓冲区,点击功能按钮完成各个功能。
|
||||
* ScopeHelper:范围判断,点击功能按钮完成各个功能。
|
||||
* Base64Helper:Base64编解码,点击功能按钮完成各个功能。
|
||||
* TypeCheck:类型检查,点击功能按钮完成各个功能。
|
||||
* StringCode:字符串编解码,点击功能按钮完成各个功能。
|
||||
* RationnalNumber:有理数比较,点击功能按钮完成各个功能。
|
||||
* LRUCache:LRU缓冲区,点击功能按钮完成各个功能。
|
||||
* ScopeHelper:范围判断,点击功能按钮完成各个功能。
|
||||
* Base64Helper:Base64编解码,点击功能按钮完成各个功能。
|
||||
* TypeCheck:类型检查,点击功能按钮完成各个功能。
|
||||
4. TaskPool界面中,点击Execute task执行任务,点击Cancel task取消任务。
|
||||
5. ArrayList界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。
|
||||
6. Deque界面中,点击+号添加数据后展示数据,点击删除按钮删除对应的一条数据。
|
||||
@ -167,11 +167,11 @@ LanguageBaseClassLibrary
|
||||
|
||||
1. 本示例仅支持标准系统上运行。
|
||||
|
||||
2. 本示例适配API version 10版本,版本号:4.0.8.3,镜像版本号:OpenHarmony 4.0.8.3。
|
||||
2. 本示例适配API version 10版本,版本号:4.0.10.11,镜像版本号:OpenHarmony 4.1.1.5。
|
||||
|
||||
3. 本示例涉及使用系统接口,需要手动替换Full SDK才能编译通过,具体操作可参考[替换指南](https://docs.openharmony.cn/pages/v3.2/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md/) 。
|
||||
|
||||
4. 本示例需要使用DevEco Studio 3.1 Release (Build Version: 3.1.0.500, built on April 28, 2023)才可编译运行。
|
||||
4. 本示例需要使用DevEco Studio 4.0 Beta2 (Build Version: 4.0.0.400, built on August 2, 2023)才可编译运行。
|
||||
|
||||
### 下载
|
||||
|
||||
|
@ -16,12 +16,13 @@
|
||||
{
|
||||
"app": {
|
||||
"signingConfigs": [],
|
||||
"compileSdkVersion": 10,
|
||||
"compatibleSdkVersion": 10,
|
||||
"products": [
|
||||
{
|
||||
"name": "default",
|
||||
"signingConfig": "default",
|
||||
"compileSdkVersion": 10,
|
||||
"compatibleSdkVersion": 10,
|
||||
"runtimeOS": "OpenHarmony"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -23,7 +23,7 @@ export class BaseDataSource implements IDataSource {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public getData(index: number): any {
|
||||
public getData(index: number): ESObject {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ class BasicDataSource implements IDataSource {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public getData(index: number): any {
|
||||
public getData(index: number): ESObject {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ class BasicDataSource implements IDataSource {
|
||||
export class CustomDataSource extends BasicDataSource {
|
||||
public dataArray: string[] = [];
|
||||
|
||||
constructor(ele) {
|
||||
constructor(ele: string[]) {
|
||||
super();
|
||||
for (let index = 0;index < ele.length; index++) {
|
||||
this.dataArray.push(ele[index]);
|
||||
@ -75,7 +75,7 @@ export class CustomDataSource extends BasicDataSource {
|
||||
}
|
||||
|
||||
public addData(index: number, data: string): void {
|
||||
this.dataArray.splice(index, 0);
|
||||
this.dataArray.splice(index, 0, data);
|
||||
this.notifyDataAdd(index);
|
||||
}
|
||||
}
|
@ -16,12 +16,12 @@
|
||||
import common from '@ohos.app.ability.common';
|
||||
|
||||
export async function getStringArray(resource: Resource): Promise<Array<string>> {
|
||||
let context = getContext(this) as common.UIAbilityContext;
|
||||
let context = getContext() as common.UIAbilityContext;
|
||||
let menuList: Array<string> = await context.resourceManager.getStringArrayValue(resource);
|
||||
return menuList;
|
||||
}
|
||||
|
||||
export function getString(resource: Resource): string {
|
||||
let context = getContext(this) as common.UIAbilityContext;
|
||||
let context = getContext() as common.UIAbilityContext;
|
||||
return context.resourceManager.getStringSync(resource);
|
||||
}
|
||||
|
@ -15,8 +15,10 @@
|
||||
|
||||
import display from '@ohos.display';
|
||||
import UIAbility from '@ohos.app.ability.UIAbility';
|
||||
import type window from '@ohos.window';
|
||||
import window from '@ohos.window';
|
||||
import { logger } from '@ohos/common';
|
||||
import Want from '@ohos.app.ability.Want';
|
||||
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
|
||||
|
||||
const BREAKPOINT_MD: number = 600;
|
||||
const BREAKPOINT_BIG: number = 840;
|
||||
@ -24,7 +26,7 @@ const PARAMS_PX_TO_VP: number = 160;
|
||||
const TAG: string = 'EntryAbility';
|
||||
|
||||
export default class EntryAbility extends UIAbility {
|
||||
onCreate(want, launchParam): void {
|
||||
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
|
||||
logger.info(TAG, 'Ability onCreate');
|
||||
AppStorage.SetOrCreate('selectedLabel', '');
|
||||
AppStorage.SetOrCreate('selectedSecondLabel', '');
|
@ -22,12 +22,14 @@ const MIN_AGE = 1;
|
||||
const AGE_RANGE = 9;
|
||||
const AGE_DEFAULT = 0;
|
||||
|
||||
const arr = Array(AGE_RANGE).fill(0).map((_, i) => `${i + MIN_AGE}${getString($r('app.string.old'))}`);
|
||||
const arr = Array(AGE_RANGE)
|
||||
.fill(0)
|
||||
.map<string>((_: number, i: number) => `${i + MIN_AGE}${getString($r('app.string.old'))}`);
|
||||
|
||||
@CustomDialog
|
||||
struct AgePickDialog {
|
||||
private controller: CustomDialogController;
|
||||
private sure: (age: number) => void;
|
||||
private controller?: CustomDialogController;
|
||||
private sure: (age: number) => void = () => {};
|
||||
@State select: number = AGE_DEFAULT;
|
||||
|
||||
build() {
|
||||
@ -41,8 +43,10 @@ struct AgePickDialog {
|
||||
|
||||
Column() {
|
||||
TextPicker({ range: arr, selected: this.select })
|
||||
.onChange((value: string, index: number) => {
|
||||
this.select = index;
|
||||
.onChange((value: string | string[], index: number | number[]) => {
|
||||
if (typeof index === 'number') {
|
||||
this.select = index;
|
||||
}
|
||||
})
|
||||
}
|
||||
.width('100%')
|
||||
@ -56,7 +60,7 @@ struct AgePickDialog {
|
||||
.fontSize(16)
|
||||
.fontColor($r('app.color.text_color_accent'))
|
||||
.onClick(() => {
|
||||
this.controller.close();
|
||||
this.controller?.close();
|
||||
})
|
||||
Divider()
|
||||
.vertical(true)
|
||||
@ -70,7 +74,7 @@ struct AgePickDialog {
|
||||
.fontColor($r('app.color.text_color_accent'))
|
||||
.onClick(() => {
|
||||
this.sure(this.select + MIN_AGE)
|
||||
this.controller.close();
|
||||
this.controller?.close();
|
||||
})
|
||||
}
|
||||
.height(40)
|
||||
@ -85,7 +89,7 @@ struct AgePickDialog {
|
||||
@Entry
|
||||
@Component
|
||||
export struct AddInformationView {
|
||||
@State information: Information = { name: '', age: 0, phone: '', clickAble: true }
|
||||
@State information: Information = new Information('', 0, '', true)
|
||||
private dialogController: CustomDialogController = new CustomDialogController({
|
||||
builder: AgePickDialog({ sure: (age: number) => {
|
||||
this.information.age = age;
|
||||
@ -96,7 +100,7 @@ export struct AddInformationView {
|
||||
@State flag: string = '';
|
||||
|
||||
aboutToAppear() {
|
||||
let tem: string = router.getParams()['title'];
|
||||
let tem: string = (router.getParams() as Record<string, Object>)['title'] as string;
|
||||
if (!tem) {
|
||||
return;
|
||||
}
|
||||
@ -162,12 +166,12 @@ export struct AddInformationView {
|
||||
break;
|
||||
}
|
||||
|
||||
let event = {
|
||||
let event: emitter.InnerEvent = {
|
||||
eventId: eventId,
|
||||
priority: emitter.EventPriority.HIGH
|
||||
};
|
||||
|
||||
let eventData = {
|
||||
let eventData: emitter.EventData = {
|
||||
data: this.information
|
||||
};
|
||||
|
||||
|
@ -21,17 +21,20 @@ import { getString } from '@ohos/common';
|
||||
@Entry
|
||||
@Component
|
||||
export struct AddKeyValueView {
|
||||
@State keyValuePair: KeyValuePair = { key: '', value: '' }
|
||||
@State keyValuePair: KeyValuePair = new KeyValuePair('', '')
|
||||
@State title: string = '';
|
||||
@State flag: string = '';
|
||||
|
||||
aboutToAppear() {
|
||||
let tem: string = router.getParams()['title'];
|
||||
let tem: string = (router.getParams() as Record<string, Object>)['title'] as string;
|
||||
if (!tem) {
|
||||
return;
|
||||
}
|
||||
this.flag = tem;
|
||||
this.title = `${getString($r('app.string.add'))}${tem.match(/.*(?=\(|()/)[0]}`;
|
||||
let matchArr: RegExpMatchArray | null = tem.match(new RegExp('.*(?=\\(|()'));
|
||||
if (matchArr !== null) {
|
||||
this.title = `${getString($r('app.string.add'))}${matchArr[0]}`;
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
@ -87,12 +90,12 @@ export struct AddKeyValueView {
|
||||
break;
|
||||
}
|
||||
|
||||
let event = {
|
||||
let event: emitter.InnerEvent = {
|
||||
eventId: eventId,
|
||||
priority: emitter.EventPriority.HIGH
|
||||
};
|
||||
|
||||
let eventData = {
|
||||
let eventData: emitter.EventData = {
|
||||
data: this.keyValuePair
|
||||
};
|
||||
|
||||
|
@ -26,12 +26,16 @@ export struct AddKeyValueView {
|
||||
@State flag: string = '';
|
||||
|
||||
aboutToAppear() {
|
||||
let tem: string = router.getParams()['title'];
|
||||
let tem: string = (router.getParams() as Record<string, Object>)['title'] as string;
|
||||
if (!tem) {
|
||||
return;
|
||||
}
|
||||
this.flag = tem;
|
||||
this.title = `${getString($r('app.string.add'))}${tem.match(/.*(?=\(|()/)[0]}`;
|
||||
let regex: RegExp = new RegExp('.*(?=\\(|()');
|
||||
let matchArr: RegExpMatchArray | null = tem.match(regex);
|
||||
if (matchArr !== null) {
|
||||
this.title = `${getString($r('app.string.add'))}${matchArr[0]}`;
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
@ -84,12 +88,12 @@ export struct AddKeyValueView {
|
||||
break;
|
||||
}
|
||||
|
||||
let event = {
|
||||
let event: emitter.InnerEvent = {
|
||||
eventId: eventId,
|
||||
priority: emitter.EventPriority.HIGH
|
||||
};
|
||||
|
||||
let eventData = {
|
||||
let eventData: emitter.EventData = {
|
||||
data: { 'value': this.value }
|
||||
};
|
||||
|
||||
|
@ -38,7 +38,7 @@ struct Index {
|
||||
.color($r('sys.color.ohos_id_color_list_separator'))
|
||||
MenuList({
|
||||
menuList: $r('app.strarray.language_base_class_library_list'),
|
||||
addAction: (title) => {
|
||||
addAction: (title: string) => {
|
||||
logger.info(TAG, `addAction: title = ${title}`)
|
||||
switch (title) {
|
||||
case getString($r('app.string.deque')):
|
||||
|
@ -29,7 +29,7 @@
|
||||
"abilities": [
|
||||
{
|
||||
"name": "EntryAbility",
|
||||
"srcEntrance": "./ets/entryability/EntryAbility.ts",
|
||||
"srcEntrance": "./ets/entryability/EntryAbility.ets",
|
||||
"description": "$string:EntryAbility_desc",
|
||||
"icon": "$media:icon",
|
||||
"label": "$string:lable_name",
|
||||
|
@ -17,6 +17,7 @@ import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry
|
||||
import { describe, it, expect } from '@ohos/hypium';
|
||||
import { Driver, ON, MatchPattern } from '@ohos.UiTest';
|
||||
import { logger } from '../util/Logger';
|
||||
import Want from '@ohos.app.ability.Want';
|
||||
|
||||
const TAG: string = 'Sample_LanguageBaseClassLibraryTest';
|
||||
const BUNDLE = 'LanguageBaseClassLibrary';
|
||||
@ -112,11 +113,11 @@ async function addValue(driver: Driver, value: string) {
|
||||
}
|
||||
|
||||
export default function abilityTest() {
|
||||
describe('ActsAbilityTest', function () {
|
||||
describe('ActsAbilityTest', () => {
|
||||
// 打开应用
|
||||
it(BUNDLE + 'StartAbility_001', 0, async function (done) {
|
||||
it(BUNDLE + 'StartAbility_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, `${BUNDLE}StartAbility_001 begin`);
|
||||
let want = {
|
||||
let want: Want = {
|
||||
bundleName: 'com.samples.languagebaseclasslibrary',
|
||||
abilityName: 'EntryAbility'
|
||||
};
|
||||
@ -129,7 +130,7 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
// 进入xml解析、生成与转换页面
|
||||
it(BUNDLE + 'Xml_ConvertXml_001', 0, async function (done) {
|
||||
it(BUNDLE + 'Xml_ConvertXml_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, `${BUNDLE}Xml_ConvertXml_001 begin`);
|
||||
await driver.delayMs(200);
|
||||
// find component on text 'Xml'
|
||||
@ -162,7 +163,7 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
// 进入Util界面
|
||||
it(BUNDLE + 'util_001', 0, async function (done) {
|
||||
it(BUNDLE + 'util_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, `${BUNDLE}util_001 begin`);
|
||||
await driver.delayMs(200);
|
||||
// check text
|
||||
@ -175,7 +176,7 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
// StringCode(字符串编码)
|
||||
it(BUNDLE + 'StringCodeFunction_001', 0, async function (done) {
|
||||
it(BUNDLE + 'StringCodeFunction_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, `${BUNDLE} StringCodeFunction_001 begin`);
|
||||
await driver.delayMs(200);
|
||||
// 进入字符串编解码界面
|
||||
@ -222,7 +223,7 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
// RationalNumber(有理数)
|
||||
it(BUNDLE + 'RationalNumber_001', 0, async function (done) {
|
||||
it(BUNDLE + 'RationalNumber_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, `${BUNDLE}RationalNumber_001 begin`);
|
||||
await driver.delayMs(200);
|
||||
// 进入有理数界面
|
||||
@ -267,7 +268,7 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
// 进入到LRUCache (缓冲区)
|
||||
it(BUNDLE + 'UtilLruBuffer_001', 0, async function (done) {
|
||||
it(BUNDLE + 'UtilLruBuffer_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, `${BUNDLE}UtilLruBuffer_001 begin`);
|
||||
await driver.delayMs(200);
|
||||
// find component on text 'LRUCache'
|
||||
@ -351,7 +352,7 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
// Base64Helper (Base64编解码)
|
||||
it(BUNDLE + 'UtilBase64Codec_001', 0, async function (done) {
|
||||
it(BUNDLE + 'UtilBase64Codec_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, `${BUNDLE}UtilBase64Codec_001 begin`);
|
||||
await driver.delayMs(200);
|
||||
// 进入Base64编解码
|
||||
@ -376,7 +377,7 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
// TypeCheck (类型检查)
|
||||
it(BUNDLE + 'TypeCheck_001', 0, async function (done) {
|
||||
it(BUNDLE + 'TypeCheck_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, `${BUNDLE}TypeCheck_001 begin`);
|
||||
await driver.delayMs(200);
|
||||
// 进入类型检查
|
||||
@ -404,7 +405,7 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
// 进入Url字符串解析页面
|
||||
it(BUNDLE + 'Url_001', 0, async function (done) {
|
||||
it(BUNDLE + 'Url_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, `${BUNDLE}Url_001 begin`);
|
||||
await driver.delayMs(500);
|
||||
// find component on text 'Xml'
|
||||
@ -420,7 +421,7 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
// Url字符串解析
|
||||
it(BUNDLE + 'ClickUrlStringBtnFunction_001', 0, async function (done) {
|
||||
it(BUNDLE + 'ClickUrlStringBtnFunction_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, BUNDLE + 'ClickUrlStringBtnFunction_001 begin')
|
||||
await driver.delayMs(1000)
|
||||
// 点击插入键值对到查询字符串
|
||||
@ -478,7 +479,7 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
// 进入TaskPool页面
|
||||
it(BUNDLE + 'TaskPool_001', 0, async function (done) {
|
||||
it(BUNDLE + 'TaskPool_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, `${BUNDLE}TaskPool_001 begin`);
|
||||
await driver.delayMs(200);
|
||||
// 滚动到TaskPool
|
||||
@ -506,7 +507,7 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
// 进入Deque界面
|
||||
it(BUNDLE + 'deque_001', 0, async function (done) {
|
||||
it(BUNDLE + 'deque_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, `${BUNDLE}deque_001 begin`);
|
||||
await driver.delayMs(200);
|
||||
// 滚动到Deque
|
||||
@ -524,7 +525,7 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
// 新增数据
|
||||
it(BUNDLE + 'DequeAddFunction_001', 0, async function (done) {
|
||||
it(BUNDLE + 'DequeAddFunction_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, `${BUNDLE} DequeAddFunction_001 begin`);
|
||||
await driver.delayMs(200);
|
||||
// 添加三条数据
|
||||
@ -542,7 +543,7 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
// 进入HashMap界面
|
||||
it(BUNDLE + 'hash_map_001', 0, async function (done) {
|
||||
it(BUNDLE + 'hash_map_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, `${BUNDLE}hash_map_001 begin`);
|
||||
await driver.delayMs(200);
|
||||
// 滚动到HashMap
|
||||
@ -560,7 +561,7 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
// 新增数据
|
||||
it(BUNDLE + 'HashMapAddFunction_001', 0, async function (done) {
|
||||
it(BUNDLE + 'HashMapAddFunction_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, `${BUNDLE} HashMapAddFunction_001 begin`);
|
||||
await driver.delayMs(200);
|
||||
// 添加三条数据
|
||||
@ -578,7 +579,7 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
// 进入HashSet界面
|
||||
it(BUNDLE + 'hash_set_001', 0, async function (done) {
|
||||
it(BUNDLE + 'hash_set_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, `${BUNDLE}hash_set_001 begin`);
|
||||
await driver.delayMs(200);
|
||||
// 滚动到HashSet
|
||||
@ -596,7 +597,7 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
// 新增数据
|
||||
it(BUNDLE + 'HashSetAddFunction_001', 0, async function (done) {
|
||||
it(BUNDLE + 'HashSetAddFunction_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, `${BUNDLE} HashSetAddFunction_001 begin`);
|
||||
await driver.delayMs(200);
|
||||
// 添加三条数据
|
||||
@ -614,7 +615,7 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
// 进入LightWeightMap界面
|
||||
it(BUNDLE + 'light_weight_map_001', 0, async function (done) {
|
||||
it(BUNDLE + 'light_weight_map_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, `${BUNDLE}light_weight_map_001 begin`);
|
||||
await driver.delayMs(200);
|
||||
// 滚动到LightWeightMap
|
||||
@ -632,7 +633,7 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
// 新增数据
|
||||
it(BUNDLE + 'LightWeightMapAddFunction_001', 0, async function (done) {
|
||||
it(BUNDLE + 'LightWeightMapAddFunction_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, `${BUNDLE} LightWeightMapAddFunction_001 begin`);
|
||||
await driver.delayMs(200);
|
||||
// 添加三条数据
|
||||
@ -650,7 +651,7 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
// 进入LightWeightSet界面
|
||||
it(BUNDLE + 'light_weight_set_001', 0, async function (done) {
|
||||
it(BUNDLE + 'light_weight_set_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, `${BUNDLE}light_weight_set_001 begin`);
|
||||
await driver.delayMs(200);
|
||||
// 滚动到LightWeightSet
|
||||
@ -668,7 +669,7 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
// 新增数据
|
||||
it(BUNDLE + 'LightWeightSetAddFunction_001', 0, async function (done) {
|
||||
it(BUNDLE + 'LightWeightSetAddFunction_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, `${BUNDLE} LightWeightSetAddFunction_001 begin`);
|
||||
await driver.delayMs(200);
|
||||
// 添加三条数据
|
||||
@ -686,7 +687,7 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
// 进入LinkedList界面
|
||||
it(BUNDLE + 'linked_list_001', 0, async function (done) {
|
||||
it(BUNDLE + 'linked_list_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, `${BUNDLE}linked_list_001 begin`);
|
||||
await driver.delayMs(200);
|
||||
// 滚动到LinkedList
|
||||
@ -704,7 +705,7 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
// 新增数据
|
||||
it(BUNDLE + 'LinkedListAddFunction_001', 0, async function (done) {
|
||||
it(BUNDLE + 'LinkedListAddFunction_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, `${BUNDLE} LinkedListAddFunction_001 begin`);
|
||||
await driver.delayMs(200);
|
||||
// 添加三条数据
|
||||
@ -722,7 +723,7 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
// 进入List页面
|
||||
it(BUNDLE + 'list_001', 0, async function (done) {
|
||||
it(BUNDLE + 'list_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, `${BUNDLE} list_001 begin`);
|
||||
await driver.delayMs(200);
|
||||
//find component on text 'list'
|
||||
@ -745,7 +746,7 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
// 进入plain_array页面
|
||||
it(BUNDLE + 'plain_array_001', 0, async function (done) {
|
||||
it(BUNDLE + 'plain_array_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, `${BUNDLE} plain_array_001 begin`);
|
||||
await driver.delayMs(200);
|
||||
//find component on text 'plain_array'
|
||||
@ -768,7 +769,7 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
// 进入queue页面
|
||||
it(BUNDLE + 'queue_001', 0, async function (done) {
|
||||
it(BUNDLE + 'queue_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, `${BUNDLE} queue_001 begin`);
|
||||
await driver.delayMs(200);
|
||||
//find component on text 'queue'
|
||||
@ -791,7 +792,7 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
// 进入stack页面
|
||||
it(BUNDLE + 'stack_001', 0, async function (done) {
|
||||
it(BUNDLE + 'stack_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, `${BUNDLE} stack_001 begin`);
|
||||
await driver.delayMs(200);
|
||||
// find component on text 'stack'
|
||||
@ -814,7 +815,7 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
// 进入tree_map页面
|
||||
it(BUNDLE + 'tree_map_001', 0, async function (done) {
|
||||
it(BUNDLE + 'tree_map_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, `${BUNDLE} tree_map_001 begin`);
|
||||
await driver.delayMs(200);
|
||||
//find component on text 'tree_map'
|
||||
@ -837,7 +838,7 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
// 进入tree_set页面
|
||||
it(BUNDLE + 'tree_set_001', 0, async function (done) {
|
||||
it(BUNDLE + 'tree_set_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, `${BUNDLE} tree_set_001 begin`);
|
||||
await driver.delayMs(200);
|
||||
//find component on text 'tree_set'
|
||||
@ -860,7 +861,7 @@ export default function abilityTest() {
|
||||
})
|
||||
|
||||
// 进入vector页面
|
||||
it(BUNDLE + 'vector_001', 0, async function (done) {
|
||||
it(BUNDLE + 'vector_001', 0, async (done: Function) => {
|
||||
logger.info(TAG, `${BUNDLE} vector_001 begin`);
|
||||
await driver.delayMs(200);
|
||||
//find component on text 'vector'
|
||||
|
@ -19,11 +19,13 @@ import UIAbility from '@ohos.app.ability.UIAbility';
|
||||
import window from '@ohos.window';
|
||||
import { Hypium } from '@ohos/hypium';
|
||||
import { logger } from '../util/Logger';
|
||||
import Want from '@ohos.app.ability.Want';
|
||||
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
|
||||
|
||||
const TAG: string = 'TestAbility';
|
||||
|
||||
export default class TestAbility extends UIAbility {
|
||||
onCreate(want, launchParam) {
|
||||
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
|
||||
logger.info(TAG, `TestAbility onCreate`);
|
||||
setTimeout(() => {
|
||||
let abilityDelegator: AbilityDelegatorRegistry.AbilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
|
||||
|
@ -25,15 +25,14 @@ const TAG: string = 'ArrayListView';
|
||||
@Preview
|
||||
@Component
|
||||
export struct ArrayListView {
|
||||
private dataSource: MyDataSource = new MyDataSource([]);
|
||||
private informations: ArrayList<Information> = new ArrayList();
|
||||
@State dataSource: Information[] = [];
|
||||
private informations: Information[] = [];
|
||||
private dialogController: CustomDialogController = new CustomDialogController({
|
||||
builder: AddDialog({
|
||||
saveData: (writeInformation: Information) => {
|
||||
this.informations.add(writeInformation);
|
||||
this.dataSource['dataArray'] = this.informations;
|
||||
this.dataSource.notifyDataReload();
|
||||
logger.info(TAG, `this.list= ${this.dataSource.totalCount()}`);
|
||||
this.informations.push(writeInformation);
|
||||
this.dataSource = this.informations;
|
||||
logger.info(TAG, `this.list= ${this.dataSource.length}`);
|
||||
}
|
||||
}),
|
||||
autoCancel: true,
|
||||
@ -64,11 +63,11 @@ export struct ArrayListView {
|
||||
.width('100%')
|
||||
|
||||
List({ space: 12 }) {
|
||||
LazyForEach(this.dataSource, (item, index) => {
|
||||
ForEach(this.dataSource, (item: Information, index: number) => {
|
||||
ListItem() {
|
||||
ArrayListItem({ information: item, index: index, handleOnClick: this.handleOnClick })
|
||||
}
|
||||
}, (item, index) => JSON.stringify(item) + index)
|
||||
}, (item: Information, index: number) => JSON.stringify(item) + index)
|
||||
}
|
||||
.margin({ top: 10 })
|
||||
}
|
||||
@ -77,8 +76,6 @@ export struct ArrayListView {
|
||||
}
|
||||
|
||||
handleOnClick = (index: number) => {
|
||||
this.informations.removeByIndex(index);
|
||||
this.dataSource['dataArray'] = this.informations;
|
||||
this.dataSource.notifyDataReload();
|
||||
this.dataSource = this.informations.splice(index);
|
||||
}
|
||||
}
|
@ -46,7 +46,7 @@ export struct ConvertXml {
|
||||
.align(Alignment.Start)
|
||||
}
|
||||
|
||||
doOperation = (index) => {
|
||||
doOperation = (index: number) => {
|
||||
switch (index) {
|
||||
case 0:
|
||||
this.output = serializerNode();
|
||||
|
@ -63,7 +63,7 @@ export struct DequeView {
|
||||
.height(72)
|
||||
.width('100%')
|
||||
.margin({ bottom: 20 })
|
||||
}, (item, index) => JSON.stringify(item) + index)
|
||||
}, (item: Information, index: number) => JSON.stringify(item) + index)
|
||||
}
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
|
@ -61,7 +61,7 @@ export struct HashMapView {
|
||||
}
|
||||
.height(72)
|
||||
.width('100%')
|
||||
}, (item, index) => JSON.stringify(item) + index)
|
||||
}, (item: KeyValuePair, index: number) => JSON.stringify(item) + index)
|
||||
}
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
|
@ -29,7 +29,10 @@ export struct HashSetView {
|
||||
private dataSource: HashSetDataSource = new HashSetDataSource();
|
||||
|
||||
aboutToAppear() {
|
||||
emitter.on({ eventId: Constant.EMITTER_ID_HASH_SET }, (eventData) => {
|
||||
emitter.on({ eventId: Constant.EMITTER_ID_HASH_SET }, (eventData: emitter.EventData) => {
|
||||
if (eventData.data === undefined) {
|
||||
return;
|
||||
}
|
||||
let item: string = eventData.data.value;
|
||||
this.dataSource.addData(item);
|
||||
this.totalCount = this.dataSource.totalCount();
|
||||
@ -60,7 +63,7 @@ export struct HashSetView {
|
||||
}
|
||||
.height(72)
|
||||
.width('100%')
|
||||
}, (item, index) => JSON.stringify(item) + index)
|
||||
}, (item: string, index: number) => JSON.stringify(item) + index)
|
||||
}
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
|
@ -61,7 +61,7 @@ export struct LightWeightMapView {
|
||||
}
|
||||
.height(72)
|
||||
.width('100%')
|
||||
}, (item, index) => JSON.stringify(item) + index)
|
||||
}, (item: KeyValuePair, index: number) => JSON.stringify(item) + index)
|
||||
}
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
|
@ -29,7 +29,10 @@ export struct LightWeightSetView {
|
||||
private dataSource: LightWeightSetDataSource = new LightWeightSetDataSource();
|
||||
|
||||
aboutToAppear() {
|
||||
emitter.on({ eventId: Constant.EMITTER_ID_LIGHT_WEIGHT_SET }, (eventData) => {
|
||||
emitter.on({ eventId: Constant.EMITTER_ID_LIGHT_WEIGHT_SET }, (eventData: emitter.EventData) => {
|
||||
if (eventData.data === undefined) {
|
||||
return;
|
||||
}
|
||||
let item: string = eventData.data.value;
|
||||
this.dataSource.addData(item);
|
||||
this.lightWeightSet.add(item);
|
||||
@ -60,7 +63,7 @@ export struct LightWeightSetView {
|
||||
}
|
||||
.height(72)
|
||||
.width('100%')
|
||||
}, (item, index) => JSON.stringify(item) + index)
|
||||
}, (item: string, index: number) => JSON.stringify(item) + index)
|
||||
}
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
|
@ -66,7 +66,7 @@ export struct LinkedListView {
|
||||
.height(72)
|
||||
.width('100%')
|
||||
.margin({ bottom: 20 })
|
||||
}, (item, index) => JSON.stringify(item) + index)
|
||||
}, (item: Information, index: number) => JSON.stringify(item) + index)
|
||||
}
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
|
@ -53,7 +53,7 @@ export struct ListView {
|
||||
.height(72)
|
||||
.width('100%')
|
||||
.margin({ bottom: 20 })
|
||||
}, (item, index) => JSON.stringify(item) + index)
|
||||
}, (item: Information, index: number) => JSON.stringify(item) + index)
|
||||
}
|
||||
.width('100%')
|
||||
.layoutWeight(1)
|
||||
|
@ -23,7 +23,7 @@ import { Constant } from '../Constant';
|
||||
|
||||
const MIN_LENGTH = 0;
|
||||
const isNaturalNumber = (str: string): boolean => {
|
||||
const regExp = /^\d+$/;
|
||||
let regExp: RegExp = new RegExp('^\\d+$');
|
||||
return regExp.test(str);
|
||||
};
|
||||
|
||||
@ -62,7 +62,7 @@ export struct PlainArrayView {
|
||||
.height(72)
|
||||
.width('100%')
|
||||
.margin({ bottom: 20 })
|
||||
}, (item, index) => JSON.stringify(item) + index)
|
||||
}, (item: KeyValuePair, index: number) => JSON.stringify(item) + index)
|
||||
}
|
||||
.width('100%')
|
||||
.layoutWeight(1)
|
||||
|
@ -17,7 +17,7 @@ import process from '@ohos.process';
|
||||
import { ColumnOperation } from '../components/ColumnOperation';
|
||||
import { getString, logger } from '@ohos/common';
|
||||
|
||||
let child: process.ChildProcess = undefined;
|
||||
let child: process.ChildProcess | undefined = undefined;
|
||||
const TAG: string = 'Process';
|
||||
|
||||
@Component
|
||||
|
@ -52,7 +52,7 @@ export struct QueueView {
|
||||
.height(72)
|
||||
.width('100%')
|
||||
.margin({ bottom: 20 })
|
||||
}, (item, index) => JSON.stringify(item) + index)
|
||||
}, (item: Information, index: number) => JSON.stringify(item) + index)
|
||||
}
|
||||
.width('100%')
|
||||
.layoutWeight(1)
|
||||
|
@ -56,7 +56,7 @@ export struct StackView {
|
||||
.height(72)
|
||||
.width('100%')
|
||||
.margin({ bottom: 20 })
|
||||
}, (item, index) => JSON.stringify(item) + index)
|
||||
}, (item: Information, index: number) => JSON.stringify(item) + index)
|
||||
}
|
||||
.width('100%')
|
||||
.layoutWeight(1)
|
||||
|
@ -16,7 +16,7 @@
|
||||
import taskpool from '@ohos.taskpool'
|
||||
import router from '@ohos.router'
|
||||
|
||||
function functionForTasks(numberOfExecutions) {
|
||||
function functionForTasks(numberOfExecutions: number) {
|
||||
"use concurrent"
|
||||
return numberOfExecutions + 1
|
||||
}
|
||||
@ -26,7 +26,7 @@ export struct TaskPool {
|
||||
@State numberOfExecutions: number = 0;
|
||||
private isExecute = true;
|
||||
private clickAble = true;
|
||||
@State task: taskpool.Task = null;
|
||||
@State task: taskpool.Task | null = null;
|
||||
@State msg: string = 'task ready';
|
||||
|
||||
build() {
|
||||
@ -83,7 +83,7 @@ export struct TaskPool {
|
||||
this.clickAble = false;
|
||||
this.msg = 'task is running';
|
||||
await taskpool.execute(this.task)
|
||||
.then((res) => {
|
||||
.then((res: ESObject) => {
|
||||
this.numberOfExecutions = Number(JSON.parse(JSON.stringify(res)));
|
||||
});
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ export struct TreeMapView {
|
||||
.height(72)
|
||||
.width('100%')
|
||||
.margin({ bottom: 20 })
|
||||
}, (item, index) => JSON.stringify(item) + index)
|
||||
}, (item: KeyValuePair, index: number) => JSON.stringify(item) + index)
|
||||
}
|
||||
.width('100%')
|
||||
.layoutWeight(1)
|
||||
|
@ -29,7 +29,7 @@ export struct TreeSetView {
|
||||
|
||||
aboutToAppear() {
|
||||
emitter.on({ eventId: Constant.EMITTER_ID_TREE_SET }, (eventData) => {
|
||||
this.dataSource.addData(eventData.data['value']);
|
||||
this.dataSource.addData((eventData.data as Record<string, Object>)['value'] as string);
|
||||
this.totalCount = this.dataSource.totalCount();
|
||||
});
|
||||
}
|
||||
@ -52,7 +52,7 @@ export struct TreeSetView {
|
||||
.height(72)
|
||||
.width('100%')
|
||||
.margin({ bottom: 20 })
|
||||
}, (item, index) => JSON.stringify(item) + index)
|
||||
}, (item: string, index: number) => JSON.stringify(item) + index)
|
||||
}
|
||||
.width('100%')
|
||||
.layoutWeight(1)
|
||||
|
@ -52,7 +52,7 @@ export struct VectorView {
|
||||
.height(72)
|
||||
.width('100%')
|
||||
.margin({ bottom: 20 })
|
||||
}, (item, index) => JSON.stringify(item) + index)
|
||||
}, (item: Information, index: number) => JSON.stringify(item) + index)
|
||||
}
|
||||
.width('100%')
|
||||
.layoutWeight(1)
|
||||
|
@ -17,13 +17,13 @@ import { CustomDataSource, getStringArray } from '@ohos/common';
|
||||
|
||||
@Component
|
||||
export struct ColumnOperation {
|
||||
private operationRes: Resource = undefined;
|
||||
private operationSource: CustomDataSource = new CustomDataSource([]);
|
||||
private doOperation: (index: number) => void;
|
||||
private operationRes: Resource | undefined = undefined;
|
||||
@State operationSource: string[] = [];
|
||||
private doOperation: (index: number) => void = () => {};
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
LazyForEach(this.operationSource, (item, index) => {
|
||||
ForEach(this.operationSource, (item: string, index: number) => {
|
||||
Row() {
|
||||
Button() {
|
||||
Text(item)
|
||||
@ -41,7 +41,7 @@ export struct ColumnOperation {
|
||||
}
|
||||
.width('100%')
|
||||
.justifyContent(FlexAlign.Center)
|
||||
}, index => index)
|
||||
}, (index: string) => index)
|
||||
}
|
||||
.width('100%')
|
||||
.padding({ bottom: 15 })
|
||||
@ -50,8 +50,7 @@ export struct ColumnOperation {
|
||||
async aboutToAppear() {
|
||||
if (this.operationRes) {
|
||||
let menuList = await getStringArray(this.operationRes);
|
||||
this.operationSource['dataArray'] = menuList;
|
||||
this.operationSource.notifyDataReload();
|
||||
this.operationSource = menuList;
|
||||
}
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@
|
||||
|
||||
@Component
|
||||
export struct DeleteView {
|
||||
private enable: boolean;
|
||||
private enable: boolean = false;
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
|
@ -17,16 +17,16 @@ import { CustomDataSource, getStringArray } from '@ohos/common';
|
||||
|
||||
@Component
|
||||
export struct GridOperation {
|
||||
private operationRes: Resource = undefined;
|
||||
private operationSource: CustomDataSource = new CustomDataSource([]);
|
||||
private doOperation: (index: number) => void;
|
||||
private operationRes: Resource | undefined = undefined;
|
||||
@State operationSource: string[] = [];
|
||||
private doOperation: (index: number) => void = () => {};
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
GridRow({ columns: 12, gutter: { x: 2, y: 5 },
|
||||
direction: GridRowDirection.Row
|
||||
}) {
|
||||
LazyForEach(this.operationSource, (item, index) => {
|
||||
ForEach(this.operationSource, (item: string, index: number) => {
|
||||
GridCol({ span: { xs: 6, sm: 6, md: 4, lg: 4 } }) {
|
||||
Row() {
|
||||
Button() {
|
||||
@ -44,7 +44,7 @@ export struct GridOperation {
|
||||
}
|
||||
.justifyContent(FlexAlign.Center)
|
||||
}
|
||||
}, index => index)
|
||||
}, (index: string) => index)
|
||||
}
|
||||
}
|
||||
.width('100%')
|
||||
@ -54,8 +54,7 @@ export struct GridOperation {
|
||||
async aboutToAppear() {
|
||||
if (this.operationRes) {
|
||||
let menuList = await getStringArray(this.operationRes);
|
||||
this.operationSource['dataArray'] = menuList;
|
||||
this.operationSource.notifyDataReload();
|
||||
this.operationSource = menuList;
|
||||
}
|
||||
}
|
||||
}
|
@ -20,8 +20,8 @@ import { getString } from '@ohos/common';
|
||||
@Component
|
||||
export struct InformationItemView {
|
||||
@ObjectLink information: Information;
|
||||
private deleteAction: (event?: ClickEvent) => void;
|
||||
private index: number;
|
||||
private deleteAction: (event?: ClickEvent) => void = () => {};
|
||||
private index: number = 0;
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
|
@ -20,8 +20,9 @@ import { DeleteView } from './DeleteView';
|
||||
export struct KeyValueItemView {
|
||||
@ObjectLink keyValuePair: KeyValuePair;
|
||||
@State deleteEnabled: boolean = true;
|
||||
private deleteAction: (event?: ClickEvent) => void;
|
||||
private index: number;
|
||||
private deleteAction: (event?: ClickEvent) => void = () => {
|
||||
};
|
||||
private index: number = 0;
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
|
@ -18,9 +18,9 @@ import { DeleteView } from './DeleteView';
|
||||
@Component
|
||||
export struct ValueItemView {
|
||||
@State deleteEnabled: boolean = true;
|
||||
private value: string;
|
||||
private deleteAction: (event?: ClickEvent) => void;
|
||||
private index: number;
|
||||
private value: string = '';
|
||||
private deleteAction: (event?: ClickEvent) => void = () => {};
|
||||
private index: number = 0;
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
|
@ -21,9 +21,9 @@ const TAG: string = 'AddDialog';
|
||||
|
||||
@CustomDialog
|
||||
export struct AddDialog {
|
||||
@State writeInformation: Information = new Information('', NaN, '')
|
||||
private saveData: (information: Information) => void;
|
||||
private controller: CustomDialogController;
|
||||
@State writeInformation: Information = new Information('', Number.NaN, '')
|
||||
private saveData: (information: Information) => void = () => {};
|
||||
private controller?: CustomDialogController;
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
@ -128,7 +128,7 @@ export struct AddDialog {
|
||||
.layoutWeight(7)
|
||||
.backgroundColor(Color.White)
|
||||
.onClick(() => {
|
||||
this.controller.close();
|
||||
this.controller?.close();
|
||||
})
|
||||
}
|
||||
.margin({ top: 12 })
|
||||
@ -141,7 +141,7 @@ export struct AddDialog {
|
||||
prompt.showToast({ message: $r('app.string.name_null') });
|
||||
return;
|
||||
}
|
||||
if (this.writeInformation.age < 1 || isNaN(this.writeInformation.age)) {
|
||||
if (this.writeInformation.age < 1 || Number.isNaN(this.writeInformation.age)) {
|
||||
prompt.showToast({ message: $r('app.string.age_null') });
|
||||
return;
|
||||
}
|
||||
@ -152,6 +152,6 @@ export struct AddDialog {
|
||||
if (this.writeInformation.name !== '' && this.writeInformation.phone !== '' && this.writeInformation.age > 0) {
|
||||
this.saveData(this.writeInformation);
|
||||
}
|
||||
this.controller.close();
|
||||
this.controller?.close();
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@ import { Information } from '../../model/Information';
|
||||
export struct ArrayListItem {
|
||||
@ObjectLink information: Information;
|
||||
private index: number = 0;
|
||||
private handleOnClick: (index: number) => void;
|
||||
private handleOnClick: (index: number) => void = () => {};
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
|
@ -20,7 +20,7 @@ export class MyDataSource {
|
||||
public dataArray: ArrayList<Information> = new ArrayList();
|
||||
private listeners: DataChangeListener[] = [];
|
||||
|
||||
constructor(ele) {
|
||||
constructor(ele: ArrayList<Information>) {
|
||||
for (let index = 0;index < ele.length; index++) {
|
||||
this.dataArray.add(ele[index]);
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ export class ListDateSource extends BaseDataSource {
|
||||
return this.dataArr.length;
|
||||
}
|
||||
|
||||
public getData(index: number): any {
|
||||
public getData(index: number): Information {
|
||||
return this.dataArr.get(index);
|
||||
}
|
||||
|
||||
|
@ -26,11 +26,11 @@ export class PlainArrayDataSource extends BaseDataSource {
|
||||
return this.arr.length;
|
||||
}
|
||||
|
||||
public getData(index: number): any {
|
||||
let key = this.arr[index];
|
||||
let value = this.dataArr.get(key);
|
||||
public getData(index: number): KeyValuePair {
|
||||
let key: number = this.arr[index];
|
||||
let value: string = this.dataArr.get(key);
|
||||
this.dataArr.get(this.arr[index]);
|
||||
let keyValuePair: KeyValuePair = { key: `${this.arr[index]}`, value: value };
|
||||
let keyValuePair: KeyValuePair = new KeyValuePair(`${this.arr[index]}`, value);
|
||||
return keyValuePair;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ export class QueueDataSource extends BaseDataSource {
|
||||
return this.dataArr.length;
|
||||
}
|
||||
|
||||
public getData(index: number): any {
|
||||
public getData(index: number): Information {
|
||||
return this.dataArr[index];
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ export class StackDataSource extends BaseDataSource {
|
||||
return this.dataArr.length;
|
||||
}
|
||||
|
||||
public getData(index: number): any {
|
||||
public getData(index: number): Information {
|
||||
return this.dataArr[index];
|
||||
}
|
||||
|
||||
|
@ -26,11 +26,11 @@ export class TreeMapDataSource extends BaseDataSource {
|
||||
return this.arr.length;
|
||||
}
|
||||
|
||||
public getData(index: number): any {
|
||||
let key = this.arr[index];
|
||||
let value = this.dataArr.get(key);
|
||||
public getData(index: number): KeyValuePair {
|
||||
let key: string = this.arr[index];
|
||||
let value: string = this.dataArr.get(key);
|
||||
this.dataArr.get(this.arr[index]);
|
||||
let keyValuePair: KeyValuePair = { key: `${this.arr[index]}`, value: value };
|
||||
let keyValuePair: KeyValuePair = new KeyValuePair(`${this.arr[index]}`, value);
|
||||
return keyValuePair;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ export class TreeSetDataSource extends BaseDataSource {
|
||||
return this.dataArr.length;
|
||||
}
|
||||
|
||||
public getData(index: number): any {
|
||||
public getData(index: number): string {
|
||||
return this.arr[index];
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ export class TreeSetDataSource extends BaseDataSource {
|
||||
this.notifyDataReload();
|
||||
}
|
||||
|
||||
public deleteData(value: string, index): void {
|
||||
public deleteData(value: string, index: number): void {
|
||||
this.dataArr.remove(value);
|
||||
this.arr.removeByIndex(index);
|
||||
this.notifyDataDelete(index);
|
||||
|
@ -89,7 +89,7 @@ export struct Base64Helper {
|
||||
}
|
||||
|
||||
encode() {
|
||||
let strToAscii = [];
|
||||
let strToAscii: number[] = [];
|
||||
for (let i = 0;i < this.input.length; i++) {
|
||||
strToAscii.push(this.input.charCodeAt(i));
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ export struct LRUCache {
|
||||
action = (key: string) => {
|
||||
if (this.isGet) {
|
||||
if (lruBuffer.contains(key)) {
|
||||
let value = lruBuffer.get(key);
|
||||
let value: string = lruBuffer.get(key) as string;
|
||||
this.resultText = `key = ${key}, value=${value}`;
|
||||
} else {
|
||||
this.resultText = `the key:${key} is not found`;
|
||||
@ -101,7 +101,7 @@ export struct LRUCache {
|
||||
break;
|
||||
case 5:
|
||||
this.isGet = true;
|
||||
this.actionSheets = <string[]> lruBuffer.keys();
|
||||
this.actionSheets = lruBuffer.keys() as string[];
|
||||
this.actionDialogController.open();
|
||||
break;
|
||||
case 6:
|
||||
@ -109,7 +109,7 @@ export struct LRUCache {
|
||||
break;
|
||||
case 7:
|
||||
this.isGet = false;
|
||||
this.actionSheets = <string[]> lruBuffer.keys();
|
||||
this.actionSheets = lruBuffer.keys() as string[];
|
||||
this.actionDialogController.open();
|
||||
break;
|
||||
case 8:
|
||||
|
@ -79,7 +79,7 @@ export struct ScopeHelper {
|
||||
.align(Alignment.Start)
|
||||
}
|
||||
|
||||
dialog(title, message, value) {
|
||||
dialog(title: ResourceStr, message: ResourceStr, value: ResourceStr) {
|
||||
AlertDialog.show(
|
||||
{
|
||||
title: title,
|
||||
|
@ -28,7 +28,7 @@ export struct StringCode {
|
||||
@State resdec: string = '';
|
||||
@State read: string = '';
|
||||
@State write: string = '';
|
||||
private resArray: Uint8Array = undefined;
|
||||
private resArray: Uint8Array | undefined = undefined;
|
||||
|
||||
build() {
|
||||
Scroll() {
|
||||
|
@ -30,7 +30,7 @@ for (let i = 0; i < int8Array.length; i++) {
|
||||
@Component
|
||||
export struct TypeCheck {
|
||||
@State checkResult: string = '';
|
||||
@State presetValue: Array<unknown> = [numVal, strVal, boolVal, int8Array];
|
||||
@State presetValue: Array<Int8Array | Number | String | Boolean> = [numVal, strVal, boolVal, int8Array];
|
||||
|
||||
build() {
|
||||
Scroll() {
|
||||
|
@ -15,10 +15,10 @@
|
||||
|
||||
@CustomDialog
|
||||
export struct ActionSheetDialog {
|
||||
private controller: CustomDialogController;
|
||||
private controller?: CustomDialogController;
|
||||
private title: string = '';
|
||||
private sheets = [];
|
||||
private action: (key: string) => void;
|
||||
private sheets: string[] = [];
|
||||
private action: (key: string) => void = () => {};
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
@ -29,7 +29,7 @@ export struct ActionSheetDialog {
|
||||
.textAlign(TextAlign.Center)
|
||||
.margin({ top: 10, bottom: 10 })
|
||||
List() {
|
||||
ForEach(this.sheets, item => {
|
||||
ForEach(this.sheets, (item: string) => {
|
||||
ListItem() {
|
||||
Row() {
|
||||
Text('key:')
|
||||
@ -45,7 +45,7 @@ export struct ActionSheetDialog {
|
||||
}
|
||||
.width('100%')
|
||||
.onClick(() => {
|
||||
this.controller.close();
|
||||
this.controller?.close();
|
||||
this.action(item);
|
||||
})
|
||||
})
|
||||
|
@ -71,7 +71,7 @@ export struct TempView {
|
||||
.width('100%')
|
||||
}
|
||||
|
||||
alertDialog(title, message, value) {
|
||||
alertDialog(title: ResourceStr, message: ResourceStr, value: ResourceStr) {
|
||||
AlertDialog.show(
|
||||
{
|
||||
title: title,
|
||||
|
@ -19,11 +19,11 @@ import util from '@ohos.util';
|
||||
export struct CheckType {
|
||||
@State result: string = ' ';
|
||||
@Link checkResult: string;
|
||||
@Link presetValue: Array<unknown>;
|
||||
@Link presetValue: Array<Int8Array | Number | String | Boolean>;
|
||||
|
||||
check(value) {
|
||||
let utilType = new util.types();
|
||||
let utilData = new Map([
|
||||
check(value: Object) {
|
||||
let utilType: util.types = new util.types();
|
||||
let utilData: Map<string, boolean> | null = new Map([
|
||||
['ArrayBuffer', utilType.isAnyArrayBuffer(value)],
|
||||
['Int8Array', utilType.isInt8Array(value)],
|
||||
['Number', utilType.isNumberObject(value)],
|
||||
@ -37,10 +37,9 @@ export struct CheckType {
|
||||
['Float32Array', utilType.isFloat32Array(value)],
|
||||
['Generator', utilType.isGeneratorFunction(value)]
|
||||
]);
|
||||
for (let [key, value] of utilData) {
|
||||
if (value === true) {
|
||||
this.result = key;
|
||||
break;
|
||||
for (let item of utilData) {
|
||||
if (item[1] === true) {
|
||||
this.result = item[0];
|
||||
}
|
||||
}
|
||||
utilData = null;
|
||||
|
@ -17,7 +17,7 @@
|
||||
export struct ShowKey {
|
||||
@State result: string = ' ';
|
||||
@Link checkResult: string;
|
||||
@Link presetValue: Array<unknown>;
|
||||
@Link presetValue: Array<Int8Array | Number | String | Boolean>;
|
||||
|
||||
build() {
|
||||
Button() {
|
||||
|
@ -24,7 +24,7 @@ export class VectorDataSource extends BaseDataSource {
|
||||
return this.dataArr.length;
|
||||
}
|
||||
|
||||
public getData(index: number): any {
|
||||
public getData(index: number): Information {
|
||||
return this.dataArr.get(index);
|
||||
}
|
||||
|
||||
|
@ -16,11 +16,11 @@
|
||||
export class ScopeNumber {
|
||||
temp: number;
|
||||
|
||||
constructor(value) {
|
||||
constructor(value: number) {
|
||||
this.temp = value;
|
||||
}
|
||||
|
||||
compareTo(value) {
|
||||
compareTo(value: ScopeNumber) {
|
||||
return this.temp >= value.getTemp();
|
||||
}
|
||||
|
||||
|
@ -48,18 +48,18 @@ export function parserNode(input: string): string {
|
||||
bufView[k] = input.charCodeAt(k);
|
||||
}
|
||||
let parser = new xml.XmlPullParser(arrayBuffer);
|
||||
let arr = {};
|
||||
let arr: Record<number, string> = {};
|
||||
let i = 0;
|
||||
|
||||
function func(key, info) {
|
||||
let func = (key: xml.EventType, info: xml.ParseInfo) => {
|
||||
arr[i] = `key:${key}, value:${info.getDepth()} ${info.getColumnNumber()} ` +
|
||||
`${info.getLineNumber()} ${info.getAttributeCount()} ${info.getName()} ` +
|
||||
`${info.getText()} ${info.isEmptyElementTag()} ${info.isWhitespace()}\n`;
|
||||
`${info.getLineNumber()} ${info.getAttributeCount()} ${info.getName()} ` +
|
||||
`${info.getText()} ${info.isEmptyElementTag()} ${info.isWhitespace()}\n`;
|
||||
i++;
|
||||
return true;
|
||||
}
|
||||
|
||||
let options = { supportDoctype: true, ignoreNameSpace: true, tokenValueCallbackFunction: func };
|
||||
let options: xml.ParseOptions = { supportDoctype: true, ignoreNameSpace: true, tokenValueCallbackFunction: func };
|
||||
parser.parse(options);
|
||||
let str = '';
|
||||
for (let j = 0; j < i; ++j) {
|
||||
@ -70,7 +70,7 @@ export function parserNode(input: string): string {
|
||||
|
||||
export function convertNode(input: string): string {
|
||||
logger.info(TAG, 'convertNode start');
|
||||
let options = {
|
||||
let options: ConvertXML.ConvertOptions = {
|
||||
trim: false,
|
||||
declarationKey: "_declaration",
|
||||
instructionKey: "_instruction",
|
||||
|
@ -16,7 +16,7 @@
|
||||
import common from '@ohos.app.ability.common';
|
||||
import util from '@ohos.util';
|
||||
|
||||
export let lruBuffer = new util.LRUCache();
|
||||
export let lruBuffer: util.LRUCache<string, string> = new util.LRUCache();
|
||||
|
||||
export function initLRUCache(): string {
|
||||
lruBuffer = new util.LRUCache();
|
||||
@ -47,17 +47,17 @@ export function putKeyValue(): string {
|
||||
}
|
||||
|
||||
export function operationLog(): string {
|
||||
lruBuffer.createDefault(10);
|
||||
lruBuffer.get(10);
|
||||
lruBuffer.createDefault('10');
|
||||
lruBuffer.get('10');
|
||||
return `getCreateCount=${lruBuffer.getCreateCount()}\n`
|
||||
+ `getMissCount=${lruBuffer.getMissCount()}\n`
|
||||
+ `getRemovalCount=${lruBuffer.getRemovalCount()}\n`
|
||||
+ `getMatchCount=${lruBuffer.getMatchCount()}\n`
|
||||
+ `getPutCount=${lruBuffer.getPutCount()}\n`;
|
||||
+ `getMissCount=${lruBuffer.getMissCount()}\n`
|
||||
+ `getRemovalCount=${lruBuffer.getRemovalCount()}\n`
|
||||
+ `getMatchCount=${lruBuffer.getMatchCount()}\n`
|
||||
+ `getPutCount=${lruBuffer.getPutCount()}\n`;
|
||||
}
|
||||
|
||||
export function getString(resource: Resource) {
|
||||
let context = getContext(this) as common.UIAbilityContext;
|
||||
let context = getContext() as common.UIAbilityContext;
|
||||
let resultStr = context.resourceManager.getStringSync(resource);
|
||||
return resultStr;
|
||||
}
|
||||
@ -75,9 +75,11 @@ export function randomString(length: number): string {
|
||||
|
||||
export function getAllKeyValues(): string {
|
||||
let result = '';
|
||||
let entries = lruBuffer.entries();
|
||||
for (let iterator of entries) {
|
||||
result += `key: ${iterator[0]}, value: ${iterator[1]}\n`;
|
||||
}
|
||||
let keyArr: string[] = lruBuffer.keys();
|
||||
let valueArr: string[] = lruBuffer.values();
|
||||
keyArr.forEach((key: string, index: number) => {
|
||||
result += `key: ${key}, value: ${valueArr[index]}\n`;
|
||||
})
|
||||
|
||||
return result;
|
||||
}
|
@ -34,6 +34,7 @@ export function compareTo(): string {
|
||||
if (result === -1) {
|
||||
return getString($r('app.string.less_than'));
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
export function getValueOf(): string {
|
||||
|
@ -41,7 +41,7 @@ export function deleteNode(): string {
|
||||
export function getFirstNode(): string {
|
||||
if (paramsObject.has(nodeKey)) {
|
||||
let fod = paramsObject.get(nodeKey);
|
||||
return fod.toString();
|
||||
return fod !== null ? fod.toString() : '';
|
||||
} else {
|
||||
return getString($r('app.string.please_insert'));
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
@Component
|
||||
export struct MainItem {
|
||||
private title: string | Resource;
|
||||
private title: string | Resource = '';
|
||||
@LocalStorageProp('isSplitMode') isSplitMode: boolean = false;
|
||||
@State isTouched: boolean = false;
|
||||
|
||||
|
@ -26,7 +26,7 @@ export struct MenuNavRouter {
|
||||
@StorageLink('selectedSecondLabel') selectedSecondLabel: string = '';
|
||||
@BuilderParam navDestination: () => void;
|
||||
private childList: Array<string> = [];
|
||||
private addAction?: (title) => void;
|
||||
private addAction?: (title:string) => void;
|
||||
|
||||
@Builder CustomDivider() {
|
||||
Divider()
|
||||
@ -59,13 +59,13 @@ export struct MenuNavRouter {
|
||||
logger.info(TAG, `NavRouter isActivated= ${isActivated}, selectedLabel=${item}`);
|
||||
}
|
||||
})
|
||||
}, item => JSON.stringify(item))
|
||||
}, (item: string) => JSON.stringify(item))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Builder
|
||||
CustomTitle(title) {
|
||||
CustomTitle(title: string) {
|
||||
Row() {
|
||||
Text(title)
|
||||
.fontColor($r('app.color.black'))
|
||||
@ -94,7 +94,7 @@ export struct MenuNavRouter {
|
||||
.justifyContent(FlexAlign.SpaceBetween)
|
||||
}
|
||||
|
||||
showAddButton(title) {
|
||||
showAddButton(title: string) {
|
||||
let ret = false
|
||||
switch (title) {
|
||||
case getString($r('app.string.deque')):
|
||||
|
@ -20,8 +20,8 @@ import { MenuNavRouter } from '../components/MenuNavRouter';
|
||||
export struct MenuList {
|
||||
@State menuListData: Array<string> = [];
|
||||
@BuilderParam childNavDestination: () => void;
|
||||
private menuList: Resource = undefined;
|
||||
private addAction?: (title) => void;
|
||||
private menuList: Resource | undefined = undefined;
|
||||
private addAction?: (title: string) => void;
|
||||
|
||||
build() {
|
||||
List({ space: 12 }) {
|
||||
|
@ -14,8 +14,8 @@
|
||||
*/
|
||||
|
||||
{
|
||||
"hvigorVersion": "2.1.1",
|
||||
"hvigorVersion": "3.0.2",
|
||||
"dependencies": {
|
||||
"@ohos/hvigor-ohos-plugin": "2.1.1"
|
||||
"@ohos/hvigor-ohos-plugin": "3.0.2"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user