nwo
stringclasses 304
values | sha
stringclasses 304
values | path
stringlengths 9
214
| language
stringclasses 1
value | identifier
stringlengths 0
49
| docstring
stringlengths 1
34.2k
| function
stringlengths 8
59.4k
| ast_function
stringlengths 71
497k
| obf_function
stringlengths 8
39.4k
| url
stringlengths 102
324
| function_sha
stringlengths 40
40
| source
stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
kico0909/crazy_miner.git
|
13eae3ac4d8ca11ecf2c97b375f82f24ab7919b9
|
entry/src/main/ets/common/utils.ets
|
arkts
|
将storage中的用户存档初始化
|
export function initData() {
const avhieveDefaultData = core.initWorldData()
}
|
AST#export_declaration#Left export AST#function_declaration#Left function initData AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left avhieveDefaultData = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left core AST#expression#Right . initWorldData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
|
export function initData() {
const avhieveDefaultData = core.initWorldData()
}
|
https://github.com/kico0909/crazy_miner.git/blob/13eae3ac4d8ca11ecf2c97b375f82f24ab7919b9/entry/src/main/ets/common/utils.ets#L109-L111
|
627d65a20f855ba5a03e5960e091110ac25f4b32
|
github
|
|
zqaini002/YaoYaoLingXian.git
|
5095b12cbeea524a87c42d0824b1702978843d39
|
YaoYaoLingXian/entry/src/main/ets/pages/community/PostCreatePage.ets
|
arkts
|
convertImageToBase64
|
图片转Base64
|
private async convertImageToBase64(imageUri: string): Promise<string | null> {
try {
// 直接文件路径读取
if (imageUri.startsWith('file://') && !imageUri.startsWith('file://media/')) {
try {
const realPath: string = imageUri.replace('file://', '');
await fileIo.access(realPath);
const fd: number = await fileIo.open(realPath, 0);
const stat: fileIo.Stat = await fileIo.stat(realPath);
const fileSize: number = stat.size;
const buffer: ArrayBuffer = new ArrayBuffer(fileSize);
await fileIo.read(fd, buffer);
await fileIo.close(fd);
const base64Helper: util.Base64Helper = new util.Base64Helper();
return base64Helper.encodeToStringSync(new Uint8Array(buffer));
} catch (err) {
console.error('直接文件路径读取失败,尝试使用photoAccessHelper', err);
}
}
// 使用photoAccessHelper正确的API
const context = getContext(this);
const phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
// 构建查询条件
let predicates = new dataSharePredicates.DataSharePredicates();
predicates.equalTo('uri', imageUri);
let fetchOptions: FetchOptions = {
fetchColumns: [],
predicates: predicates
};
// 返回Promise
return new Promise<string | null>((resolve, reject) => {
// 定义数据处理器
class MediaDataHandler implements MediaAssetDataHandlerInterface<ArrayBuffer> {
onDataPrepared(data: ArrayBuffer): void {
if (data === undefined) {
console.error('获取图片数据失败');
reject(new Error('获取图片数据失败'));
return;
}
try {
// 转换为Base64
const uint8Array = new Uint8Array(data);
const base64Helper: util.Base64Helper = new util.Base64Helper();
const base64 = base64Helper.encodeToStringSync(uint8Array);
// 添加适当的数据URL前缀
let contentType = 'image/jpeg'; // 默认为JPEG
if (imageUri.toLowerCase().endsWith('.png')) {
contentType = 'image/png';
} else if (imageUri.toLowerCase().endsWith('.gif')) {
contentType = 'image/gif';
} else if (imageUri.toLowerCase().endsWith('.webp')) {
contentType = 'image/webp';
}
// 添加数据URL前缀
const base64WithPrefix = `data:${contentType};base64,${base64}`;
resolve(base64WithPrefix);
} catch (err) {
console.error('Base64转换失败:', err);
reject(err);
}
}
}
// 先获取资源
phAccessHelper.getAssets(fetchOptions)
.then(async (fetchResult) => {
if (fetchResult.getCount() > 0) {
const photoAsset = await fetchResult.getFirstObject();
if (photoAsset) {
// 配置请求选项
const requestOptions: RequestOptions = {
deliveryMode: 1 // 使用数字1代表HIGH_QUALITY_MODE
};
// 请求图片数据
const handler = new MediaDataHandler();
photoAccessHelper.MediaAssetManager.requestImageData(context, photoAsset, requestOptions, handler)
.catch((err: Error) => {
console.error(`获取图片数据失败: ${err.name}, ${err.message}`);
reject(err);
});
} else {
console.error('未找到图片资源');
reject(new Error('未找到图片资源'));
}
} else {
console.error('未找到匹配的图片资源');
reject(new Error('未找到匹配的图片资源'));
}
})
.catch((error: Error) => {
console.error('获取资源失败:', error);
reject(error instanceof Error ? error : new Error(String(error)));
});
});
} catch (error) {
console.error('图片处理过程中发生错误:', error);
throw error instanceof Error ? error : new Error(String(error));
}
}
build() {
Column() {
// 顶部标题栏
Row() {
Button() {
Image($r('app.media.ic_back'))
.width(24)
.height(24)
.fillColor(Color.White)
}
.width(40)
.height(40)
.backgroundColor($r('app.color.primary_color'))
.borderRadius(20)
.onClick(() => {
router.back();
})
Text('发布动态')
.fontSize(CommonConstants.FONT_SIZE_LARGE)
.fontWeight(FontWeight.Bold)
.margin({ left: CommonConstants.MARGIN_LARGE })
Blank()
Button('发布')
.fontSize(CommonConstants.FONT_SIZE_NORMAL)
.fontWeight(FontWeight.Medium)
.backgroundColor(this.isSubmitting ? $r('app.color.text_tertiary') : $r('app.color.primary_color'))
.height(40)
.borderRadius(CommonConstants.RADIUS_NORMAL)
.enabled(!this.isSubmitting)
.onClick(() => {
this.submitPost();
})
}
.width('100%')
.height(56)
.padding({ left: CommonConstants.MARGIN_LARGE, right: CommonConstants.MARGIN_LARGE })
.alignItems(VerticalAlign.Center)
// 内容区域
Scroll() {
Column() {
// 标题输入
TextInput({ placeholder: '标题(选填)', text: this.post.title })
.fontSize(CommonConstants.FONT_SIZE_NORMAL)
.height(50)
.backgroundColor(Color.Transparent)
.placeholderFont({ size: CommonConstants.FONT_SIZE_NORMAL })
.width('100%')
.onChange((value: string) => {
this.post.title = value;
})
// 内容输入
TextArea({ placeholder: '分享你的梦想与生活...', text: this.post.content })
.fontSize(CommonConstants.FONT_SIZE_NORMAL)
.placeholderFont({ size: CommonConstants.FONT_SIZE_NORMAL })
.backgroundColor(Color.Transparent)
.height(200)
.width('100%')
.onChange((value: string) => {
this.post.content = value;
})
// 关联梦想提示
if (!this.post.dreamId) {
Row() {
Image(AppIcons.error)
.width(16)
.height(16)
.fillColor('#FF4757')
.margin({ right: 4 })
Text('发布动态需要关联一个梦想,点击下方的"关联梦想"按钮进行选择')
.fontSize(CommonConstants.FONT_SIZE_SMALL)
.fontColor('#FF4757')
.fontStyle(FontStyle.Italic)
}
.width('100%')
.padding(8)
.backgroundColor('#FFEEEE')
.borderRadius(CommonConstants.RADIUS_SMALL)
.margin({ top: CommonConstants.MARGIN_NORMAL })
}
// 图片展示区
if (this.selectedImages.length > 0) {
Grid() {
ForEach(this.selectedImages, (image: string, index: number) => {
GridItem() {
Stack({ alignContent: Alignment.TopEnd }) {
Image(image)
.width('100%')
.height('100%')
.borderRadius(CommonConstants.RADIUS_SMALL)
.objectFit(ImageFit.Cover)
Button({ type: ButtonType.Circle }) {
Image(AppIcons.delete)
.width(16)
.height(16)
.fillColor(Color.White)
}
.width(24)
.height(24)
.backgroundColor('#66000000')
.margin(4)
.onClick(() => {
this.removeImage(index);
})
}
}
})
}
.columnsTemplate(this.selectedImages.length === 1 ? '1fr' :
this.selectedImages.length === 2 ? '1fr 1fr' : '1fr 1fr 1fr')
.rowsTemplate(this.selectedImages.length <= 3 ? '1fr' :
this.selectedImages.length <= 6 ? '1fr 1fr' : '1fr 1fr 1fr')
.columnsGap(CommonConstants.MARGIN_SMALL)
.rowsGap(CommonConstants.MARGIN_SMALL)
.height(this.selectedImages.length <= 3 ? 100 :
this.selectedImages.length <= 6 ? 200 : 300)
.width('100%')
.margin({ top: CommonConstants.MARGIN_NORMAL })
}
// 关联梦想卡片
if (this.post.dreamId) {
Row() {
Text('关联梦想:')
.fontSize(CommonConstants.FONT_SIZE_SMALL)
.fontColor($r('app.color.text_tertiary'))
Text(this.userDreams.find(d => d.id === this.post.dreamId)?.title || '')
.fontSize(CommonConstants.FONT_SIZE_SMALL)
.fontColor($r('app.color.primary_color'))
.fontWeight(FontWeight.Medium)
Blank()
Button({ type: ButtonType.Circle }) {
Image(AppIcons.close)
.width(16)
.height(16)
.fillColor($r('app.color.text_tertiary'))
}
.width(24)
.height(24)
.backgroundColor($r('app.color.background'))
.onClick(() => {
this.post.dreamId = undefined;
})
}
.width('100%')
.padding(CommonConstants.MARGIN_MEDIUM)
.borderRadius(CommonConstants.RADIUS_NORMAL)
.backgroundColor($r('app.color.background'))
.margin({ top: CommonConstants.MARGIN_NORMAL })
}
}
.width('100%')
.padding({
left: CommonConstants.MARGIN_LARGE,
right: CommonConstants.MARGIN_LARGE,
bottom: CommonConstants.MARGIN_LARGE
})
}
.width('100%')
.layoutWeight(1)
// 底部工具栏
Column() {
Divider()
.width('100%')
.height(1)
.color('#E0E0E0')
Row() {
Row() {
Image(AppIcons.image)
.width(24)
.height(24)
.fillColor('#666666')
Text('图片')
.fontSize(CommonConstants.FONT_SIZE_SMALL)
.fontColor('#666666')
.margin({ left: 4 })
}
.onClick(() => {
this.pickImages();
})
Divider()
.vertical(true)
.height(24)
.width(1)
.color('#E0E0E0')
.margin({ left: CommonConstants.MARGIN_LARGE, right: CommonConstants.MARGIN_LARGE })
Row() {
Image(AppIcons.tag)
.width(24)
.height(24)
.fillColor(this.post.dreamId ? '#666666' : '#FF4757')
Text('关联梦想')
.fontSize(CommonConstants.FONT_SIZE_SMALL)
.fontColor(this.post.dreamId ? '#666666' : '#FF4757')
.margin({ left: 4 })
Text(' *')
.fontSize(CommonConstants.FONT_SIZE_SMALL)
.fontColor('#FF4757')
}
.onClick(() => {
this.showDreamSelector = true;
})
}
.width('100%')
.height(56)
.justifyContent(FlexAlign.Start)
.alignItems(VerticalAlign.Center)
.padding({ left: CommonConstants.MARGIN_LARGE, right: CommonConstants.MARGIN_LARGE })
}
.width('100%')
// 梦想选择对话框
if (this.showDreamSelector) {
Column() {
// 对话框标题
Row() {
Text('选择关联的梦想')
.fontSize(CommonConstants.FONT_SIZE_LARGE)
.fontWeight(FontWeight.Bold)
Image(AppIcons.close)
.width(24)
.height(24)
.fillColor($r('app.color.text_primary'))
.onClick(() => {
this.showDreamSelector = false;
})
}
.width('100%')
.justifyContent(FlexAlign.SpaceBetween)
.padding({
top: CommonConstants.MARGIN_LARGE,
bottom: CommonConstants.MARGIN_NORMAL,
left: CommonConstants.MARGIN_LARGE,
right: CommonConstants.MARGIN_LARGE
})
Divider()
.width('100%')
.height(1)
.color('#E0E0E0')
// 梦想列表
List() {
if (this.isLoadingDreams) {
ListItem() {
Row() {
LoadingProgress()
.width(20)
.height(20)
.margin({ right: CommonConstants.MARGIN_SMALL })
Text('加载中...')
.fontSize(CommonConstants.FONT_SIZE_SMALL)
.fontColor($r('app.color.text_tertiary'))
}
.width('100%')
.justifyContent(FlexAlign.Center)
.padding({ top: CommonConstants.MARGIN_LARGE, bottom: CommonConstants.MARGIN_LARGE })
}
}
|
AST#method_declaration#Left private async convertImageToBase64 AST#parameter_list#Left ( AST#parameter#Left imageUri : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { // 直接文件路径读取 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left imageUri AST#expression#Right . startsWith AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'file://' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right && AST#expression#Left AST#unary_expression#Left ! AST#expression#Left imageUri AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . startsWith AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'file://media/' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left realPath : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left imageUri AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'file://' AST#expression#Right , AST#expression#Left '' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left fileIo AST#expression#Right AST#await_expression#Right AST#expression#Right . access AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left realPath AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left fd : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left fileIo AST#expression#Right AST#await_expression#Right AST#expression#Right . open AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left realPath AST#expression#Right , AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left stat : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left fileIo . Stat AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left fileIo AST#expression#Right AST#await_expression#Right AST#expression#Right . stat AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left realPath AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left fileSize : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left stat AST#expression#Right . size AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left buffer : AST#type_annotation#Left AST#primary_type#Left ArrayBuffer AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ArrayBuffer AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left fileSize AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left fileIo AST#expression#Right AST#await_expression#Right AST#expression#Right . read AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left fd AST#expression#Right , AST#expression#Left buffer AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left fileIo AST#expression#Right AST#await_expression#Right AST#expression#Right . close AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left fd AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left base64Helper : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left util . Base64Helper AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left util AST#expression#Right AST#new_expression#Right AST#expression#Right . Base64Helper AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left base64Helper AST#expression#Right . encodeToStringSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Uint8Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left buffer AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '直接文件路径读取失败,尝试使用photoAccessHelper' AST#expression#Right , AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 使用photoAccessHelper正确的API AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left context = AST#expression#Left AST#call_expression#Left AST#expression#Left getContext AST#expression#Right AST#argument_list#Left ( AST#expression#Left this AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left phAccessHelper = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left photoAccessHelper AST#expression#Right . getPhotoAccessHelper AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 构建查询条件 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left predicates = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left dataSharePredicates AST#expression#Right AST#new_expression#Right AST#expression#Right . DataSharePredicates AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left predicates AST#expression#Right . equalTo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'uri' AST#expression#Right , AST#expression#Left imageUri AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left fetchOptions : AST#type_annotation#Left AST#primary_type#Left FetchOptions AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left fetchColumns AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left predicates AST#property_name#Right : AST#expression#Left predicates AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 返回Promise AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Promise AST#expression#Right AST#new_expression#Right AST#expression#Right AST#ERROR#Left AST#type_arguments#Left < AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right > AST#type_arguments#Right ( AST#ERROR#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left resolve AST#parameter#Right , AST#parameter#Left reject AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { // 定义数据处理器 AST#statement#Left AST#expression_statement#Left AST#expression#Left class AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left MediaDataHandler AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left implements AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left MediaAssetDataHandlerInterface AST#expression#Right < AST#expression#Left ArrayBuffer AST#expression#Right AST#binary_expression#Right AST#expression#Right > AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left onDataPrepared AST#property_name#Right AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left ArrayBuffer AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left data AST#expression#Right === AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '获取图片数据失败' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left reject AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Error AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '获取图片数据失败' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { // 转换为Base64 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left uint8Array = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Uint8Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left data AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left base64Helper : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left util . Base64Helper AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left util AST#expression#Right AST#new_expression#Right AST#expression#Right . Base64Helper AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left base64 = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left base64Helper AST#expression#Right . encodeToStringSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left uint8Array AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 添加适当的数据URL前缀 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left contentType = AST#expression#Left 'image/jpeg' AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 默认为JPEG AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left imageUri AST#expression#Right . toLowerCase AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . endsWith AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '.png' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left contentType = AST#expression#Left 'image/png' AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left imageUri AST#expression#Right . toLowerCase AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . endsWith AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '.gif' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left contentType = AST#expression#Left 'image/gif' AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left imageUri AST#expression#Right . toLowerCase AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . endsWith AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '.webp' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left contentType = AST#expression#Left 'image/webp' AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#statement#Right // 添加数据URL前缀 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left base64WithPrefix = AST#expression#Left AST#template_literal#Left ` data: AST#template_substitution#Left $ { AST#expression#Left contentType AST#expression#Right } AST#template_substitution#Right ;base64, AST#template_substitution#Left $ { AST#expression#Left base64 AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left resolve AST#expression#Right AST#argument_list#Left ( AST#expression#Left base64WithPrefix AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Base64转换失败:' AST#expression#Right , AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left reject AST#expression#Right AST#argument_list#Left ( AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right // 先获取资源 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left phAccessHelper AST#expression#Right . getAssets AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left fetchOptions AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left async AST#parameter_list#Left ( AST#parameter#Left fetchResult AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fetchResult AST#expression#Right . getCount AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left photoAsset = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left fetchResult AST#expression#Right AST#await_expression#Right AST#expression#Right . getFirstObject AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left photoAsset AST#expression#Right ) AST#block_statement#Left { // 配置请求选项 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left requestOptions : AST#type_annotation#Left AST#primary_type#Left RequestOptions AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left deliveryMode AST#property_name#Right : AST#expression#Left 1 AST#expression#Right AST#property_assignment#Right // 使用数字1代表HIGH_QUALITY_MODE } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 请求图片数据 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left handler = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left MediaDataHandler AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left photoAccessHelper AST#expression#Right . MediaAssetManager AST#member_expression#Right AST#expression#Right . requestImageData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right , AST#expression#Left photoAsset AST#expression#Right , AST#expression#Left requestOptions AST#expression#Right , AST#expression#Left handler AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . catch AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err : AST#type_annotation#Left AST#primary_type#Left Error AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` 获取图片数据失败: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . name AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left reject AST#expression#Right AST#argument_list#Left ( AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '未找到图片资源' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left reject AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Error AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '未找到图片资源' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '未找到匹配的图片资源' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left reject AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Error AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '未找到匹配的图片资源' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . catch AST#member_expression#Right AST#expression#Right AST#ERROR#Left ( AST#parameter_list#Left ( AST#parameter#Left error : AST#type_annotation#Left AST#primary_type#Left Error AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '获取资源失败:' AST#expression#Right , AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left reject AST#expression#Right AST#ERROR#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left error AST#expression#Right instanceof AST#expression#Left Error AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#ERROR#Left error : AST#ERROR#Left new Error AST#type_annotation#Left AST#primary_type#Left AST#parenthesized_type#Left ( AST#ERROR#Left String AST#ERROR#Right AST#type_annotation#Left AST#primary_type#Left AST#parenthesized_type#Left ( AST#type_annotation#Left AST#primary_type#Left error AST#primary_type#Right AST#type_annotation#Right ) AST#parenthesized_type#Right AST#primary_type#Right AST#type_annotation#Right ) AST#parenthesized_type#Right AST#primary_type#Right AST#type_annotation#Right ) ; } ) ; } ) ; } catch AST#ERROR#Right AST#type_annotation#Left AST#primary_type#Left AST#parenthesized_type#Left ( AST#type_annotation#Left AST#primary_type#Left error AST#primary_type#Right AST#type_annotation#Right ) AST#parenthesized_type#Right AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Right AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left console AST#property_assignment#Right AST#object_literal#Right AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '图片处理过程中发生错误:' AST#expression#Right , AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#throw_statement#Left throw AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left error AST#expression#Right instanceof AST#expression#Left Error AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#ERROR#Left ? AST#ERROR#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right AST#ERROR#Left : AST#ERROR#Left new Error AST#type_annotation#Left AST#primary_type#Left AST#parenthesized_type#Left ( AST#ERROR#Left String AST#ERROR#Right AST#type_annotation#Left AST#primary_type#Left AST#parenthesized_type#Left ( AST#type_annotation#Left AST#primary_type#Left error AST#primary_type#Right AST#type_annotation#Right ) AST#parenthesized_type#Right AST#primary_type#Right AST#type_annotation#Right ) AST#parenthesized_type#Right AST#primary_type#Right AST#type_annotation#Right ; } } build AST#parameter_list#Left ( ) AST#parameter_list#Right { Column AST#parameter_list#Left ( ) AST#parameter_list#Right { // 顶部标题栏 Row AST#parameter_list#Left ( ) AST#parameter_list#Right { Button AST#parameter_list#Left ( ) AST#parameter_list#Right { Image AST#ERROR#Right AST#type_annotation#Left AST#primary_type#Left AST#parenthesized_type#Left ( AST#type_annotation#Left AST#primary_type#Left $r AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left ( 'app.media.ic_back' AST#ERROR#Right ) AST#parenthesized_type#Right AST#primary_type#Right AST#type_annotation#Right ) AST#ERROR#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 24 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 24 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fillColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . White AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left } AST#ERROR#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 40 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 40 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . backgroundColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.primary_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . borderRadius AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 20 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . onClick AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left router AST#expression#Right . back AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left Text AST#ERROR#Right AST#argument_list#Left ( AST#expression#Left '发布动态' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fontSize AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FONT_SIZE_LARGE AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fontWeight AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Bold AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . margin AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . MARGIN_LARGE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left Blank AST#ERROR#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left Button AST#ERROR#Right AST#argument_list#Left ( AST#expression#Left '发布' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fontSize AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FONT_SIZE_NORMAL AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fontWeight AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Medium AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . backgroundColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isSubmitting AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.text_tertiary' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.primary_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 40 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . borderRadius AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . RADIUS_NORMAL AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . enabled AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . isSubmitting AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . onClick AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . submitPost AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left } AST#ERROR#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '100%' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 56 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . padding AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . MARGIN_LARGE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . MARGIN_LARGE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . alignItems AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left VerticalAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right // 内容区域 AST#ERROR#Left Scroll AST#ERROR#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left { Column AST#ERROR#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left { // 标题输入 TextInput AST#ERROR#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left placeholder AST#property_name#Right : AST#expression#Left '标题(选填)' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left text AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . post AST#member_expression#Right AST#expression#Right . title AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fontSize AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FONT_SIZE_NORMAL AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 50 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . backgroundColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Transparent AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . placeholderFont AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left size AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FONT_SIZE_NORMAL AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '100%' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . onChange AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . post AST#member_expression#Right AST#expression#Right . title AST#member_expression#Right = AST#expression#Left value AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right // 内容输入 AST#ERROR#Left TextArea AST#ERROR#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left placeholder AST#property_name#Right : AST#expression#Left '分享你的梦想与生活...' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left text AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . post AST#member_expression#Right AST#expression#Right . content AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fontSize AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FONT_SIZE_NORMAL AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . placeholderFont AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left size AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FONT_SIZE_NORMAL AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . backgroundColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Transparent AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 200 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '100%' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . onChange AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . post AST#member_expression#Right AST#expression#Right . content AST#member_expression#Right = AST#expression#Left value AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right // 关联梦想提示 AST#ERROR#Left if AST#ERROR#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . post AST#member_expression#Right AST#expression#Right . dreamId AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left { Row AST#ERROR#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left { Image AST#ERROR#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AppIcons AST#expression#Right . error AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 16 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 16 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fillColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '#FF4757' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . margin AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 4 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left Text AST#ERROR#Right AST#argument_list#Left ( AST#expression#Left '发布动态需要关联一个梦想,点击下方的"关联梦想"按钮进行选择' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fontSize AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FONT_SIZE_SMALL AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fontColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '#FF4757' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fontStyle AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontStyle AST#expression#Right . Italic AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left } AST#ERROR#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '100%' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . padding AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 8 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . backgroundColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '#FFEEEE' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . borderRadius AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . RADIUS_SMALL AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . margin AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . MARGIN_NORMAL AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left } // 图片展示区 if AST#ERROR#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedImages AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left { Grid AST#ERROR#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left { ForEach AST#ERROR#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedImages AST#member_expression#Right AST#expression#Right AST#ERROR#Left , AST#parameter_list#Left ( AST#parameter#Left image : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => { AST#property_name#Left GridItem AST#property_name#Right AST#parameter_list#Left ( ) AST#parameter_list#Right { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left Stack AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left alignContent AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Alignment AST#expression#Right . TopEnd AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right { AST#property_name#Left Image AST#property_name#Right AST#parameter_list#Left ( AST#parameter#Left image AST#parameter#Right ) AST#parameter_list#Right AST#ERROR#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '100%' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '100%' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . borderRadius AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . RADIUS_SMALL AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . objectFit AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left ImageFit AST#expression#Right . Cover AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left Button AST#ERROR#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left type AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left ButtonType AST#expression#Right . Circle AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left { Image AST#ERROR#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AppIcons AST#expression#Right . delete AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 16 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 16 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fillColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . White AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left } AST#ERROR#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 24 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 24 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . backgroundColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '#66000000' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . margin AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 4 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . onClick AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . removeImage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left index AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left } } } AST#ERROR#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left } AST#ERROR#Right . columnsTemplate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedImages AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right === AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left '1fr' AST#expression#Right : AST#expression#Left this AST#expression#Right AST#conditional_expression#Right AST#expression#Right . selectedImages AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right === AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left '1fr 1fr' AST#expression#Right : AST#expression#Left '1fr 1fr 1fr' AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . rowsTemplate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedImages AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right <= AST#expression#Left 3 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left '1fr' AST#expression#Right : AST#expression#Left this AST#expression#Right AST#conditional_expression#Right AST#expression#Right . selectedImages AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right <= AST#expression#Left 6 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left '1fr 1fr' AST#expression#Right : AST#expression#Left '1fr 1fr 1fr' AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . columnsGap AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . MARGIN_SMALL AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . rowsGap AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . MARGIN_SMALL AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedImages AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right <= AST#expression#Left 3 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left 100 AST#expression#Right : AST#expression#Left this AST#expression#Right AST#conditional_expression#Right AST#expression#Right . selectedImages AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right <= AST#expression#Left 6 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left 200 AST#expression#Right : AST#expression#Left 300 AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '100%' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . margin AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . MARGIN_NORMAL AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left } // 关联梦想卡片 if AST#ERROR#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . post AST#member_expression#Right AST#expression#Right . dreamId AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left { Row AST#ERROR#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left { Text AST#ERROR#Right AST#argument_list#Left ( AST#expression#Left '关联梦想:' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fontSize AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FONT_SIZE_SMALL AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fontColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.text_tertiary' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left Text AST#ERROR#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . userDreams AST#member_expression#Right AST#expression#Right . find AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left d => AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left d AST#expression#Right . id AST#member_expression#Right AST#expression#Right === AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . post AST#member_expression#Right AST#expression#Right . dreamId AST#member_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ?. title AST#member_expression#Right AST#expression#Right || AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fontSize AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FONT_SIZE_SMALL AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fontColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.primary_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fontWeight AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Medium AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left Blank AST#ERROR#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left Button AST#ERROR#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left type AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left ButtonType AST#expression#Right . Circle AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left { Image AST#ERROR#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AppIcons AST#expression#Right . close AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 16 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 16 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fillColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.text_tertiary' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left } AST#ERROR#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 24 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 24 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . backgroundColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.background' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . onClick AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . post AST#member_expression#Right AST#expression#Right . dreamId AST#member_expression#Right = AST#expression#Left undefined AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left } AST#ERROR#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '100%' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . padding AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . MARGIN_MEDIUM AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . borderRadius AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . RADIUS_NORMAL AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . backgroundColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.background' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . margin AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . MARGIN_NORMAL AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left } } AST#ERROR#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '100%' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . padding AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . MARGIN_LARGE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . MARGIN_LARGE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . MARGIN_LARGE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left } AST#ERROR#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '100%' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . layoutWeight AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right // 底部工具栏 AST#ERROR#Left Column AST#ERROR#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Right { AST#property_name#Left Divider AST#property_name#Right AST#parameter_list#Left ( ) AST#parameter_list#Right AST#ERROR#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '100%' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . color AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '#E0E0E0' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left Row AST#ERROR#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#throw_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left Row AST#property_name#Right AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left Image AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AppIcons AST#expression#Right . image AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 24 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 24 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fillColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '#666666' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left Text AST#expression#Right AST#argument_list#Left ( AST#expression#Left '图片' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fontSize AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FONT_SIZE_SMALL AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fontColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '#666666' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . margin AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 4 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#property_assignment#Right AST#object_literal#Right AST#expression#Right . onClick AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . pickImages AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left Divider AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . vertical AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 24 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . color AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '#E0E0E0' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . margin AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . MARGIN_LARGE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . MARGIN_LARGE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left Row AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right { AST#property_name#Left Image AST#property_name#Right ( AppIcons AST#ERROR#Right . tag AST#member_expression#Right AST#expression#Right AST#ERROR#Left ) AST#ERROR#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 24 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 24 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fillColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . post AST#member_expression#Right AST#expression#Right . dreamId AST#member_expression#Right AST#expression#Right ? AST#expression#Left '#666666' AST#expression#Right : AST#expression#Left '#FF4757' AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left Text AST#expression#Right AST#argument_list#Left ( AST#expression#Left '关联梦想' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fontSize AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FONT_SIZE_SMALL AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fontColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . post AST#member_expression#Right AST#expression#Right . dreamId AST#member_expression#Right AST#expression#Right ? AST#expression#Left '#666666' AST#expression#Right : AST#expression#Left '#FF4757' AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . margin AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 4 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left Text AST#expression#Right AST#argument_list#Left ( AST#expression#Left ' *' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fontSize AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FONT_SIZE_SMALL AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fontColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '#FF4757' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right . onClick AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showDreamSelector AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left } AST#ERROR#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '100%' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 56 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . justifyContent AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . alignItems AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left VerticalAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . padding AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . MARGIN_LARGE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . MARGIN_LARGE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left } AST#ERROR#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '100%' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right // 梦想选择对话框 AST#ERROR#Left if AST#ERROR#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showDreamSelector AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left { Column AST#ERROR#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left { // 对话框标题 Row AST#ERROR#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left { Text AST#ERROR#Right AST#argument_list#Left ( AST#expression#Left '选择关联的梦想' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fontSize AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FONT_SIZE_LARGE AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fontWeight AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Bold AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left Image AST#ERROR#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AppIcons AST#expression#Right . close AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 24 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 24 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fillColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.text_primary' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . onClick AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showDreamSelector AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left } AST#ERROR#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '100%' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . justifyContent AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . SpaceBetween AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . padding AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . MARGIN_LARGE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . MARGIN_NORMAL AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . MARGIN_LARGE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . MARGIN_LARGE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left Divider AST#ERROR#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '100%' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . color AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '#E0E0E0' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right // 梦想列表 AST#ERROR#Left List AST#ERROR#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left { if AST#ERROR#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLoadingDreams AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left { ListItem AST#ERROR#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left { Row AST#ERROR#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Right { AST#property_name#Left LoadingProgress AST#property_name#Right AST#parameter_list#Left ( ) AST#parameter_list#Right AST#ERROR#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 20 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 20 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . margin AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . MARGIN_SMALL AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left Text AST#ERROR#Right AST#argument_list#Left ( AST#expression#Left '加载中...' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fontSize AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FONT_SIZE_SMALL AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fontColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.text_tertiary' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left } AST#ERROR#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '100%' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . justifyContent AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . padding AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . MARGIN_LARGE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . MARGIN_LARGE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private async convertImageToBase64(imageUri: string): Promise<string | null> {
try {
if (imageUri.startsWith('file://') && !imageUri.startsWith('file://media/')) {
try {
const realPath: string = imageUri.replace('file://', '');
await fileIo.access(realPath);
const fd: number = await fileIo.open(realPath, 0);
const stat: fileIo.Stat = await fileIo.stat(realPath);
const fileSize: number = stat.size;
const buffer: ArrayBuffer = new ArrayBuffer(fileSize);
await fileIo.read(fd, buffer);
await fileIo.close(fd);
const base64Helper: util.Base64Helper = new util.Base64Helper();
return base64Helper.encodeToStringSync(new Uint8Array(buffer));
} catch (err) {
console.error('直接文件路径读取失败,尝试使用photoAccessHelper', err);
}
}
const context = getContext(this);
const phAccessHelper = photoAccessHelper.getPhotoAccessHelper(context);
let predicates = new dataSharePredicates.DataSharePredicates();
predicates.equalTo('uri', imageUri);
let fetchOptions: FetchOptions = {
fetchColumns: [],
predicates: predicates
};
return new Promise<string | null>((resolve, reject) => {
class MediaDataHandler implements MediaAssetDataHandlerInterface<ArrayBuffer> {
onDataPrepared(data: ArrayBuffer): void {
if (data === undefined) {
console.error('获取图片数据失败');
reject(new Error('获取图片数据失败'));
return;
}
try {
const uint8Array = new Uint8Array(data);
const base64Helper: util.Base64Helper = new util.Base64Helper();
const base64 = base64Helper.encodeToStringSync(uint8Array);
let contentType = 'image/jpeg';
if (imageUri.toLowerCase().endsWith('.png')) {
contentType = 'image/png';
} else if (imageUri.toLowerCase().endsWith('.gif')) {
contentType = 'image/gif';
} else if (imageUri.toLowerCase().endsWith('.webp')) {
contentType = 'image/webp';
}
const base64WithPrefix = `data:${contentType};base64,${base64}`;
resolve(base64WithPrefix);
} catch (err) {
console.error('Base64转换失败:', err);
reject(err);
}
}
}
phAccessHelper.getAssets(fetchOptions)
.then(async (fetchResult) => {
if (fetchResult.getCount() > 0) {
const photoAsset = await fetchResult.getFirstObject();
if (photoAsset) {
const requestOptions: RequestOptions = {
deliveryMode: 1
};
const handler = new MediaDataHandler();
photoAccessHelper.MediaAssetManager.requestImageData(context, photoAsset, requestOptions, handler)
.catch((err: Error) => {
console.error(`获取图片数据失败: ${err.name}, ${err.message}`);
reject(err);
});
} else {
console.error('未找到图片资源');
reject(new Error('未找到图片资源'));
}
} else {
console.error('未找到匹配的图片资源');
reject(new Error('未找到匹配的图片资源'));
}
})
.catch((error: Error) => {
console.error('获取资源失败:', error);
reject(error instanceof Error ? error : new Error(String(error)));
});
});
} catch (error) {
console.error('图片处理过程中发生错误:', error);
throw error instanceof Error ? error : new Error(String(error));
}
}
build() {
Column() {
Row() {
Button() {
Image($r('app.media.ic_back'))
.width(24)
.height(24)
.fillColor(Color.White)
}
.width(40)
.height(40)
.backgroundColor($r('app.color.primary_color'))
.borderRadius(20)
.onClick(() => {
router.back();
})
Text('发布动态')
.fontSize(CommonConstants.FONT_SIZE_LARGE)
.fontWeight(FontWeight.Bold)
.margin({ left: CommonConstants.MARGIN_LARGE })
Blank()
Button('发布')
.fontSize(CommonConstants.FONT_SIZE_NORMAL)
.fontWeight(FontWeight.Medium)
.backgroundColor(this.isSubmitting ? $r('app.color.text_tertiary') : $r('app.color.primary_color'))
.height(40)
.borderRadius(CommonConstants.RADIUS_NORMAL)
.enabled(!this.isSubmitting)
.onClick(() => {
this.submitPost();
})
}
.width('100%')
.height(56)
.padding({ left: CommonConstants.MARGIN_LARGE, right: CommonConstants.MARGIN_LARGE })
.alignItems(VerticalAlign.Center)
Scroll() {
Column() {
TextInput({ placeholder: '标题(选填)', text: this.post.title })
.fontSize(CommonConstants.FONT_SIZE_NORMAL)
.height(50)
.backgroundColor(Color.Transparent)
.placeholderFont({ size: CommonConstants.FONT_SIZE_NORMAL })
.width('100%')
.onChange((value: string) => {
this.post.title = value;
})
TextArea({ placeholder: '分享你的梦想与生活...', text: this.post.content })
.fontSize(CommonConstants.FONT_SIZE_NORMAL)
.placeholderFont({ size: CommonConstants.FONT_SIZE_NORMAL })
.backgroundColor(Color.Transparent)
.height(200)
.width('100%')
.onChange((value: string) => {
this.post.content = value;
})
if (!this.post.dreamId) {
Row() {
Image(AppIcons.error)
.width(16)
.height(16)
.fillColor('#FF4757')
.margin({ right: 4 })
Text('发布动态需要关联一个梦想,点击下方的"关联梦想"按钮进行选择')
.fontSize(CommonConstants.FONT_SIZE_SMALL)
.fontColor('#FF4757')
.fontStyle(FontStyle.Italic)
}
.width('100%')
.padding(8)
.backgroundColor('#FFEEEE')
.borderRadius(CommonConstants.RADIUS_SMALL)
.margin({ top: CommonConstants.MARGIN_NORMAL })
}
if (this.selectedImages.length > 0) {
Grid() {
ForEach(this.selectedImages, (image: string, index: number) => {
GridItem() {
Stack({ alignContent: Alignment.TopEnd }) {
Image(image)
.width('100%')
.height('100%')
.borderRadius(CommonConstants.RADIUS_SMALL)
.objectFit(ImageFit.Cover)
Button({ type: ButtonType.Circle }) {
Image(AppIcons.delete)
.width(16)
.height(16)
.fillColor(Color.White)
}
.width(24)
.height(24)
.backgroundColor('#66000000')
.margin(4)
.onClick(() => {
this.removeImage(index);
})
}
}
})
}
.columnsTemplate(this.selectedImages.length === 1 ? '1fr' :
this.selectedImages.length === 2 ? '1fr 1fr' : '1fr 1fr 1fr')
.rowsTemplate(this.selectedImages.length <= 3 ? '1fr' :
this.selectedImages.length <= 6 ? '1fr 1fr' : '1fr 1fr 1fr')
.columnsGap(CommonConstants.MARGIN_SMALL)
.rowsGap(CommonConstants.MARGIN_SMALL)
.height(this.selectedImages.length <= 3 ? 100 :
this.selectedImages.length <= 6 ? 200 : 300)
.width('100%')
.margin({ top: CommonConstants.MARGIN_NORMAL })
}
if (this.post.dreamId) {
Row() {
Text('关联梦想:')
.fontSize(CommonConstants.FONT_SIZE_SMALL)
.fontColor($r('app.color.text_tertiary'))
Text(this.userDreams.find(d => d.id === this.post.dreamId)?.title || '')
.fontSize(CommonConstants.FONT_SIZE_SMALL)
.fontColor($r('app.color.primary_color'))
.fontWeight(FontWeight.Medium)
Blank()
Button({ type: ButtonType.Circle }) {
Image(AppIcons.close)
.width(16)
.height(16)
.fillColor($r('app.color.text_tertiary'))
}
.width(24)
.height(24)
.backgroundColor($r('app.color.background'))
.onClick(() => {
this.post.dreamId = undefined;
})
}
.width('100%')
.padding(CommonConstants.MARGIN_MEDIUM)
.borderRadius(CommonConstants.RADIUS_NORMAL)
.backgroundColor($r('app.color.background'))
.margin({ top: CommonConstants.MARGIN_NORMAL })
}
}
.width('100%')
.padding({
left: CommonConstants.MARGIN_LARGE,
right: CommonConstants.MARGIN_LARGE,
bottom: CommonConstants.MARGIN_LARGE
})
}
.width('100%')
.layoutWeight(1)
Column() {
Divider()
.width('100%')
.height(1)
.color('#E0E0E0')
Row() {
Row() {
Image(AppIcons.image)
.width(24)
.height(24)
.fillColor('#666666')
Text('图片')
.fontSize(CommonConstants.FONT_SIZE_SMALL)
.fontColor('#666666')
.margin({ left: 4 })
}
.onClick(() => {
this.pickImages();
})
Divider()
.vertical(true)
.height(24)
.width(1)
.color('#E0E0E0')
.margin({ left: CommonConstants.MARGIN_LARGE, right: CommonConstants.MARGIN_LARGE })
Row() {
Image(AppIcons.tag)
.width(24)
.height(24)
.fillColor(this.post.dreamId ? '#666666' : '#FF4757')
Text('关联梦想')
.fontSize(CommonConstants.FONT_SIZE_SMALL)
.fontColor(this.post.dreamId ? '#666666' : '#FF4757')
.margin({ left: 4 })
Text(' *')
.fontSize(CommonConstants.FONT_SIZE_SMALL)
.fontColor('#FF4757')
}
.onClick(() => {
this.showDreamSelector = true;
})
}
.width('100%')
.height(56)
.justifyContent(FlexAlign.Start)
.alignItems(VerticalAlign.Center)
.padding({ left: CommonConstants.MARGIN_LARGE, right: CommonConstants.MARGIN_LARGE })
}
.width('100%')
if (this.showDreamSelector) {
Column() {
Row() {
Text('选择关联的梦想')
.fontSize(CommonConstants.FONT_SIZE_LARGE)
.fontWeight(FontWeight.Bold)
Image(AppIcons.close)
.width(24)
.height(24)
.fillColor($r('app.color.text_primary'))
.onClick(() => {
this.showDreamSelector = false;
})
}
.width('100%')
.justifyContent(FlexAlign.SpaceBetween)
.padding({
top: CommonConstants.MARGIN_LARGE,
bottom: CommonConstants.MARGIN_NORMAL,
left: CommonConstants.MARGIN_LARGE,
right: CommonConstants.MARGIN_LARGE
})
Divider()
.width('100%')
.height(1)
.color('#E0E0E0')
List() {
if (this.isLoadingDreams) {
ListItem() {
Row() {
LoadingProgress()
.width(20)
.height(20)
.margin({ right: CommonConstants.MARGIN_SMALL })
Text('加载中...')
.fontSize(CommonConstants.FONT_SIZE_SMALL)
.fontColor($r('app.color.text_tertiary'))
}
.width('100%')
.justifyContent(FlexAlign.Center)
.padding({ top: CommonConstants.MARGIN_LARGE, bottom: CommonConstants.MARGIN_LARGE })
}
}
|
https://github.com/zqaini002/YaoYaoLingXian.git/blob/5095b12cbeea524a87c42d0824b1702978843d39/YaoYaoLingXian/entry/src/main/ets/pages/community/PostCreatePage.ets#L291-L671
|
7fd21c3f0f2c8b65ee645cab1c66c3f2224e2ad0
|
github
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_utils/src/main/ets/utils/FileUtil.ets
|
arkts
|
mkdirSync
|
创建目录以同步方法,当recursion指定为true,可多层级创建目录。
@param path 目录的应用沙箱路径。
@param recursion 是否多层级创建目录。recursion指定为true时,可多层级创建目录。recursion指定为false时,仅可创建单层目录。
|
static mkdirSync(path: string, recursion: boolean = true) {
if (recursion) {
fs.mkdirSync(path, recursion);
} else {
fs.mkdirSync(path);
}
}
|
AST#method_declaration#Left static mkdirSync AST#parameter_list#Left ( AST#parameter#Left path : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left recursion : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left recursion AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fs AST#expression#Right . mkdirSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left path AST#expression#Right , AST#expression#Left recursion AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } else { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fs AST#expression#Right . mkdirSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left path AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
static mkdirSync(path: string, recursion: boolean = true) {
if (recursion) {
fs.mkdirSync(path, recursion);
} else {
fs.mkdirSync(path);
}
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/FileUtil.ets#L330-L336
|
0bfa1268a50c662e5b82437ce9619975856c57cb
|
gitee
|
JackJiang2011/harmonychat.git
|
bca3f3e1ce54d763720510f99acf595a49e37879
|
entry/src/main/ets/pages/SplashPage.ets
|
arkts
|
checkAgreedPrivacy
|
检查是否已确认过隐私提示(就是在SafePage中确认过的)。
|
checkAgreedPrivacy(): void {
if (this.isAgreedPrivacy) {
this.preferenceManager.setValue('isAgreedPrivacy', true).then(() => {
ClientCoreSDK.Log.info(TAG+ 'Put the value of isAgreedPrivacy Successfully.');
this.init();
}).catch((err: BusinessError) => {
ClientCoreSDK.Log.error(TAG+ 'Put the value of isAgreedPrivacy Failed, err: ' + err);
});
} else {
this.preferenceManager.getValue<boolean>('isAgreedPrivacy').then((isAgreed: boolean | null) => {
if (isAgreed) {
this.init();
} else {
router.replaceUrl({ url: 'pages/SafePage' });
}
}).catch((err: BusinessError) => {
ClientCoreSDK.Log.error(TAG+ 'check isAgreedPrivacy Failed, err: ' + err);
});
}
}
|
AST#method_declaration#Left checkAgreedPrivacy AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isAgreedPrivacy AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . preferenceManager AST#member_expression#Right AST#expression#Right . setValue AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'isAgreedPrivacy' AST#expression#Right , AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ClientCoreSDK AST#expression#Right . Log AST#member_expression#Right AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left TAG AST#expression#Right + AST#expression#Left 'Put the value of isAgreedPrivacy Successfully.' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . init AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . catch AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err : AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ClientCoreSDK AST#expression#Right . Log AST#member_expression#Right AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left TAG AST#expression#Right + AST#expression#Left 'Put the value of isAgreedPrivacy Failed, err: ' AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left err AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } else { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . preferenceManager AST#member_expression#Right AST#expression#Right . getValue AST#member_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left 'isAgreedPrivacy' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left isAgreed : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left boolean AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left isAgreed AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . init AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left router AST#expression#Right . replaceUrl AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left url AST#property_name#Right : AST#expression#Left 'pages/SafePage' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . catch AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err : AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ClientCoreSDK AST#expression#Right . Log AST#member_expression#Right AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left TAG AST#expression#Right + AST#expression#Left 'check isAgreedPrivacy Failed, err: ' AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left err AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
checkAgreedPrivacy(): void {
if (this.isAgreedPrivacy) {
this.preferenceManager.setValue('isAgreedPrivacy', true).then(() => {
ClientCoreSDK.Log.info(TAG+ 'Put the value of isAgreedPrivacy Successfully.');
this.init();
}).catch((err: BusinessError) => {
ClientCoreSDK.Log.error(TAG+ 'Put the value of isAgreedPrivacy Failed, err: ' + err);
});
} else {
this.preferenceManager.getValue<boolean>('isAgreedPrivacy').then((isAgreed: boolean | null) => {
if (isAgreed) {
this.init();
} else {
router.replaceUrl({ url: 'pages/SafePage' });
}
}).catch((err: BusinessError) => {
ClientCoreSDK.Log.error(TAG+ 'check isAgreedPrivacy Failed, err: ' + err);
});
}
}
|
https://github.com/JackJiang2011/harmonychat.git/blob/bca3f3e1ce54d763720510f99acf595a49e37879/entry/src/main/ets/pages/SplashPage.ets#L52-L71
|
2e11d5a8e3021d87b39ade84c1a867a63f7d2957
|
github
|
sithvothykiv/dialog_hub.git
|
b676c102ef2d05f8994d170abe48dcc40cd39005
|
custom_dialog/src/main/ets/component/BottomDialogView.ets
|
arkts
|
BottomDialogView
|
底部滑出弹窗组件 TODO
@author pll
@create 2025-05-20
@modify 2025-05-28
|
@ComponentV2
export struct BottomDialogView {
@Require @Param options: IBaseDialogOptions;
@Local primaryButton?: ButtonOptions = undefined; //弹框左侧按钮。
@Local secondaryButton?: ButtonOptions = undefined; //弹框右侧按钮。
aboutToAppear(): void {
}
aboutToDisappear(): void {
}
build() {
List() {
}
.sticky(StickyStyle.Header | StickyStyle.Footer)
.edgeEffect(EdgeEffect.None)
.width(this.options.style?.width)
.height(this.options.style?.height ?? "auto")
.constraintSize({ maxWidth: this.options.style?.maxWidth, maxHeight: this.options.style?.maxHeight })
// .margin({ top: this.statusBarHeight, bottom: this.isLargeScreen ? this.indicatorHeight : 0 }) //TODO
.backgroundColor(this.options.style?.backgroundColor)
.backgroundBlurStyle(this.options.style?.backgroundBlurStyle)
.borderRadius(this.options.style?.borderRadius)
.clip(true)
.onClick(() => {
//用于阻止点击冒泡,让点击mask遮罩事件能正常
})
}
//标题
@Builder
headBuilder() {
}
//底部按钮
@Builder
footBuilder() {
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ ComponentV2 AST#decorator#Right export struct BottomDialogView AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ Require AST#decorator#Right AST#decorator#Left @ Param AST#decorator#Right options : AST#type_annotation#Left AST#primary_type#Left IBaseDialogOptions AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Local AST#decorator#Right primaryButton ? : AST#type_annotation#Left AST#primary_type#Left ButtonOptions AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left undefined AST#expression#Right ; AST#property_declaration#Right //弹框左侧按钮。 AST#property_declaration#Left AST#decorator#Left @ Local AST#decorator#Right secondaryButton ? : AST#type_annotation#Left AST#primary_type#Left ButtonOptions AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left undefined AST#expression#Right ; AST#property_declaration#Right //弹框右侧按钮。 AST#method_declaration#Left aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left aboutToDisappear AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { } AST#builder_function_body#Right AST#method_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left List ( ) AST#container_content_body#Left { } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . sticky ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left StickyStyle AST#expression#Right . Header AST#member_expression#Right AST#expression#Right | AST#expression#Left StickyStyle AST#expression#Right AST#binary_expression#Right AST#expression#Right . Footer AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . edgeEffect ( AST#expression#Left AST#member_expression#Left AST#expression#Left EdgeEffect AST#expression#Right . None AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . style AST#member_expression#Right AST#expression#Right ?. width AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . style AST#member_expression#Right AST#expression#Right ?. height AST#member_expression#Right AST#expression#Right ?? AST#expression#Left "auto" AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . constraintSize ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left maxWidth AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . style AST#member_expression#Right AST#expression#Right ?. maxWidth AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left maxHeight AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . style AST#member_expression#Right AST#expression#Right ?. maxHeight AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) // .margin({ top: this.statusBarHeight, bottom: this.isLargeScreen ? this.indicatorHeight : 0 }) //TODO AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . style AST#member_expression#Right AST#expression#Right ?. backgroundColor AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundBlurStyle ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . style AST#member_expression#Right AST#expression#Right ?. backgroundBlurStyle AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . style AST#member_expression#Right AST#expression#Right ?. borderRadius AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . clip ( AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#expression#Left AST#object_literal#Left { //用于阻止点击冒泡,让点击mask遮罩事件能正常 } AST#object_literal#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right //标题 AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right headBuilder AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { } AST#builder_function_body#Right AST#method_declaration#Right //底部按钮 AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right footBuilder AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { } AST#builder_function_body#Right AST#method_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@ComponentV2
export struct BottomDialogView {
@Require @Param options: IBaseDialogOptions;
@Local primaryButton?: ButtonOptions = undefined;
@Local secondaryButton?: ButtonOptions = undefined;
aboutToAppear(): void {
}
aboutToDisappear(): void {
}
build() {
List() {
}
.sticky(StickyStyle.Header | StickyStyle.Footer)
.edgeEffect(EdgeEffect.None)
.width(this.options.style?.width)
.height(this.options.style?.height ?? "auto")
.constraintSize({ maxWidth: this.options.style?.maxWidth, maxHeight: this.options.style?.maxHeight })
.backgroundColor(this.options.style?.backgroundColor)
.backgroundBlurStyle(this.options.style?.backgroundBlurStyle)
.borderRadius(this.options.style?.borderRadius)
.clip(true)
.onClick(() => {
})
}
@Builder
headBuilder() {
}
@Builder
footBuilder() {
}
}
|
https://github.com/sithvothykiv/dialog_hub.git/blob/b676c102ef2d05f8994d170abe48dcc40cd39005/custom_dialog/src/main/ets/component/BottomDialogView.ets#L9-L51
|
a99c1334348117de7a076e773f2b30a13b65da77
|
github
|
shubai-xixi/DistributeNewsArkts.git
|
7a527c5f4121612c8070d809824b0f2615d1b238
|
entry/src/main/ets/utils/HttpSyncService.ets
|
arkts
|
从服务器获取当前选中的新闻ID
|
export async function fetchRemoteNewsId(): Promise<string> {
const req = http.createHttp(); // 创建HTTP实例
try {
const res = await req.request(SERVER_URL);
// 新增:打印 res.result 的原始值和类型(关键!确认是否为字符串)
console.log(`[拉取响应] 状态码:${res.responseCode},result原始值:${res.result},result类型:${typeof res.result}`);
// 第一步:判断状态码为200(单独判断,避免被数据类型阻塞)
if (res.responseCode === 200) {
let remoteState: SharedNewsState | null = null;
// 第二步:处理 res.result(可能是字符串,手动解析为对象)
if (typeof res.result === 'string' && res.result.trim() !== '') {
// 字符串类型:手动解析为JSON对象
try {
remoteState = JSON.parse(res.result) as SharedNewsState;
} catch (e) {
console.error(`[拉取失败] JSON解析失败,错误:`, e);
}
} else if (typeof res.result === 'object' && res.result !== null) {
// 对象类型:直接断言使用
remoteState = res.result as SharedNewsState;
}
// 第三步:读取真实ID(匹配db.json的id字段)
if (remoteState && remoteState.id) {
console.log(`[拉取成功] 获取到新闻ID:${remoteState.id}`);
return remoteState.id;
} else {
console.warn(`[拉取失败] 未从响应中提取到有效ID`);
}
} else {
console.warn(`[拉取失败] 状态码非200,当前状态码:${res.responseCode}`);
}
} catch (e) {
console.error(`[拉取异常] 拉取失败,错误:`, e);
} finally {
req.destroy();
}
// 兜底返回默认值
console.log(`[拉取兜底] 返回默认ID:1`);
return '1';
}
|
AST#export_declaration#Left export AST#function_declaration#Left async function fetchRemoteNewsId AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left req = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left http AST#expression#Right . createHttp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 创建HTTP实例 AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left res = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left req AST#expression#Right AST#await_expression#Right AST#expression#Right . request AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left SERVER_URL AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 新增:打印 res.result 的原始值和类型(关键!确认是否为字符串) AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` [拉取响应] 状态码: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left res AST#expression#Right . responseCode AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ,result原始值: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left res AST#expression#Right . result AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ,result类型: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left res AST#expression#Right AST#unary_expression#Right AST#expression#Right . result AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 第一步:判断状态码为200(单独判断,避免被数据类型阻塞) AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left res AST#expression#Right . responseCode AST#member_expression#Right AST#expression#Right === AST#expression#Left 200 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left remoteState : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left SharedNewsState AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 第二步:处理 res.result(可能是字符串,手动解析为对象) AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left res AST#expression#Right AST#unary_expression#Right AST#expression#Right . result AST#member_expression#Right AST#expression#Right === AST#expression#Left 'string' AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left res AST#expression#Right AST#binary_expression#Right AST#expression#Right . result AST#member_expression#Right AST#expression#Right . trim AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right !== AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { // 字符串类型:手动解析为JSON对象 AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left remoteState = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . parse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left res AST#expression#Right . result AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left SharedNewsState AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( e ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` [拉取失败] JSON解析失败,错误: ` AST#template_literal#Right AST#expression#Right , AST#expression#Left e AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left res AST#expression#Right AST#unary_expression#Right AST#expression#Right . result AST#member_expression#Right AST#expression#Right === AST#expression#Left 'object' AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left res AST#expression#Right AST#binary_expression#Right AST#expression#Right . result AST#member_expression#Right AST#expression#Right !== AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { // 对象类型:直接断言使用 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left remoteState = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left res AST#expression#Right . result AST#member_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left SharedNewsState AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#if_statement#Right AST#statement#Right // 第三步:读取真实ID(匹配db.json的id字段) AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left remoteState AST#expression#Right && AST#expression#Left remoteState AST#expression#Right AST#binary_expression#Right AST#expression#Right . id AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` [拉取成功] 获取到新闻ID: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left remoteState AST#expression#Right . id AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left remoteState AST#expression#Right . id AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . warn AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` [拉取失败] 未从响应中提取到有效ID ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . warn AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` [拉取失败] 状态码非200,当前状态码: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left res AST#expression#Right . responseCode AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( e ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` [拉取异常] 拉取失败,错误: ` AST#template_literal#Right AST#expression#Right , AST#expression#Left e AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#finally_clause#Left finally AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left req AST#expression#Right . destroy AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#finally_clause#Right AST#try_statement#Right AST#statement#Right // 兜底返回默认值 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` [拉取兜底] 返回默认ID:1 ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left '1' AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
|
export async function fetchRemoteNewsId(): Promise<string> {
const req = http.createHttp();
try {
const res = await req.request(SERVER_URL);
console.log(`[拉取响应] 状态码:${res.responseCode},result原始值:${res.result},result类型:${typeof res.result}`);
if (res.responseCode === 200) {
let remoteState: SharedNewsState | null = null;
if (typeof res.result === 'string' && res.result.trim() !== '') {
try {
remoteState = JSON.parse(res.result) as SharedNewsState;
} catch (e) {
console.error(`[拉取失败] JSON解析失败,错误:`, e);
}
} else if (typeof res.result === 'object' && res.result !== null) {
remoteState = res.result as SharedNewsState;
}
if (remoteState && remoteState.id) {
console.log(`[拉取成功] 获取到新闻ID:${remoteState.id}`);
return remoteState.id;
} else {
console.warn(`[拉取失败] 未从响应中提取到有效ID`);
}
} else {
console.warn(`[拉取失败] 状态码非200,当前状态码:${res.responseCode}`);
}
} catch (e) {
console.error(`[拉取异常] 拉取失败,错误:`, e);
} finally {
req.destroy();
}
console.log(`[拉取兜底] 返回默认ID:1`);
return '1';
}
|
https://github.com/shubai-xixi/DistributeNewsArkts.git/blob/7a527c5f4121612c8070d809824b0f2615d1b238/entry/src/main/ets/utils/HttpSyncService.ets#L8-L52
|
74dae83a8456291f5a014d97e89a93a4ce04ed2e
|
github
|
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/BasicFeature/Notification/CustomNotification/notification/src/main/ets/notification/NotificationRequestUtil.ets
|
arkts
|
initButtonNotificationRequest
|
init NotificationRequest width buttons
@param notificationContent
@param notificationActionButtons
@return return the created NotificationRequest
|
initButtonNotificationRequest(notificationContent: notification.NotificationContent, notificationActionButtons: notification.NotificationActionButton[]): notification.NotificationRequest {
let actionButtons = notificationActionButtons
if (notificationActionButtons.length > 2) { // 当前通知接口最大允许有两个按钮,超过两个按钮不展示
actionButtons = notificationActionButtons.splice(0, 2)
}
return {
slotType: notification.SlotType.CONTENT_INFORMATION,
id: 1, // 通知id,默认为1
content: notificationContent,
actionButtons: actionButtons
};
}
|
AST#method_declaration#Left initButtonNotificationRequest AST#parameter_list#Left ( AST#parameter#Left notificationContent : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left notification . NotificationContent AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left notificationActionButtons : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left notification . NotificationActionButton AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right AST#ERROR#Left [ ] AST#ERROR#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left notification . NotificationRequest AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left actionButtons = AST#expression#Left notificationActionButtons AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left notificationActionButtons AST#expression#Right . length AST#member_expression#Right AST#expression#Right > AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { // 当前通知接口最大允许有两个按钮,超过两个按钮不展示 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left actionButtons = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left notificationActionButtons AST#expression#Right . splice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left 2 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left slotType AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left notification AST#expression#Right . SlotType AST#member_expression#Right AST#expression#Right . CONTENT_INFORMATION AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left id AST#property_name#Right : AST#expression#Left 1 AST#expression#Right AST#property_assignment#Right , // 通知id,默认为1 AST#property_assignment#Left AST#property_name#Left content AST#property_name#Right : AST#expression#Left notificationContent AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left actionButtons AST#property_name#Right : AST#expression#Left actionButtons AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
initButtonNotificationRequest(notificationContent: notification.NotificationContent, notificationActionButtons: notification.NotificationActionButton[]): notification.NotificationRequest {
let actionButtons = notificationActionButtons
if (notificationActionButtons.length > 2) {
actionButtons = notificationActionButtons.splice(0, 2)
}
return {
slotType: notification.SlotType.CONTENT_INFORMATION,
id: 1,
content: notificationContent,
actionButtons: actionButtons
};
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/BasicFeature/Notification/CustomNotification/notification/src/main/ets/notification/NotificationRequestUtil.ets#L56-L67
|
ee464061c275484f247d1b1c6812b8c6fdc9003a
|
gitee
|
wangjinyuan/JS-TS-ArkTS-database.git
|
a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26
|
npm/alprazolamdiv/11.5.1/package/src/client/voice/util/SecretKey.ets
|
arkts
|
应用约束1:为参数添加明确类型注解
|
constructor(key: number[]) {
// 应用约束2:显式初始化类属性
this.key = new Uint8Array(new ArrayBuffer(key.length));
// 应用约束37:将for-in循环改为常规for循环
for (let i = 0; i < key.length; i++) {
this.key[i] = key[i];
}
}
|
AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left key : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left number [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { // 应用约束2:显式初始化类属性 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . key AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Uint8Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ArrayBuffer AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left key AST#expression#Right . length AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 应用约束37:将for-in循环改为常规for循环 AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left key AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . key AST#member_expression#Right AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#ERROR#Left = key AST#ERROR#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right
|
constructor(key: number[]) {
this.key = new Uint8Array(new ArrayBuffer(key.length));
for (let i = 0; i < key.length; i++) {
this.key[i] = key[i];
}
}
|
https://github.com/wangjinyuan/JS-TS-ArkTS-database.git/blob/a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26/npm/alprazolamdiv/11.5.1/package/src/client/voice/util/SecretKey.ets#L10-L18
|
0de7e22b00f83b3b0ba35f6c8b4f871121d653e7
|
github
|
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_utils/src/main/ets/utils/AppUtil.ets
|
arkts
|
setWindowFocusable
|
设置点击时是否支持切换焦点窗口。该方法已过时,推荐使用:WindowUtil.setWindowFocusable()
|
static async setWindowFocusable(isFocusable: boolean, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> {
return WindowUtil.setWindowFocusable(isFocusable, windowClass);
}
|
AST#method_declaration#Left static async setWindowFocusable AST#parameter_list#Left ( AST#parameter#Left isFocusable : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left WindowUtil AST#expression#Right . setWindowFocusable AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left isFocusable AST#expression#Right , AST#expression#Left windowClass AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static async setWindowFocusable(isFocusable: boolean, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> {
return WindowUtil.setWindowFocusable(isFocusable, windowClass);
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/AppUtil.ets#L613-L615
|
d46d44cbe28cd772c02f5c1998313919ee337c6b
|
gitee
|
openharmony/xts_acts
|
5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686
|
arkui/ace_ets_component_common_attrss/ace_ets_component_common_attrss_onAreaChange/entry/src/main/ets/MainAbility/view/offset/NavRouterView.ets
|
arkts
|
NavRouterView
|
Copyright (c) 2023 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
|
@Component
export struct NavRouterView {
@State isActive: boolean = false;
@State indexDev: number = 0;
@Link _offset: Position;
private componentKey: string;
build() {
NavRouter() {
Row() {
Image($r('app.media.icon'))
.width(30)
.height(30)
.borderRadius(30)
.margin({ left: 3, right: 10 })
Text(`NavRouter`)
.fontSize(22)
.fontWeight(500)
.textAlign(TextAlign.Center)
}
.width(180)
.height(72)
.backgroundColor('#fff')
.borderRadius(24)
NavDestination() {
Text(`Page 1 Content`).fontSize(50)
Flex({ direction: FlexDirection.Row }) {
Row() {
Image($r('app.media.icon'))
.width(40)
.height(40)
.borderRadius(40)
.margin({ right: 15 })
Text('Seven classes in total')
.fontSize(30)
}.padding({ left: 15 })
}
}.backgroundColor('#ccc')
.title(`NavDestination`)
}.onStateChange((isActivated: boolean) => {
console.info('isActivated = ' + isActivated);
})
.offset(this._offset)
.key(this.componentKey)
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct NavRouterView AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right isActive : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right indexDev : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Link AST#decorator#Right _offset : AST#type_annotation#Left AST#primary_type#Left Position AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left private componentKey : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left NavRouter ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.icon' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 3 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 10 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#template_literal#Left ` NavRouter ` AST#template_literal#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 22 AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left 500 AST#expression#Right ) AST#modifier_chain_expression#Left . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 180 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 72 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#fff' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 24 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left NavDestination ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#template_literal#Left ` Page 1 Content ` AST#template_literal#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 50 AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Flex ( AST#component_parameters#Left { AST#component_parameter#Left direction : AST#expression#Left AST#member_expression#Left AST#expression#Left FlexDirection AST#expression#Right . Row AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.icon' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 40 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 40 AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 40 AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 15 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left 'Seven classes in total' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 15 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#ccc' AST#expression#Right ) AST#modifier_chain_expression#Left . title ( AST#expression#Left AST#template_literal#Left ` NavDestination ` AST#template_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . onStateChange ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left isActivated : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left 'isActivated = ' AST#expression#Right + AST#expression#Left isActivated AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Left . offset ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . _offset AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . key ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . componentKey AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@Component
export struct NavRouterView {
@State isActive: boolean = false;
@State indexDev: number = 0;
@Link _offset: Position;
private componentKey: string;
build() {
NavRouter() {
Row() {
Image($r('app.media.icon'))
.width(30)
.height(30)
.borderRadius(30)
.margin({ left: 3, right: 10 })
Text(`NavRouter`)
.fontSize(22)
.fontWeight(500)
.textAlign(TextAlign.Center)
}
.width(180)
.height(72)
.backgroundColor('#fff')
.borderRadius(24)
NavDestination() {
Text(`Page 1 Content`).fontSize(50)
Flex({ direction: FlexDirection.Row }) {
Row() {
Image($r('app.media.icon'))
.width(40)
.height(40)
.borderRadius(40)
.margin({ right: 15 })
Text('Seven classes in total')
.fontSize(30)
}.padding({ left: 15 })
}
}.backgroundColor('#ccc')
.title(`NavDestination`)
}.onStateChange((isActivated: boolean) => {
console.info('isActivated = ' + isActivated);
})
.offset(this._offset)
.key(this.componentKey)
}
}
|
https://github.com/openharmony/xts_acts/blob/5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686/arkui/ace_ets_component_common_attrss/ace_ets_component_common_attrss_onAreaChange/entry/src/main/ets/MainAbility/view/offset/NavRouterView.ets#L16-L62
|
c59390d0699a427e2df0d39da6a7d37a66b71adc
|
gitee
|
iotjin/JhHarmonyDemo.git
|
819e6c3b1db9984c042a181967784550e171b2e8
|
JhCommon/src/main/ets/JhCommon/components/JhProgressHUD.ets
|
arkts
|
showBarProgressLoadingText
|
/ 下载中 - 水平进度条
|
public static showBarProgressLoadingText(progress: number, loadingText = '正在下载...') {
JhProgressHUD._showBarProgress(progress, loadingText)
}
|
AST#method_declaration#Left public static showBarProgressLoadingText AST#parameter_list#Left ( AST#parameter#Left progress : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left loadingText = AST#expression#Left '正在下载...' AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JhProgressHUD AST#expression#Right . _showBarProgress AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left progress AST#expression#Right , AST#expression#Left loadingText AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
public static showBarProgressLoadingText(progress: number, loadingText = '正在下载...') {
JhProgressHUD._showBarProgress(progress, loadingText)
}
|
https://github.com/iotjin/JhHarmonyDemo.git/blob/819e6c3b1db9984c042a181967784550e171b2e8/JhCommon/src/main/ets/JhCommon/components/JhProgressHUD.ets#L84-L86
|
152a42f5e6d0629362fc0422462721936c06a90e
|
github
|
FantasyWind/fwrouter
|
eea785a7bf728862de1f88de487ef3857dee3364
|
router/src/main/ets/RouterManagerForNavigation.ets
|
arkts
|
Navigation模式的路由管理类。
|
export class RouterManagerForNavigation implements RouterHandler {
private static sInstance: RouterManagerForNavigation
public static getInstance(): RouterManagerForNavigation {
if (!RouterManagerForNavigation.sInstance) {
RouterManagerForNavigation.sInstance = new RouterManagerForNavigation()
}
return RouterManagerForNavigation.sInstance
}
// 管理需要动态导入的模块,key是模块名,value是WrappedBuilder对象,动态调用创建页面的接口
builderMap: Map<string, WrappedBuilder<[params?: ESObject]>> = new Map<string, WrappedBuilder<[params?: ESObject]>>();
// 多Navigation状态下,每个Navigation都要将自己的`navPathStacks`对象托管给管理器。
navPathStacks: NavPathStack[] = [];
get currentNavPathStack(): NavPathStack | undefined {
return this.navPathStacks[this.navPathStacks.length-1]
}
pushNavPathStack(stack: NavPathStack) {
this.navPathStacks.push(stack)
}
popNavPathStack(stack?: NavPathStack) {
if (stack != undefined && this.navPathStacks.indexOf(stack) >= 0) {
this.navPathStacks = this.navPathStacks.filter((item) => item !== stack)
} else {
this.navPathStacks.pop()
}
}
// 通过名称注册builder
registerBuilder(builderName: string, builder: WrappedBuilder<[params?: ESObject]>): void {
this.builderMap.set(builderName, builder);
}
/**
* 是否可以打开
*/
canOpen(path: string): boolean {
return this.builderMap.has(path)
}
// 通过名称获取builder
public getBuilder(builderName: string): WrappedBuilder<[params?: ESObject]> {
const builder: WrappedBuilder<[params?: ESObject]> | undefined = this.builderMap.get(builderName);
if (!builder) {
const MSG = "not found builder";
console.info(MSG + builderName);
}
return builder as WrappedBuilder<[params?: ESObject]>;
}
/* RouterHandler相关方法 */
init(uiAbility: UIAbility): void {
this.observerPageLifecycle(uiAbility)
}
open(request: RouterRequestWrapper): Promise<RouterResponse> {
return new Promise((resolve, reject) => {
if (!this.currentNavPathStack) {
resolve(RouterResponseError.RequestNotFoundResponsor)
return
}
if (!this.canOpen(request.routeName)) {
resolve(RouterResponseError.RequestNotFoundResponsor)
return
}
switch (request.rawRequest.openMode) {
case PageRouteOpenMode.replace:
this.currentNavPathStack!.replacePath({
name: request.routeName, param: request.params
})
request.resolve = resolve;
this.inject(request)
break;
default:
this.currentNavPathStack!.pushDestination({
name: request.routeName, param: request.params
}).then(() => {
request.resolve = resolve;
this.inject(request)
}).catch((e: ESObject) => {
console.log(`${e}`)
if (e.code == 100005) {
resolve(RouterResponseError.RequestNotFoundResponsor)
} else {
resolve(RouterResponseError.UnknownError)
}
})
break;
}
}
|
AST#export_declaration#Left export AST#class_declaration#Left class RouterManagerForNavigation AST#implements_clause#Left implements RouterHandler AST#implements_clause#Right AST#class_body#Left { AST#property_declaration#Left private static sInstance : AST#type_annotation#Left AST#primary_type#Left RouterManagerForNavigation AST#primary_type#Right AST#type_annotation#Right AST#property_declaration#Right AST#method_declaration#Left public static getInstance AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left RouterManagerForNavigation AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left RouterManagerForNavigation AST#expression#Right AST#unary_expression#Right AST#expression#Right . sInstance AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left RouterManagerForNavigation AST#expression#Right . sInstance AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left RouterManagerForNavigation AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#expression_statement#Left AST#expression#Left return AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left RouterManagerForNavigation AST#expression#Right . sInstance AST#member_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right // 管理需要动态导入的模块,key是模块名,value是WrappedBuilder对象,动态调用创建页面的接口 AST#property_declaration#Left builderMap AST#ERROR#Left : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Map AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left WrappedBuilder AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#tuple_type#Left [ AST#type_annotation#Left AST#primary_type#Left params AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left ? : ESObject AST#ERROR#Right ] AST#tuple_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#new_expression#Left new AST#expression#Left Map AST#expression#Right AST#new_expression#Right AST#expression#Right < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , WrappedBuilder < [ AST#type_annotation#Left AST#primary_type#Left params AST#primary_type#Right AST#type_annotation#Right ? : AST#ERROR#Left AST#type_annotation#Left AST#primary_type#Left ESObject AST#primary_type#Right AST#type_annotation#Right ] >> AST#ERROR#Right AST#parameter_list#Left ( ) AST#parameter_list#Right AST#ERROR#Right ; AST#property_declaration#Right // 多Navigation状态下,每个Navigation都要将自己的`navPathStacks`对象托管给管理器。 AST#property_declaration#Left navPathStacks : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left NavPathStack [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#method_declaration#Left get AST#ERROR#Left currentNavPath Stack AST#ERROR#Right AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left NavPathStack AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . navPathStacks AST#member_expression#Right AST#expression#Right [ AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . navPathStacks AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right - AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left pushNavPathStack AST#parameter_list#Left ( AST#parameter#Left stack : AST#type_annotation#Left AST#primary_type#Left NavPathStack AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . navPathStacks AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left stack AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left popNavPathStack AST#parameter_list#Left ( AST#parameter#Left stack ? : AST#type_annotation#Left AST#primary_type#Left NavPathStack AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left stack AST#expression#Right != AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . navPathStacks AST#member_expression#Right AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left stack AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right >= AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . navPathStacks AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . navPathStacks AST#member_expression#Right AST#expression#Right . filter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#binary_expression#Left AST#expression#Left item AST#expression#Right !== AST#expression#Left stack AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right } else { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . navPathStacks AST#member_expression#Right AST#expression#Right . pop AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right // 通过名称注册builder AST#method_declaration#Left registerBuilder AST#parameter_list#Left ( AST#parameter#Left builderName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left builder : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left WrappedBuilder AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#tuple_type#Left [ AST#type_annotation#Left AST#primary_type#Left params AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left ? : ESObject AST#ERROR#Right ] AST#tuple_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . builderMap AST#member_expression#Right AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left builderName AST#expression#Right , AST#expression#Left builder AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right /**
* 是否可以打开
*/ AST#method_declaration#Left canOpen AST#parameter_list#Left ( AST#parameter#Left path : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . builderMap AST#member_expression#Right AST#expression#Right . has AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left path AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right // 通过名称获取builder AST#method_declaration#Left public getBuilder AST#parameter_list#Left ( AST#parameter#Left builderName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left WrappedBuilder AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#tuple_type#Left [ AST#type_annotation#Left AST#primary_type#Left params AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left ? : ESObject AST#ERROR#Right ] AST#tuple_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left builder : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#generic_type#Left WrappedBuilder AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#tuple_type#Left [ AST#type_annotation#Left AST#primary_type#Left params AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left ? : ESObject AST#ERROR#Right ] AST#tuple_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . builderMap AST#member_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left builderName AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left builder AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left MSG = AST#expression#Left "not found builder" AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left MSG AST#expression#Right + AST#expression#Left builderName AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#as_expression#Left AST#expression#Left builder AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left WrappedBuilder AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right < AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#conditional_expression#Left AST#expression#Left params AST#expression#Right ? AST#expression#Left AST#expression#Right : AST#expression#Left ESObject AST#expression#Right AST#conditional_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right > AST#expression#Left AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /* RouterHandler相关方法 */ AST#method_declaration#Left init AST#parameter_list#Left ( AST#parameter#Left uiAbility : AST#type_annotation#Left AST#primary_type#Left UIAbility AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . observerPageLifecycle AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left uiAbility AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left open AST#parameter_list#Left ( AST#parameter#Left request : AST#type_annotation#Left AST#primary_type#Left RouterRequestWrapper AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#ERROR#Left : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left RouterResponse AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right { return AST#expression#Left AST#member_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Promise AST#expression#Right AST#new_expression#Right AST#expression#Right AST#ERROR#Left ( AST#parameter_list#Left ( AST#parameter#Left resolve AST#parameter#Right , AST#parameter#Left reject AST#parameter#Right ) AST#parameter_list#Right => { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . currentNavPathStack AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left resolve AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left RouterResponseError AST#expression#Right . RequestNotFoundResponsor AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . canOpen AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left request AST#expression#Right . routeName AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left resolve AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left RouterResponseError AST#expression#Right . RequestNotFoundResponsor AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left switch AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left request AST#expression#Right . rawRequest AST#member_expression#Right AST#expression#Right . openMode AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right { AST#property_name#Left case AST#property_name#Right PageRouteOpenMode AST#ERROR#Right . replace AST#member_expression#Right AST#expression#Right AST#ERROR#Right : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left this . currentNavPathStack AST#ERROR#Left ! AST#ERROR#Right . replacePath AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left ( AST#ERROR#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left name AST#ERROR#Left : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left request . routeName AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right , param : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left request . params AST#ERROR#Left } ) request AST#ERROR#Right . resolve AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Right = AST#expression#Left resolve AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . inject AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left request AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left break AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#non_null_assertion_expression#Left AST#expression#Left default AST#expression#Right AST#ERROR#Left : AST#qualified_type#Left this . currentNavPathStack AST#qualified_type#Right AST#ERROR#Right ! AST#non_null_assertion_expression#Right AST#expression#Right . pushDestination AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left name AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left request AST#expression#Right . routeName AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left param AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left request AST#expression#Right . params AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left request AST#expression#Right . resolve AST#member_expression#Right = AST#expression#Left resolve AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . inject AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left request AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . catch AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left e : AST#type_annotation#Left AST#primary_type#Left ESObject AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left e AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left e AST#expression#Right . code AST#member_expression#Right AST#expression#Right == AST#expression#Left 100005 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left resolve AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left RouterResponseError AST#expression#Right . RequestNotFoundResponsor AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left resolve AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left RouterResponseError AST#expression#Right . UnknownError AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left break AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class RouterManagerForNavigation implements RouterHandler {
private static sInstance: RouterManagerForNavigation
public static getInstance(): RouterManagerForNavigation {
if (!RouterManagerForNavigation.sInstance) {
RouterManagerForNavigation.sInstance = new RouterManagerForNavigation()
}
return RouterManagerForNavigation.sInstance
}
builderMap: Map<string, WrappedBuilder<[params?: ESObject]>> = new Map<string, WrappedBuilder<[params?: ESObject]>>();
navPathStacks: NavPathStack[] = [];
get currentNavPathStack(): NavPathStack | undefined {
return this.navPathStacks[this.navPathStacks.length-1]
}
pushNavPathStack(stack: NavPathStack) {
this.navPathStacks.push(stack)
}
popNavPathStack(stack?: NavPathStack) {
if (stack != undefined && this.navPathStacks.indexOf(stack) >= 0) {
this.navPathStacks = this.navPathStacks.filter((item) => item !== stack)
} else {
this.navPathStacks.pop()
}
}
registerBuilder(builderName: string, builder: WrappedBuilder<[params?: ESObject]>): void {
this.builderMap.set(builderName, builder);
}
canOpen(path: string): boolean {
return this.builderMap.has(path)
}
public getBuilder(builderName: string): WrappedBuilder<[params?: ESObject]> {
const builder: WrappedBuilder<[params?: ESObject]> | undefined = this.builderMap.get(builderName);
if (!builder) {
const MSG = "not found builder";
console.info(MSG + builderName);
}
return builder as WrappedBuilder<[params?: ESObject]>;
}
init(uiAbility: UIAbility): void {
this.observerPageLifecycle(uiAbility)
}
open(request: RouterRequestWrapper): Promise<RouterResponse> {
return new Promise((resolve, reject) => {
if (!this.currentNavPathStack) {
resolve(RouterResponseError.RequestNotFoundResponsor)
return
}
if (!this.canOpen(request.routeName)) {
resolve(RouterResponseError.RequestNotFoundResponsor)
return
}
switch (request.rawRequest.openMode) {
case PageRouteOpenMode.replace:
this.currentNavPathStack!.replacePath({
name: request.routeName, param: request.params
})
request.resolve = resolve;
this.inject(request)
break;
default:
this.currentNavPathStack!.pushDestination({
name: request.routeName, param: request.params
}).then(() => {
request.resolve = resolve;
this.inject(request)
}).catch((e: ESObject) => {
console.log(`${e}`)
if (e.code == 100005) {
resolve(RouterResponseError.RequestNotFoundResponsor)
} else {
resolve(RouterResponseError.UnknownError)
}
})
break;
}
}
|
https://github.com/FantasyWind/fwrouter/blob/eea785a7bf728862de1f88de487ef3857dee3364/router/src/main/ets/RouterManagerForNavigation.ets#L48-L143
|
c6e308b8fb0421d2fb4dcf3b3a81c6172ac06008
|
gitee
|
|
harmonyos_samples/BestPracticeSnippets
|
490ea539a6d4427dd395f3dac3cf4887719f37af
|
AppAspectProgrammingDesign/entry/src/main/ets/pages/Index2.ets
|
arkts
|
addTimePrinter
|
Print the time before and after the insertion, and encapsulate the insertion action into an interface
|
function addTimePrinter(targetClass: Object, methodName: string, isStatic: boolean) {
let t1 = 0;
let t2 = 0;
util.Aspect.addBefore(targetClass, methodName, isStatic, () => {
t1 = new Date().getTime();
});
util.Aspect.addAfter(targetClass, methodName, isStatic, () => {
t2 = new Date().getTime();
console.log("t2---t1 = " + (t2 - t1).toString());
});
}
|
AST#function_declaration#Left function addTimePrinter AST#parameter_list#Left ( AST#parameter#Left targetClass : AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left methodName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left isStatic : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left t1 = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left t2 = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left util AST#expression#Right . Aspect AST#member_expression#Right AST#expression#Right . addBefore AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left targetClass AST#expression#Right , AST#expression#Left methodName AST#expression#Right , AST#expression#Left isStatic AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left t1 = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . getTime AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left util AST#expression#Right . Aspect AST#member_expression#Right AST#expression#Right . addAfter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left targetClass AST#expression#Right , AST#expression#Left methodName AST#expression#Right , AST#expression#Left isStatic AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left t2 = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . getTime AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left "t2---t1 = " AST#expression#Right + AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left t2 AST#expression#Right - AST#expression#Left t1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right
|
function addTimePrinter(targetClass: Object, methodName: string, isStatic: boolean) {
let t1 = 0;
let t2 = 0;
util.Aspect.addBefore(targetClass, methodName, isStatic, () => {
t1 = new Date().getTime();
});
util.Aspect.addAfter(targetClass, methodName, isStatic, () => {
t2 = new Date().getTime();
console.log("t2---t1 = " + (t2 - t1).toString());
});
}
|
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/AppAspectProgrammingDesign/entry/src/main/ets/pages/Index2.ets#L33-L43
|
3fc3f59e8cebb522a310b8b416e804a1c9c5cc77
|
gitee
|
sbyder/MyChat.git
|
4f4a34156092458cc44614cb45f70af6f0ed2fd8
|
entry/src/main/ets/view/Avatar/Avatar.ets
|
arkts
|
Avatar
|
使用时需在外面包一层正方形盒子
|
@Component
export struct Avatar{
@Prop content:string|Resource
build() {
Flex({justifyContent:FlexAlign.Center,alignItems:ItemAlign.Center}){
if(typeof this.content==='string'){
Text(this.content[0])
.fontSize(18)
.fontColor('#fff')
}else {
Image(this.content)
.width('100%')
.height('100%')
}
}
.height('100%')
.width('100%')
.backgroundColor(typeof this.content==='string'?$r('app.color.theme_color'):'transparent')
.borderRadius(8)
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct Avatar AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right content : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left Resource AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#property_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Flex ( AST#component_parameters#Left { AST#component_parameter#Left justifyContent : AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left alignItems : AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . content AST#member_expression#Right AST#expression#Right === AST#expression#Left 'string' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . content AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 18 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#fff' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } else { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . content AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . height ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . content AST#member_expression#Right AST#expression#Right === AST#expression#Left 'string' AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.theme_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left 'transparent' AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 8 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@Component
export struct Avatar{
@Prop content:string|Resource
build() {
Flex({justifyContent:FlexAlign.Center,alignItems:ItemAlign.Center}){
if(typeof this.content==='string'){
Text(this.content[0])
.fontSize(18)
.fontColor('#fff')
}else {
Image(this.content)
.width('100%')
.height('100%')
}
}
.height('100%')
.width('100%')
.backgroundColor(typeof this.content==='string'?$r('app.color.theme_color'):'transparent')
.borderRadius(8)
}
}
|
https://github.com/sbyder/MyChat.git/blob/4f4a34156092458cc44614cb45f70af6f0ed2fd8/entry/src/main/ets/view/Avatar/Avatar.ets#L3-L23
|
71d56a4fab62874982e3dff97c47063f3e96a37f
|
github
|
Joker-x-dev/CoolMallArkTS.git
|
9f3fabf89fb277692cb82daf734c220c7282919c
|
core/model/src/main/ets/entity/Home.ets
|
arkts
|
@file 首页模型
@author Joker.X
|
export class Home {
/**
* 轮播图
*/
banner?: Banner[] | null = null;
/**
* 分类
*/
category?: Category[] | null = null;
/**
* 全部分类
*/
categoryAll?: Category[] | null = null;
/**
* 限时精选商品
*/
flashSale?: Goods[] | null = null;
/**
* 推荐商品
*/
recommend?: Goods[] | null = null;
/**
* 优惠券
*/
coupon?: Coupon[] | null = null;
/**
* 第一页全部商品
*/
goods?: Goods[] | null = null;
constructor(init?: Partial<Home>) {
if (!init) {
return;
}
this.banner = init.banner ? init.banner.map((b) => new Banner(b)) : this.banner;
this.category = init.category ? init.category.map((c) => new Category(c)) : this.category;
this.categoryAll = init.categoryAll ? init.categoryAll.map((c) => new Category(c)) : this.categoryAll;
this.flashSale = init.flashSale ? init.flashSale.map((g) => new Goods(g)) : this.flashSale;
this.recommend = init.recommend ? init.recommend.map((g) => new Goods(g)) : this.recommend;
this.coupon = init.coupon ? init.coupon.map((c) => new Coupon(c)) : this.coupon;
this.goods = init.goods ? init.goods.map((g) => new Goods(g)) : this.goods;
}
}
|
AST#export_declaration#Left export AST#class_declaration#Left class Home AST#class_body#Left { /**
* 轮播图
*/ AST#property_declaration#Left banner ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#array_type#Left Banner [ ] AST#array_type#Right AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#property_declaration#Right /**
* 分类
*/ AST#property_declaration#Left category ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#array_type#Left Category [ ] AST#array_type#Right AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#property_declaration#Right /**
* 全部分类
*/ AST#property_declaration#Left categoryAll ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#array_type#Left Category [ ] AST#array_type#Right AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#property_declaration#Right /**
* 限时精选商品
*/ AST#property_declaration#Left flashSale ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#array_type#Left Goods [ ] AST#array_type#Right AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#property_declaration#Right /**
* 推荐商品
*/ AST#property_declaration#Left recommend ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#array_type#Left Goods [ ] AST#array_type#Right AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#property_declaration#Right /**
* 优惠券
*/ AST#property_declaration#Left coupon ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#array_type#Left Coupon [ ] AST#array_type#Right AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#property_declaration#Right /**
* 第一页全部商品
*/ AST#property_declaration#Left goods ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#array_type#Left Goods [ ] AST#array_type#Right AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left init ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Partial AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left Home AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left init AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . banner AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left init AST#expression#Right . banner AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left init AST#expression#Right . banner AST#member_expression#Right AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left b AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Banner AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left b AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right : AST#expression#Left this AST#expression#Right AST#conditional_expression#Right AST#expression#Right . banner AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . category AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left init AST#expression#Right . category AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left init AST#expression#Right . category AST#member_expression#Right AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left c AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Category AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left c AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right : AST#expression#Left this AST#expression#Right AST#conditional_expression#Right AST#expression#Right . category AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . categoryAll AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left init AST#expression#Right . categoryAll AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left init AST#expression#Right . categoryAll AST#member_expression#Right AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left c AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Category AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left c AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right : AST#expression#Left this AST#expression#Right AST#conditional_expression#Right AST#expression#Right . categoryAll AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . flashSale AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left init AST#expression#Right . flashSale AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left init AST#expression#Right . flashSale AST#member_expression#Right AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left g AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Goods AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left g AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right : AST#expression#Left this AST#expression#Right AST#conditional_expression#Right AST#expression#Right . flashSale AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . recommend AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left init AST#expression#Right . recommend AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left init AST#expression#Right . recommend AST#member_expression#Right AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left g AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Goods AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left g AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right : AST#expression#Left this AST#expression#Right AST#conditional_expression#Right AST#expression#Right . recommend AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . coupon AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left init AST#expression#Right . coupon AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left init AST#expression#Right . coupon AST#member_expression#Right AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left c AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Coupon AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left c AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right : AST#expression#Left this AST#expression#Right AST#conditional_expression#Right AST#expression#Right . coupon AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . goods AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left init AST#expression#Right . goods AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left init AST#expression#Right . goods AST#member_expression#Right AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left g AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Goods AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left g AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right : AST#expression#Left this AST#expression#Right AST#conditional_expression#Right AST#expression#Right . goods AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class Home {
banner?: Banner[] | null = null;
category?: Category[] | null = null;
categoryAll?: Category[] | null = null;
flashSale?: Goods[] | null = null;
recommend?: Goods[] | null = null;
coupon?: Coupon[] | null = null;
goods?: Goods[] | null = null;
constructor(init?: Partial<Home>) {
if (!init) {
return;
}
this.banner = init.banner ? init.banner.map((b) => new Banner(b)) : this.banner;
this.category = init.category ? init.category.map((c) => new Category(c)) : this.category;
this.categoryAll = init.categoryAll ? init.categoryAll.map((c) => new Category(c)) : this.categoryAll;
this.flashSale = init.flashSale ? init.flashSale.map((g) => new Goods(g)) : this.flashSale;
this.recommend = init.recommend ? init.recommend.map((g) => new Goods(g)) : this.recommend;
this.coupon = init.coupon ? init.coupon.map((c) => new Coupon(c)) : this.coupon;
this.goods = init.goods ? init.goods.map((g) => new Goods(g)) : this.goods;
}
}
|
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/model/src/main/ets/entity/Home.ets#L10-L52
|
4c9ae72681b3a46fb5696a9b8066e0ad73c183f3
|
github
|
|
openharmony/arkui_ace_engine
|
30c7d1ee12fbedf0fabece54291d75897e2ad44f
|
examples/Overlay/entry/src/main/ets/pages/components/menu/MultiLevelSubMenu.ets
|
arkts
|
MultiLevelSubMenuBuilder
|
Copyright (c) 2025 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
|
@Builder
export function MultiLevelSubMenuBuilder(name: string, param: Object) {
MultiLevelSubMenuExample()
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right export function MultiLevelSubMenuBuilder AST#parameter_list#Left ( AST#parameter#Left name : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left param : AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left MultiLevelSubMenuExample ( ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#decorated_export_declaration#Right
|
@Builder
export function MultiLevelSubMenuBuilder(name: string, param: Object) {
MultiLevelSubMenuExample()
}
|
https://github.com/openharmony/arkui_ace_engine/blob/30c7d1ee12fbedf0fabece54291d75897e2ad44f/examples/Overlay/entry/src/main/ets/pages/components/menu/MultiLevelSubMenu.ets#L16-L19
|
02f39726a05730bd9e08fca949c2717c632f8a2d
|
gitee
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/services/database/DatabaseService.ets
|
arkts
|
getRecentGreetingHistory
|
获取最近的祝福记录
@param limit 数量限制
|
async getRecentGreetingHistory(limit: number = 10): Promise<GreetingHistoryWithContact[]> {
this.checkInitialization();
return await this.greetingHistoryDAO.getGreetingHistoryWithContactInfo(limit);
}
|
AST#method_declaration#Left async getRecentGreetingHistory AST#parameter_list#Left ( AST#parameter#Left limit : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 10 AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left GreetingHistoryWithContact [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . checkInitialization AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . greetingHistoryDAO AST#member_expression#Right AST#expression#Right . getGreetingHistoryWithContactInfo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left limit AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
async getRecentGreetingHistory(limit: number = 10): Promise<GreetingHistoryWithContact[]> {
this.checkInitialization();
return await this.greetingHistoryDAO.getGreetingHistoryWithContactInfo(limit);
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/database/DatabaseService.ets#L231-L234
|
550492cbf8b91464214befec56987defe5b34a92
|
github
|
Joker-x-dev/CoolMallArkTS.git
|
9f3fabf89fb277692cb82daf734c220c7282919c
|
core/datastore/src/main/ets/datasource/ordercache/OrderCacheStoreDataSourceImpl.ets
|
arkts
|
clearAll
|
清除所有订单缓存
@returns {Promise<void>} Promise<void>
|
async clearAll(): Promise<void> {
await this.prefs.remove(OrderCacheStoreDataSourceImpl.KEY_CARTS);
await this.prefs.remove(OrderCacheStoreDataSourceImpl.KEY_SELECTED_GOODS_LIST);
}
|
AST#method_declaration#Left async clearAll AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . prefs AST#member_expression#Right AST#expression#Right . remove AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left OrderCacheStoreDataSourceImpl AST#expression#Right . KEY_CARTS AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . prefs AST#member_expression#Right AST#expression#Right . remove AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left OrderCacheStoreDataSourceImpl AST#expression#Right . KEY_SELECTED_GOODS_LIST AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
async clearAll(): Promise<void> {
await this.prefs.remove(OrderCacheStoreDataSourceImpl.KEY_CARTS);
await this.prefs.remove(OrderCacheStoreDataSourceImpl.KEY_SELECTED_GOODS_LIST);
}
|
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/datastore/src/main/ets/datasource/ordercache/OrderCacheStoreDataSourceImpl.ets#L152-L155
|
3259feb3d5e5275fd985a16dc0e2e39a1fb0a4ee
|
github
|
Hyricane/Interview_Success.git
|
9783273fe05fc8951b99bf32d3887c605268db8f
|
entry/src/main/ets/entryability/EntryAbility.ets
|
arkts
|
onCreate
|
最早的创建窗口的钩子 提前将后续使用的上下文context放到appstorage 共享给整个应用
|
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
// hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate');
logger.info('生命周期', 'Ability onCreate')
// AppStorage.setOrCreate<string>('username', 'zs')
AppStorage.setOrCreate('context', this.context)
}
|
AST#method_declaration#Left onCreate AST#parameter_list#Left ( AST#parameter#Left want : AST#type_annotation#Left AST#primary_type#Left Want AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left launchParam : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left AbilityConstant . LaunchParam AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . context AST#member_expression#Right AST#expression#Right . getApplicationContext AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . setColorMode AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ConfigurationConstant AST#expression#Right . ColorMode AST#member_expression#Right AST#expression#Right . COLOR_MODE_NOT_SET AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right // hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '生命周期' AST#expression#Right , AST#expression#Left 'Ability onCreate' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right // AppStorage.setOrCreate<string>('username', 'zs') AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . setOrCreate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'context' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . context AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
logger.info('生命周期', 'Ability onCreate')
AppStorage.setOrCreate('context', this.context)
}
|
https://github.com/Hyricane/Interview_Success.git/blob/9783273fe05fc8951b99bf32d3887c605268db8f/entry/src/main/ets/entryability/EntryAbility.ets#L46-L53
|
1c463493be6ef5b685ce52a8bd5ee4d7106d57ad
|
github
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_utils/src/main/ets/utils/AppUtil.ets
|
arkts
|
getBundleInfoSync
|
获取当前应用的BundleInfo
|
static getBundleInfoSync(): bundleManager.BundleInfo {
const bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION |
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY |
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY |
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE |
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA |
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION |
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO |
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_ROUTER_MAP |
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_MENU |
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SKILL |
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_DISABLE;
return bundleManager.getBundleInfoForSelfSync(bundleFlags);
}
|
AST#method_declaration#Left static getBundleInfoSync AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left bundleManager . BundleInfo AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left bundleFlags = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left bundleManager AST#expression#Right . BundleFlag AST#member_expression#Right AST#expression#Right . GET_BUNDLE_INFO_WITH_APPLICATION AST#member_expression#Right AST#expression#Right | AST#expression#Left bundleManager AST#expression#Right AST#binary_expression#Right AST#expression#Right . BundleFlag AST#member_expression#Right AST#expression#Right . GET_BUNDLE_INFO_WITH_ABILITY AST#member_expression#Right AST#expression#Right | AST#expression#Left bundleManager AST#expression#Right AST#binary_expression#Right AST#expression#Right . BundleFlag AST#member_expression#Right AST#expression#Right . GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY AST#member_expression#Right AST#expression#Right | AST#expression#Left bundleManager AST#expression#Right AST#binary_expression#Right AST#expression#Right . BundleFlag AST#member_expression#Right AST#expression#Right . GET_BUNDLE_INFO_WITH_HAP_MODULE AST#member_expression#Right AST#expression#Right | AST#expression#Left bundleManager AST#expression#Right AST#binary_expression#Right AST#expression#Right . BundleFlag AST#member_expression#Right AST#expression#Right . GET_BUNDLE_INFO_WITH_METADATA AST#member_expression#Right AST#expression#Right | AST#expression#Left bundleManager AST#expression#Right AST#binary_expression#Right AST#expression#Right . BundleFlag AST#member_expression#Right AST#expression#Right . GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION AST#member_expression#Right AST#expression#Right | AST#expression#Left bundleManager AST#expression#Right AST#binary_expression#Right AST#expression#Right . BundleFlag AST#member_expression#Right AST#expression#Right . GET_BUNDLE_INFO_WITH_SIGNATURE_INFO AST#member_expression#Right AST#expression#Right | AST#expression#Left bundleManager AST#expression#Right AST#binary_expression#Right AST#expression#Right . BundleFlag AST#member_expression#Right AST#expression#Right . GET_BUNDLE_INFO_WITH_ROUTER_MAP AST#member_expression#Right AST#expression#Right | AST#expression#Left bundleManager AST#expression#Right AST#binary_expression#Right AST#expression#Right . BundleFlag AST#member_expression#Right AST#expression#Right . GET_BUNDLE_INFO_WITH_MENU AST#member_expression#Right AST#expression#Right | AST#expression#Left bundleManager AST#expression#Right AST#binary_expression#Right AST#expression#Right . BundleFlag AST#member_expression#Right AST#expression#Right . GET_BUNDLE_INFO_WITH_SKILL AST#member_expression#Right AST#expression#Right | AST#expression#Left bundleManager AST#expression#Right AST#binary_expression#Right AST#expression#Right . BundleFlag AST#member_expression#Right AST#expression#Right . GET_BUNDLE_INFO_WITH_DISABLE AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left bundleManager AST#expression#Right . getBundleInfoForSelfSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left bundleFlags AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static getBundleInfoSync(): bundleManager.BundleInfo {
const bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION |
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY |
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY |
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE |
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA |
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION |
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO |
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_ROUTER_MAP |
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_MENU |
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SKILL |
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_DISABLE;
return bundleManager.getBundleInfoForSelfSync(bundleFlags);
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/AppUtil.ets#L454-L467
|
2ed3d0f7f5b42384e9cc37ef714227ffe8b690de
|
gitee
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/common/components/Sounds/Cloud/CSoundDbAccessor/CSoundDbAccessor.ets
|
arkts
|
get
|
获取单例实例
|
public static get shared(): CSoundDbAccessor {
if (!CSoundDbAccessor.instance) {
CSoundDbAccessor.instance = new CSoundDbAccessor();
}
return CSoundDbAccessor.instance;
}
|
AST#method_declaration#Left public static get AST#ERROR#Left shared AST#ERROR#Right AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left CSoundDbAccessor AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left CSoundDbAccessor AST#expression#Right AST#unary_expression#Right AST#expression#Right . instance AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left CSoundDbAccessor AST#expression#Right . instance AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left CSoundDbAccessor AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#expression_statement#Left AST#expression#Left return AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CSoundDbAccessor AST#expression#Right . instance AST#member_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
public static get shared(): CSoundDbAccessor {
if (!CSoundDbAccessor.instance) {
CSoundDbAccessor.instance = new CSoundDbAccessor();
}
return CSoundDbAccessor.instance;
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/components/Sounds/Cloud/CSoundDbAccessor/CSoundDbAccessor.ets#L45-L50
|
ff2d8949ad5235d3f0697020b9c354bb1535c563
|
github
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/multiplefilesdownload/src/main/ets/view/FileDownloadItem.ets
|
arkts
|
FileDownloadItem
|
单个下载任务
|
@Component
export struct FileDownloadItem {
// 文件下载配置
@State downloadConfig: request.agent.Config = { action: request.agent.Action.DOWNLOAD, url: '' };
// 下载文件名
@State fileName: string = '';
// 下载任务状态
@State state: string = "";
// 监听是否全部开始下载
@Link @Watch('onDownLoadUpdated') isStartAllDownload: boolean;
// 下载任务对象初始化。用于下载失败和下载过程中暂停和重新启动下载。
private downloadTask: request.agent.Task | undefined;
// 待下载任务数量
@Link downloadCount: number;
// 下载失败任务数量
@Link downloadFailCount: number;
// 下载状态图标显隐控制。下载中显示图标,下载完成或者下载失败隐藏图标
@State isShow: boolean = false;
// 是否正在下载标志位
@State downloading: boolean = false;
// 下载文件大小。类型字符串
@State sFileSize: string = "-";
// 下载文件大小。类型数值
@State nFileSize: number = 0;
// 当前已下载数据量。类型字符串
@State sCurrentDownloadSize: string = "-";
// 当前已下载数据量。类型数值
@State nCurrentDownloadSize: number = 0;
// 下载文件数据
@ObjectLink fileDataInfo: downloadFilesData;
// 下载历史列表
@Link historyArray: downloadFilesData[];
// 下载列表
@Link downloadFileArray: downloadFilesData[];
// 下载任务完成回调
private completedCallback = (progress: request.agent.Progress) => {
// 下载状态设置为下载完成
this.state = "下载完成";
// 获取下载完成的时间
const downloadTime = new Date().getTime();
// 下载完成时更改对应数据源中的下载状态与下载时间
this.getFileStatusAndTime(1, downloadTime);
if (this.sFileSize === '未知大小') {
// 如果下载url文件的服务器采用chunk分块传输文件数据,是获取不到下载文件总大小的。对于这种下载文件大小无法获取到的情况,
// 本例中下载进度条展示效果是初始未下载时进度为0,总进度为1,当文件下载完成时下载进度值改成1,表示下载完成,同步更新显示到进度条上。
this.nCurrentDownloadSize = 1;
}
// 文件下载完成,待下载任务数量减1
if(this.downloadCount > 0) {
this.downloadCount--;
}
// 隐藏下载状态图标
this.isShow = false;
}
// 下载任务失败回调。任务下载失败一般是由于网络不好,底层重试也失败后进入该下载失败回调。如果网络没问题,建议重新下载再试。
private failedCallback = (progress: request.agent.Progress) => {
this.state = "下载失败";
// 下载失败时更改对应数据源中的下载状态
this.getFileStatusAndTime(2);
// 当所有任务下载失败时,"全部暂停"状态重置为"全部开始"。
this.downloadFailCount++;
if (this.downloadFailCount === this.downloadCount) {
this.isStartAllDownload = false;
}
if (this.downloadTask) {
// show用于获取下载任务相关信息。
request.agent.show(this.downloadTask.tid, (err: BusinessError, taskInfo: request.agent.TaskInfo) => {
if (err) {
logger.error(TAG, `Failed to show with error message: ${err.message}, error code: ${err.code}`);
return;
}
if (this.downloadTask) {
// 打印下载失败的任务id和任务状态
logger.error(TAG, `Failed to download with error downloadTask tid: ${this.downloadTask.tid} state: ${taskInfo.progress.state}`);
// 隐藏下载状态图标
this.isShow = false;
}
});
}
}
// 暂停任务回调
private pauseCallback = (progress: request.agent.Progress) => {
this.state = "已暂停";
// 切换下载状态图标
this.downloading = false;
}
// 重新启动任务回调。如果下载url文件的服务器不支持分片传输,则文件将重新下载。如果服务器支持分片传输,则会基于之前暂停时的下载进度继续下载。
private resumeCallback = (progress: request.agent.Progress) => {
// 切换下载状态图标
this.downloading = true;
}
// 下载进度更新回调
private progressCallback = (progress: request.agent.Progress) => {
// 性能知识点: 如果注册了progress下载进度更新监听,不建议在progress下载进度更新回调中加日志打印,减少不必要的性能损耗。
this.state = "下载中";
this.downloading = true;
// 显示下载状态图标
this.isShow = true;
if (this.downloadTask) {
// 第一次开始下载
if (this.sFileSize === '-') {
// 如果下载url文件的服务器采用chunk分块传输文件数据,是获取不到下载文件总大小的。传过来的值为-1,则在页面上显示'未知大小'
if (progress.sizes[0] === -1) {
this.sFileSize = '未知大小';
// 文件大小无法获取的情况下,进度条的值设置为0,总进度设置为1
this.nCurrentDownloadSize = 0;
this.nFileSize = 1;
} else {
// 能获取文件大小时,按实际下载数据量更新进度
this.nFileSize = progress.sizes[0];
this.sFileSize = (progress.sizes[0] / BYTE_CONVERSION).toFixed() + 'kb';
this.nCurrentDownloadSize = progress.processed;
}
} else if (this.sFileSize === '未知大小') {
// 非首次下载(暂停过下载任务后重新启动下载时),文件大小未知情况时,下载时进度不做更新
logger.info(TAG, `When the file size is unknown, the download progress will not be updated`);
} else {
// 非首次下载(暂停过下载任务后重新启动下载时),文件大小能获取到的情况,更新下载进度
this.nCurrentDownloadSize = progress.processed;
}
// 用于显示已下载文件数据大小
this.sCurrentDownloadSize = (progress.processed / BYTE_CONVERSION).toFixed() + 'kb';
}
}
aboutToAppear(): void {
// 初始化下载配置
this.downloadConfig = downloadConfig(this.fileDataInfo.url);
// 从下载链接获取文件名
this.fileName = getFileNameFromUrl(this.fileDataInfo.url);
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct FileDownloadItem AST#component_body#Left { // 文件下载配置 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right downloadConfig : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left request . agent . Config AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left action AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left request AST#expression#Right . agent AST#member_expression#Right AST#expression#Right . Action AST#member_expression#Right AST#expression#Right . DOWNLOAD AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left url AST#property_name#Right : AST#expression#Left '' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#property_declaration#Right // 下载文件名 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right fileName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '' AST#expression#Right ; AST#property_declaration#Right // 下载任务状态 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right state : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "" AST#expression#Right ; AST#property_declaration#Right // 监听是否全部开始下载 AST#property_declaration#Left AST#decorator#Left @ Link AST#decorator#Right AST#decorator#Left @ Watch ( AST#expression#Left 'onDownLoadUpdated' AST#expression#Right ) AST#decorator#Right isStartAllDownload : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right // 下载任务对象初始化。用于下载失败和下载过程中暂停和重新启动下载。 AST#property_declaration#Left private downloadTask : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#qualified_type#Left request . agent . Task AST#qualified_type#Right AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right ; AST#property_declaration#Right // 待下载任务数量 AST#property_declaration#Left AST#decorator#Left @ Link AST#decorator#Right downloadCount : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right // 下载失败任务数量 AST#property_declaration#Left AST#decorator#Left @ Link AST#decorator#Right downloadFailCount : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right // 下载状态图标显隐控制。下载中显示图标,下载完成或者下载失败隐藏图标 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right isShow : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#property_declaration#Right // 是否正在下载标志位 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right downloading : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#property_declaration#Right // 下载文件大小。类型字符串 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right sFileSize : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "-" AST#expression#Right ; AST#property_declaration#Right // 下载文件大小。类型数值 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right nFileSize : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right // 当前已下载数据量。类型字符串 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right sCurrentDownloadSize : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "-" AST#expression#Right ; AST#property_declaration#Right // 当前已下载数据量。类型数值 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right nCurrentDownloadSize : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right // 下载文件数据 AST#property_declaration#Left AST#decorator#Left @ ObjectLink AST#decorator#Right fileDataInfo : AST#type_annotation#Left AST#primary_type#Left downloadFilesData AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right // 下载历史列表 AST#property_declaration#Left AST#decorator#Left @ Link AST#decorator#Right historyArray : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left downloadFilesData [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right // 下载列表 AST#property_declaration#Left AST#decorator#Left @ Link AST#decorator#Right downloadFileArray : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left downloadFilesData [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right // 下载任务完成回调 AST#property_declaration#Left private completedCallback = AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left progress : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left request . agent . Progress AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { // 下载状态设置为下载完成 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . state AST#member_expression#Right = AST#expression#Left "下载完成" AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 获取下载完成的时间 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left downloadTime = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . getTime AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 下载完成时更改对应数据源中的下载状态与下载时间 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getFileStatusAndTime AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 1 AST#expression#Right , AST#expression#Left downloadTime AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . sFileSize AST#member_expression#Right AST#expression#Right === AST#expression#Left '未知大小' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { // 如果下载url文件的服务器采用chunk分块传输文件数据,是获取不到下载文件总大小的。对于这种下载文件大小无法获取到的情况, // 本例中下载进度条展示效果是初始未下载时进度为0,总进度为1,当文件下载完成时下载进度值改成1,表示下载完成,同步更新显示到进度条上。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . nCurrentDownloadSize AST#member_expression#Right = AST#expression#Left 1 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 文件下载完成,待下载任务数量减1 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloadCount AST#member_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#update_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloadCount AST#member_expression#Right AST#expression#Right -- AST#update_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 隐藏下载状态图标 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isShow AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right // 下载任务失败回调。任务下载失败一般是由于网络不好,底层重试也失败后进入该下载失败回调。如果网络没问题,建议重新下载再试。 AST#property_declaration#Right AST#property_declaration#Left private failedCallback = AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left progress : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left request . agent . Progress AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . state AST#member_expression#Right = AST#expression#Left "下载失败" AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 下载失败时更改对应数据源中的下载状态 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getFileStatusAndTime AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 2 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 当所有任务下载失败时,"全部暂停"状态重置为"全部开始"。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#update_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloadFailCount AST#member_expression#Right AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloadFailCount AST#member_expression#Right AST#expression#Right === AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . downloadCount AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isStartAllDownload AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloadTask AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { // show用于获取下载任务相关信息。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left request AST#expression#Right . agent AST#member_expression#Right AST#expression#Right . show AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloadTask AST#member_expression#Right AST#expression#Right . tid AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err : AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left taskInfo : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left request . agent . TaskInfo AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left err AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Failed to show with error message: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , error code: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloadTask AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { // 打印下载失败的任务id和任务状态 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Failed to download with error downloadTask tid: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloadTask AST#member_expression#Right AST#expression#Right . tid AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right state: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left taskInfo AST#expression#Right . progress AST#member_expression#Right AST#expression#Right . state AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 隐藏下载状态图标 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isShow AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right // 暂停任务回调 AST#property_declaration#Right AST#property_declaration#Left private pauseCallback = AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left progress : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left request . agent . Progress AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . state AST#member_expression#Right = AST#expression#Left "已暂停" AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 切换下载状态图标 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloading AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right // 重新启动任务回调。如果下载url文件的服务器不支持分片传输,则文件将重新下载。如果服务器支持分片传输,则会基于之前暂停时的下载进度继续下载。 AST#property_declaration#Right AST#property_declaration#Left private resumeCallback = AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left progress : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left request . agent . Progress AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { // 切换下载状态图标 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloading AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right // 下载进度更新回调 AST#property_declaration#Right AST#property_declaration#Left private progressCallback = AST#ERROR#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left progress : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left request . agent . Progress AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { // 性能知识点: 如果注册了progress下载进度更新监听,不建议在progress下载进度更新回调中加日志打印,减少不必要的性能损耗。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . state AST#member_expression#Right = AST#expression#Left "下载中" AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloading AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 显示下载状态图标 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isShow AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloadTask AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { // 第一次开始下载 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . sFileSize AST#member_expression#Right AST#expression#Right === AST#expression#Left '-' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { // 如果下载url文件的服务器采用chunk分块传输文件数据,是获取不到下载文件总大小的。传过来的值为-1,则在页面上显示'未知大小' AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left progress AST#expression#Right . sizes AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right === AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . sFileSize AST#member_expression#Right = AST#expression#Left '未知大小' AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 文件大小无法获取的情况下,进度条的值设置为0,总进度设置为1 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . nCurrentDownloadSize AST#member_expression#Right = AST#expression#Left 0 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . nFileSize AST#member_expression#Right = AST#expression#Left 1 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { // 能获取文件大小时,按实际下载数据量更新进度 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . nFileSize AST#member_expression#Right = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left progress AST#expression#Right . sizes AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . sFileSize AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left progress AST#expression#Right . sizes AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right / AST#expression#Left BYTE_CONVERSION AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . toFixed AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left 'kb' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . nCurrentDownloadSize AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left progress AST#expression#Right . processed AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . sFileSize AST#member_expression#Right AST#expression#Right === AST#expression#Left '未知大小' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { // 非首次下载(暂停过下载任务后重新启动下载时),文件大小未知情况时,下载时进度不做更新 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` When the file size is unknown, the download progress will not be updated ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { // 非首次下载(暂停过下载任务后重新启动下载时),文件大小能获取到的情况,更新下载进度 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . nCurrentDownloadSize AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left progress AST#expression#Right . processed AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#if_statement#Right AST#statement#Right // 用于显示已下载文件数据大小 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . sCurrentDownloadSize AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left progress AST#expression#Right . processed AST#member_expression#Right AST#expression#Right / AST#expression#Left BYTE_CONVERSION AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . toFixed AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left 'kb' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#ERROR#Left aboutToAppear AST#ERROR#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right : AST#ERROR#Right AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left void AST#expression#Left AST#object_literal#Left { // 初始化下载配置 AST#property_assignment#Left this AST#property_assignment#Right AST#object_literal#Right AST#expression#Right AST#unary_expression#Right AST#expression#Right . downloadConfig AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left downloadConfig AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . fileDataInfo AST#member_expression#Right AST#expression#Right . url AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#property_declaration#Right // 从下载链接获取文件名 AST#property_declaration#Left this AST#ERROR#Left . fileName AST#ERROR#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left getFileNameFromUrl AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . fileDataInfo AST#member_expression#Right AST#expression#Right . url AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@Component
export struct FileDownloadItem {
@State downloadConfig: request.agent.Config = { action: request.agent.Action.DOWNLOAD, url: '' };
@State fileName: string = '';
@State state: string = "";
@Link @Watch('onDownLoadUpdated') isStartAllDownload: boolean;
private downloadTask: request.agent.Task | undefined;
@Link downloadCount: number;
@Link downloadFailCount: number;
@State isShow: boolean = false;
@State downloading: boolean = false;
@State sFileSize: string = "-";
@State nFileSize: number = 0;
@State sCurrentDownloadSize: string = "-";
@State nCurrentDownloadSize: number = 0;
@ObjectLink fileDataInfo: downloadFilesData;
@Link historyArray: downloadFilesData[];
@Link downloadFileArray: downloadFilesData[];
private completedCallback = (progress: request.agent.Progress) => {
this.state = "下载完成";
const downloadTime = new Date().getTime();
this.getFileStatusAndTime(1, downloadTime);
if (this.sFileSize === '未知大小') {
this.nCurrentDownloadSize = 1;
}
if(this.downloadCount > 0) {
this.downloadCount--;
}
this.isShow = false;
}
private failedCallback = (progress: request.agent.Progress) => {
this.state = "下载失败";
this.getFileStatusAndTime(2);
this.downloadFailCount++;
if (this.downloadFailCount === this.downloadCount) {
this.isStartAllDownload = false;
}
if (this.downloadTask) {
request.agent.show(this.downloadTask.tid, (err: BusinessError, taskInfo: request.agent.TaskInfo) => {
if (err) {
logger.error(TAG, `Failed to show with error message: ${err.message}, error code: ${err.code}`);
return;
}
if (this.downloadTask) {
logger.error(TAG, `Failed to download with error downloadTask tid: ${this.downloadTask.tid} state: ${taskInfo.progress.state}`);
this.isShow = false;
}
});
}
}
private pauseCallback = (progress: request.agent.Progress) => {
this.state = "已暂停";
this.downloading = false;
}
private resumeCallback = (progress: request.agent.Progress) => {
this.downloading = true;
}
private progressCallback = (progress: request.agent.Progress) => {
this.state = "下载中";
this.downloading = true;
this.isShow = true;
if (this.downloadTask) {
if (this.sFileSize === '-') {
if (progress.sizes[0] === -1) {
this.sFileSize = '未知大小';
this.nCurrentDownloadSize = 0;
this.nFileSize = 1;
} else {
this.nFileSize = progress.sizes[0];
this.sFileSize = (progress.sizes[0] / BYTE_CONVERSION).toFixed() + 'kb';
this.nCurrentDownloadSize = progress.processed;
}
} else if (this.sFileSize === '未知大小') {
logger.info(TAG, `When the file size is unknown, the download progress will not be updated`);
} else {
this.nCurrentDownloadSize = progress.processed;
}
this.sCurrentDownloadSize = (progress.processed / BYTE_CONVERSION).toFixed() + 'kb';
}
}
aboutToAppear(): void {
this.downloadConfig = downloadConfig(this.fileDataInfo.url);
this.fileName = getFileNameFromUrl(this.fileDataInfo.url);
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/multiplefilesdownload/src/main/ets/view/FileDownloadItem.ets#L46-L183
|
6d137ffdb1d7081042ea0a2ad15ff254c205cedf
|
gitee
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_utils/src/main/ets/utils/FileUtil.ets
|
arkts
|
rmdirSync
|
删除整个目录,以同步方法。
@param path 目录的应用沙箱路径。
|
static rmdirSync(path: string) {
return fs.rmdirSync(path);
}
|
AST#method_declaration#Left static rmdirSync AST#parameter_list#Left ( AST#parameter#Left path : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fs AST#expression#Right . rmdirSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left path AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static rmdirSync(path: string) {
return fs.rmdirSync(path);
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/FileUtil.ets#L352-L354
|
5bce5ad286ba0fa0796a7c8b7c24d51b2b8384bb
|
gitee
|
harmonyos_samples/BestPracticeSnippets
|
490ea539a6d4427dd395f3dac3cf4887719f37af
|
ArkUI/Component_Reuse_Scenarios/entry/src/main/ets/segment/segment4.ets
|
arkts
|
[StartExclude Case4]
|
build() {
Column() {
}
}
|
AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right
|
build() {
Column() {
}
}
|
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/ArkUI/Component_Reuse_Scenarios/entry/src/main/ets/segment/segment4.ets#L70-L73
|
ff96a5ceff8edd29099207ac849990bdfad48ed1
|
gitee
|
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/DocsSample/NetWork_Kit/NetWorkKit_Datatransmission/Socket/entry/src/main/ets/connect/TlsServer.ets
|
arkts
|
selectServerCert
|
选择并加载服务器证书
|
selectServerCert() {
let documentPicker = new picker.DocumentViewPicker();
documentPicker.select().then((result) => {
if (result.length > 0) {
this.serverCert = result[0];
this.msgHistory += `Selected server certificate file: ${this.serverCert}\n`;
}
}).catch((err: Error) => {
this.msgHistory += `Failed to select server certificate file: ${err.message}\n`;
});
}
|
AST#method_declaration#Left selectServerCert AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left documentPicker = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left picker AST#expression#Right AST#new_expression#Right AST#expression#Right . DocumentViewPicker AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left documentPicker AST#expression#Right . select AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left result AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . length AST#member_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . serverCert AST#member_expression#Right = AST#expression#Left AST#subscript_expression#Left AST#expression#Left result AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . msgHistory AST#member_expression#Right += AST#expression#Left AST#template_literal#Left ` Selected server certificate file: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . serverCert AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right \n ` AST#template_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . catch AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err : AST#type_annotation#Left AST#primary_type#Left Error AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . msgHistory AST#member_expression#Right += AST#expression#Left AST#template_literal#Left ` Failed to select server certificate file: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right \n ` AST#template_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
selectServerCert() {
let documentPicker = new picker.DocumentViewPicker();
documentPicker.select().then((result) => {
if (result.length > 0) {
this.serverCert = result[0];
this.msgHistory += `Selected server certificate file: ${this.serverCert}\n`;
}
}).catch((err: Error) => {
this.msgHistory += `Failed to select server certificate file: ${err.message}\n`;
});
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/NetWork_Kit/NetWorkKit_Datatransmission/Socket/entry/src/main/ets/connect/TlsServer.ets#L200-L210
|
5697c329799fc96a77b4eff561622ef76a8d3dba
|
gitee
|
iichen-bycode/ArkTsWanandroid.git
|
ad128756a6c703d9a72cf7f6da128c27fc63bd00
|
entry/src/main/ets/http/api.ets
|
arkts
|
消息列表
@param date
@returns
|
export function getMessageList(page:number) {
return axiosClient.post<MessageWrapModel>({
url: `message/lg/readed_list/${page}/json`,
checkResultCode:true,
showLoading:true,
})
}
|
AST#export_declaration#Left export AST#function_declaration#Left function getMessageList AST#parameter_list#Left ( AST#parameter#Left page : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left axiosClient AST#expression#Right . post AST#member_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left MessageWrapModel AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left url AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` message/lg/readed_list/ AST#template_substitution#Left $ { AST#expression#Left page AST#expression#Right } AST#template_substitution#Right /json ` AST#template_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left checkResultCode AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left showLoading AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
|
export function getMessageList(page:number) {
return axiosClient.post<MessageWrapModel>({
url: `message/lg/readed_list/${page}/json`,
checkResultCode:true,
showLoading:true,
})
}
|
https://github.com/iichen-bycode/ArkTsWanandroid.git/blob/ad128756a6c703d9a72cf7f6da128c27fc63bd00/entry/src/main/ets/http/api.ets#L344-L350
|
35f2c49b7ff007897ec16537e97d81fff5bcb3c0
|
github
|
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/models/managers/plan/plancurve/PlanManager.ets
|
arkts
|
boxesComputed
|
/计算 指定piece的所有box
|
private static boxesComputed(piece: Piece, distances: DistanceFromBase[]): Box[] {
let boxes: Box[] = [];
//遍历每个distance
distances.forEach(distance => {
//某天的其中一个box
boxes.push(new Box(distance, piece.pieceNo));
});
return boxes;
}
|
AST#method_declaration#Left private static boxesComputed AST#parameter_list#Left ( AST#parameter#Left piece : AST#type_annotation#Left AST#primary_type#Left Piece AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left distances : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left DistanceFromBase [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Box [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left boxes : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Box [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right //遍历每个distance AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left distances AST#expression#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left distance => AST#block_statement#Left { //某天的其中一个box AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left boxes AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Box AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left distance AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left piece AST#expression#Right . pieceNo AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left boxes AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private static boxesComputed(piece: Piece, distances: DistanceFromBase[]): Box[] {
let boxes: Box[] = [];
distances.forEach(distance => {
boxes.push(new Box(distance, piece.pieceNo));
});
return boxes;
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/managers/plan/plancurve/PlanManager.ets#L469-L477
|
24ac45fb3ddcdae34dde3e71c137794576b1ac6b
|
github
|
openharmony-tpc/ohos_mpchart
|
4fb43a7137320ef2fee2634598f53d93975dfb4a
|
library/src/main/ets/components/components/YAxis.ets
|
arkts
|
isUseAutoScaleMaxRestriction
|
Returns true if autoscale restriction for axis max value is enabled
@Deprecated
|
public isUseAutoScaleMaxRestriction(): boolean {
return this.mUseAutoScaleRestrictionMax;
}
|
AST#method_declaration#Left public isUseAutoScaleMaxRestriction AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mUseAutoScaleRestrictionMax AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
public isUseAutoScaleMaxRestriction(): boolean {
return this.mUseAutoScaleRestrictionMax;
}
|
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/components/YAxis.ets#L479-L481
|
d71e89c2efe4a9c647ef3e7875caef4f2095e93d
|
gitee
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/SystemFeature/TaskManagement/TransientTask/entry/src/main/ets/pages/TitleBar.ets
|
arkts
|
TitleBar
|
Copyright (c) 2023 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
|
@Component
export struct TitleBar {
build() {
Row() {
Text($r("app.string.MainAbility_label"))
.fontSize(25)
.layoutWeight(1)
.fontColor(Color.White)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('8%')
.backgroundColor($r('app.color.background'))
.constraintSize({ minHeight: 50 })
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct TitleBar AST#component_body#Left { AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.MainAbility_label" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 25 AST#expression#Right ) AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . White AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Bold AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '8%' AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.background' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . constraintSize ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left minHeight AST#property_name#Right : AST#expression#Left 50 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@Component
export struct TitleBar {
build() {
Row() {
Text($r("app.string.MainAbility_label"))
.fontSize(25)
.layoutWeight(1)
.fontColor(Color.White)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('8%')
.backgroundColor($r('app.color.background'))
.constraintSize({ minHeight: 50 })
}
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/SystemFeature/TaskManagement/TransientTask/entry/src/main/ets/pages/TitleBar.ets#L16-L31
|
4f8fc6d06adaa331e3987bfe1aa4a88a0dd6924f
|
gitee
|
azhuge233/ASFShortcut-HN.git
|
d1669c920c56317611b5b0375aa5315c1b91211b
|
entry/src/main/ets/common/utils/ASF.ets
|
arkts
|
setAddress
|
设置全局服务器地址
|
setAddress(address: string) {
this.address = this.getFinalAddress(address);
Logger.debug(this.LOG_TAG, `当前ASF地址: ${this.address}`);
}
|
AST#method_declaration#Left setAddress AST#parameter_list#Left ( AST#parameter#Left address : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . address AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getFinalAddress AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left address AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . debug AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . LOG_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` 当前ASF地址: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . address AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
setAddress(address: string) {
this.address = this.getFinalAddress(address);
Logger.debug(this.LOG_TAG, `当前ASF地址: ${this.address}`);
}
|
https://github.com/azhuge233/ASFShortcut-HN.git/blob/d1669c920c56317611b5b0375aa5315c1b91211b/entry/src/main/ets/common/utils/ASF.ets#L18-L21
|
4ceaa93a20aa71ec0cc988a51028af5406bb5736
|
github
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_utils/src/main/ets/utils/TypeUtil.ets
|
arkts
|
isSharedArrayBuffer
|
检查是否为SharedArrayBuffer类型。
@param value
@returns
|
static isSharedArrayBuffer(value: Object): boolean {
return new util.types().isSharedArrayBuffer(value);
}
|
AST#method_declaration#Left static isSharedArrayBuffer AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left util AST#expression#Right AST#new_expression#Right AST#expression#Right . types AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . isSharedArrayBuffer AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left value AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static isSharedArrayBuffer(value: Object): boolean {
return new util.types().isSharedArrayBuffer(value);
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/TypeUtil.ets#L154-L156
|
8a8810bffb2c11d8608cafd56f90014d08f7858e
|
gitee
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/common/utils/strings/StringEncrypt.ets
|
arkts
|
decodeAfterRemoveSalt
|
先去盐再进行Base64解码
@param str 要处理的字符串
@returns 处理后的字符串或null
|
static decodeAfterRemoveSalt(str: string | null): string | null {
const withoutSalt = StringEncoder.removedSalt(str);
return withoutSalt ? StringEncoder.decodedFromBase64(withoutSalt) : null;
}
|
AST#method_declaration#Left static decodeAfterRemoveSalt AST#parameter_list#Left ( AST#parameter#Left str : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left withoutSalt = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left StringEncoder AST#expression#Right . removedSalt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left str AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#conditional_expression#Left AST#expression#Left withoutSalt AST#expression#Right ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left StringEncoder AST#expression#Right . decodedFromBase64 AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left withoutSalt AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right : AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static decodeAfterRemoveSalt(str: string | null): string | null {
const withoutSalt = StringEncoder.removedSalt(str);
return withoutSalt ? StringEncoder.decodedFromBase64(withoutSalt) : null;
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/utils/strings/StringEncrypt.ets#L61-L64
|
b648372e1ea0b0a6bbcead4a01445517ff34cc5e
|
github
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/palette/src/main/ets/pages/PaletteMainPage.ets
|
arkts
|
computeHSLGradient
|
TODO:知识点:根据 HSL 色相数组和色阶数生成按亮度渐变的 HEX 格式颜色
|
computeHSLGradient(hues: HslType[], levels: number): string[] {
if (levels <= 0) {
return [];
}
const colors: string[] = [];
for (let i = 0; i < levels; i++) {
hues.forEach(hsl => {
// 根据给定的渐变亮度起止点和所处色阶计算渐变亮度
const fadedL =
this.gradientStartPoint + Math.round(i * (this.gradientEndPoint - this.gradientStartPoint) / levels); // 逐渐变淡
// 将 HSL 转换为 HEX 格式
const hex = hslToHex(hsl.hue, hsl.saturation, fadedL);
// 添加到颜色数组
colors.push(hex);
});
}
return colors;
}
|
AST#method_declaration#Left computeHSLGradient AST#parameter_list#Left ( AST#parameter#Left hues : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left HslType [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left levels : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left levels AST#expression#Right <= AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left colors : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left levels AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hues AST#expression#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left hsl => AST#block_statement#Left { // 根据给定的渐变亮度起止点和所处色阶计算渐变亮度 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left fadedL = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . gradientStartPoint AST#member_expression#Right AST#expression#Right + AST#expression#Left Math AST#expression#Right AST#binary_expression#Right AST#expression#Right . round AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right * AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . gradientEndPoint AST#member_expression#Right AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . gradientStartPoint AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right / AST#expression#Left levels AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 逐渐变淡 // 将 HSL 转换为 HEX 格式 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left hex = AST#expression#Left AST#call_expression#Left AST#expression#Left hslToHex AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left hsl AST#expression#Right . hue AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left hsl AST#expression#Right . saturation AST#member_expression#Right AST#expression#Right , AST#expression#Left fadedL AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 添加到颜色数组 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left colors AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left hex AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left colors AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
computeHSLGradient(hues: HslType[], levels: number): string[] {
if (levels <= 0) {
return [];
}
const colors: string[] = [];
for (let i = 0; i < levels; i++) {
hues.forEach(hsl => {
const fadedL =
this.gradientStartPoint + Math.round(i * (this.gradientEndPoint - this.gradientStartPoint) / levels);
const hex = hslToHex(hsl.hue, hsl.saturation, fadedL);
colors.push(hex);
});
}
return colors;
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/palette/src/main/ets/pages/PaletteMainPage.ets#L371-L388
|
9ff59e69c66936e0be625f0f6f38afc42572f050
|
gitee
|
openharmony/interface_sdk-js
|
c349adc73e2ec1f61f6fca489b5af059e3ed6999
|
api/@ohos.arkui.advanced.SegmentButtonV2.d.ets
|
arkts
|
SegmentButtonV2Items
|
Defines the items of the segmented button.
@extends Array<SegmentButtonV2Item>
@syscap SystemCapability.ArkUI.ArkUI.Full
@crossplatform
@atomicservice
@since 18
|
@ObservedV2
export declare class SegmentButtonV2Items extends Array<SegmentButtonV2Item> {
/**
* The constructor of SegmentedButtonItems
*
* @param { SegmentButtonV2ItemOptions[] } items - the options array of the segmented button items
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 18
*/
constructor(items: SegmentButtonV2ItemOptions[]);
/**
* Is there an option in the segmented button options that sets both text and icon?
*
* @type { boolean }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 18
*/
get hasHybrid(): boolean;
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ ObservedV2 AST#decorator#Right export AST#ERROR#Left declare AST#ERROR#Right class SegmentButtonV2Items extends AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left SegmentButtonV2Item AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#class_body#Left { /**
* The constructor of SegmentedButtonItems
*
* @param { SegmentButtonV2ItemOptions[] } items - the options array of the segmented button items
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 18
*/ AST#ERROR#Left constructor AST#ERROR#Left AST#parameter_list#Left ( AST#parameter#Left items : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left SegmentButtonV2ItemOptions [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right ; /**
* Is there an option in the segmented button options that sets both text and icon?
*
* @type { boolean }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 18
*/ get h as Hybrid AST#ERROR#Right AST#parameter_list#Left ( ) AST#parameter_list#Right : boolean ; AST#ERROR#Right } AST#class_body#Right AST#decorated_export_declaration#Right
|
@ObservedV2
export declare class SegmentButtonV2Items extends Array<SegmentButtonV2Item> {
constructor(items: SegmentButtonV2ItemOptions[]);
get hasHybrid(): boolean;
}
|
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.arkui.advanced.SegmentButtonV2.d.ets#L325-L348
|
11d9912847f85e13c7ca156d8d41400cef0b337f
|
gitee
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/UI/CustomAnimationTab/customanimationtab/src/main/ets/view/CustomAnimationTabView.ets
|
arkts
|
tabBar
|
tabBar样式
|
@Builder
function tabBar($$: TabBarItemInterface) {
Column() {
Image($r('app.media.return_home_fill'))
.height(20)
.width(20)
.objectFit(ImageFit.Contain)
Text($$.title)
.fontSize($$.curIndex === $$.index ? $r('app.float.custom_animation_tab_list_select_font_size') :
$r('app.float.custom_animation_tab_list_unselect_font_size'))
.fontColor($r('app.color.custom_animation_tab_list_font_color'))
.fontWeight($$.curIndex === $$.index ? FontWeight.Bold : FontWeight.Medium)
.textAlign(TextAlign.Center)
}
}
|
AST#decorated_function_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right function tabBar AST#parameter_list#Left ( AST#parameter#Left $$ : AST#type_annotation#Left AST#primary_type#Left TabBarItemInterface AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.return_home_fill' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . height ( AST#expression#Left 20 AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left 20 AST#expression#Right ) AST#modifier_chain_expression#Left . objectFit ( AST#expression#Left AST#member_expression#Left AST#expression#Left ImageFit AST#expression#Right . Contain AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left $$ AST#expression#Right . title AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left $$ AST#expression#Right . curIndex AST#member_expression#Right AST#expression#Right === AST#expression#Left $$ AST#expression#Right AST#binary_expression#Right AST#expression#Right . index AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.custom_animation_tab_list_select_font_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.custom_animation_tab_list_unselect_font_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.custom_animation_tab_list_font_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left $$ AST#expression#Right . curIndex AST#member_expression#Right AST#expression#Right === AST#expression#Left $$ AST#expression#Right AST#binary_expression#Right AST#expression#Right . index AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Bold AST#member_expression#Right AST#expression#Right : AST#expression#Left FontWeight AST#expression#Right AST#conditional_expression#Right AST#expression#Right . Medium AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#decorated_function_declaration#Right
|
@Builder
function tabBar($$: TabBarItemInterface) {
Column() {
Image($r('app.media.return_home_fill'))
.height(20)
.width(20)
.objectFit(ImageFit.Contain)
Text($$.title)
.fontSize($$.curIndex === $$.index ? $r('app.float.custom_animation_tab_list_select_font_size') :
$r('app.float.custom_animation_tab_list_unselect_font_size'))
.fontColor($r('app.color.custom_animation_tab_list_font_color'))
.fontWeight($$.curIndex === $$.index ? FontWeight.Bold : FontWeight.Medium)
.textAlign(TextAlign.Center)
}
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/UI/CustomAnimationTab/customanimationtab/src/main/ets/view/CustomAnimationTabView.ets#L189-L203
|
24e8b90cf6a6ec323d8fe94337fe7f1820a87456
|
gitee
|
openharmony/codelabs
|
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
|
Ability/StageAbility/entry/src/main/ets/common/utils/Logger.ets
|
arkts
|
error
|
Outputs error-level logs.
@param args Indicates the log parameters.
|
error(...args: string[]) {
hilog.error(this.domain, this.prefix, this.format, args);
}
|
AST#method_declaration#Left error AST#parameter_list#Left ( AST#parameter#Left ... args : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . domain AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . prefix AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . format AST#member_expression#Right AST#expression#Right , AST#expression#Left args AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
error(...args: string[]) {
hilog.error(this.domain, this.prefix, this.format, args);
}
|
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Ability/StageAbility/entry/src/main/ets/common/utils/Logger.ets#L65-L67
|
033be9614d0efe91ffce8941249ab2c3030de436
|
gitee
|
harmonyos_samples/BestPracticeSnippets
|
490ea539a6d4427dd395f3dac3cf4887719f37af
|
ArkUI/PureTabsExt/entry/src/main/ets/view/SwitchTabComponent.ets
|
arkts
|
[EndExclude custom_switch_tab]
|
build() {
Column() {
Row() {
Button('Previous Tab')
.onClick(() => {
this.tabController.changeIndex((this.currentIndex + 3) % 4); // call tabController.changeIndex() to switch tab
})
// [StartExclude custom_switch_tab]
.width(158)
.height(40)
.margin({top:10, right: 10 })
.backgroundColor('rgba(0,0,0,0.05)')
.fontColor('#0A59F7')
.fontSize(16)
.fontWeight(FontWeight.Medium)
// [EndExclude custom_switch_tab]
Button('Next Tab')
.onClick(() => {
this.currentIndex = (this.currentIndex + 1) % 4; // change currentIndex to switch tab
})
// [StartExclude custom_switch_tab]
.width(158)
.height(40)
.margin({top:10, left: 10 })
.backgroundColor('rgba(0,0,0,0.05)')
.fontColor('#0A59F7')
.fontSize(16)
.fontWeight(FontWeight.Medium)
// [EndExclude custom_switch_tab]
}
Tabs({
controller: this.tabController,
index: $$this.currentIndex // use $$ for two-way data binding
}) {
// [StartExclude custom_switch_tab]
ForEach(this.tabItems, (item: string, index: number) => {
TabContent() {
Column() {
Text(`${item}`)
}
.width('100%')
.height('70%')
.justifyContent(FlexAlign.Center)
}.tabBar(item).align(Alignment.Top)
})
// [EndExclude custom_switch_tab]
}
}
}
|
AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#expression#Left 'Previous Tab' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . tabController AST#member_expression#Right AST#expression#Right . changeIndex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentIndex AST#member_expression#Right AST#expression#Right + AST#expression#Left 3 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right % AST#expression#Left 4 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // call tabController.changeIndex() to switch tab } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) // [StartExclude custom_switch_tab] AST#modifier_chain_expression#Left . width ( AST#expression#Left 158 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 40 AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 10 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 10 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 'rgba(0,0,0,0.05)' AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#0A59F7' AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Medium AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // [EndExclude custom_switch_tab] AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#expression#Left 'Next Tab' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentIndex AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentIndex AST#member_expression#Right AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right % AST#expression#Left 4 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // change currentIndex to switch tab } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) // [StartExclude custom_switch_tab] AST#modifier_chain_expression#Left . width ( AST#expression#Left 158 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 40 AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 10 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 10 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 'rgba(0,0,0,0.05)' AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#0A59F7' AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Medium AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // [EndExclude custom_switch_tab] } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Tabs ( AST#component_parameters#Left { AST#component_parameter#Left controller : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . tabController AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left index : AST#expression#Left AST#member_expression#Left AST#expression#Left $$this AST#expression#Right . currentIndex AST#member_expression#Right AST#expression#Right AST#component_parameter#Right // use $$ for two-way data binding } AST#component_parameters#Right ) AST#container_content_body#Left { // [StartExclude custom_switch_tab] AST#ui_control_flow#Left AST#for_each_statement#Left ForEach ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . tabItems AST#member_expression#Right AST#expression#Right , AST#ui_builder_arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#ui_arrow_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left TabContent ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left item AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '70%' AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . tabBar ( AST#expression#Left item AST#expression#Right ) AST#modifier_chain_expression#Left . align ( AST#expression#Left AST#member_expression#Left AST#expression#Left Alignment AST#expression#Right . Top AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_arrow_function_body#Right AST#ui_builder_arrow_function#Right ) AST#for_each_statement#Right AST#ui_control_flow#Right // [EndExclude custom_switch_tab] } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right
|
build() {
Column() {
Row() {
Button('Previous Tab')
.onClick(() => {
this.tabController.changeIndex((this.currentIndex + 3) % 4);
})
.width(158)
.height(40)
.margin({top:10, right: 10 })
.backgroundColor('rgba(0,0,0,0.05)')
.fontColor('#0A59F7')
.fontSize(16)
.fontWeight(FontWeight.Medium)
Button('Next Tab')
.onClick(() => {
this.currentIndex = (this.currentIndex + 1) % 4;
})
.width(158)
.height(40)
.margin({top:10, left: 10 })
.backgroundColor('rgba(0,0,0,0.05)')
.fontColor('#0A59F7')
.fontSize(16)
.fontWeight(FontWeight.Medium)
}
Tabs({
controller: this.tabController,
index: $$this.currentIndex
}) {
ForEach(this.tabItems, (item: string, index: number) => {
TabContent() {
Column() {
Text(`${item}`)
}
.width('100%')
.height('70%')
.justifyContent(FlexAlign.Center)
}.tabBar(item).align(Alignment.Top)
})
}
}
}
|
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/ArkUI/PureTabsExt/entry/src/main/ets/view/SwitchTabComponent.ets#L64-L115
|
5df1e03015f3cb9859cc848b65348efa33b12b93
|
gitee
|
|
chongzi/Lucky-ArkTs.git
|
84fc104d4a68def780a483e2543ebf9f53e793fd
|
entry/src/main/ets/mock/InterviewArticleMockData.ets
|
arkts
|
getArticlesByCategory
|
根据分类获取文章
|
static getArticlesByCategory(category: InterviewArticleCategory): InterviewArticleModel[] {
return InterviewArticleMockData.articles.filter(article => article.category === category);
}
|
AST#method_declaration#Left static getArticlesByCategory AST#parameter_list#Left ( AST#parameter#Left category : AST#type_annotation#Left AST#primary_type#Left InterviewArticleCategory AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left InterviewArticleModel [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left InterviewArticleMockData AST#expression#Right . articles AST#member_expression#Right AST#expression#Right . filter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left article => AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left article AST#expression#Right . category AST#member_expression#Right AST#expression#Right === AST#expression#Left category AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static getArticlesByCategory(category: InterviewArticleCategory): InterviewArticleModel[] {
return InterviewArticleMockData.articles.filter(article => article.category === category);
}
|
https://github.com/chongzi/Lucky-ArkTs.git/blob/84fc104d4a68def780a483e2543ebf9f53e793fd/entry/src/main/ets/mock/InterviewArticleMockData.ets#L986-L988
|
65290f0bf3d3bf89846cccab809ff40da94b556d
|
github
|
jxdiaodeyi/YX_Sports.git
|
af5346bd3d5003c33c306ff77b4b5e9184219893
|
YX_Sports/oh_modules/.ohpm/@pura+spinkit@1.0.5/oh_modules/@pura/spinkit/src/main/ets/components/SpinS.ets
|
arkts
|
SpinS
|
TODO SpinKit动画组件
author: 桃花镇童长老
since: 2024/05/01
仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fspinkit
github: https://github.com/787107497
gitee: https://gitee.com/tongyuyan/spinkit
QQ交流群: 569512366
|
@ComponentV2
export struct SpinS {
@Require @Param spinSize: number = 36;
@Require @Param spinColor: ResourceColor;
@Local round1: number = this.spinSize * 0.2
@Local scale1: number = 1;
@Local scale2: number = 0.3;
@Local scale3: number = 0.4;
@Local scale4: number = 0.5;
@Local scale5: number = 0.6;
@Local scale6: number = 0.7;
@Local scale7: number = 0.8;
@Local scale8: number = 0.9;
@Local angle1: number = 0;
aboutToAppear(): void {
this.round1 = this.spinSize * 0.2
}
build() {
Stack() {
Column() {
Canvas()
.roundStyle()
.scale({ x: this.scale1, y: this.scale1 })
}
.frame1Style()
.rotate({ angle: 0 })
Column() {
Canvas()
.roundStyle()
.scale({ x: this.scale2, y: this.scale2 })
}
.frame1Style()
.rotate({ angle: 45 })
Column() {
Canvas()
.roundStyle()
.scale({ x: this.scale3, y: this.scale3 })
}
.frame1Style()
.rotate({ angle: 90 })
Column() {
Canvas()
.roundStyle()
.scale({ x: this.scale4, y: this.scale4 })
}
.frame1Style()
.rotate({ angle: 135 })
Column() {
Canvas()
.roundStyle()
.scale({ x: this.scale5, y: this.scale5 })
}
.frame1Style()
.rotate({ angle: 180 })
Column() {
Canvas()
.roundStyle()
.scale({ x: this.scale6, y: this.scale6 })
}
.frame1Style()
.rotate({ angle: 225 })
Column() {
Canvas()
.roundStyle()
.scale({ x: this.scale7, y: this.scale7 })
}
.frame1Style()
.rotate({ angle: 270 })
Column() {
Canvas()
.roundStyle()
.scale({ x: this.scale8, y: this.scale8 })
}
.frame1Style()
.rotate({ angle: 315 })
}
.renderFit(RenderFit.CENTER)
.width(this.spinSize)
.height(this.spinSize)
.rotate({ angle: this.angle1 })
.onAppear(() => {
this.getUIContext().keyframeAnimateTo({ iterations: -1, delay: 0 }, [{
duration: 1200,
curve: Curve.Linear,
event: () => {
this.angle1 = 360
}
}]);
})
}
@Styles
roundStyle(){
.width(this.round1)
.height(this.round1)
.borderRadius(this.round1)
.backgroundColor(this.spinColor)
.shadow(ShadowStyle.OUTER_DEFAULT_XS)
}
@Styles
frame1Style(){
.height('100%')
.width(this.round1)
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ ComponentV2 AST#decorator#Right export struct SpinS AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ Require AST#decorator#Right AST#decorator#Left @ Param AST#decorator#Right spinSize : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 36 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Require AST#decorator#Right AST#decorator#Left @ Param AST#decorator#Right spinColor : AST#type_annotation#Left AST#primary_type#Left ResourceColor AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Local AST#decorator#Right round1 : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . spinSize AST#member_expression#Right AST#expression#Right * AST#expression#Left 0.2 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Local AST#decorator#Right scale1 : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 1 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Local AST#decorator#Right scale2 : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0.3 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Local AST#decorator#Right scale3 : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0.4 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Local AST#decorator#Right scale4 : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0.5 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Local AST#decorator#Right scale5 : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0.6 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Local AST#decorator#Right scale6 : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0.7 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Local AST#decorator#Right scale7 : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0.8 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Local AST#decorator#Right scale8 : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0.9 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Local AST#decorator#Right angle1 : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right AST#method_declaration#Left aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . round1 AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . spinSize AST#member_expression#Right AST#expression#Right * AST#expression#Left 0.2 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Stack ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Canvas ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . roundStyle ( ) AST#modifier_chain_expression#Left . scale ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scale1 AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scale1 AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . frame1Style ( ) AST#modifier_chain_expression#Left . rotate ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left angle AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Canvas ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . roundStyle ( ) AST#modifier_chain_expression#Left . scale ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scale2 AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scale2 AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . frame1Style ( ) AST#modifier_chain_expression#Left . rotate ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left angle AST#property_name#Right : AST#expression#Left 45 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Canvas ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . roundStyle ( ) AST#modifier_chain_expression#Left . scale ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scale3 AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scale3 AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . frame1Style ( ) AST#modifier_chain_expression#Left . rotate ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left angle AST#property_name#Right : AST#expression#Left 90 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Canvas ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . roundStyle ( ) AST#modifier_chain_expression#Left . scale ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scale4 AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scale4 AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . frame1Style ( ) AST#modifier_chain_expression#Left . rotate ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left angle AST#property_name#Right : AST#expression#Left 135 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Canvas ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . roundStyle ( ) AST#modifier_chain_expression#Left . scale ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scale5 AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scale5 AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . frame1Style ( ) AST#modifier_chain_expression#Left . rotate ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left angle AST#property_name#Right : AST#expression#Left 180 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Canvas ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . roundStyle ( ) AST#modifier_chain_expression#Left . scale ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scale6 AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scale6 AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . frame1Style ( ) AST#modifier_chain_expression#Left . rotate ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left angle AST#property_name#Right : AST#expression#Left 225 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Canvas ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . roundStyle ( ) AST#modifier_chain_expression#Left . scale ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scale7 AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scale7 AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . frame1Style ( ) AST#modifier_chain_expression#Left . rotate ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left angle AST#property_name#Right : AST#expression#Left 270 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Canvas ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . roundStyle ( ) AST#modifier_chain_expression#Left . scale ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scale8 AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scale8 AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . frame1Style ( ) AST#modifier_chain_expression#Left . rotate ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left angle AST#property_name#Right : AST#expression#Left 315 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . renderFit ( AST#expression#Left AST#member_expression#Left AST#expression#Left RenderFit AST#expression#Right . CENTER AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . spinSize AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . spinSize AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . rotate ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left angle AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . angle1 AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onAppear ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getUIContext AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . keyframeAnimateTo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left iterations AST#property_name#Right : AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left delay AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left duration AST#property_name#Right : AST#expression#Left 1200 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left curve AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Curve AST#expression#Right . Linear AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left event AST#property_name#Right : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . angle1 AST#member_expression#Right = AST#expression#Left 360 AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right AST#method_declaration#Left AST#decorator#Left @ Styles AST#decorator#Right roundStyle AST#parameter_list#Left ( ) AST#parameter_list#Right AST#extend_function_body#Left { AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . round1 AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . round1 AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . round1 AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . spinColor AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . shadow ( AST#expression#Left AST#member_expression#Left AST#expression#Left ShadowStyle AST#expression#Right . OUTER_DEFAULT_XS AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right } AST#extend_function_body#Right AST#method_declaration#Right AST#method_declaration#Left AST#decorator#Left @ Styles AST#decorator#Right frame1Style AST#parameter_list#Left ( ) AST#parameter_list#Right AST#extend_function_body#Left { AST#modifier_chain_expression#Left . height ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . round1 AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right } AST#extend_function_body#Right AST#method_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@ComponentV2
export struct SpinS {
@Require @Param spinSize: number = 36;
@Require @Param spinColor: ResourceColor;
@Local round1: number = this.spinSize * 0.2
@Local scale1: number = 1;
@Local scale2: number = 0.3;
@Local scale3: number = 0.4;
@Local scale4: number = 0.5;
@Local scale5: number = 0.6;
@Local scale6: number = 0.7;
@Local scale7: number = 0.8;
@Local scale8: number = 0.9;
@Local angle1: number = 0;
aboutToAppear(): void {
this.round1 = this.spinSize * 0.2
}
build() {
Stack() {
Column() {
Canvas()
.roundStyle()
.scale({ x: this.scale1, y: this.scale1 })
}
.frame1Style()
.rotate({ angle: 0 })
Column() {
Canvas()
.roundStyle()
.scale({ x: this.scale2, y: this.scale2 })
}
.frame1Style()
.rotate({ angle: 45 })
Column() {
Canvas()
.roundStyle()
.scale({ x: this.scale3, y: this.scale3 })
}
.frame1Style()
.rotate({ angle: 90 })
Column() {
Canvas()
.roundStyle()
.scale({ x: this.scale4, y: this.scale4 })
}
.frame1Style()
.rotate({ angle: 135 })
Column() {
Canvas()
.roundStyle()
.scale({ x: this.scale5, y: this.scale5 })
}
.frame1Style()
.rotate({ angle: 180 })
Column() {
Canvas()
.roundStyle()
.scale({ x: this.scale6, y: this.scale6 })
}
.frame1Style()
.rotate({ angle: 225 })
Column() {
Canvas()
.roundStyle()
.scale({ x: this.scale7, y: this.scale7 })
}
.frame1Style()
.rotate({ angle: 270 })
Column() {
Canvas()
.roundStyle()
.scale({ x: this.scale8, y: this.scale8 })
}
.frame1Style()
.rotate({ angle: 315 })
}
.renderFit(RenderFit.CENTER)
.width(this.spinSize)
.height(this.spinSize)
.rotate({ angle: this.angle1 })
.onAppear(() => {
this.getUIContext().keyframeAnimateTo({ iterations: -1, delay: 0 }, [{
duration: 1200,
curve: Curve.Linear,
event: () => {
this.angle1 = 360
}
}]);
})
}
@Styles
roundStyle(){
.width(this.round1)
.height(this.round1)
.borderRadius(this.round1)
.backgroundColor(this.spinColor)
.shadow(ShadowStyle.OUTER_DEFAULT_XS)
}
@Styles
frame1Style(){
.height('100%')
.width(this.round1)
}
}
|
https://github.com/jxdiaodeyi/YX_Sports.git/blob/af5346bd3d5003c33c306ff77b4b5e9184219893/YX_Sports/oh_modules/.ohpm/@pura+spinkit@1.0.5/oh_modules/@pura/spinkit/src/main/ets/components/SpinS.ets#L27-L142
|
54c8e0277e56d0c235e5336400ecbbe98e8d54e5
|
github
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/containernestedslide/src/main/ets/mock/NewsDetailData.ets
|
arkts
|
模拟评论数据
|
export function mockData(): NewsCommentData {
const commentList: NewsCommentData = new NewsCommentData();
commentList.pushData(new NewsCommentModel("1", $r("app.media.news_image_1"), '你若安好便是晴天', '', '', '国足加油!国足必胜!', new Date('2024-11-01 23:00:00'),new NewsCommentData()))
commentList.pushData(new NewsCommentModel("2", $r("app.media.news_image_2"), '天要下雨娘要嫁人', '', '', '来点信心,加油加油~', new Date('2024-11-01 23:00:00'), new NewsCommentData()))
commentList.pushData(new NewsCommentModel("3", $r("app.media.news_image_3"), '太阳打北边出来了', '', '', '下一场什么时候,有直播吗', new Date('2024-11-01 23:00:00'), new NewsCommentData()))
commentList.pushData(new NewsCommentModel("4", $r("app.media.news_image_4"), '西红柿炒鸡蛋蛋卷(特辣)', '', '', '教练组的战术调整值得肯定,尤其是在中场控制方面有所改善。', new Date('2024-11-01 23:00:00'), new NewsCommentData()))
commentList.pushData(new NewsCommentModel("5", $r("app.media.news_image_6"), '东边有个塔玛,西边有个喇嘛', '', '', '期待他们在未来的比赛中继续进步!', new Date('2024-11-01 23:00:00'),new NewsCommentData()))
commentList.pushData(new NewsCommentModel("7", $r("app.media.news_image_7"), '天青色等烟雨而我在等你', '', '', '希望他们能在接下来的比赛中继续发挥,成为球队的中坚力量。',new Date('2024-11-01 23:00:00'), new NewsCommentData()))
commentList.pushData(new NewsCommentModel("8", $r("app.media.news_image_8"), '大事不妙了', '', '', '与世界强队的差距依然显著,继续努力吧。', new Date('2024-11-01 23:00:00'), new NewsCommentData()))
commentList.pushData(new NewsCommentModel("9", $r("app.media.news_image_6"), '小猫带耳机', '', '', '国足必胜,加油加油。', new Date('2024-11-01 23:00:00'), new NewsCommentData()))
return commentList;
}
|
AST#export_declaration#Left export AST#function_declaration#Left function mockData AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left NewsCommentData AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left commentList : AST#type_annotation#Left AST#primary_type#Left NewsCommentData AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left NewsCommentData AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left commentList AST#expression#Right . pushData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left NewsCommentModel AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "1" AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.media.news_image_1" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left '你若安好便是晴天' AST#expression#Right , AST#expression#Left '' AST#expression#Right , AST#expression#Left '' AST#expression#Right , AST#expression#Left '国足加油!国足必胜!' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '2024-11-01 23:00:00' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left NewsCommentData AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left commentList AST#expression#Right . pushData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left NewsCommentModel AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "2" AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.media.news_image_2" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left '天要下雨娘要嫁人' AST#expression#Right , AST#expression#Left '' AST#expression#Right , AST#expression#Left '' AST#expression#Right , AST#expression#Left '来点信心,加油加油~' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '2024-11-01 23:00:00' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left NewsCommentData AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left commentList AST#expression#Right . pushData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left NewsCommentModel AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "3" AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.media.news_image_3" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left '太阳打北边出来了' AST#expression#Right , AST#expression#Left '' AST#expression#Right , AST#expression#Left '' AST#expression#Right , AST#expression#Left '下一场什么时候,有直播吗' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '2024-11-01 23:00:00' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left NewsCommentData AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left commentList AST#expression#Right . pushData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left NewsCommentModel AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "4" AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.media.news_image_4" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left '西红柿炒鸡蛋蛋卷(特辣)' AST#expression#Right , AST#expression#Left '' AST#expression#Right , AST#expression#Left '' AST#expression#Right , AST#expression#Left '教练组的战术调整值得肯定,尤其是在中场控制方面有所改善。' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '2024-11-01 23:00:00' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left NewsCommentData AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left commentList AST#expression#Right . pushData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left NewsCommentModel AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "5" AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.media.news_image_6" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left '东边有个塔玛,西边有个喇嘛' AST#expression#Right , AST#expression#Left '' AST#expression#Right , AST#expression#Left '' AST#expression#Right , AST#expression#Left '期待他们在未来的比赛中继续进步!' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '2024-11-01 23:00:00' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left NewsCommentData AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left commentList AST#expression#Right . pushData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left NewsCommentModel AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "7" AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.media.news_image_7" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left '天青色等烟雨而我在等你' AST#expression#Right , AST#expression#Left '' AST#expression#Right , AST#expression#Left '' AST#expression#Right , AST#expression#Left '希望他们能在接下来的比赛中继续发挥,成为球队的中坚力量。' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '2024-11-01 23:00:00' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left NewsCommentData AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left commentList AST#expression#Right . pushData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left NewsCommentModel AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "8" AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.media.news_image_8" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left '大事不妙了' AST#expression#Right , AST#expression#Left '' AST#expression#Right , AST#expression#Left '' AST#expression#Right , AST#expression#Left '与世界强队的差距依然显著,继续努力吧。' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '2024-11-01 23:00:00' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left NewsCommentData AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left commentList AST#expression#Right . pushData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left NewsCommentModel AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "9" AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.media.news_image_6" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left '小猫带耳机' AST#expression#Right , AST#expression#Left '' AST#expression#Right , AST#expression#Left '' AST#expression#Right , AST#expression#Left '国足必胜,加油加油。' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '2024-11-01 23:00:00' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left NewsCommentData AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left commentList AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
|
export function mockData(): NewsCommentData {
const commentList: NewsCommentData = new NewsCommentData();
commentList.pushData(new NewsCommentModel("1", $r("app.media.news_image_1"), '你若安好便是晴天', '', '', '国足加油!国足必胜!', new Date('2024-11-01 23:00:00'),new NewsCommentData()))
commentList.pushData(new NewsCommentModel("2", $r("app.media.news_image_2"), '天要下雨娘要嫁人', '', '', '来点信心,加油加油~', new Date('2024-11-01 23:00:00'), new NewsCommentData()))
commentList.pushData(new NewsCommentModel("3", $r("app.media.news_image_3"), '太阳打北边出来了', '', '', '下一场什么时候,有直播吗', new Date('2024-11-01 23:00:00'), new NewsCommentData()))
commentList.pushData(new NewsCommentModel("4", $r("app.media.news_image_4"), '西红柿炒鸡蛋蛋卷(特辣)', '', '', '教练组的战术调整值得肯定,尤其是在中场控制方面有所改善。', new Date('2024-11-01 23:00:00'), new NewsCommentData()))
commentList.pushData(new NewsCommentModel("5", $r("app.media.news_image_6"), '东边有个塔玛,西边有个喇嘛', '', '', '期待他们在未来的比赛中继续进步!', new Date('2024-11-01 23:00:00'),new NewsCommentData()))
commentList.pushData(new NewsCommentModel("7", $r("app.media.news_image_7"), '天青色等烟雨而我在等你', '', '', '希望他们能在接下来的比赛中继续发挥,成为球队的中坚力量。',new Date('2024-11-01 23:00:00'), new NewsCommentData()))
commentList.pushData(new NewsCommentModel("8", $r("app.media.news_image_8"), '大事不妙了', '', '', '与世界强队的差距依然显著,继续努力吧。', new Date('2024-11-01 23:00:00'), new NewsCommentData()))
commentList.pushData(new NewsCommentModel("9", $r("app.media.news_image_6"), '小猫带耳机', '', '', '国足必胜,加油加油。', new Date('2024-11-01 23:00:00'), new NewsCommentData()))
return commentList;
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/containernestedslide/src/main/ets/mock/NewsDetailData.ets#L19-L30
|
adf58f6fe2b51bd70f192103ec25720baae71c91
|
gitee
|
|
harmonyos_samples/BestPracticeSnippets
|
490ea539a6d4427dd395f3dac3cf4887719f37af
|
SegmentedPhotograph/entry/src/main/ets/common/utils/DateTimeUtil.ets
|
arkts
|
getVideoTime
|
Recording Time Timer
@param millisecond-Data value
|
getVideoTime(millisecond: number): string {
let millisecond2minute = 60000;
let millisecond2second = 1000;
let minute = Math.floor(millisecond / millisecond2minute);
let second = Math.floor((millisecond - minute * millisecond2minute) / millisecond2second);
return `${this.fill(minute)} : ${this.fill(second)}`;
}
|
AST#method_declaration#Left getVideoTime AST#parameter_list#Left ( AST#parameter#Left millisecond : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left millisecond2minute = AST#expression#Left 60000 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left millisecond2second = AST#expression#Left 1000 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left minute = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . floor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left millisecond AST#expression#Right / AST#expression#Left millisecond2minute AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left second = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . floor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left millisecond AST#expression#Right - AST#expression#Left AST#binary_expression#Left AST#expression#Left minute AST#expression#Right * AST#expression#Left millisecond2minute AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right / AST#expression#Left millisecond2second AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . fill AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left minute AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right : AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . fill AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left second AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
getVideoTime(millisecond: number): string {
let millisecond2minute = 60000;
let millisecond2second = 1000;
let minute = Math.floor(millisecond / millisecond2minute);
let second = Math.floor((millisecond - minute * millisecond2minute) / millisecond2second);
return `${this.fill(minute)} : ${this.fill(second)}`;
}
|
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/SegmentedPhotograph/entry/src/main/ets/common/utils/DateTimeUtil.ets#L49-L55
|
3291f636db3af1b860a38b744936450008298716
|
gitee
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/services/data/ContactService.ets
|
arkts
|
initializeMappingService
|
初始化农历公历映射服务
|
private async initializeMappingService(): Promise<void> {
try {
await this.mappingService.initialize();
hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP,
'LunarSolarMappingService initialized successfully in ContactService');
} catch (error) {
hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP,
`Failed to initialize mapping service: ${error}`);
}
}
|
AST#method_declaration#Left private async initializeMappingService AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . mappingService AST#member_expression#Right AST#expression#Right . initialize AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left 'LunarSolarMappingService initialized successfully in ContactService' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Failed to initialize mapping service: AST#template_substitution#Left $ { AST#expression#Left error AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private async initializeMappingService(): Promise<void> {
try {
await this.mappingService.initialize();
hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP,
'LunarSolarMappingService initialized successfully in ContactService');
} catch (error) {
hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP,
`Failed to initialize mapping service: ${error}`);
}
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/data/ContactService.ets#L94-L103
|
439d6a6c90d59799ef79b6d79019884e4e4dd561
|
github
|
pangpang20/wavecast.git
|
d3da8a0009eb44a576a2b9d9d9fe6195a2577e32
|
entry/src/main/ets/entryability/EntryAbility.ets
|
arkts
|
requestPermissions
|
请求必要权限
|
private async requestPermissions(): Promise<void> {
try {
const atManager = abilityAccessCtrl.createAtManager();
const bundleInfo = await bundleManager.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION);
const tokenId = bundleInfo.appInfo.accessTokenId;
// 必要权限:联网
const requiredPermissions: Permissions[] = [
'ohos.permission.INTERNET',
'ohos.permission.GET_NETWORK_INFO'
];
// 可选权限:后台运行(用于后台播放)
const optionalPermissions: Permissions[] = [
'ohos.permission.KEEP_BACKGROUND_RUNNING'
];
// 检查并请求必要权限
const permissionsToRequest: Permissions[] = [];
for (const permission of requiredPermissions) {
const grantStatus = await atManager.checkAccessToken(tokenId, permission);
if (grantStatus !== abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) {
permissionsToRequest.push(permission);
}
}
// 检查可选权限
for (const permission of optionalPermissions) {
const grantStatus = await atManager.checkAccessToken(tokenId, permission);
if (grantStatus !== abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) {
permissionsToRequest.push(permission);
}
}
// 如果有需要请求的权限
if (permissionsToRequest.length > 0) {
console.info('Requesting permissions:', permissionsToRequest);
try {
await atManager.requestPermissionsFromUser(this.context, permissionsToRequest);
console.info('Permissions granted successfully');
this.permissionsGranted = true;
} catch (err) {
console.error('User denied permissions:', err);
// 用户拒绝了权限,但应用仍然可以启动(功能可能受限)
this.permissionsGranted = false;
}
} else {
console.info('All permissions already granted');
this.permissionsGranted = true;
}
} catch (error) {
console.error('Failed to request permissions:', error);
// ArkTS 不允许抛出任意类型,这里直接返回,让应用继续启动
this.permissionsGranted = false;
}
}
|
AST#method_declaration#Left private async requestPermissions AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left atManager = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left abilityAccessCtrl AST#expression#Right . createAtManager AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left bundleInfo = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left bundleManager AST#expression#Right AST#await_expression#Right AST#expression#Right . getBundleInfoForSelf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left bundleManager AST#expression#Right . BundleFlag AST#member_expression#Right AST#expression#Right . GET_BUNDLE_INFO_WITH_APPLICATION AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left tokenId = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left bundleInfo AST#expression#Right . appInfo AST#member_expression#Right AST#expression#Right . accessTokenId AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 必要权限:联网 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left requiredPermissions : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Permissions [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left 'ohos.permission.INTERNET' AST#expression#Right , AST#expression#Left 'ohos.permission.GET_NETWORK_INFO' AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 可选权限:后台运行(用于后台播放) AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left optionalPermissions : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Permissions [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left 'ohos.permission.KEEP_BACKGROUND_RUNNING' AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 检查并请求必要权限 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left permissionsToRequest : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Permissions [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( const permission of AST#expression#Left requiredPermissions AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left grantStatus = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left atManager AST#expression#Right AST#await_expression#Right AST#expression#Right . checkAccessToken AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left tokenId AST#expression#Right , AST#expression#Left permission AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left grantStatus AST#expression#Right !== AST#expression#Left abilityAccessCtrl AST#expression#Right AST#binary_expression#Right AST#expression#Right . GrantStatus AST#member_expression#Right AST#expression#Right . PERMISSION_GRANTED AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left permissionsToRequest AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left permission AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right // 检查可选权限 AST#statement#Left AST#for_statement#Left for ( const permission of AST#expression#Left optionalPermissions AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left grantStatus = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left atManager AST#expression#Right AST#await_expression#Right AST#expression#Right . checkAccessToken AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left tokenId AST#expression#Right , AST#expression#Left permission AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left grantStatus AST#expression#Right !== AST#expression#Left abilityAccessCtrl AST#expression#Right AST#binary_expression#Right AST#expression#Right . GrantStatus AST#member_expression#Right AST#expression#Right . PERMISSION_GRANTED AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left permissionsToRequest AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left permission AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right // 如果有需要请求的权限 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left permissionsToRequest AST#expression#Right . length AST#member_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Requesting permissions:' AST#expression#Right , AST#expression#Left permissionsToRequest AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left atManager AST#expression#Right AST#await_expression#Right AST#expression#Right . requestPermissionsFromUser AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . context AST#member_expression#Right AST#expression#Right , AST#expression#Left permissionsToRequest AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Permissions granted successfully' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . permissionsGranted AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'User denied permissions:' AST#expression#Right , AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 用户拒绝了权限,但应用仍然可以启动(功能可能受限) AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . permissionsGranted AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'All permissions already granted' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . permissionsGranted AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Failed to request permissions:' AST#expression#Right , AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // ArkTS 不允许抛出任意类型,这里直接返回,让应用继续启动 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . permissionsGranted AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private async requestPermissions(): Promise<void> {
try {
const atManager = abilityAccessCtrl.createAtManager();
const bundleInfo = await bundleManager.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION);
const tokenId = bundleInfo.appInfo.accessTokenId;
const requiredPermissions: Permissions[] = [
'ohos.permission.INTERNET',
'ohos.permission.GET_NETWORK_INFO'
];
const optionalPermissions: Permissions[] = [
'ohos.permission.KEEP_BACKGROUND_RUNNING'
];
const permissionsToRequest: Permissions[] = [];
for (const permission of requiredPermissions) {
const grantStatus = await atManager.checkAccessToken(tokenId, permission);
if (grantStatus !== abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) {
permissionsToRequest.push(permission);
}
}
for (const permission of optionalPermissions) {
const grantStatus = await atManager.checkAccessToken(tokenId, permission);
if (grantStatus !== abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) {
permissionsToRequest.push(permission);
}
}
if (permissionsToRequest.length > 0) {
console.info('Requesting permissions:', permissionsToRequest);
try {
await atManager.requestPermissionsFromUser(this.context, permissionsToRequest);
console.info('Permissions granted successfully');
this.permissionsGranted = true;
} catch (err) {
console.error('User denied permissions:', err);
this.permissionsGranted = false;
}
} else {
console.info('All permissions already granted');
this.permissionsGranted = true;
}
} catch (error) {
console.error('Failed to request permissions:', error);
this.permissionsGranted = false;
}
}
|
https://github.com/pangpang20/wavecast.git/blob/d3da8a0009eb44a576a2b9d9d9fe6195a2577e32/entry/src/main/ets/entryability/EntryAbility.ets#L94-L151
|
ff3aba7d4dcfac4c9246361d409a94fc1de6e501
|
github
|
yunkss/ef-tool
|
75f6761a0f2805d97183504745bf23c975ae514d
|
ef_crypto/src/main/ets/crypto/encryption/SHA.ets
|
arkts
|
digestSHA1
|
SHA1摘要
@param str 带摘要的字符串
@returns 摘要后的字符串
|
static async digestSHA1(str: string): Promise<string> {
return CryptoUtil.digest(str, 'SHA1');
}
|
AST#method_declaration#Left static async digestSHA1 AST#parameter_list#Left ( AST#parameter#Left str : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CryptoUtil AST#expression#Right . digest AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left str AST#expression#Right , AST#expression#Left 'SHA1' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static async digestSHA1(str: string): Promise<string> {
return CryptoUtil.digest(str, 'SHA1');
}
|
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto/src/main/ets/crypto/encryption/SHA.ets#L32-L34
|
3c93a42501103b549387903bb88a3d75c8715007
|
gitee
|
salehelper/algorithm_arkts.git
|
61af15272038646775a4745fca98a48ba89e1f4e
|
entry/src/main/ets/ciphers/EllipticCurveKeyExchange.ets
|
arkts
|
modSqrt
|
计算模P下的平方根
@param a 要计算平方根的数
@returns 平方根,如果不存在则返回null
|
private static modSqrt(a: number): number | null {
a = ((a % EllipticCurveKeyExchange.P) + EllipticCurveKeyExchange.P) % EllipticCurveKeyExchange.P;
for (let x = 0; x < EllipticCurveKeyExchange.P; x++) {
if ((x * x) % EllipticCurveKeyExchange.P === a) {
return x;
}
}
return null;
}
|
AST#method_declaration#Left private static modSqrt AST#parameter_list#Left ( AST#parameter#Left a : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left number AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left a = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left a AST#expression#Right % AST#expression#Left EllipticCurveKeyExchange AST#expression#Right AST#binary_expression#Right AST#expression#Right . P AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right + AST#expression#Left EllipticCurveKeyExchange AST#expression#Right AST#binary_expression#Right AST#expression#Right . P AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right % AST#expression#Left EllipticCurveKeyExchange AST#expression#Right AST#binary_expression#Right AST#expression#Right . P AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left x = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left x AST#expression#Right < AST#expression#Left EllipticCurveKeyExchange AST#expression#Right AST#binary_expression#Right AST#expression#Right . P AST#member_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left x AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left x AST#expression#Right * AST#expression#Left x AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right % AST#expression#Left EllipticCurveKeyExchange AST#expression#Right AST#binary_expression#Right AST#expression#Right . P AST#member_expression#Right AST#expression#Right === AST#expression#Left a AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left x AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private static modSqrt(a: number): number | null {
a = ((a % EllipticCurveKeyExchange.P) + EllipticCurveKeyExchange.P) % EllipticCurveKeyExchange.P;
for (let x = 0; x < EllipticCurveKeyExchange.P; x++) {
if ((x * x) % EllipticCurveKeyExchange.P === a) {
return x;
}
}
return null;
}
|
https://github.com/salehelper/algorithm_arkts.git/blob/61af15272038646775a4745fca98a48ba89e1f4e/entry/src/main/ets/ciphers/EllipticCurveKeyExchange.ets#L36-L44
|
ddf359ddfa3b1223f0329395ad55681ef65a79f8
|
github
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_utils/src/main/ets/utils/LogUtil.ets
|
arkts
|
uniLog
|
统一日志输出
|
private static uniLog(message: string[] | object[], level: hilog.LogLevel) {
if (!LogUtil.showLog) {
return; //不打印日志
}
let topLine = LogUtil.getLine(LogUtil.tag);
LogUtil.levelLog(topLine, level);
if (level === hilog.LogLevel.ERROR || level === hilog.LogLevel.FATAL) {
let locationLog = LogUtil.getLogLocation(); //代码位置
LogUtil.levelLog(locationLog, level);
}
const content = LogUtil.getMessage(message);
const len = Math.ceil(content.length / LogUtil.logSize);
for (let i = 0; i < len; i++) {
let end = (i + 1) * LogUtil.logSize;
if (i === (len - 1)) {
end = content.length;
}
let msg = '\n│ ' + content.substring(i * LogUtil.logSize, end);
LogUtil.levelLog(msg, level);
}
let bottomLine = LogUtil.getLine('');
LogUtil.levelLog(bottomLine, level);
}
|
AST#method_declaration#Left private static uniLog AST#parameter_list#Left ( AST#parameter#Left message : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right | AST#primary_type#Left AST#array_type#Left object [ ] AST#array_type#Right AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left level : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left hilog . LogLevel AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left LogUtil AST#expression#Right AST#unary_expression#Right AST#expression#Right . showLog AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right //不打印日志 } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left topLine = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LogUtil AST#expression#Right . getLine AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogUtil AST#expression#Right . tag AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LogUtil AST#expression#Right . levelLog AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left topLine AST#expression#Right , AST#expression#Left level AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left level AST#expression#Right === AST#expression#Left hilog AST#expression#Right AST#binary_expression#Right AST#expression#Right . LogLevel AST#member_expression#Right AST#expression#Right . ERROR AST#member_expression#Right AST#expression#Right || AST#expression#Left AST#binary_expression#Left AST#expression#Left level AST#expression#Right === AST#expression#Left hilog AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . LogLevel AST#member_expression#Right AST#expression#Right . FATAL AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left locationLog = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LogUtil AST#expression#Right . getLogLocation AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right //代码位置 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LogUtil AST#expression#Right . levelLog AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left locationLog AST#expression#Right , AST#expression#Left level AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left content = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LogUtil AST#expression#Right . getMessage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left message AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left len = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . ceil AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left content AST#expression#Right . length AST#member_expression#Right AST#expression#Right / AST#expression#Left LogUtil AST#expression#Right AST#binary_expression#Right AST#expression#Right . logSize AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left len AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left end = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right * AST#expression#Left LogUtil AST#expression#Right AST#binary_expression#Right AST#expression#Right . logSize AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right === AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left len AST#expression#Right - AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left end = AST#expression#Left AST#member_expression#Left AST#expression#Left content AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left msg = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left '\n│ ' AST#expression#Right + AST#expression#Left content AST#expression#Right AST#binary_expression#Right AST#expression#Right . substring AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right * AST#expression#Left LogUtil AST#expression#Right AST#binary_expression#Right AST#expression#Right . logSize AST#member_expression#Right AST#expression#Right , AST#expression#Left end AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LogUtil AST#expression#Right . levelLog AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left msg AST#expression#Right , AST#expression#Left level AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left bottomLine = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LogUtil AST#expression#Right . getLine AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LogUtil AST#expression#Right . levelLog AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left bottomLine AST#expression#Right , AST#expression#Left level AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private static uniLog(message: string[] | object[], level: hilog.LogLevel) {
if (!LogUtil.showLog) {
return;
}
let topLine = LogUtil.getLine(LogUtil.tag);
LogUtil.levelLog(topLine, level);
if (level === hilog.LogLevel.ERROR || level === hilog.LogLevel.FATAL) {
let locationLog = LogUtil.getLogLocation();
LogUtil.levelLog(locationLog, level);
}
const content = LogUtil.getMessage(message);
const len = Math.ceil(content.length / LogUtil.logSize);
for (let i = 0; i < len; i++) {
let end = (i + 1) * LogUtil.logSize;
if (i === (len - 1)) {
end = content.length;
}
let msg = '\n│ ' + content.substring(i * LogUtil.logSize, end);
LogUtil.levelLog(msg, level);
}
let bottomLine = LogUtil.getLine('');
LogUtil.levelLog(bottomLine, level);
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/LogUtil.ets#L163-L185
|
3ae347bffce0d08cf26a2dd11838ae5573d43646
|
gitee
|
Piagari/arkts_example.git
|
a63b868eaa2a50dc480d487b84c4650cc6a40fc8
|
hmos_app-main/hmos_app-main/DriverLicenseExam-master/components/module_city_select/src/main/ets/common/Utils.ets
|
arkts
|
getCurrentCityInfo
|
获取当前所在城市位置
@returns
|
static async getCurrentCityInfo(): Promise<string> {
try {
const requestInfo: geoLocationManager.CurrentLocationRequest = {
priority: geoLocationManager.LocationRequestPriority.FIRST_FIX,
timeoutMs: 1000,
};
const currentLocation = await geoLocationManager.getCurrentLocation(requestInfo);
const reverseGeoCodeReq: site.ReverseGeocodeParams = {
location: currentLocation,
language: 'zh_CN',
};
const reverseGeocodeResult = await site.reverseGeocode(reverseGeoCodeReq);
Logger.info('reverseGeocodeResult=' + JSON.stringify(reverseGeocodeResult));
return reverseGeocodeResult.addressComponent.city?.cityName ?? '';
} catch (e) {
Logger.error('getCurrentCityInfo fail, error: ' + JSON.stringify(e));
return '';
}
}
|
AST#method_declaration#Left static async getCurrentCityInfo AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left requestInfo : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left geoLocationManager . CurrentLocationRequest AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left priority AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left geoLocationManager AST#expression#Right . LocationRequestPriority AST#member_expression#Right AST#expression#Right . FIRST_FIX AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left timeoutMs AST#property_name#Right : AST#expression#Left 1000 AST#expression#Right AST#property_assignment#Right , } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left currentLocation = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left geoLocationManager AST#expression#Right AST#await_expression#Right AST#expression#Right . getCurrentLocation AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left requestInfo AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left reverseGeoCodeReq : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left site . ReverseGeocodeParams AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left location AST#property_name#Right : AST#expression#Left currentLocation AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left language AST#property_name#Right : AST#expression#Left 'zh_CN' AST#expression#Right AST#property_assignment#Right , } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left reverseGeocodeResult = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left site AST#expression#Right AST#await_expression#Right AST#expression#Right . reverseGeocode AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left reverseGeoCodeReq AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'reverseGeocodeResult=' AST#expression#Right + AST#expression#Left JSON AST#expression#Right AST#binary_expression#Right AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left reverseGeocodeResult AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left reverseGeocodeResult AST#expression#Right . addressComponent AST#member_expression#Right AST#expression#Right . city AST#member_expression#Right AST#expression#Right ?. cityName AST#member_expression#Right AST#expression#Right ?? AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( e ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'getCurrentCityInfo fail, error: ' AST#expression#Right + AST#expression#Left JSON AST#expression#Right AST#binary_expression#Right AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left e AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left '' AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static async getCurrentCityInfo(): Promise<string> {
try {
const requestInfo: geoLocationManager.CurrentLocationRequest = {
priority: geoLocationManager.LocationRequestPriority.FIRST_FIX,
timeoutMs: 1000,
};
const currentLocation = await geoLocationManager.getCurrentLocation(requestInfo);
const reverseGeoCodeReq: site.ReverseGeocodeParams = {
location: currentLocation,
language: 'zh_CN',
};
const reverseGeocodeResult = await site.reverseGeocode(reverseGeoCodeReq);
Logger.info('reverseGeocodeResult=' + JSON.stringify(reverseGeocodeResult));
return reverseGeocodeResult.addressComponent.city?.cityName ?? '';
} catch (e) {
Logger.error('getCurrentCityInfo fail, error: ' + JSON.stringify(e));
return '';
}
}
|
https://github.com/Piagari/arkts_example.git/blob/a63b868eaa2a50dc480d487b84c4650cc6a40fc8/hmos_app-main/hmos_app-main/DriverLicenseExam-master/components/module_city_select/src/main/ets/common/Utils.ets#L158-L177
|
ca4fd7d3a53684dbb5d356a0b1ba2d9714d7b636
|
github
|
openharmony/codelabs
|
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
|
ExcellentCase/Healthy_life/entry/src/main/ets/viewmodel/AchievementMapInfo.ets
|
arkts
|
Achievement map info
|
export default class AchievementMapInfo {
off_3: Resource = $r('app.media.ic_badge_3_off');
on_3: Resource = $r('app.media.ic_badge_3_on');
off_7: Resource = $r('app.media.ic_badge_7_off');
on_7: Resource = $r('app.media.ic_badge_7_on');
off_30: Resource = $r('app.media.ic_badge_30_off');
on_30: Resource = $r('app.media.ic_badge_30_on');
off_50: Resource = $r('app.media.ic_badge_50_off');
on_50: Resource = $r('app.media.ic_badge_50_on');
off_73: Resource = $r('app.media.ic_badge_73_off');
on_73: Resource = $r('app.media.ic_badge_73_on');
off_99: Resource = $r('app.media.ic_badge_99_off');
on_99: Resource = $r('app.media.ic_badge_99_on');
}
|
AST#export_declaration#Left export default AST#class_declaration#Left class AchievementMapInfo AST#class_body#Left { AST#property_declaration#Left off_3 : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.ic_badge_3_off' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left on_3 : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.ic_badge_3_on' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left off_7 : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.ic_badge_7_off' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left on_7 : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.ic_badge_7_on' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left off_30 : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.ic_badge_30_off' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left on_30 : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.ic_badge_30_on' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left off_50 : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.ic_badge_50_off' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left on_50 : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.ic_badge_50_on' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left off_73 : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.ic_badge_73_off' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left on_73 : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.ic_badge_73_on' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left off_99 : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.ic_badge_99_off' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left on_99 : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.ic_badge_99_on' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export default class AchievementMapInfo {
off_3: Resource = $r('app.media.ic_badge_3_off');
on_3: Resource = $r('app.media.ic_badge_3_on');
off_7: Resource = $r('app.media.ic_badge_7_off');
on_7: Resource = $r('app.media.ic_badge_7_on');
off_30: Resource = $r('app.media.ic_badge_30_off');
on_30: Resource = $r('app.media.ic_badge_30_on');
off_50: Resource = $r('app.media.ic_badge_50_off');
on_50: Resource = $r('app.media.ic_badge_50_on');
off_73: Resource = $r('app.media.ic_badge_73_off');
on_73: Resource = $r('app.media.ic_badge_73_on');
off_99: Resource = $r('app.media.ic_badge_99_off');
on_99: Resource = $r('app.media.ic_badge_99_on');
}
|
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/ExcellentCase/Healthy_life/entry/src/main/ets/viewmodel/AchievementMapInfo.ets#L19-L32
|
2c61d041719564c9ab2bba009f3022e8f1a52970
|
gitee
|
|
yycy134679/FoodieHarmony.git
|
e6971f0a8f7574ae278d02eb5c057e57e667dab5
|
entry/src/main/ets/pages/FootprintPage.ets
|
arkts
|
loadFootprintMerchants
|
加载足迹商家数据
|
private async loadFootprintMerchants(): Promise<void> {
try {
this.isLoading = true;
hilog.info(DOMAIN, TAG, 'Loading footprint merchants, ids: %{public}s', JSON.stringify(this.footprintIds));
// 获取所有商家数据
const allMerchants = MockDataManager.getInstance().getAllMerchants();
// 根据足迹 ID 列表筛选并排序商家
const merchants: MerchantModel[] = [];
for (const id of this.footprintIds) {
const merchant = allMerchants.find(m => m.id === id);
if (merchant) {
merchants.push(merchant);
}
}
this.footprintMerchants = merchants;
hilog.info(DOMAIN, TAG, 'Footprint merchants loaded: %{public}d', merchants.length);
} catch (err) {
hilog.error(DOMAIN, TAG, 'Failed to load footprint merchants: %{public}s', JSON.stringify(err));
} finally {
this.isLoading = false;
}
}
|
AST#method_declaration#Left private async loadFootprintMerchants AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLoading AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left DOMAIN AST#expression#Right , AST#expression#Left TAG AST#expression#Right , AST#expression#Left 'Loading footprint merchants, ids: %{public}s' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . footprintIds AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 获取所有商家数据 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left allMerchants = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left MockDataManager AST#expression#Right . getInstance AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . getAllMerchants AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 根据足迹 ID 列表筛选并排序商家 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left merchants : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left MerchantModel [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( const id of AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . footprintIds AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left merchant = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left allMerchants AST#expression#Right . find AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left m => AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left m AST#expression#Right . id AST#member_expression#Right AST#expression#Right === AST#expression#Left id AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left merchant AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left merchants AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left merchant AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . footprintMerchants AST#member_expression#Right = AST#expression#Left merchants AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left DOMAIN AST#expression#Right , AST#expression#Left TAG AST#expression#Right , AST#expression#Left 'Footprint merchants loaded: %{public}d' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left merchants AST#expression#Right . length AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left DOMAIN AST#expression#Right , AST#expression#Left TAG AST#expression#Right , AST#expression#Left 'Failed to load footprint merchants: %{public}s' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#finally_clause#Left finally AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLoading AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#finally_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private async loadFootprintMerchants(): Promise<void> {
try {
this.isLoading = true;
hilog.info(DOMAIN, TAG, 'Loading footprint merchants, ids: %{public}s', JSON.stringify(this.footprintIds));
const allMerchants = MockDataManager.getInstance().getAllMerchants();
const merchants: MerchantModel[] = [];
for (const id of this.footprintIds) {
const merchant = allMerchants.find(m => m.id === id);
if (merchant) {
merchants.push(merchant);
}
}
this.footprintMerchants = merchants;
hilog.info(DOMAIN, TAG, 'Footprint merchants loaded: %{public}d', merchants.length);
} catch (err) {
hilog.error(DOMAIN, TAG, 'Failed to load footprint merchants: %{public}s', JSON.stringify(err));
} finally {
this.isLoading = false;
}
}
|
https://github.com/yycy134679/FoodieHarmony.git/blob/e6971f0a8f7574ae278d02eb5c057e57e667dab5/entry/src/main/ets/pages/FootprintPage.ets#L39-L63
|
a53ba86c16fd46d612eecfc0e0ac3aea9aac999d
|
github
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/SystemFeature/FileManagement/Photos/entry/src/main/ets/components/EmptyAlbumComponent.ets
|
arkts
|
EmptyAlbumComponent
|
New style
|
@Component
export struct EmptyAlbumComponent {
@Consume gridHeight: number;
@Consume isBigCard: boolean;
@State icHeight: number = 0;
gridAspectRatio = Constants.CARD_ASPECT_RATIO;
aboutToAppear(): void {
let numberHeight = px2vp(fp2px(Constants.TEXT_SIZE_BODY2));
let nameHeight = px2vp(fp2px(Constants.TEXT_SIZE_SUB_TITLE1));
this.icHeight = this.gridHeight - Constants.ALBUM_SET_NEW_ICON_MARGIN - numberHeight - nameHeight;
}
build() {
if (this.isBigCard) {
Flex({
direction: FlexDirection.Column,
justifyContent: FlexAlign.Center,
alignItems: ItemAlign.Center
}) {
Image($r('app.media.ic_goto_photos'))
.width($r('app.float.recycle_album_cover_icon_size'))
.height($r('app.float.recycle_album_cover_icon_size'))
.fillColor($r('app.color.empty_or_recycle_album_icon'))
}
.width('100%')
.height(this.gridHeight)
.backgroundColor($r('app.color.empty_or_recycle_album_back'))
.border({ radius: $r('sys.float.ohos_id_corner_radius_default_l') })
} else {
Flex({
direction: FlexDirection.Column,
justifyContent: FlexAlign.Start,
alignItems: ItemAlign.Start
}) {
Stack({ alignContent: Alignment.Center }) {
Image($r('app.media.ic_goto_photos'))
.width($r('app.float.recycle_album_cover_icon_size'))
.height($r('app.float.recycle_album_cover_icon_size'))
.fillColor($r('app.color.empty_or_recycle_album_icon'))
}
.height(this.icHeight)
.width('100%')
}
.aspectRatio(this.gridAspectRatio)
.backgroundColor($r('app.color.empty_or_recycle_album_back'))
.border({ radius: $r('sys.float.ohos_id_corner_radius_default_l') })
}
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct EmptyAlbumComponent AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ Consume AST#decorator#Right gridHeight : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Consume AST#decorator#Right isBigCard : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right icHeight : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left gridAspectRatio = AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . CARD_ASPECT_RATIO AST#member_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#method_declaration#Left aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left numberHeight = AST#expression#Left AST#call_expression#Left AST#expression#Left px2vp AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left fp2px AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . TEXT_SIZE_BODY2 AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left nameHeight = AST#expression#Left AST#call_expression#Left AST#expression#Left px2vp AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left fp2px AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . TEXT_SIZE_SUB_TITLE1 AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . icHeight AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . gridHeight AST#member_expression#Right AST#expression#Right - AST#expression#Left Constants AST#expression#Right AST#binary_expression#Right AST#expression#Right . ALBUM_SET_NEW_ICON_MARGIN AST#member_expression#Right AST#expression#Right - AST#expression#Left numberHeight AST#expression#Right AST#binary_expression#Right AST#expression#Right - AST#expression#Left nameHeight AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isBigCard AST#member_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Flex ( AST#component_parameters#Left { AST#component_parameter#Left direction : AST#expression#Left AST#member_expression#Left AST#expression#Left FlexDirection AST#expression#Right . Column AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left justifyContent : AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left alignItems : AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.ic_goto_photos' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.recycle_album_cover_icon_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.recycle_album_cover_icon_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fillColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.empty_or_recycle_album_icon' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . gridHeight AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.empty_or_recycle_album_back' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . border ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left radius AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'sys.float.ohos_id_corner_radius_default_l' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } else { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Flex ( AST#component_parameters#Left { AST#component_parameter#Left direction : AST#expression#Left AST#member_expression#Left AST#expression#Left FlexDirection AST#expression#Right . Column AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left justifyContent : AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left alignItems : AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Stack ( AST#component_parameters#Left { AST#component_parameter#Left alignContent : AST#expression#Left AST#member_expression#Left AST#expression#Left Alignment AST#expression#Right . Center AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.ic_goto_photos' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.recycle_album_cover_icon_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.recycle_album_cover_icon_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fillColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.empty_or_recycle_album_icon' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . icHeight AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . aspectRatio ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . gridAspectRatio AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.empty_or_recycle_album_back' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . border ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left radius AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'sys.float.ohos_id_corner_radius_default_l' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@Component
export struct EmptyAlbumComponent {
@Consume gridHeight: number;
@Consume isBigCard: boolean;
@State icHeight: number = 0;
gridAspectRatio = Constants.CARD_ASPECT_RATIO;
aboutToAppear(): void {
let numberHeight = px2vp(fp2px(Constants.TEXT_SIZE_BODY2));
let nameHeight = px2vp(fp2px(Constants.TEXT_SIZE_SUB_TITLE1));
this.icHeight = this.gridHeight - Constants.ALBUM_SET_NEW_ICON_MARGIN - numberHeight - nameHeight;
}
build() {
if (this.isBigCard) {
Flex({
direction: FlexDirection.Column,
justifyContent: FlexAlign.Center,
alignItems: ItemAlign.Center
}) {
Image($r('app.media.ic_goto_photos'))
.width($r('app.float.recycle_album_cover_icon_size'))
.height($r('app.float.recycle_album_cover_icon_size'))
.fillColor($r('app.color.empty_or_recycle_album_icon'))
}
.width('100%')
.height(this.gridHeight)
.backgroundColor($r('app.color.empty_or_recycle_album_back'))
.border({ radius: $r('sys.float.ohos_id_corner_radius_default_l') })
} else {
Flex({
direction: FlexDirection.Column,
justifyContent: FlexAlign.Start,
alignItems: ItemAlign.Start
}) {
Stack({ alignContent: Alignment.Center }) {
Image($r('app.media.ic_goto_photos'))
.width($r('app.float.recycle_album_cover_icon_size'))
.height($r('app.float.recycle_album_cover_icon_size'))
.fillColor($r('app.color.empty_or_recycle_album_icon'))
}
.height(this.icHeight)
.width('100%')
}
.aspectRatio(this.gridAspectRatio)
.backgroundColor($r('app.color.empty_or_recycle_album_back'))
.border({ radius: $r('sys.float.ohos_id_corner_radius_default_l') })
}
}
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/SystemFeature/FileManagement/Photos/entry/src/main/ets/components/EmptyAlbumComponent.ets#L19-L68
|
52eeb640fca91e45cc324c3a57e1606989a5e74f
|
gitee
|
openharmony/codelabs
|
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
|
Media/ImageEdit/entry/src/main/ets/viewModel/CropShow.ets
|
arkts
|
init
|
Init cropShow.
@param limit
@param imageRatio
|
init(limit: RectF, imageRatio: number) {
this.limitRect.set(limit.left, limit.top, limit.right, limit.bottom);
MathUtils.computeMaxRectWithinLimit(this.imageRect, limit, imageRatio);
this.cropRect.set(this.imageRect.left, this.imageRect.top, this.imageRect.right, this.imageRect.bottom);
this.ratio.set(CommonConstants.DEFAULT_RATIO, CommonConstants.DEFAULT_RATIO);
this.rotationAngle = 0;
this.horizontalAngle = 0;
this.isFlipHorizontal = false;
this.isFlipVertically = false;
}
|
AST#method_declaration#Left init AST#parameter_list#Left ( AST#parameter#Left limit : AST#type_annotation#Left AST#primary_type#Left RectF AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left imageRatio : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . limitRect AST#member_expression#Right AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left limit AST#expression#Right . left AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left limit AST#expression#Right . top AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left limit AST#expression#Right . right AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left limit AST#expression#Right . bottom AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left MathUtils AST#expression#Right . computeMaxRectWithinLimit AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . imageRect AST#member_expression#Right AST#expression#Right , AST#expression#Left limit AST#expression#Right , AST#expression#Left imageRatio AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cropRect AST#member_expression#Right AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . imageRect AST#member_expression#Right AST#expression#Right . left AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . imageRect AST#member_expression#Right AST#expression#Right . top AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . imageRect AST#member_expression#Right AST#expression#Right . right AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . imageRect AST#member_expression#Right AST#expression#Right . bottom AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . ratio AST#member_expression#Right AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . DEFAULT_RATIO AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . DEFAULT_RATIO AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rotationAngle AST#member_expression#Right = AST#expression#Left 0 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . horizontalAngle AST#member_expression#Right = AST#expression#Left 0 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isFlipHorizontal AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isFlipVertically AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
init(limit: RectF, imageRatio: number) {
this.limitRect.set(limit.left, limit.top, limit.right, limit.bottom);
MathUtils.computeMaxRectWithinLimit(this.imageRect, limit, imageRatio);
this.cropRect.set(this.imageRect.left, this.imageRect.top, this.imageRect.right, this.imageRect.bottom);
this.ratio.set(CommonConstants.DEFAULT_RATIO, CommonConstants.DEFAULT_RATIO);
this.rotationAngle = 0;
this.horizontalAngle = 0;
this.isFlipHorizontal = false;
this.isFlipVertically = false;
}
|
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Media/ImageEdit/entry/src/main/ets/viewModel/CropShow.ets#L70-L79
|
27a64992624e06f035a9f66f3e6b1f7df2730c58
|
gitee
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/pages/Index.ets
|
arkts
|
buildInfoRow
|
信息行
|
@Builder
buildInfoRow(label: string, value: string) {
Row() {
Text(label)
.fontSize(14)
.fontColor(this.COLORS.textSecondary)
.layoutWeight(1)
Text(value)
.fontSize(14)
.fontWeight(FontWeight.Medium)
.fontColor(this.COLORS.textPrimary)
}
.width('100%')
}
|
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildInfoRow AST#parameter_list#Left ( AST#parameter#Left label : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left label AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . COLORS AST#member_expression#Right AST#expression#Right . textSecondary AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left value AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Medium AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . COLORS AST#member_expression#Right AST#expression#Right . textPrimary AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
@Builder
buildInfoRow(label: string, value: string) {
Row() {
Text(label)
.fontSize(14)
.fontColor(this.COLORS.textSecondary)
.layoutWeight(1)
Text(value)
.fontSize(14)
.fontWeight(FontWeight.Medium)
.fontColor(this.COLORS.textPrimary)
}
.width('100%')
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/Index.ets#L5783-L5797
|
3a12fe5a9ba68e917ecb8911d0cf81b5efcc64f3
|
github
|
njkndxz/learn-ArkTs.git
|
70fabab8ee28e3637329d53a4ec93afc72a001c2
|
entry/src/main/ets/entryability/EntryAbility.ets
|
arkts
|
onBackground
|
当切换到后台
|
onBackground(): void {
// Ability has back to background
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
}
|
AST#method_declaration#Left onBackground AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { // Ability has back to background AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left 'testTag' AST#expression#Right , AST#expression#Left '%{public}s' AST#expression#Right , AST#expression#Left 'Ability onBackground' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
onBackground(): void {
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
}
|
https://github.com/njkndxz/learn-ArkTs.git/blob/70fabab8ee28e3637329d53a4ec93afc72a001c2/entry/src/main/ets/entryability/EntryAbility.ets#L55-L58
|
23662176e272e3adf4284054126318180f399245
|
github
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_utils/src/main/ets/crypto/CryptoHelper.ets
|
arkts
|
stringToHex
|
字符串转Hex
@param str
@returns
|
static stringToHex(str: string): string {
let hex = '';
for (let i = 0; i < str.length; i++) {
let hexCharCode = str.charCodeAt(i).toString(16);
// 确保每个字符的十六进制编码占两位,不足补零
hex += ('00' + hexCharCode).slice(-2);
}
return hex;
}
|
AST#method_declaration#Left static stringToHex AST#parameter_list#Left ( AST#parameter#Left str : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left hex = AST#expression#Left '' AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left str AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left hexCharCode = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . charCodeAt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left i AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 16 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 确保每个字符的十六进制编码占两位,不足补零 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left hex += AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left '00' AST#expression#Right + AST#expression#Left hexCharCode AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . slice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#unary_expression#Left - AST#expression#Left 2 AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left hex AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static stringToHex(str: string): string {
let hex = '';
for (let i = 0; i < str.length; i++) {
let hexCharCode = str.charCodeAt(i).toString(16);
hex += ('00' + hexCharCode).slice(-2);
}
return hex;
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/crypto/CryptoHelper.ets#L187-L195
|
dfc374f3d5488af941a2839eb46f46a237d2ebaa
|
gitee
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/shortvideo/src/main/ets/view/Side.ets
|
arkts
|
changefavoriteCount
|
点击收藏按钮的回调函数
|
private changefavoriteCount(isIncrease: boolean) {
let favoriteCountNum = Number(this.favoriteCount);
if (isIncrease) {
favoriteCountNum++;
} else {
favoriteCountNum--;
}
this.favoriteCount = '' + favoriteCountNum;
animateTo({ duration: 200, curve: Curve.EaseInOut }, () => {
this.isFavorite = !this.isFavorite;
})
}
|
AST#method_declaration#Left private changefavoriteCount AST#parameter_list#Left ( AST#parameter#Left isIncrease : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left favoriteCountNum = AST#expression#Left AST#call_expression#Left AST#expression#Left Number AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . favoriteCount AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left isIncrease AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#update_expression#Left AST#expression#Left favoriteCountNum AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#update_expression#Left AST#expression#Left favoriteCountNum AST#expression#Right -- AST#update_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . favoriteCount AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left '' AST#expression#Right + AST#expression#Left favoriteCountNum AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left animateTo AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left duration AST#property_name#Right : AST#expression#Left 200 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left curve AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Curve AST#expression#Right . EaseInOut AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isFavorite AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . isFavorite AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private changefavoriteCount(isIncrease: boolean) {
let favoriteCountNum = Number(this.favoriteCount);
if (isIncrease) {
favoriteCountNum++;
} else {
favoriteCountNum--;
}
this.favoriteCount = '' + favoriteCountNum;
animateTo({ duration: 200, curve: Curve.EaseInOut }, () => {
this.isFavorite = !this.isFavorite;
})
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/shortvideo/src/main/ets/view/Side.ets#L59-L70
|
9316bb8d6f010d0ba16e337427c84c2176ea5b2b
|
gitee
|
zhangyuhang0914/ArkTs-HarmonyOs.git
|
c9773cad7ebeee413f98ee1a57cc8fba91fecf7d
|
entry/src/main/ets/route/RoutePath.ets
|
arkts
|
路由表管理
|
export class RoutePath {
static readonly SplashPage = "pages/SplashPage"
static readonly MainPage = "pages/MainPage"
static readonly NewNoticeTab = "pages/list/NewNoticeTab"
static readonly CommonDetail = "pages/newNotice/detail/CommonDetail"
}
|
AST#export_declaration#Left export AST#class_declaration#Left class RoutePath AST#class_body#Left { AST#property_declaration#Left static readonly SplashPage = AST#expression#Left "pages/SplashPage" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left static readonly MainPage = AST#expression#Left "pages/MainPage" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left static readonly NewNoticeTab = AST#expression#Left "pages/list/NewNoticeTab" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left static readonly CommonDetail = AST#expression#Left "pages/newNotice/detail/CommonDetail" AST#expression#Right AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class RoutePath {
static readonly SplashPage = "pages/SplashPage"
static readonly MainPage = "pages/MainPage"
static readonly NewNoticeTab = "pages/list/NewNoticeTab"
static readonly CommonDetail = "pages/newNotice/detail/CommonDetail"
}
|
https://github.com/zhangyuhang0914/ArkTs-HarmonyOs.git/blob/c9773cad7ebeee413f98ee1a57cc8fba91fecf7d/entry/src/main/ets/route/RoutePath.ets#L4-L9
|
db8ae3ada5772980814670bc8ff9a57b7fc92642
|
github
|
|
Joker-x-dev/CoolMallArkTS.git
|
9f3fabf89fb277692cb82daf734c220c7282919c
|
feature/auth/src/main/ets/component/VerificationCodeField.ets
|
arkts
|
getSendCodeTextColor
|
获取发送验证码文本颜色
@returns {ResourceColor} 文本颜色
|
private getSendCodeTextColor(): ResourceColor {
return this.isPhoneValid ? $r("app.color.warning") : $r("app.color.text_quaternary");
}
|
AST#method_declaration#Left private getSendCodeTextColor AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left ResourceColor AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isPhoneValid AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.color.warning" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.color.text_quaternary" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
private getSendCodeTextColor(): ResourceColor {
return this.isPhoneValid ? $r("app.color.warning") : $r("app.color.text_quaternary");
}
|
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/auth/src/main/ets/component/VerificationCodeField.ets#L105-L107
|
1e42be8059ce8d793580e8826e16dc5a44c5ebd1
|
github
|
openharmony/graphic_graphic_2d
|
46a11e91c9709942196ad2a7afea2e0fcd1349f3
|
frameworks/text/interface/export/ani/@ohos.graphics.text.ets
|
arkts
|
Enumeration the type of text baseline.
@enum { number }
@syscap SystemCapability.Graphics.Drawing
@since 12
|
export enum TextBaseline {
/**
* The alphabetic baseline, typically used for Latin-based scripts where the baseline aligns
* with the base of lowercase letters.
* @syscap SystemCapability.Graphics.Drawing
* @since 12
*/
ALPHABETIC,
/**
* The ideographic baseline, commonly used for ideographic scripts such as Chinese, Japanese, and Korean,
* where the baseline aligns with the center of characters.
* @syscap SystemCapability.Graphics.Drawing
* @since 12
*/
IDEOGRAPHIC,
}
|
AST#export_declaration#Left export AST#enum_declaration#Left enum TextBaseline AST#enum_body#Left { /**
* The alphabetic baseline, typically used for Latin-based scripts where the baseline aligns
* with the base of lowercase letters.
* @syscap SystemCapability.Graphics.Drawing
* @since 12
*/ AST#enum_member#Left ALPHABETIC AST#enum_member#Right , /**
* The ideographic baseline, commonly used for ideographic scripts such as Chinese, Japanese, and Korean,
* where the baseline aligns with the center of characters.
* @syscap SystemCapability.Graphics.Drawing
* @since 12
*/ AST#enum_member#Left IDEOGRAPHIC AST#enum_member#Right , } AST#enum_body#Right AST#enum_declaration#Right AST#export_declaration#Right
|
export enum TextBaseline {
ALPHABETIC,
IDEOGRAPHIC,
}
|
https://github.com/openharmony/graphic_graphic_2d/blob/46a11e91c9709942196ad2a7afea2e0fcd1349f3/frameworks/text/interface/export/ani/@ohos.graphics.text.ets#L1152-L1168
|
cccf9773019c53dfe80de1014d61ebfc7038d279
|
gitee
|
|
JackJiang2011/harmonychat.git
|
bca3f3e1ce54d763720510f99acf595a49e37879
|
entry/src/main/ets/pages/model/MessagesProvider.ets
|
arkts
|
putMessage
|
加入一条新消息。
@param m 消息对象
|
putMessage(m: Message): void {
// 以下代码用于判断并实现仿微信的只显示2分钟内聊天消息的时间标识(参考资料:http://www.52im.net/thread-3008-1-1.html#40)
let previousMessage: Message | undefined = undefined;
let messagesSize: number = this.messages.length;
if (messagesSize > 0) {
previousMessage = this.messages[messagesSize - 1];
}
MessagesProvider.setMessageShowTopTime(m, previousMessage);
// 将此新消息对象放入数据模型(列表)
this.messages.push(m);
// 通知应用层更新ui
IMClientManager.getInstance().getEmitter().emit(UIEvent.UIEVENT_messageAdded, this.messages.length - 1);
}
|
AST#method_declaration#Left putMessage AST#parameter_list#Left ( AST#parameter#Left m : AST#type_annotation#Left AST#primary_type#Left Message AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { // 以下代码用于判断并实现仿微信的只显示2分钟内聊天消息的时间标识(参考资料:http://www.52im.net/thread-3008-1-1.html#40) AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left previousMessage : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Message AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left undefined AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left messagesSize : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . messages AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left messagesSize AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left previousMessage = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . messages AST#member_expression#Right AST#expression#Right [ AST#expression#Left AST#binary_expression#Left AST#expression#Left messagesSize AST#expression#Right - AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left MessagesProvider AST#expression#Right . setMessageShowTopTime AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left m AST#expression#Right , AST#expression#Left previousMessage AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 将此新消息对象放入数据模型(列表) AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . messages AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left m AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 通知应用层更新ui AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left IMClientManager AST#expression#Right . getInstance AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . getEmitter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . emit AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left UIEvent AST#expression#Right . UIEVENT_messageAdded AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . messages AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right - AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
putMessage(m: Message): void {
let previousMessage: Message | undefined = undefined;
let messagesSize: number = this.messages.length;
if (messagesSize > 0) {
previousMessage = this.messages[messagesSize - 1];
}
MessagesProvider.setMessageShowTopTime(m, previousMessage);
this.messages.push(m);
IMClientManager.getInstance().getEmitter().emit(UIEvent.UIEVENT_messageAdded, this.messages.length - 1);
}
|
https://github.com/JackJiang2011/harmonychat.git/blob/bca3f3e1ce54d763720510f99acf595a49e37879/entry/src/main/ets/pages/model/MessagesProvider.ets#L39-L53
|
ffbd3e0099030d65b80222f9340205617a581951
|
github
|
harmonyos_samples/BestPracticeSnippets
|
490ea539a6d4427dd395f3dac3cf4887719f37af
|
animation/entry/src/main/ets/pages/IconItem.ets
|
arkts
|
IconItem
|
[Start icon_item]
|
@Component
export struct IconItem {
@StorageLink('renderGroupFlag') renderGroupFlag: boolean = false;
image: string | Resource = '';
text: string | Resource = '';
build() {
Flex({
direction: FlexDirection.Column,
justifyContent: FlexAlign.Center,
alignContent: FlexAlign.Center
}) {
Image(this.image)
.height(20)
.width(20)
.objectFit(ImageFit.Contain)
.margin({ left: 15 })
Text(this.text)
.fontSize(10)
.fontColor('#182431')
.margin({ top: 5 })
.width(50)
.opacity(0.8)
.textAlign(TextAlign.Center)
}
.backgroundColor('#e3e3e3')
.width(50)
.height(50)
.borderRadius(25)
// Call renderGroup within IconItem, false to disable, true to enable.
.renderGroup(this.renderGroupFlag)
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct IconItem AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ StorageLink ( AST#expression#Left 'renderGroupFlag' AST#expression#Right ) AST#decorator#Right renderGroupFlag : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left image : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left Resource AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left '' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left text : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left Resource AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left '' AST#expression#Right ; AST#property_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Flex ( AST#component_parameters#Left { AST#component_parameter#Left direction : AST#expression#Left AST#member_expression#Left AST#expression#Left FlexDirection AST#expression#Right . Column AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left justifyContent : AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left alignContent : AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . image AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . height ( AST#expression#Left 20 AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left 20 AST#expression#Right ) AST#modifier_chain_expression#Left . objectFit ( AST#expression#Left AST#member_expression#Left AST#expression#Left ImageFit AST#expression#Right . Contain AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 15 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . text AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 10 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#182431' AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 5 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left 50 AST#expression#Right ) AST#modifier_chain_expression#Left . opacity ( AST#expression#Left 0.8 AST#expression#Right ) AST#modifier_chain_expression#Left . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#e3e3e3' AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left 50 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 50 AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 25 AST#expression#Right ) // Call renderGroup within IconItem, false to disable, true to enable. AST#modifier_chain_expression#Left . renderGroup ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . renderGroupFlag AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@Component
export struct IconItem {
@StorageLink('renderGroupFlag') renderGroupFlag: boolean = false;
image: string | Resource = '';
text: string | Resource = '';
build() {
Flex({
direction: FlexDirection.Column,
justifyContent: FlexAlign.Center,
alignContent: FlexAlign.Center
}) {
Image(this.image)
.height(20)
.width(20)
.objectFit(ImageFit.Contain)
.margin({ left: 15 })
Text(this.text)
.fontSize(10)
.fontColor('#182431')
.margin({ top: 5 })
.width(50)
.opacity(0.8)
.textAlign(TextAlign.Center)
}
.backgroundColor('#e3e3e3')
.width(50)
.height(50)
.borderRadius(25)
.renderGroup(this.renderGroupFlag)
}
}
|
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/animation/entry/src/main/ets/pages/IconItem.ets#L17-L50
|
89ba2f1f94381ec5e86449a39b224e3f8e701ab1
|
gitee
|
openharmony-tpc/ohos_mpchart
|
4fb43a7137320ef2fee2634598f53d93975dfb4a
|
library/src/main/ets/components/components/AxisBase.ets
|
arkts
|
enableGridDashedLine
|
Enables the grid line to be drawn in dashed mode, e.g. like this
"- - - - - -". THIS ONLY WORKS IF HARDWARE-ACCELERATION IS TURNED OFF.
Keep in mind that hardware acceleration boosts performance.
@param lineLength the length of the line pieces
@param spaceLength the length of space in between the pieces
@param phase offset, in degrees (normally, use 0)
|
public enableGridDashedLine(lineLength: number, spaceLength: number, phase: number): void {
this.mGridDashPathEffect = new DashPathEffect([lineLength, spaceLength], phase);
}
|
AST#method_declaration#Left public enableGridDashedLine AST#parameter_list#Left ( AST#parameter#Left lineLength : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left spaceLength : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left phase : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mGridDashPathEffect AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left DashPathEffect AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#array_literal#Left [ AST#expression#Left lineLength AST#expression#Right , AST#expression#Left spaceLength AST#expression#Right ] AST#array_literal#Right AST#expression#Right , AST#expression#Left phase AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
public enableGridDashedLine(lineLength: number, spaceLength: number, phase: number): void {
this.mGridDashPathEffect = new DashPathEffect([lineLength, spaceLength], phase);
}
|
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/components/AxisBase.ets#L585-L587
|
d6749049f8d424369f253242ac4e0ac6566491ce
|
gitee
|
openharmony-tpc/ohos_mpchart
|
4fb43a7137320ef2fee2634598f53d93975dfb4a
|
library/src/main/ets/components/charts/ChartModel.ets
|
arkts
|
notifyDataSetChanged
|
Lets the chart know its underlying data has changed and performs all
necessary recalculations. It is crucial that this method is called
every time data is changed dynamically. Not calling this method can lead
to crashes or unexpected behaviour.
|
public abstract notifyDataSetChanged();
|
AST#method_declaration#Left public abstract notifyDataSetChanged AST#parameter_list#Left ( ) AST#parameter_list#Right ; AST#method_declaration#Right
|
public abstract notifyDataSetChanged();
|
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/charts/ChartModel.ets#L309-L309
|
6b36c5797b0eb7226eb6632ec35aa312df0b2431
|
gitee
|
openharmony/developtools_profiler
|
73d26bb5acfcafb2b1f4f94ead5640241d1e5f73
|
host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/components/AxisBase.ets
|
arkts
|
addLimitLine
|
Adds a new LimitLine to this axis.
@param l
|
public addLimitLine(l: LimitLine): void {
this.mLimitLines.add(l);
if (this.mLimitLines.size() > 6) {
console.log(
'MPAndroiChart',
'Warning! You have more than 6 LimitLines on your axis, do you really want ' + 'that?'
);
}
}
|
AST#method_declaration#Left public addLimitLine AST#parameter_list#Left ( AST#parameter#Left l : AST#type_annotation#Left AST#primary_type#Left LimitLine AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mLimitLines AST#member_expression#Right AST#expression#Right . add AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left l AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mLimitLines AST#member_expression#Right AST#expression#Right . size AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right > AST#expression#Left 6 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'MPAndroiChart' AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left 'Warning! You have more than 6 LimitLines on your axis, do you really want ' AST#expression#Right + AST#expression#Left 'that?' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
public addLimitLine(l: LimitLine): void {
this.mLimitLines.add(l);
if (this.mLimitLines.size() > 6) {
console.log(
'MPAndroiChart',
'Warning! You have more than 6 LimitLines on your axis, do you really want ' + 'that?'
);
}
}
|
https://github.com/openharmony/developtools_profiler/blob/73d26bb5acfcafb2b1f4f94ead5640241d1e5f73/host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/components/AxisBase.ets#L430-L439
|
2ffce60ee46a28db172a6e3a3065a642c3c3e5c9
|
gitee
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/ArkTS1.2/ComponentSample/entry/src/main/ets/pages/Example1/SecondaryLinkExample.ets
|
arkts
|
aboutToAppear
|
是否点击一级列表
生命周期函数
|
aboutToAppear(): void {
// 构造数据
for (let i = 0; i < TAG_LIST_LENGTH; i++) {
this.tagLists.push(`类别${i + 1}`);
const tempData: Array<CustomDataType> = new Array<CustomDataType>(CONTENT_PER_TAG).fill({
desc: '内容数据',
tag: `类别${i + 1}`
});
this.records.push(i * CONTENT_PER_TAG);
this.contentData.pushData(tempData);
}
this.records.push(CONTENT_PER_TAG * TAG_LIST_LENGTH);
this.tagIndexPosition = { start: 0, end: 0 };
}
|
AST#method_declaration#Left aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { // 构造数据 AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left TAG_LIST_LENGTH AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . tagLists AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` 类别 AST#template_substitution#Left $ { AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left tempData : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left CustomDataType AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left CustomDataType AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left CONTENT_PER_TAG AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fill AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left desc AST#property_name#Right : AST#expression#Left '内容数据' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left tag AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` 类别 AST#template_substitution#Left $ { AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . records AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right * AST#expression#Left CONTENT_PER_TAG AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . contentData AST#member_expression#Right AST#expression#Right . pushData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left tempData AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . records AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left CONTENT_PER_TAG AST#expression#Right * AST#expression#Left TAG_LIST_LENGTH AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . tagIndexPosition AST#member_expression#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left start AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left end AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
aboutToAppear(): void {
for (let i = 0; i < TAG_LIST_LENGTH; i++) {
this.tagLists.push(`类别${i + 1}`);
const tempData: Array<CustomDataType> = new Array<CustomDataType>(CONTENT_PER_TAG).fill({
desc: '内容数据',
tag: `类别${i + 1}`
});
this.records.push(i * CONTENT_PER_TAG);
this.contentData.pushData(tempData);
}
this.records.push(CONTENT_PER_TAG * TAG_LIST_LENGTH);
this.tagIndexPosition = { start: 0, end: 0 };
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/ArkTS1.2/ComponentSample/entry/src/main/ets/pages/Example1/SecondaryLinkExample.ets#L108-L121
|
21a9a286efb9fe4f5a85e802564a5af6aa4d1d64
|
gitee
|
fengmingdev/protobuf-arkts-generator.git
|
75888d404fd6ce52a046cba2a94807ecf1350147
|
runtime/arkpb/util.ets
|
arkts
|
Encode bytes to base64 string (unpadded standard alphabet)
|
export function encodeBase64(bytes: Uint8Array): string {
let out = ''
let i = 0
const dv = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength)
const n = bytes.byteLength
while (i < n) {
const b0 = dv.getUint8(i++)
const b1 = i < n ? dv.getUint8(i++) : 0
const b2 = i < n ? dv.getUint8(i++) : 0
out += b64abc.charAt(b0 >> 2)
out += b64abc.charAt(((b0 & 0x03) << 4) | (b1 >> 4))
out += i - 1 < n ? b64abc.charAt(((b1 & 0x0F) << 2) | (b2 >> 6)) : '='
out += i < n ? b64abc.charAt(b2 & 0x3F) : '='
}
return out
}
|
AST#export_declaration#Left export AST#function_declaration#Left function encodeBase64 AST#parameter_list#Left ( AST#parameter#Left bytes : AST#type_annotation#Left AST#primary_type#Left Uint8Array AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left out = AST#expression#Left '' AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left dv = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left DataView AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left bytes AST#expression#Right . buffer AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left bytes AST#expression#Right . byteOffset AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left bytes AST#expression#Right . byteLength AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left n = AST#expression#Left AST#member_expression#Left AST#expression#Left bytes AST#expression#Right . byteLength AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#while_statement#Left while ( AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left n AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left b0 = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left dv AST#expression#Right . getUint8 AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left b1 = AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left n AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left dv AST#expression#Right . getUint8 AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right : AST#expression#Left 0 AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left b2 = AST#ERROR#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left n AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left dv AST#expression#Right . getUint8 AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right : AST#ERROR#Left AST#expression#Left 0 AST#expression#Right out += b AST#ERROR#Right AST#expression#Left 64 AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#ERROR#Left abc AST#ERROR#Right . charAt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left b0 AST#expression#Right >> AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right out += b AST#ERROR#Right AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 64 AST#expression#Right AST#ERROR#Left abc AST#ERROR#Right . charAt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left b0 AST#expression#Right & AST#expression#Left 0x03 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right << AST#expression#Left 4 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right | AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left b1 AST#expression#Right >> AST#expression#Left 4 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left out += i AST#ERROR#Right - AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right < AST#expression#Left n AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left b64abc AST#expression#Right . charAt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left b1 AST#expression#Right & AST#expression#Left 0x0F AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right << AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right | AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left b2 AST#expression#Right >> AST#expression#Left 6 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right : AST#expression#Left '=' AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#ERROR#Left out += i AST#ERROR#Right < AST#expression#Left n AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left b64abc AST#expression#Right . charAt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left b2 AST#expression#Right & AST#expression#Left 0x3F AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right : AST#expression#Left '=' AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right } AST#block_statement#Right AST#while_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left out AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
|
export function encodeBase64(bytes: Uint8Array): string {
let out = ''
let i = 0
const dv = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength)
const n = bytes.byteLength
while (i < n) {
const b0 = dv.getUint8(i++)
const b1 = i < n ? dv.getUint8(i++) : 0
const b2 = i < n ? dv.getUint8(i++) : 0
out += b64abc.charAt(b0 >> 2)
out += b64abc.charAt(((b0 & 0x03) << 4) | (b1 >> 4))
out += i - 1 < n ? b64abc.charAt(((b1 & 0x0F) << 2) | (b2 >> 6)) : '='
out += i < n ? b64abc.charAt(b2 & 0x3F) : '='
}
return out
}
|
https://github.com/fengmingdev/protobuf-arkts-generator.git/blob/75888d404fd6ce52a046cba2a94807ecf1350147/runtime/arkpb/util.ets#L68-L83
|
6b17bafd06ab9e4cfda0e14fa47cf652fe361e20
|
github
|
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/SystemFeature/DeviceManagement/DeviceManagementCollection/feature/capabilities/src/main/ets/components/GlobalContext.ets
|
arkts
|
Copyright (c) 2023-2025 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
|
export class GlobalContext {
private constructor() {
}
private static instance: GlobalContext;
private _objects = new Map<string, Object>();
public static getContext(): GlobalContext {
if (!GlobalContext.instance) {
GlobalContext.instance = new GlobalContext();
}
return GlobalContext.instance;
}
getValue(value: string): Object {
let result = this._objects.get(value);
if (!result) {
throw new Error("this value undefined");
}
return result;
}
setValue(key: string, objectClass: Object): void {
this._objects.set(key, objectClass);
}
}
|
AST#export_declaration#Left export AST#class_declaration#Left class GlobalContext AST#class_body#Left { AST#constructor_declaration#Left private constructor AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { } AST#block_statement#Right AST#constructor_declaration#Right AST#property_declaration#Left private static instance : AST#type_annotation#Left AST#primary_type#Left GlobalContext AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left private _objects = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Map AST#expression#Right AST#new_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#method_declaration#Left public static getContext AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left GlobalContext AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left GlobalContext AST#expression#Right AST#unary_expression#Right AST#expression#Right . instance AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left GlobalContext AST#expression#Right . instance AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left GlobalContext AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#expression_statement#Left AST#expression#Left return AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left GlobalContext AST#expression#Right . instance AST#member_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left getValue AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left result = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . _objects AST#member_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left value AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left result AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#throw_statement#Left throw AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Error AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "this value undefined" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#throw_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left result AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left setValue AST#parameter_list#Left ( AST#parameter#Left key : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left objectClass : AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . _objects AST#member_expression#Right AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right , AST#expression#Left objectClass AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class GlobalContext {
private constructor() {
}
private static instance: GlobalContext;
private _objects = new Map<string, Object>();
public static getContext(): GlobalContext {
if (!GlobalContext.instance) {
GlobalContext.instance = new GlobalContext();
}
return GlobalContext.instance;
}
getValue(value: string): Object {
let result = this._objects.get(value);
if (!result) {
throw new Error("this value undefined");
}
return result;
}
setValue(key: string, objectClass: Object): void {
this._objects.set(key, objectClass);
}
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/SystemFeature/DeviceManagement/DeviceManagementCollection/feature/capabilities/src/main/ets/components/GlobalContext.ets#L17-L42
|
7c353284f7432cb427493a79f2effa0858aae2ad
|
gitee
|
|
openharmony/arkui_ace_engine
|
30c7d1ee12fbedf0fabece54291d75897e2ad44f
|
advanced_ui_component/treeview/source/treeview.ets
|
arkts
|
getNodeInfoData
|
To gain the information while to alter node.
|
getNodeInfoData(): NodeParam {
return this.nodeParam;
}
|
AST#method_declaration#Left getNodeInfoData AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left NodeParam AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . nodeParam AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
getNodeInfoData(): NodeParam {
return this.nodeParam;
}
|
https://github.com/openharmony/arkui_ace_engine/blob/30c7d1ee12fbedf0fabece54291d75897e2ad44f/advanced_ui_component/treeview/source/treeview.ets#L616-L618
|
0dfdbeded1eb7bc714ca3d068febeb35ae82043c
|
gitee
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/common/components/Sounds/Cloud/Download/Downloader/CosDownloader.ets
|
arkts
|
MARK: - 腾讯云下载器类
|
export class CosDownloader {
// MARK: - 单例实例
private static instance: CosDownloader = new CosDownloader();
// MARK: - 私有属性
private downloadingSet: Set<string> = new Set();
// private downloadQueue: taskpool.TaskPool = new taskpool.TaskPool("com.ou.TencentCos.Downloader.Queue");
// MARK: - 构造函数
private constructor() {
// 初始化腾讯云服务
CosService.shared;
}
// 获取单例实例
public static get shared(): CosDownloader {
return this.instance;
}
// MARK: - 下载方法
private async downloadData(text: string, finished: (data: Uint8Array | null, error: string | null) => void) {
// 生成文件名,将文本转为拼音并转换为.mp3格式
const fileName = `${StringPyHelper.convertUnicodeForPinyin(text)}.mp3`;
// 缓存文件夹路径
const context = getContext() as common.UIAbilityContext;
const downloadCacheFolder = `${context.cacheDir}/CosDownloads`;
const downloadFileUrl = `${downloadCacheFolder}/${fileName}`;
// 确保目标文件夹存在
createFolderIfNeeds(downloadCacheFolder);
// 存储桶名称,由 bucketname-appid 组成,appid 必须填入,可以在 COS 控制台查看存储桶名称。 https://console.cloud.tencent.com/cos5/bucket
let bucket = CurrentBucket//"examplebucket-1250000000";
//对象在存储桶中的位置标识符,即称对象键
let cosPath = `${StringEncoder.removedSalt(CosConfig.soundPrefix)}${fileName}` // 对象键,是对象在 COS 上的完整路径 "exampleobject.txt";
//本地文件路径
let downloadPath = downloadFileUrl // 设置文件下载保存路径\n "本地文件路径";
let request = new GetObjectRequest(bucket, cosPath, downloadPath);
request.credential = CosService.shared.getCredential()
let task: DownloadTask = CosXmlBaseService.default().download(request);
// 下载进度回调
task.onProgress = (progress: HttpProgress) => {
// progress.complete 为当前已下载大小
// progress.target 为总大小
};
task.onResult = {
// 下载成功回调
onSuccess: (request, result: CosXmlDownloadTaskResult) => {
// todo 下载成功后的逻辑
// 如果下载成功,解析结果
if (!result.accessUrl){
finished(null, "Download result is empty.")
return
}
// 成功:尝试读取数据
DebugLog.i("Download completed. Result: \(result)")
// 尝试读取下载的文件数据
this.readFileAsUint8Array(downloadFileUrl, (data: Uint8Array | null, error: string | null) => {
if (data) {
//下载成功 回调
finished(data, null)
// 下载完毕后,删除缓存文件
FileUtility.deleteFileAt(result.accessUrl!)
}else{
finished(null, error)
}
})
},
//下载失败回调
onFail: (request, error: CosError) => {
// 错误处理:下载失败
DebugLog.e(`Download error: ${error.message}`)
finished(null, error.message ?? "Download error")
}
}
//开始下载
task.start();
//暂停任务
// task.pause();
//恢复任务
// task.resume();
//取消任务
// task.cancel();
}
// MARK: - 公共方法
public async startDownloadIfNeeds(
text: string,
finished: (data: Uint8Array | null, error: string | null) => void
) {
// 校验text是否有效
if (!text || text.trim().length === 0) {
finished(null, "text is empty");
return;
}
// 检查网络连接(需实现checkConnection方法)
if (!NetWorkTool.checkInternetConnection()) {
finished(null, "Network is not connectable");
return;
}
const language = "zh_cn";
const tag = `language:${language}, title:${text}`;
// 检查是否已经在下载
if (this.downloadingSet.has(tag)) {
DebugLog.i(`Download for ${tag} is already in progress.`);
finished(null, "Download is already in progress.");
return;
}
// 标记当前任务正在下载
this.downloadingSet.add(tag);
DebugLog.i(`Start downloading sound for ${tag}...`);
logEvent("Audio_Cos_Download") //日志
// 执行下载
await this.downloadData(text, (data, error) => {
// 下载完成后回调
finished(data, error);
// 下载完成,移除标记
this.downloadingSet.delete(tag);
});
}
///将下载文件读取为data
readFileAsUint8Array(filePath: string, callback: (data: Uint8Array | null, error: string | null) => void): void {
// fs.open(filePath, fs.OpenMode.READ_ONLY, (err, file) => {
// if (err) {
// callback(null, `打开文件失败: ${err.message}`);
// return;
// }
//
// const arrayBuffer = new ArrayBuffer(1024 * 1024);
// fs.read(file.fd, arrayBuffer, (readErr, bytesRead) => {
// fs.close(file.fd);
// if (readErr) {
// callback(null, `读取文件失败: ${readErr.message}`);
// } else {
// callback(new Uint8Array(arrayBuffer, 0, bytesRead), null);
// }
// });
// });
FileUtility.readFileAsUint8Array(filePath, callback)
}
/**
* 清空临时文件目录(temp_folder)
*/
static clearTempFolder(): boolean {
const tempDir = `${getContext().cacheDir}/CosDownloads`;
return FileUtility.deleteDirectoryAt(tempDir);
}
}
|
AST#export_declaration#Left export AST#class_declaration#Left class CosDownloader AST#class_body#Left { // MARK: - 单例实例 AST#property_declaration#Left private static instance : AST#type_annotation#Left AST#primary_type#Left CosDownloader AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left CosDownloader AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right // MARK: - 私有属性 AST#property_declaration#Left private downloadingSet : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Set AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Set AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right // private downloadQueue: taskpool.TaskPool = new taskpool.TaskPool("com.ou.TencentCos.Downloader.Queue"); // MARK: - 构造函数 AST#constructor_declaration#Left private constructor AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { // 初始化腾讯云服务 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CosService AST#expression#Right . shared AST#member_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right // 获取单例实例 AST#method_declaration#Left public static get AST#ERROR#Left shared AST#ERROR#Right AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left CosDownloader AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . instance AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right // MARK: - 下载方法 AST#method_declaration#Left private async downloadData AST#parameter_list#Left ( AST#parameter#Left text : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left finished : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Uint8Array AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left error : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { // 生成文件名,将文本转为拼音并转换为.mp3格式 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left fileName = AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left StringPyHelper AST#expression#Right . convertUnicodeForPinyin AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left text AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right .mp3 ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 缓存文件夹路径 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left context = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left getContext AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . UIAbilityContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left downloadCacheFolder = AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left context AST#expression#Right . cacheDir AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right /CosDownloads ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left downloadFileUrl = AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left downloadCacheFolder AST#expression#Right } AST#template_substitution#Right / AST#template_substitution#Left $ { AST#expression#Left fileName AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 确保目标文件夹存在 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left createFolderIfNeeds AST#expression#Right AST#argument_list#Left ( AST#expression#Left downloadCacheFolder AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 存储桶名称,由 bucketname-appid 组成,appid 必须填入,可以在 COS 控制台查看存储桶名称。 https://console.cloud.tencent.com/cos5/bucket AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left bucket = AST#expression#Left CurrentBucket AST#expression#Right AST#variable_declarator#Right //"examplebucket-1250000000"; //对象在存储桶中的位置标识符,即称对象键 AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left cosPath = AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left StringEncoder AST#expression#Right . removedSalt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CosConfig AST#expression#Right . soundPrefix AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right AST#template_substitution#Left $ { AST#expression#Left fileName AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right // 对象键,是对象在 COS 上的完整路径 "exampleobject.txt"; //本地文件路径 AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left downloadPath = AST#expression#Left downloadFileUrl AST#expression#Right AST#variable_declarator#Right // 设置文件下载保存路径\n "本地文件路径"; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left request = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left GetObjectRequest AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left bucket AST#expression#Right , AST#expression#Left cosPath AST#expression#Right , AST#expression#Left downloadPath AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left request AST#expression#Right . credential AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CosService AST#expression#Right . shared AST#member_expression#Right AST#expression#Right . getCredential AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left task : AST#type_annotation#Left AST#primary_type#Left DownloadTask AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CosXmlBaseService AST#expression#Right . default AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . download AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left request AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 下载进度回调 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left task AST#expression#Right . onProgress AST#member_expression#Right = AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left progress : AST#type_annotation#Left AST#primary_type#Left HttpProgress AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#object_literal#Left { // progress.complete 为当前已下载大小 // progress.target 为总大小 } AST#object_literal#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left task AST#expression#Right . onResult AST#member_expression#Right = AST#expression#Left AST#object_literal#Left { // 下载成功回调 AST#property_assignment#Left AST#property_name#Left onSuccess AST#property_name#Right : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left request AST#parameter#Right , AST#parameter#Left result : AST#type_annotation#Left AST#primary_type#Left CosXmlDownloadTaskResult AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { // todo 下载成功后的逻辑 // 如果下载成功,解析结果 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left result AST#expression#Right AST#unary_expression#Right AST#expression#Right . accessUrl AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left finished AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right , AST#expression#Left "Download result is empty." AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 成功:尝试读取数据 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DebugLog AST#expression#Right . i AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "Download completed. Result: \(result)" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right // 尝试读取下载的文件数据 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . readFileAsUint8Array AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left downloadFileUrl AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Uint8Array AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left error : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left data AST#expression#Right ) AST#block_statement#Left { //下载成功 回调 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left finished AST#expression#Right AST#argument_list#Left ( AST#expression#Left data AST#expression#Right , AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right // 下载完毕后,删除缓存文件 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left FileUtility AST#expression#Right . deleteFileAt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#non_null_assertion_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . accessUrl AST#member_expression#Right AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left finished AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right , AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#property_assignment#Right , //下载失败回调 AST#property_assignment#Left AST#property_name#Left onFail AST#property_name#Right : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left request AST#parameter#Right , AST#parameter#Left error : AST#type_annotation#Left AST#primary_type#Left CosError AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { // 错误处理:下载失败 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DebugLog AST#expression#Right . e AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` Download error: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left finished AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . message AST#member_expression#Right AST#expression#Right ?? AST#expression#Left "Download error" AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right //开始下载 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left task AST#expression#Right . start AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right //暂停任务 // task.pause(); //恢复任务 // task.resume(); //取消任务 // task.cancel(); } AST#block_statement#Right AST#method_declaration#Right // MARK: - 公共方法 AST#method_declaration#Left public async startDownloadIfNeeds AST#parameter_list#Left ( AST#parameter#Left text : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left finished : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Uint8Array AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left error : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { // 校验text是否有效 AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left text AST#expression#Right AST#unary_expression#Right AST#expression#Right || AST#expression#Left text AST#expression#Right AST#binary_expression#Right AST#expression#Right . trim AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left finished ( AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right , AST#expression#Left "text is empty" AST#expression#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#expression_statement#Left AST#expression#Left AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left return AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right // 检查网络连接(需实现checkConnection方法) AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left NetWorkTool AST#expression#Right AST#unary_expression#Right AST#expression#Right . checkInternetConnection AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left finished ( AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right , AST#expression#Left "Network is not connectable" AST#expression#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#expression_statement#Left AST#expression#Left AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left return AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#expression_statement#Left AST#expression#Left const AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left language = AST#expression#Left "zh_cn" AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left const AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left tag = AST#expression#Left AST#template_literal#Left ` language: AST#template_substitution#Left $ { AST#expression#Left language AST#expression#Right } AST#template_substitution#Right , title: AST#template_substitution#Left $ { AST#expression#Left text AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right // 检查是否已经在下载 AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloadingSet AST#member_expression#Right AST#expression#Right . has AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left tag AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DebugLog AST#expression#Right . i AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` Download for AST#template_substitution#Left $ { AST#expression#Left tag AST#expression#Right } AST#template_substitution#Right is already in progress. ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left finished ( AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right , AST#expression#Left "Download is already in progress." AST#expression#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#expression_statement#Left AST#expression#Left AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left return AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right // 标记当前任务正在下载 AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloadingSet AST#member_expression#Right AST#expression#Right . add AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left tag AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DebugLog AST#expression#Right . i AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` Start downloading sound for AST#template_substitution#Left $ { AST#expression#Left tag AST#expression#Right } AST#template_substitution#Right ... ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left logEvent ( AST#expression#Left "Audio_Cos_Download" AST#expression#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right //日志 // 执行下载 AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . downloadData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left text AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left data AST#parameter#Right , AST#parameter#Left error AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { // 下载完成后回调 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left finished AST#expression#Right AST#argument_list#Left ( AST#expression#Left data AST#expression#Right , AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 下载完成,移除标记 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloadingSet AST#member_expression#Right AST#expression#Right . delete AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left tag AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right ///将下载文件读取为data AST#method_declaration#Left readFileAsUint8Array AST#parameter_list#Left ( AST#parameter#Left filePath : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left callback : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Uint8Array AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left error : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { // fs.open(filePath, fs.OpenMode.READ_ONLY, (err, file) => { // if (err) { // callback(null, `打开文件失败: ${err.message}`); // return; // } // // const arrayBuffer = new ArrayBuffer(1024 * 1024); // fs.read(file.fd, arrayBuffer, (readErr, bytesRead) => { // fs.close(file.fd); // if (readErr) { // callback(null, `读取文件失败: ${readErr.message}`); // } else { // callback(new Uint8Array(arrayBuffer, 0, bytesRead), null); // } // }); // }); AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left FileUtility AST#expression#Right . readFileAsUint8Array AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left filePath AST#expression#Right , AST#expression#Left callback AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right /**
* 清空临时文件目录(temp_folder)
*/ AST#method_declaration#Left static clearTempFolder AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left tempDir = AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left getContext AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . cacheDir AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right /CosDownloads ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left FileUtility AST#expression#Right . deleteDirectoryAt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left tempDir AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class CosDownloader {
private static instance: CosDownloader = new CosDownloader();
private downloadingSet: Set<string> = new Set();
private constructor() {
CosService.shared;
}
public static get shared(): CosDownloader {
return this.instance;
}
private async downloadData(text: string, finished: (data: Uint8Array | null, error: string | null) => void) {
const fileName = `${StringPyHelper.convertUnicodeForPinyin(text)}.mp3`;
const context = getContext() as common.UIAbilityContext;
const downloadCacheFolder = `${context.cacheDir}/CosDownloads`;
const downloadFileUrl = `${downloadCacheFolder}/${fileName}`;
createFolderIfNeeds(downloadCacheFolder);
let bucket = CurrentBucket
let cosPath = `${StringEncoder.removedSalt(CosConfig.soundPrefix)}${fileName}`
let downloadPath = downloadFileUrl
let request = new GetObjectRequest(bucket, cosPath, downloadPath);
request.credential = CosService.shared.getCredential()
let task: DownloadTask = CosXmlBaseService.default().download(request);
task.onProgress = (progress: HttpProgress) => {
};
task.onResult = {
onSuccess: (request, result: CosXmlDownloadTaskResult) => {
if (!result.accessUrl){
finished(null, "Download result is empty.")
return
}
DebugLog.i("Download completed. Result: \(result)")
this.readFileAsUint8Array(downloadFileUrl, (data: Uint8Array | null, error: string | null) => {
if (data) {
finished(data, null)
FileUtility.deleteFileAt(result.accessUrl!)
}else{
finished(null, error)
}
})
},
onFail: (request, error: CosError) => {
DebugLog.e(`Download error: ${error.message}`)
finished(null, error.message ?? "Download error")
}
}
task.start();
}
public async startDownloadIfNeeds(
text: string,
finished: (data: Uint8Array | null, error: string | null) => void
) {
if (!text || text.trim().length === 0) {
finished(null, "text is empty");
return;
}
if (!NetWorkTool.checkInternetConnection()) {
finished(null, "Network is not connectable");
return;
}
const language = "zh_cn";
const tag = `language:${language}, title:${text}`;
if (this.downloadingSet.has(tag)) {
DebugLog.i(`Download for ${tag} is already in progress.`);
finished(null, "Download is already in progress.");
return;
}
this.downloadingSet.add(tag);
DebugLog.i(`Start downloading sound for ${tag}...`);
logEvent("Audio_Cos_Download")
await this.downloadData(text, (data, error) => {
finished(data, error);
this.downloadingSet.delete(tag);
});
}
readFileAsUint8Array(filePath: string, callback: (data: Uint8Array | null, error: string | null) => void): void {
const arrayBuffer = new ArrayBuffer(1024 * 1024);
fs.read(file.fd, arrayBuffer, (readErr, bytesRead) => {
fs.close(file.fd);
if (readErr) {
callback(null, `读取文件失败: ${readErr.message}`);
} else {
callback(new Uint8Array(arrayBuffer, 0, bytesRead), null);
}
);
});
FileUtility.readFileAsUint8Array(filePath, callback)
}
static clearTempFolder(): boolean {
const tempDir = `${getContext().cacheDir}/CosDownloads`;
return FileUtility.deleteDirectoryAt(tempDir);
}
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/components/Sounds/Cloud/Download/Downloader/CosDownloader.ets#L21-L191
|
430e2ea038f5abbb039e9c4aa1af3a260f91640b
|
github
|
|
ThePivotPoint/ArkTS-LSP-Server-Plugin.git
|
6231773905435f000d00d94b26504433082ba40b
|
packages/declarations/ets/api/@ohos.file.PhotoPickerComponent.d.ets
|
arkts
|
ClickType. include SELECTED and DESELECTED
@enum { number } ClickType
@syscap SystemCapability.FileManagement.PhotoAccessHelper.Core
@atomicservice
@since 12
|
export declare enum ClickType {
/**
* SELECTED. click to select photos or videos, if click camera item, the clickType is SELECTED.
*
* @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core
* @atomicservice
* @since 12
*/
SELECTED = 0,
/**
* DESELECTED. click to deselect photos or videos
*
* @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core
* @atomicservice
* @since 12
*/
DESELECTED = 1
}
|
AST#export_declaration#Left export AST#ERROR#Left declare AST#ERROR#Right AST#enum_declaration#Left enum ClickType AST#enum_body#Left { /**
* SELECTED. click to select photos or videos, if click camera item, the clickType is SELECTED.
*
* @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core
* @atomicservice
* @since 12
*/ AST#enum_member#Left SELECTED = AST#expression#Left 0 AST#expression#Right AST#enum_member#Right , /**
* DESELECTED. click to deselect photos or videos
*
* @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core
* @atomicservice
* @since 12
*/ AST#enum_member#Left DESELECTED = AST#expression#Left 1 AST#expression#Right AST#enum_member#Right } AST#enum_body#Right AST#enum_declaration#Right AST#export_declaration#Right
|
export declare enum ClickType {
SELECTED = 0,
DESELECTED = 1
}
|
https://github.com/ThePivotPoint/ArkTS-LSP-Server-Plugin.git/blob/6231773905435f000d00d94b26504433082ba40b/packages/declarations/ets/api/@ohos.file.PhotoPickerComponent.d.ets#L559-L576
|
40b03532a8f7c2740650b1f802a75ab5a6272bfe
|
github
|
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_utils/src/main/ets/crypto/DES.ets
|
arkts
|
decryptCBCSync
|
解密(CBC模式),同步
@param data 加密或者解密的数据。data不能为null。
@param symKey 指定加密或解密的密钥。
@param params 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。
@param transformation 待生成Cipher的算法名称(含密钥长度)、加密模式以及填充方法的组合(3DES192|ECB|PKCS7、3DES192|CBC|PKCS7、等)。
@returns
|
static decryptCBCSync(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey,
params: cryptoFramework.ParamsSpec | null, transformation: string = '3DES192|CBC|PKCS7'): cryptoFramework.DataBlob {
return DES.decryptSync(data, symKey, params, transformation);
}
|
AST#method_declaration#Left static decryptCBCSync AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . DataBlob AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left symKey : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . SymKey AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left params : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . ParamsSpec AST#qualified_type#Right AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left transformation : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '3DES192|CBC|PKCS7' AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . DataBlob AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DES AST#expression#Right . decryptSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left data AST#expression#Right , AST#expression#Left symKey AST#expression#Right , AST#expression#Left params AST#expression#Right , AST#expression#Left transformation AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static decryptCBCSync(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey,
params: cryptoFramework.ParamsSpec | null, transformation: string = '3DES192|CBC|PKCS7'): cryptoFramework.DataBlob {
return DES.decryptSync(data, symKey, params, transformation);
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/crypto/DES.ets#L128-L131
|
2347a4d6bf233e3b307e59a88a03c3bbe521958d
|
gitee
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_utils/src/main/ets/utils/CrashUtil.ets
|
arkts
|
TODO 全局异常捕获,崩溃日志收集
author: 桃花镇童长老ᥫ᭡
since: 2024/05/01
|
export class CrashUtil {
private static observerId: number | undefined = undefined;
private static errorFilePath: string | undefined = undefined; //错误日志文件路径
/**
* 注册错误观测器,该方法建议在Ability里调用。
* 注册后可以捕获到应用产生的js crash,应用崩溃时进程不会退出。将异常信息写入本地文件。
* @param callback 异常回调,可以在该回调里上传异常信息;
*/
static onHandled(callback: Callback<ExceptionInfo>) {
try {
if (CrashUtil.observerId === undefined) {
CrashUtil.observerId = errorManager.on('error', {
//将在js运行时引发用户未捕获的异常时调用。
onUnhandledException(errMsg) {},
//将在js运行时引发用户未捕获的异常时调用。
onException(errObject) {
let info: ExceptionInfo = new ExceptionInfo(errObject.name, errObject.message, errObject.stack ?? "");
let filePath = CrashUtil.getFilePath();
let infoJson = JSON.stringify(info, null, 2);
CrashUtil.writeStr(filePath, infoJson);
callback(info);
}
});
}
} catch (err) {
LogUtil.error(err);
}
}
/**
* 注销错误观测器。
*/
static onDestroy() {
try {
if (CrashUtil.observerId !== undefined) {
errorManager.off('error', CrashUtil.observerId, (err: BusinessError) => {
LogUtil.error('observerId: '+CrashUtil.observerId)
if (err) {
LogUtil.error(err);
return
}
CrashUtil.observerId = undefined;
});
}
} catch (err) {
LogUtil.error(err);
}
}
/**
* 判断错误观测器是否存在
* @returns
*/
static isHandled(): boolean {
return CrashUtil.observerId !== undefined;
}
/**
* 获取日志文件路径(用于读取日志文件、导出日志文件)。
* @returns
*/
static getFilePath(): string {
if (CrashUtil.errorFilePath === undefined) {
CrashUtil.errorFilePath = FileUtil.getFilesDirPath("harmony_utils_log", "ExceptionLog.json"); //错误日志文件路径
}
return CrashUtil.errorFilePath;
}
/**
* 判断日志文件是否存在
* @returns
*/
static access(): boolean {
const path = CrashUtil.getFilePath();
return FileUtil.accessSync(path);
}
/**
* 删除日志文件
* @returns
*/
static delete() {
if (CrashUtil.access()) {
const path = CrashUtil.getFilePath();
FileUtil.unlinkSync(path);
}
}
/**
* 获取异常日志的JSON字符串。
*/
static async getExceptionJson(): Promise<string> {
const errorFilePath = CrashUtil.getFilePath();
if (FileUtil.accessSync(errorFilePath)) {
return await FileUtil.readText(errorFilePath);
}
return '';
}
/**
* 获取异常日志的集合。
*/
static async getExceptionList(): Promise<ExceptionInfo[]> {
let json = await CrashUtil.getExceptionJson();
if (StrUtil.isNotEmpty(json)) {
return JSONUtil.jsonToArray<ExceptionInfo>(json);
}
return [];
}
/**
* 启用应用恢复功能,参数按顺序填入。该接口调用后,应用从启动器启动时第一个Ability支持恢复。
* @param restart RestartFlag 应用重启标志。
* ALWAYS_RESTART 0 总是重启应用。
* RESTART_WHEN_JS_CRASH 0x0001 发生JS_CRASH时重启应用。
* RESTART_WHEN_APP_FREEZE 0x0002 发生APP_FREEZE时重启应用。
* NO_RESTART 0xFFFF 总是不重启应用。
* @param saveOccasion SaveOccasionFlag 保存条件标志
* SAVE_WHEN_ERROR 0x0001 当发生应用故障时保存。
* SAVE_WHEN_BACKGROUND 0x0002 当应用切入后台时保存。
* @param saveMode SaveModeFlag 状态保存标志
* SAVE_WITH_FILE 0x0001 每次状态保存都会写入到本地文件缓存。
* SAVE_WITH_SHARED_MEMORY 0x0002 状态先保存在内存中,应用故障退出时写入到本地文件缓存。
*/
static enableAppRecovery(restart: appRecovery.RestartFlag = appRecovery.RestartFlag.ALWAYS_RESTART,
saveOccasion: appRecovery.SaveOccasionFlag = appRecovery.SaveOccasionFlag.SAVE_WHEN_ERROR,
saveMode: appRecovery.SaveModeFlag.SAVE_WITH_FILE = appRecovery.SaveModeFlag.SAVE_WITH_FILE) {
appRecovery.enableAppRecovery(restart, saveOccasion, saveMode);
}
/**
* 重启APP,并拉起应用启动时第一个Ability,可以配合errorManager相关接口使用。
* 如果该Ability存在已经保存的状态,这些状态数据会在Ability的OnCreate生命周期回调的want参数中作为wantParam属性传入。
* API10时将启动由setRestartWant指定的Ability。如果没有指定则按以下规则启动:
* 如果当前应用前台的Ability支持恢复,则重新拉起该Ability。
* 如果存在多个支持恢复的Ability处于前台,则只拉起最后一个。
* 如果没有Ability处于前台,则不拉起。
*/
static restartApp() {
appRecovery.restartApp();
}
/**
* 设置下次恢复主动拉起场景下的Ability。该Ability必须为当前包下的UIAbility。
* @param want 通过设置Want中"bundleName"和"abilityName"字段来指定恢复重启的Ability。
*/
static setRestartWant(want: Want) {
appRecovery.setRestartWant(want);
}
/**
* 保存当前App状态 或 主动保存Ability的状态,这个状态将在下次恢复启动时使用。可以配合errorManager相关接口使用
* @param context UIAbilityContext 需要保存状态的UIAbility所对应的context。
* @returns
*/
static saveAppState(context?: common.UIAbilityContext): boolean {
if (context) {
return appRecovery.saveAppState(context); //主动保存Ability的状态
} else {
return appRecovery.saveAppState(); //保存当前App状态
}
}
/**
* 将数据写入文件,并关闭文件。
*/
private static writeStr(path: string, str: string): number {
const file = FileUtil.openSync(path);
let offset = FileUtil.statSync(file.fd).size;
if (offset === 0) {
str = `[${str}]`;
} else {
offset = offset - 1;
str = `,${str}]`;
}
const options: WriteOptions = { offset: offset, encoding: 'utf-8' };
let result = FileUtil.writeSync(file.fd, str, options);
FileUtil.closeSync(file.fd); //关闭文件
return result;
}
}
|
AST#export_declaration#Left export AST#class_declaration#Left class CrashUtil AST#class_body#Left { AST#property_declaration#Left private static observerId : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left number AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left undefined AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private static errorFilePath : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left undefined AST#expression#Right ; AST#property_declaration#Right //错误日志文件路径 /**
* 注册错误观测器,该方法建议在Ability里调用。
* 注册后可以捕获到应用产生的js crash,应用崩溃时进程不会退出。将异常信息写入本地文件。
* @param callback 异常回调,可以在该回调里上传异常信息;
*/ AST#method_declaration#Left static onHandled AST#parameter_list#Left ( AST#parameter#Left callback : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Callback AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left ExceptionInfo AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CrashUtil AST#expression#Right . observerId AST#member_expression#Right AST#expression#Right === AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left CrashUtil AST#expression#Right . observerId AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left errorManager AST#expression#Right . on AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'error' AST#expression#Right , AST#expression#Left AST#object_literal#Left { //将在js运行时引发用户未捕获的异常时调用。 AST#property_assignment#Left AST#property_name#Left onUnhandledException AST#property_name#Right AST#parameter_list#Left ( AST#parameter#Left errMsg AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { } AST#block_statement#Right AST#property_assignment#Right , //将在js运行时引发用户未捕获的异常时调用。 AST#property_assignment#Left AST#property_name#Left onException AST#property_name#Right AST#parameter_list#Left ( AST#parameter#Left errObject AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left info : AST#type_annotation#Left AST#primary_type#Left ExceptionInfo AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ExceptionInfo AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left errObject AST#expression#Right . name AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left errObject AST#expression#Right . message AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left errObject AST#expression#Right . stack AST#member_expression#Right AST#expression#Right ?? AST#expression#Left "" AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left filePath = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CrashUtil AST#expression#Right . getFilePath AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left infoJson = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left info AST#expression#Right , AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right , AST#expression#Left 2 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CrashUtil AST#expression#Right . writeStr AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left filePath AST#expression#Right , AST#expression#Left infoJson AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left callback AST#expression#Right AST#argument_list#Left ( AST#expression#Left info AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LogUtil AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 注销错误观测器。
*/ AST#method_declaration#Left static onDestroy AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CrashUtil AST#expression#Right . observerId AST#member_expression#Right AST#expression#Right !== AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left errorManager AST#expression#Right . off AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'error' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left CrashUtil AST#expression#Right . observerId AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err : AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LogUtil AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'observerId: ' AST#expression#Right + AST#expression#Left CrashUtil AST#expression#Right AST#binary_expression#Right AST#expression#Right . observerId AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left err AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LogUtil AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left CrashUtil AST#expression#Right . observerId AST#member_expression#Right = AST#expression#Left undefined AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LogUtil AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 判断错误观测器是否存在
* @returns
*/ AST#method_declaration#Left static isHandled AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CrashUtil AST#expression#Right . observerId AST#member_expression#Right AST#expression#Right !== AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 获取日志文件路径(用于读取日志文件、导出日志文件)。
* @returns
*/ AST#method_declaration#Left static getFilePath AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CrashUtil AST#expression#Right . errorFilePath AST#member_expression#Right AST#expression#Right === AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left CrashUtil AST#expression#Right . errorFilePath AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left FileUtil AST#expression#Right . getFilesDirPath AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "harmony_utils_log" AST#expression#Right , AST#expression#Left "ExceptionLog.json" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right //错误日志文件路径 } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#expression_statement#Left AST#expression#Left return AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CrashUtil AST#expression#Right . errorFilePath AST#member_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right /**
* 判断日志文件是否存在
* @returns
*/ AST#method_declaration#Left static access AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left path = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CrashUtil AST#expression#Right . getFilePath AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left FileUtil AST#expression#Right . accessSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left path AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 删除日志文件
* @returns
*/ AST#method_declaration#Left static delete AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CrashUtil AST#expression#Right . access AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left path = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CrashUtil AST#expression#Right . getFilePath AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left FileUtil AST#expression#Right . unlinkSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left path AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 获取异常日志的JSON字符串。
*/ AST#method_declaration#Left static async getExceptionJson AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left errorFilePath = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CrashUtil AST#expression#Right . getFilePath AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left FileUtil AST#expression#Right . accessSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left errorFilePath AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left FileUtil AST#expression#Right AST#await_expression#Right AST#expression#Right . readText AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left errorFilePath AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left '' AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 获取异常日志的集合。
*/ AST#method_declaration#Left static async getExceptionList AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left ExceptionInfo [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left json = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left CrashUtil AST#expression#Right AST#await_expression#Right AST#expression#Right . getExceptionJson AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left StrUtil AST#expression#Right . isNotEmpty AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left json AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSONUtil AST#expression#Right . jsonToArray AST#member_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left ExceptionInfo AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left json AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 启用应用恢复功能,参数按顺序填入。该接口调用后,应用从启动器启动时第一个Ability支持恢复。
* @param restart RestartFlag 应用重启标志。
* ALWAYS_RESTART 0 总是重启应用。
* RESTART_WHEN_JS_CRASH 0x0001 发生JS_CRASH时重启应用。
* RESTART_WHEN_APP_FREEZE 0x0002 发生APP_FREEZE时重启应用。
* NO_RESTART 0xFFFF 总是不重启应用。
* @param saveOccasion SaveOccasionFlag 保存条件标志
* SAVE_WHEN_ERROR 0x0001 当发生应用故障时保存。
* SAVE_WHEN_BACKGROUND 0x0002 当应用切入后台时保存。
* @param saveMode SaveModeFlag 状态保存标志
* SAVE_WITH_FILE 0x0001 每次状态保存都会写入到本地文件缓存。
* SAVE_WITH_SHARED_MEMORY 0x0002 状态先保存在内存中,应用故障退出时写入到本地文件缓存。
*/ AST#method_declaration#Left static enableAppRecovery AST#parameter_list#Left ( AST#parameter#Left restart : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left appRecovery . RestartFlag AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left appRecovery AST#expression#Right . RestartFlag AST#member_expression#Right AST#expression#Right . ALWAYS_RESTART AST#member_expression#Right AST#expression#Right AST#parameter#Right , AST#parameter#Left saveOccasion : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left appRecovery . SaveOccasionFlag AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left appRecovery AST#expression#Right . SaveOccasionFlag AST#member_expression#Right AST#expression#Right . SAVE_WHEN_ERROR AST#member_expression#Right AST#expression#Right AST#parameter#Right , AST#parameter#Left saveMode : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left appRecovery . SaveModeFlag . SAVE_WITH_FILE AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left appRecovery AST#expression#Right . SaveModeFlag AST#member_expression#Right AST#expression#Right . SAVE_WITH_FILE AST#member_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left appRecovery AST#expression#Right . enableAppRecovery AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left restart AST#expression#Right , AST#expression#Left saveOccasion AST#expression#Right , AST#expression#Left saveMode AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right /**
* 重启APP,并拉起应用启动时第一个Ability,可以配合errorManager相关接口使用。
* 如果该Ability存在已经保存的状态,这些状态数据会在Ability的OnCreate生命周期回调的want参数中作为wantParam属性传入。
* API10时将启动由setRestartWant指定的Ability。如果没有指定则按以下规则启动:
* 如果当前应用前台的Ability支持恢复,则重新拉起该Ability。
* 如果存在多个支持恢复的Ability处于前台,则只拉起最后一个。
* 如果没有Ability处于前台,则不拉起。
*/ AST#method_declaration#Left static restartApp AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left appRecovery AST#expression#Right . restartApp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right /**
* 设置下次恢复主动拉起场景下的Ability。该Ability必须为当前包下的UIAbility。
* @param want 通过设置Want中"bundleName"和"abilityName"字段来指定恢复重启的Ability。
*/ AST#method_declaration#Left static setRestartWant AST#parameter_list#Left ( AST#parameter#Left want : AST#type_annotation#Left AST#primary_type#Left Want AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left appRecovery AST#expression#Right . setRestartWant AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left want AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right /**
* 保存当前App状态 或 主动保存Ability的状态,这个状态将在下次恢复启动时使用。可以配合errorManager相关接口使用
* @param context UIAbilityContext 需要保存状态的UIAbility所对应的context。
* @returns
*/ AST#method_declaration#Left static saveAppState AST#parameter_list#Left ( AST#parameter#Left context ? : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . UIAbilityContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left context AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left appRecovery AST#expression#Right . saveAppState AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right //主动保存Ability的状态 } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left appRecovery AST#expression#Right . saveAppState AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right //保存当前App状态 } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /**
* 将数据写入文件,并关闭文件。
*/ AST#method_declaration#Left private static writeStr AST#parameter_list#Left ( AST#parameter#Left path : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left str : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left file = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left FileUtil AST#expression#Right . openSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left path AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left offset = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left FileUtil AST#expression#Right . statSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left file AST#expression#Right . fd AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . size AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left offset AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left str = AST#expression#Left AST#template_literal#Left ` [ AST#template_substitution#Left $ { AST#expression#Left str AST#expression#Right } AST#template_substitution#Right ] ` AST#template_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left offset = AST#expression#Left AST#binary_expression#Left AST#expression#Left offset AST#expression#Right - AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left str = AST#expression#Left AST#template_literal#Left ` , AST#template_substitution#Left $ { AST#expression#Left str AST#expression#Right } AST#template_substitution#Right ] ` AST#template_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left options : AST#type_annotation#Left AST#primary_type#Left WriteOptions AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left offset AST#property_name#Right : AST#expression#Left offset AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left encoding AST#property_name#Right : AST#expression#Left 'utf-8' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left result = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left FileUtil AST#expression#Right . writeSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left file AST#expression#Right . fd AST#member_expression#Right AST#expression#Right , AST#expression#Left str AST#expression#Right , AST#expression#Left options AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left FileUtil AST#expression#Right . closeSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left file AST#expression#Right . fd AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right //关闭文件 AST#statement#Left AST#return_statement#Left return AST#expression#Left result AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class CrashUtil {
private static observerId: number | undefined = undefined;
private static errorFilePath: string | undefined = undefined;
static onHandled(callback: Callback<ExceptionInfo>) {
try {
if (CrashUtil.observerId === undefined) {
CrashUtil.observerId = errorManager.on('error', {
onUnhandledException(errMsg) {},
onException(errObject) {
let info: ExceptionInfo = new ExceptionInfo(errObject.name, errObject.message, errObject.stack ?? "");
let filePath = CrashUtil.getFilePath();
let infoJson = JSON.stringify(info, null, 2);
CrashUtil.writeStr(filePath, infoJson);
callback(info);
}
});
}
} catch (err) {
LogUtil.error(err);
}
}
static onDestroy() {
try {
if (CrashUtil.observerId !== undefined) {
errorManager.off('error', CrashUtil.observerId, (err: BusinessError) => {
LogUtil.error('observerId: '+CrashUtil.observerId)
if (err) {
LogUtil.error(err);
return
}
CrashUtil.observerId = undefined;
});
}
} catch (err) {
LogUtil.error(err);
}
}
static isHandled(): boolean {
return CrashUtil.observerId !== undefined;
}
static getFilePath(): string {
if (CrashUtil.errorFilePath === undefined) {
CrashUtil.errorFilePath = FileUtil.getFilesDirPath("harmony_utils_log", "ExceptionLog.json");
}
return CrashUtil.errorFilePath;
}
static access(): boolean {
const path = CrashUtil.getFilePath();
return FileUtil.accessSync(path);
}
static delete() {
if (CrashUtil.access()) {
const path = CrashUtil.getFilePath();
FileUtil.unlinkSync(path);
}
}
static async getExceptionJson(): Promise<string> {
const errorFilePath = CrashUtil.getFilePath();
if (FileUtil.accessSync(errorFilePath)) {
return await FileUtil.readText(errorFilePath);
}
return '';
}
static async getExceptionList(): Promise<ExceptionInfo[]> {
let json = await CrashUtil.getExceptionJson();
if (StrUtil.isNotEmpty(json)) {
return JSONUtil.jsonToArray<ExceptionInfo>(json);
}
return [];
}
static enableAppRecovery(restart: appRecovery.RestartFlag = appRecovery.RestartFlag.ALWAYS_RESTART,
saveOccasion: appRecovery.SaveOccasionFlag = appRecovery.SaveOccasionFlag.SAVE_WHEN_ERROR,
saveMode: appRecovery.SaveModeFlag.SAVE_WITH_FILE = appRecovery.SaveModeFlag.SAVE_WITH_FILE) {
appRecovery.enableAppRecovery(restart, saveOccasion, saveMode);
}
static restartApp() {
appRecovery.restartApp();
}
static setRestartWant(want: Want) {
appRecovery.setRestartWant(want);
}
static saveAppState(context?: common.UIAbilityContext): boolean {
if (context) {
return appRecovery.saveAppState(context);
} else {
return appRecovery.saveAppState();
}
}
private static writeStr(path: string, str: string): number {
const file = FileUtil.openSync(path);
let offset = FileUtil.statSync(file.fd).size;
if (offset === 0) {
str = `[${str}]`;
} else {
offset = offset - 1;
str = `,${str}]`;
}
const options: WriteOptions = { offset: offset, encoding: 'utf-8' };
let result = FileUtil.writeSync(file.fd, str, options);
FileUtil.closeSync(file.fd);
return result;
}
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/CrashUtil.ets#L33-L228
|
ca516da6be87658d4f8747138a8383b17fd7b6b5
|
gitee
|
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/components/common/EmptyView.ets
|
arkts
|
ErrorView
|
通用错误状态组件
|
@Component
export struct ErrorView {
@Prop title: string = '出错了';
@Prop message: string = '请稍后重试';
@Prop showRetry: boolean = true;
onRetry?: () => void;
build() {
EmptyView({
message: this.title,
description: this.message,
icon: $r('app.media.ic_error'),
showAction: this.showRetry,
actionText: '重试',
onAction: this.onRetry
})
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct ErrorView AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right title : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '出错了' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right message : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '请稍后重试' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right showRetry : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left onRetry ? : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left EmptyView ( AST#component_parameters#Left { AST#component_parameter#Left message : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . title AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left description : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . message AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left icon : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.ic_error' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left showAction : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showRetry AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left actionText : AST#expression#Left '重试' AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left onAction : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . onRetry AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@Component
export struct ErrorView {
@Prop title: string = '出错了';
@Prop message: string = '请稍后重试';
@Prop showRetry: boolean = true;
onRetry?: () => void;
build() {
EmptyView({
message: this.title,
description: this.message,
icon: $r('app.media.ic_error'),
showAction: this.showRetry,
actionText: '重试',
onAction: this.onRetry
})
}
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/components/common/EmptyView.ets#L170-L188
|
58a3c7f019baac494ce1febbf81c12ada68d7bb8
|
github
|
KoStudio/ArkTS-WordTree.git
|
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
|
entry/src/main/ets/models/managers/member/MemberManager.ets
|
arkts
|
get
|
格式化过期时间字符串(对应Swift中的expireDateString计算属性)
|
get expireDateString(): string {
if (this.isDebug() && this.debugMember) {
return "<DEBUG>会员无限期";
}
if (this.expireDate) {
// 这里需要实现日期格式化,暂时返回简单字符串
return DateUtils.toDateTimeString(this.expireDate)
}
return "";
}
|
AST#method_declaration#Left get AST#ERROR#Left expireDateStr in g AST#ERROR#Right AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isDebug AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . debugMember AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left "<DEBUG>会员无限期" AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . expireDate AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { // 这里需要实现日期格式化,暂时返回简单字符串 AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DateUtils AST#expression#Right . toDateTimeString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . expireDate AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left "" AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
get expireDateString(): string {
if (this.isDebug() && this.debugMember) {
return "<DEBUG>会员无限期";
}
if (this.expireDate) {
return DateUtils.toDateTimeString(this.expireDate)
}
return "";
}
|
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/managers/member/MemberManager.ets#L141-L152
|
2620749970d3399c0281494591eaf1579bb1df07
|
github
|
harmonyos_samples/BestPracticeSnippets
|
490ea539a6d4427dd395f3dac3cf4887719f37af
|
LoadPerformanceInWeb/entry/src/main/ets/pages/SetSchemeHandler.ets
|
arkts
|
onCreate
|
[Start set_scheme_handler] EntryAbility.ets
|
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
// register CustomSchemes
testNapi.registerCustomSchemes();
// initializeWebEngine
webview.WebviewController.initializeWebEngine();
// set SchemeHandler。
testNapi.setSchemeHandler();
}
|
AST#method_declaration#Left onCreate AST#parameter_list#Left ( AST#parameter#Left want : AST#type_annotation#Left AST#primary_type#Left Want AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left launchParam : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left AbilityConstant . LaunchParam AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { // register CustomSchemes AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left testNapi AST#expression#Right . registerCustomSchemes AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right // initializeWebEngine AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left webview AST#expression#Right . WebviewController AST#member_expression#Right AST#expression#Right . initializeWebEngine AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right // set SchemeHandler。 AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left testNapi AST#expression#Right . setSchemeHandler AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
testNapi.registerCustomSchemes();
webview.WebviewController.initializeWebEngine();
testNapi.setSchemeHandler();
}
|
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/LoadPerformanceInWeb/entry/src/main/ets/pages/SetSchemeHandler.ets#L9-L16
|
1d8a8984d14df29cd2608eef84a58b0c50671b38
|
gitee
|
harmonyos-cases/cases
|
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
|
CommonAppDevelopment/feature/componentstack/src/main/ets/model/IconModel.ets
|
arkts
|
图标的数据类
|
export class IconDataModel {
id: number;
span: number;
icon: ResourceStr;
title: ResourceStr;
constructor(id: number, span: number, icon: ResourceStr, title: ResourceStr) {
this.id = id;
this.span = span;
this.icon = icon;
this.title = title;
}
}
|
AST#export_declaration#Left export AST#class_declaration#Left class IconDataModel AST#class_body#Left { AST#property_declaration#Left id : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left span : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left icon : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left title : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left id : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left span : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left icon : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left title : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . id AST#member_expression#Right = AST#expression#Left id AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . span AST#member_expression#Right = AST#expression#Left span AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . icon AST#member_expression#Right = AST#expression#Left icon AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . title AST#member_expression#Right = AST#expression#Left title AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class IconDataModel {
id: number;
span: number;
icon: ResourceStr;
title: ResourceStr;
constructor(id: number, span: number, icon: ResourceStr, title: ResourceStr) {
this.id = id;
this.span = span;
this.icon = icon;
this.title = title;
}
}
|
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/componentstack/src/main/ets/model/IconModel.ets#L19-L31
|
809d2fc401e34ace28023015bba0f98b5f4d2984
|
gitee
|
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/UI/CalendarViewSwitch/casesfeature/calendarswitch/src/main/ets/customcalendar/components/CustomCalendar.ets
|
arkts
|
DayInfo
|
一天的信息
|
@Observed
export class DayInfo {
public year: number; // 年
public month: number; // 月
public date: number; // 日
public week: number; // 月视图周信息。月视图上点击上个月日期进行月份切换时需要用到
constructor(year: number, month: number, date: number, week: number) {
this.year = year;
this.month = month;
this.date = date;
this.week = week;
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Observed AST#decorator#Right export class DayInfo AST#class_body#Left { AST#property_declaration#Left public year : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right // 年 AST#property_declaration#Left public month : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right // 月 AST#property_declaration#Left public date : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right // 日 AST#property_declaration#Left public week : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right // 月视图周信息。月视图上点击上个月日期进行月份切换时需要用到 AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left year : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left month : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left date : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left week : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . year AST#member_expression#Right = AST#expression#Left year AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . month AST#member_expression#Right = AST#expression#Left month AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . date AST#member_expression#Right = AST#expression#Left date AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . week AST#member_expression#Right = AST#expression#Left week AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right } AST#class_body#Right AST#decorated_export_declaration#Right
|
@Observed
export class DayInfo {
public year: number;
public month: number;
public date: number;
public week: number; 视图周信息。月视图上点击上个月日期进行月份切换时需要用到
constructor(year: number, month: number, date: number, week: number) {
this.year = year;
this.month = month;
this.date = date;
this.week = week;
}
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/UI/CalendarViewSwitch/casesfeature/calendarswitch/src/main/ets/customcalendar/components/CustomCalendar.ets#L226-L239
|
ece9d7f7dae7bf0566d52f405cf17da0ad1ece08
|
gitee
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
harmonyos/src/main/ets/services/analytics/AnalyticsService.ets
|
arkts
|
祝福语统计
|
export interface GreetingStats {
totalGenerated: number;
totalUsed: number;
averageRating: number;
popularStyles: { style: string; count: number; percentage: number }
|
AST#export_declaration#Left export AST#interface_declaration#Left interface GreetingStats AST#ERROR#Left { AST#type_member#Left totalGenerated : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left totalUsed : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left averageRating : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; popularStyles : AST#ERROR#Right AST#object_type#Left { AST#type_member#Left style : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left count : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left percentage : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
|
export interface GreetingStats {
totalGenerated: number;
totalUsed: number;
averageRating: number;
popularStyles: { style: string; count: number; percentage: number }
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/harmonyos/src/main/ets/services/analytics/AnalyticsService.ets#L55-L59
|
bae2d6fae8a5dca87821c8daac70616717b9aa58
|
github
|
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_utils/src/main/ets/utils/PasteboardUtil.ets
|
arkts
|
setDataPixelMap
|
将PixelMap数据写入系统剪贴板,使用Promise异步回调。
@param pixelMap PixelMap
@returns
|
static async setDataPixelMap(pixelMap: image.PixelMap): Promise<void> {
PasteboardUtil.setData(pasteboard.MIMETYPE_PIXELMAP, pixelMap);
}
|
AST#method_declaration#Left static async setDataPixelMap AST#parameter_list#Left ( AST#parameter#Left pixelMap : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left image . PixelMap AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left PasteboardUtil AST#expression#Right . setData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left pasteboard AST#expression#Right . MIMETYPE_PIXELMAP AST#member_expression#Right AST#expression#Right , AST#expression#Left pixelMap AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
static async setDataPixelMap(pixelMap: image.PixelMap): Promise<void> {
PasteboardUtil.setData(pasteboard.MIMETYPE_PIXELMAP, pixelMap);
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/PasteboardUtil.ets#L258-L260
|
00c6c16923a0e8b8b2fc445ff2ff9c8fbe73e1d1
|
gitee
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_utils/src/main/ets/utils/WindowUtil.ets
|
arkts
|
isFocused
|
判断当前窗口是否已获焦。
@param windowClass 不传该值,默认主窗口。
@returns
|
static isFocused(windowClass: window.Window = AppUtil.getMainWindow()): boolean {
return windowClass.isFocused();
}
|
AST#method_declaration#Left static isFocused AST#parameter_list#Left ( AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . isFocused AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static isFocused(windowClass: window.Window = AppUtil.getMainWindow()): boolean {
return windowClass.isFocused();
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/WindowUtil.ets#L345-L347
|
1e83cea8c4869061f31bc0d50d883a2765de61c3
|
gitee
|
openharmony/codelabs
|
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
|
ETSUI/CanvasComponent/entry/src/main/ets/viewmodel/FillArcData.ets
|
arkts
|
The constructor of FillArcData.
@param x The x-axis coordinate of the center of the arc.
@param y The y-axis coordinate of the center of the arc.
@param radius Radius of the arc.
@param startAngle The start point of the arc, in radians.
@param endAngle The end point of the arc, in radians.
@param fillColor The fill color of the arc.
|
constructor(x: number, y: number, radius: number, startAngle: number, endAngle: number) {
this.x = x;
this.y = y;
this.radius = radius;
this.startAngle = startAngle;
this.endAngle = endAngle;
}
|
AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left x : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left y : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left radius : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left startAngle : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left endAngle : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . x AST#member_expression#Right = AST#expression#Left x AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . y AST#member_expression#Right = AST#expression#Left y AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . radius AST#member_expression#Right = AST#expression#Left radius AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . startAngle AST#member_expression#Right = AST#expression#Left startAngle AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . endAngle AST#member_expression#Right = AST#expression#Left endAngle AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right
|
constructor(x: number, y: number, radius: number, startAngle: number, endAngle: number) {
this.x = x;
this.y = y;
this.radius = radius;
this.startAngle = startAngle;
this.endAngle = endAngle;
}
|
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/ETSUI/CanvasComponent/entry/src/main/ets/viewmodel/FillArcData.ets#L55-L61
|
0536068a164819e03144f6f874fa709034e6cf5b
|
gitee
|
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_utils/src/main/ets/utils/CrashUtil.ets
|
arkts
|
access
|
判断日志文件是否存在
@returns
|
static access(): boolean {
const path = CrashUtil.getFilePath();
return FileUtil.accessSync(path);
}
|
AST#method_declaration#Left static access AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left path = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CrashUtil AST#expression#Right . getFilePath AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left FileUtil AST#expression#Right . accessSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left path AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static access(): boolean {
const path = CrashUtil.getFilePath();
return FileUtil.accessSync(path);
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/CrashUtil.ets#L111-L114
|
65a247343d13627289ca56a6ac44a0335572ccf7
|
gitee
|
openharmony-tpc/ohos_mpchart
|
4fb43a7137320ef2fee2634598f53d93975dfb4a
|
library/src/main/ets/components/components/YAxis.ets
|
arkts
|
getSpaceBottom
|
Returns the bottom axis space in percent of the full range. Default 10f
@return
|
public getSpaceBottom(): number {
return this.mSpacePercentBottom;
}
|
AST#method_declaration#Left public getSpaceBottom AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mSpacePercentBottom AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
public getSpaceBottom(): number {
return this.mSpacePercentBottom;
}
|
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/components/YAxis.ets#L362-L364
|
02828dee88579de781586301c20652502b14b2ec
|
gitee
|
wangjinyuan/JS-TS-ArkTS-database.git
|
a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26
|
npm/alprazolamdiv/11.5.1/package/src/structures/ReactionCollector.ets
|
arkts
|
handle
|
应用约束1:明确返回类型
|
handle(reaction: MessageReaction): { key: Snowflake, value: MessageReaction } | null {
if (reaction.message.id !== this.message.id) return null;
return {
key: reaction.emoji.id || reaction.emoji.name,
value: reaction,
};
}
|
AST#method_declaration#Left handle AST#parameter_list#Left ( AST#parameter#Left reaction : AST#type_annotation#Left AST#primary_type#Left MessageReaction AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#ERROR#Left : AST#ERROR#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left key AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left : AST#type_annotation#Left AST#primary_type#Left Snowflake AST#primary_type#Right AST#type_annotation#Right , value : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left MessageReaction AST#primary_type#Right AST#ERROR#Left } AST#ERROR#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right { AST#ERROR#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left reaction AST#expression#Right . message AST#member_expression#Right AST#expression#Right . id AST#member_expression#Right AST#expression#Right !== AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . message AST#member_expression#Right AST#expression#Right . id AST#member_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left key AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left reaction AST#expression#Right . emoji AST#member_expression#Right AST#expression#Right . id AST#member_expression#Right AST#expression#Right || AST#expression#Left reaction AST#expression#Right AST#binary_expression#Right AST#expression#Right . emoji AST#member_expression#Right AST#expression#Right . name AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left value AST#property_name#Right : AST#expression#Left reaction AST#expression#Right AST#property_assignment#Right , } AST#object_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
handle(reaction: MessageReaction): { key: Snowflake, value: MessageReaction } | null {
if (reaction.message.id !== this.message.id) return null;
return {
key: reaction.emoji.id || reaction.emoji.name,
value: reaction,
};
}
|
https://github.com/wangjinyuan/JS-TS-ArkTS-database.git/blob/a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26/npm/alprazolamdiv/11.5.1/package/src/structures/ReactionCollector.ets#L34-L40
|
fcbb853204409a486e599e2f66af12709a88efd8
|
github
|
Joker-x-dev/HarmonyKit.git
|
f97197ce157df7f303244fba42e34918306dfb08
|
core/util/Index.ets
|
arkts
|
PreferencesUtil
|
@file util 模块统一导出
@author Joker.X
|
export { PreferencesUtil } from "./src/main/ets/storage/PreferencesUtil";
|
AST#export_declaration#Left export { PreferencesUtil } from "./src/main/ets/storage/PreferencesUtil" ; AST#export_declaration#Right
|
export { PreferencesUtil } from "./src/main/ets/storage/PreferencesUtil";
|
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/util/Index.ets#L6-L6
|
5fbf5bf9f479a9d8dcda77a2c42f21d226a06b07
|
github
|
851432669/Smart-Home-ArkTs-Hi3861.git
|
0451f85f072ed3281cc23d9cdc2843d79f60f975
|
entry/src/main/ets/common/utils/GlobalDataManager.ets
|
arkts
|
deleteRoom
|
删除房间
|
deleteRoom(roomId: number): boolean {
// 不允许删除"全屋"选项(id=0)
if (roomId === 0) {
return false;
}
const index = this.rooms.findIndex(room => room.id === roomId);
if (index === -1) {
return false;
}
// 如果要删除的房间当前被选中,则选中"全屋"
if (this.rooms[index].isSelected) {
this.selectRoom(0);
}
// 删除房间
this.rooms.splice(index, 1);
// 重新分配ID
this.rooms = this.rooms.map((room, idx) => ({
id: idx,
name: room.name,
isSelected: room.isSelected
} as RoomItem));
// 更新用户房间数量
this.updateRoomCount(this.rooms.length - 1); // 减去"全屋"选项
console.info(`房间已删除, ID: ${roomId}, 当前房间数: ${this.rooms.length}`);
return true;
}
|
AST#method_declaration#Left deleteRoom AST#parameter_list#Left ( AST#parameter#Left roomId : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { // 不允许删除"全屋"选项(id=0) AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left roomId AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left index = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rooms AST#member_expression#Right AST#expression#Right . findIndex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left room => AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left room AST#expression#Right . id AST#member_expression#Right AST#expression#Right === AST#expression#Left roomId AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right === AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 如果要删除的房间当前被选中,则选中"全屋" AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rooms AST#member_expression#Right AST#expression#Right [ AST#expression#Left index AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . isSelected AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectRoom AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 删除房间 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rooms AST#member_expression#Right AST#expression#Right . splice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left index AST#expression#Right , AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 重新分配ID AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rooms AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rooms AST#member_expression#Right AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left room AST#parameter#Right , AST#parameter#Left idx AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left id AST#property_name#Right : AST#expression#Left idx AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left name AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left room AST#expression#Right . name AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left isSelected AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left room AST#expression#Right . isSelected AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left RoomItem AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 更新用户房间数量 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . updateRoomCount AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rooms AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right - AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 减去"全屋"选项 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` 房间已删除, ID: AST#template_substitution#Left $ { AST#expression#Left roomId AST#expression#Right } AST#template_substitution#Right , 当前房间数: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rooms AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
deleteRoom(roomId: number): boolean {
if (roomId === 0) {
return false;
}
const index = this.rooms.findIndex(room => room.id === roomId);
if (index === -1) {
return false;
}
if (this.rooms[index].isSelected) {
this.selectRoom(0);
}
this.rooms.splice(index, 1);
this.rooms = this.rooms.map((room, idx) => ({
id: idx,
name: room.name,
isSelected: room.isSelected
} as RoomItem));
this.updateRoomCount(this.rooms.length - 1);
console.info(`房间已删除, ID: ${roomId}, 当前房间数: ${this.rooms.length}`);
return true;
}
|
https://github.com/851432669/Smart-Home-ArkTs-Hi3861.git/blob/0451f85f072ed3281cc23d9cdc2843d79f60f975/entry/src/main/ets/common/utils/GlobalDataManager.ets#L260-L291
|
b70e659c3ff91113b949eae68095829729cc30d0
|
github
|
sithvothykiv/dialog_hub.git
|
b676c102ef2d05f8994d170abe48dcc40cd39005
|
custom_dialog/src/main/ets/utils/CryptoHelper.ets
|
arkts
|
getUint8ArrayPaddingZero
|
Uint8Array补零操作
@param len 密钥规格长度
@returns
|
static getUint8ArrayPaddingZero(uint8Array: Uint8Array, len: number = 0): Uint8Array {
if (len > 0 && uint8Array.length < len) {
let diff = len - uint8Array.length;
let randArray = new Array<number>();
for (let i = 0; i < diff; i++) {
randArray.push(0);
}
let diffUint8Array = new Uint8Array(diff);
let mergeData = new Uint8Array(len);
mergeData.set(uint8Array);
mergeData.set(diffUint8Array, uint8Array.length);
return mergeData;
}
return uint8Array;
}
|
AST#method_declaration#Left static getUint8ArrayPaddingZero AST#parameter_list#Left ( AST#parameter#Left uint8Array : AST#type_annotation#Left AST#primary_type#Left Uint8Array AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left len : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left Uint8Array AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left len AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left uint8Array AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right < AST#expression#Left len AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left diff = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left len AST#expression#Right - AST#expression#Left uint8Array AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left randArray = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left diff AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left randArray AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left diffUint8Array = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Uint8Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left diff AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left mergeData = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Uint8Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left len AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left mergeData AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left uint8Array AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left mergeData AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left diffUint8Array AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left uint8Array AST#expression#Right . length AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left mergeData AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left uint8Array AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static getUint8ArrayPaddingZero(uint8Array: Uint8Array, len: number = 0): Uint8Array {
if (len > 0 && uint8Array.length < len) {
let diff = len - uint8Array.length;
let randArray = new Array<number>();
for (let i = 0; i < diff; i++) {
randArray.push(0);
}
let diffUint8Array = new Uint8Array(diff);
let mergeData = new Uint8Array(len);
mergeData.set(uint8Array);
mergeData.set(diffUint8Array, uint8Array.length);
return mergeData;
}
return uint8Array;
}
|
https://github.com/sithvothykiv/dialog_hub.git/blob/b676c102ef2d05f8994d170abe48dcc40cd39005/custom_dialog/src/main/ets/utils/CryptoHelper.ets#L144-L158
|
edcd8e4e6f372f5e6535af7e3b08cf964b929a56
|
github
|
ThePivotPoint/ArkTS-LSP-Server-Plugin.git
|
6231773905435f000d00d94b26504433082ba40b
|
packages/declarations/ets/api/@ohos.arkui.advanced.SubHeader.d.ets
|
arkts
|
SubHeader
|
Declare struct SubHeader
@syscap SystemCapability.ArkUI.ArkUI.Full
@since 10
Declare struct SubHeader
@syscap SystemCapability.ArkUI.ArkUI.Full
@atomicservice
@since 11
|
@Component
export declare struct SubHeader {
/**
* Icon resource of content area.
* @type { ResourceStr }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/
/**
* Icon resource of content area.
* @type { ResourceStr }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 11
*/
@Prop
icon?: ResourceStr;
/**
* Attributes of Symbol icon.
* @type { SymbolOptions}.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/
iconSymbolOptions?: SymbolOptions;
/**
* The first line text of content area.
* @type { ResourceStr }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/
/**
* The first line text of content area.
* @type { ResourceStr }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 11
*/
@Prop
primaryTitle?: ResourceStr;
/**
* The secondary line text of content area.
* @type { ResourceStr }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/
/**
* The secondary line text of content area.
* @type { ResourceStr }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 11
*/
@Prop
secondaryTitle?: ResourceStr;
/**
* Select option of content area.
* @type { SelectOptions }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/
/**
* Select option of content area.
* @type { SelectOptions }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 11
*/
select?: SelectOptions;
/**
* Operation style of SubHeader.
* @type { OperationStyle }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/
/**
* Operation style of SubHeader.
* @type { OperationStyle }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 11
*/
@Prop
operationType?: OperationType;
/**
* operation item.
* @type { Array<OperationOption> }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/
/**
* operation item.
* @type { Array<OperationOption> }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 11
*/
operationItem?: Array<OperationOption>;
/**
* Attributes of Symbol icons in operation area.
* @type { Array<SymbolOptions> }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/
operationSymbolOptions?: Array<SymbolOptions>;
/**
* Text modifier for primary title.
* @type { TextModifier }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/
primaryTitleModifier?: TextModifier;
/**
* Text modifier for secondary title.
* @type { TextModifier }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/
secondaryTitleModifier?: TextModifier;
/**
* Set the title content.
* @type { () => void }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/
@BuilderParam
titleBuilder?: () => void;
/**
* Set the content margin.
* @type { ?LocalizedMargin }
* @default {start: LengthMetrics.resource($r('sys.float.margin_left')),
* <br> end: LengthMetrics.resource($r('sys.float.margin_right'))}
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/
@Prop
contentMargin?: LocalizedMargin;
/**
* Set the content padding.
* @type { ?LocalizedPadding }
* @default set different default values according to the width of the subHeader:
* <br> When the left area is secondaryTitle or the group of secondaryTitle and icon,
* <br> the default value is {start: LengthMetrics.vp(12), end: LengthMetrics.vp(12)};
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/
@Prop
contentPadding?: LocalizedPadding;
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export AST#ERROR#Left declare AST#ERROR#Right struct SubHeader AST#component_body#Left { /**
* Icon resource of content area.
* @type { ResourceStr }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/ /**
* Icon resource of content area.
* @type { ResourceStr }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 11
*/ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right icon ? : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Attributes of Symbol icon.
* @type { SymbolOptions}.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/ AST#property_declaration#Left iconSymbolOptions ? : AST#type_annotation#Left AST#primary_type#Left SymbolOptions AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* The first line text of content area.
* @type { ResourceStr }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/ /**
* The first line text of content area.
* @type { ResourceStr }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 11
*/ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right primaryTitle ? : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* The secondary line text of content area.
* @type { ResourceStr }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/ /**
* The secondary line text of content area.
* @type { ResourceStr }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 11
*/ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right secondaryTitle ? : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Select option of content area.
* @type { SelectOptions }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/ /**
* Select option of content area.
* @type { SelectOptions }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 11
*/ AST#property_declaration#Left select ? : AST#type_annotation#Left AST#primary_type#Left SelectOptions AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Operation style of SubHeader.
* @type { OperationStyle }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/ /**
* Operation style of SubHeader.
* @type { OperationStyle }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 11
*/ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right operationType ? : AST#type_annotation#Left AST#primary_type#Left OperationType AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* operation item.
* @type { Array<OperationOption> }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/ /**
* operation item.
* @type { Array<OperationOption> }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 11
*/ AST#property_declaration#Left operationItem ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left OperationOption AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Attributes of Symbol icons in operation area.
* @type { Array<SymbolOptions> }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/ AST#property_declaration#Left operationSymbolOptions ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left SymbolOptions AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Text modifier for primary title.
* @type { TextModifier }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/ AST#property_declaration#Left primaryTitleModifier ? : AST#type_annotation#Left AST#primary_type#Left TextModifier AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Text modifier for secondary title.
* @type { TextModifier }.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/ AST#property_declaration#Left secondaryTitleModifier ? : AST#type_annotation#Left AST#primary_type#Left TextModifier AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Set the title content.
* @type { () => void }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/ AST#property_declaration#Left AST#decorator#Left @ BuilderParam AST#decorator#Right titleBuilder ? : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Set the content margin.
* @type { ?LocalizedMargin }
* @default {start: LengthMetrics.resource($r('sys.float.margin_left')),
* <br> end: LengthMetrics.resource($r('sys.float.margin_right'))}
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right contentMargin ? : AST#type_annotation#Left AST#primary_type#Left LocalizedMargin AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Set the content padding.
* @type { ?LocalizedPadding }
* @default set different default values according to the width of the subHeader:
* <br> When the left area is secondaryTitle or the group of secondaryTitle and icon,
* <br> the default value is {start: LengthMetrics.vp(12), end: LengthMetrics.vp(12)};
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @atomicservice
* @since 12
*/ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right contentPadding ? : AST#type_annotation#Left AST#primary_type#Left LocalizedPadding AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@Component
export declare struct SubHeader {
@Prop
icon?: ResourceStr;
iconSymbolOptions?: SymbolOptions;
@Prop
primaryTitle?: ResourceStr;
@Prop
secondaryTitle?: ResourceStr;
select?: SelectOptions;
@Prop
operationType?: OperationType;
operationItem?: Array<OperationOption>;
operationSymbolOptions?: Array<SymbolOptions>;
primaryTitleModifier?: TextModifier;
secondaryTitleModifier?: TextModifier;
@BuilderParam
titleBuilder?: () => void;
@Prop
contentMargin?: LocalizedMargin;
@Prop
contentPadding?: LocalizedPadding;
}
|
https://github.com/ThePivotPoint/ArkTS-LSP-Server-Plugin.git/blob/6231773905435f000d00d94b26504433082ba40b/packages/declarations/ets/api/@ohos.arkui.advanced.SubHeader.d.ets#L252-L406
|
a0f19d19c54aeef571e531fbeb86ed34e0dde094
|
github
|
tongyuyan/harmony-utils
|
697472f011a43e783eeefaa28ef9d713c4171726
|
harmony_utils/src/main/ets/utils/ResUtil.ets
|
arkts
|
getBooleanByName
|
获取指定资源名称对应的布尔结果
@param resName 资源名称。
@returns
|
static getBooleanByName(resName: string): boolean {
return ResUtil.getResourceManager().getBooleanByName(resName);
}
|
AST#method_declaration#Left static getBooleanByName AST#parameter_list#Left ( AST#parameter#Left resName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ResUtil AST#expression#Right . getResourceManager AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . getBooleanByName AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left resName AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
static getBooleanByName(resName: string): boolean {
return ResUtil.getResourceManager().getBooleanByName(resName);
}
|
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/ResUtil.ets#L57-L59
|
f751380bbfc84779b6e8e0b9dfc374921bb9ceaf
|
gitee
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/ArktsSendableModule.ets
|
arkts
|
A
|
正确示例,导出对象合集
|
@Sendable
export class A {
private count_: number = 0;
public lock_: ArkTSUtils.locks.AsyncLock = new ArkTSUtils.locks.AsyncLock();
public async getCount(): Promise<number> {
return this.lock_.lockAsync(() => {
return this.count_;
})
}
public async increaseCount() {
await this.lock_.lockAsync(() => {
this.count_++;
})
}
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Sendable AST#decorator#Right export class A AST#class_body#Left { AST#property_declaration#Left private count_ : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left public lock_ : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left ArkTSUtils . locks . AsyncLock AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ArkTSUtils AST#expression#Right AST#new_expression#Right AST#expression#Right . locks AST#member_expression#Right AST#expression#Right . AsyncLock AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#method_declaration#Left public async getCount AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . lock_ AST#member_expression#Right AST#expression#Right . lockAsync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . count_ AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left public async increaseCount AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . lock_ AST#member_expression#Right AST#expression#Right . lockAsync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#update_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . count_ AST#member_expression#Right AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right } AST#class_body#Right AST#decorated_export_declaration#Right
|
@Sendable
export class A {
private count_: number = 0;
public lock_: ArkTSUtils.locks.AsyncLock = new ArkTSUtils.locks.AsyncLock();
public async getCount(): Promise<number> {
return this.lock_.lockAsync(() => {
return this.count_;
})
}
public async increaseCount() {
await this.lock_.lockAsync(() => {
this.count_++;
})
}
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/ArkTS/ArkTsConcurrent/ConcurrentThreadCommunication/InterThreadCommunicationObjects/SendableObject/SendableObjectRelated/entry/src/main/ets/managers/ArktsSendableModule.ets#L22-L38
|
3f8c5366b0831d0f74dbfeede66321479956bbaa
|
gitee
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/BasicFeature/Connectivity/NetworkObserver/entry/src/main/ets/pages/VideoPage.ets
|
arkts
|
VideoPage
|
实现步骤:
1. 通过@kit.NetworkKit接口监听网络状态
2. 添加Video组件,播放在线视频
3. 添加自动播放设置toggle,可以在网络状态变化时修改视频播放状态
|
@Component
export struct VideoPage {
@Provide('navPathStack') navPathStack: NavPathStack = new NavPathStack();
// 视频控制器
controller: VideoController = new VideoController();
// WI-FI自动播放
@StorageLink('wifi_auto_play') wifiAutoPlay: boolean = false;
// 3G/4G/5G自动播放
@StorageLink('cellular_auto_play') cellularAutoPlay: boolean = false;
// 在线视频地址
private videoUrl: string = 'https://v.oh4k.com/muhou/2022/07/20220704-RIUq3Z.mp4';
// 注册路由返回函数,案例插件不触发
popRouter: () => void = () => {
};
// 使用流量播放弹窗
networkDialog: CustomDialogController | null = new CustomDialogController({
builder: NetworkDialogComponent({
title: $r('app.string.network_status_observer_cellular_dialog_title'),
message: $r('app.string.network_status_observer_cellular_dialog_message'),
cancel: () => {
// 用户点击取消,则停止播放
this.pausePlay();
this.networkDialog?.close();
},
confirm: () => {
// 用户点击确认,则继续播放
this.startPlay();
this.networkDialog?.close();
}
}),
cornerRadius: $r('app.integer.network_status_observer_cellular_dialog_message_radius'),
alignment: DialogAlignment.Center
})
// 网络监听回调
netObserver(data: emitter.EventData) {
if (!data.data) {
logger.info('netObserver data.data is undefined.');
return;
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct VideoPage AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ Provide ( AST#expression#Left 'navPathStack' AST#expression#Right ) AST#decorator#Right navPathStack : AST#type_annotation#Left AST#primary_type#Left NavPathStack AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left NavPathStack AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right // 视频控制器 AST#property_declaration#Left controller : AST#type_annotation#Left AST#primary_type#Left VideoController AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left VideoController AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right // WI-FI自动播放 AST#property_declaration#Left AST#decorator#Left @ StorageLink ( AST#expression#Left 'wifi_auto_play' AST#expression#Right ) AST#decorator#Right wifiAutoPlay : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#property_declaration#Right // 3G/4G/5G自动播放 AST#property_declaration#Left AST#decorator#Left @ StorageLink ( AST#expression#Left 'cellular_auto_play' AST#expression#Right ) AST#decorator#Right cellularAutoPlay : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#property_declaration#Right // 在线视频地址 AST#property_declaration#Left private videoUrl : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'https://v.oh4k.com/muhou/2022/07/20220704-RIUq3Z.mp4' AST#expression#Right ; AST#property_declaration#Right // 注册路由返回函数,案例插件不触发 AST#property_declaration#Left popRouter : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right = AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#expression#Left AST#object_literal#Left { } AST#object_literal#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ; AST#property_declaration#Right // 使用流量播放弹窗 AST#property_declaration#Left networkDialog : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left CustomDialogController AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#ERROR#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left CustomDialogController AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left builder AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left NetworkDialogComponent AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left title AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.network_status_observer_cellular_dialog_title' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.network_status_observer_cellular_dialog_message' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left cancel AST#property_name#Right : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { // 用户点击取消,则停止播放 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . pausePlay AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . networkDialog AST#member_expression#Right AST#expression#Right ?. close AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left confirm AST#property_name#Right : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { // 用户点击确认,则继续播放 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . startPlay AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . networkDialog AST#member_expression#Right AST#expression#Right ?. close AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left cornerRadius AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.network_status_observer_cellular_dialog_message_radius' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left alignment AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left DialogAlignment AST#expression#Right . Center AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right // 网络监听回调 AST#ERROR#Left netObserver AST#ERROR#Right AST#argument_list#Left ( AST#ERROR#Left data : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left emitter . EventData AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right ) { AST#property_name#Left if AST#property_name#Right ( AST#ERROR#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left data AST#expression#Right AST#unary_expression#Right AST#expression#Right . data AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Right AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left logger AST#property_assignment#Right AST#object_literal#Right AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'netObserver data.data is undefined.' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left return ; AST#property_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@Component
export struct VideoPage {
@Provide('navPathStack') navPathStack: NavPathStack = new NavPathStack();
controller: VideoController = new VideoController();
@StorageLink('wifi_auto_play') wifiAutoPlay: boolean = false;
@StorageLink('cellular_auto_play') cellularAutoPlay: boolean = false;
private videoUrl: string = 'https://v.oh4k.com/muhou/2022/07/20220704-RIUq3Z.mp4';
popRouter: () => void = () => {
};
networkDialog: CustomDialogController | null = new CustomDialogController({
builder: NetworkDialogComponent({
title: $r('app.string.network_status_observer_cellular_dialog_title'),
message: $r('app.string.network_status_observer_cellular_dialog_message'),
cancel: () => {
this.pausePlay();
this.networkDialog?.close();
},
confirm: () => {
this.startPlay();
this.networkDialog?.close();
}
}),
cornerRadius: $r('app.integer.network_status_observer_cellular_dialog_message_radius'),
alignment: DialogAlignment.Center
})
netObserver(data: emitter.EventData) {
if (!data.data) {
logger.info('netObserver data.data is undefined.');
return;
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/BasicFeature/Connectivity/NetworkObserver/entry/src/main/ets/pages/VideoPage.ets#L38-L77
|
f852510748e5b71751277e2f017f0d9b35f6c716
|
gitee
|
openharmony/applications_app_samples
|
a826ab0e75fe51d028c1c5af58188e908736b53b
|
code/SystemFeature/FileManagement/FileManager/Library/src/main/ets/filemanager/fileio/NewFileIoManager.ets
|
arkts
|
setFileTime
|
修改文件时间
|
setFileTime(filePath: string, timeStr: string): void {
try {
let time = new Date(timeStr).getTime();
if (Number.isNaN(time)) {
return prompt.showToast({ message: $r('app.string.tip_invalid_time') });
}
fs.utimes(filePath,time);
} catch (err) {
Logger.error(`setFileTime failed, code is ${err.code}, message is ${err.message}`);
throw new Error(`setFileTime failed, code is ${err.code}, message is ${err.message}`);
}
}
|
AST#method_declaration#Left setFileTime AST#parameter_list#Left ( AST#parameter#Left filePath : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left timeStr : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left time = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left timeStr AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . getTime AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Number AST#expression#Right . isNaN AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left time AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left prompt AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.tip_invalid_time' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fs AST#expression#Right . utimes AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left filePath AST#expression#Right , AST#expression#Left time AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` setFileTime failed, code is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , message is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#throw_statement#Left throw AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Error AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` setFileTime failed, code is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , message is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#throw_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
setFileTime(filePath: string, timeStr: string): void {
try {
let time = new Date(timeStr).getTime();
if (Number.isNaN(time)) {
return prompt.showToast({ message: $r('app.string.tip_invalid_time') });
}
fs.utimes(filePath,time);
} catch (err) {
Logger.error(`setFileTime failed, code is ${err.code}, message is ${err.message}`);
throw new Error(`setFileTime failed, code is ${err.code}, message is ${err.message}`);
}
}
|
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/SystemFeature/FileManagement/FileManager/Library/src/main/ets/filemanager/fileio/NewFileIoManager.ets#L36-L47
|
62e8c5acfff08183f49005b2ba111dc425dff23b
|
gitee
|
awa_Liny/LinysBrowser_NEXT
|
a5cd96a9aa8114cae4972937f94a8967e55d4a10
|
home/src/main/ets/hosts/bunch_of_bookmarks.ets
|
arkts
|
add_bookmark
|
Adds a bookmark to this bunch_of_bookmarks.
@param item A bookmark object.
@param path A string, technically the path of the folder which the bookmark item will be put into.
@param no_reconstruct_plain_bookmarks A boolean, will not reconstruct the plain bookmarks array if set true,
otherwise (unfilled or set false) will reconstruct the plain bookmarks array.
@returns true if success.
@returns false if failed (for a name crash or a nonexistent destination).
|
add_bookmark(item: bookmark, path: string, no_reconstruct_plain_bookmarks?: boolean) {
let check_path = "";
if (path == "") {
check_path = item.get_label()
} else {
check_path = path + "/" + item.get_label()
}
// Add
let add_result: boolean;
if (this.access_bookmark(check_path)) {
// already exist
return false;
} else {
if (this.last_add_path == path && this.last_add_path_bookmark) {
// Direct add in cached bookmark
this.last_add_path_bookmark.add_content(item);
// console.log('[bunch_of_bookmarks][add_bookmark] Hit Cache!');
add_result = true;
} else {
add_result = this.add_bookmark_process(item, path);
this.last_add_path = path;
}
}
if (no_reconstruct_plain_bookmarks) {
return add_result;
}
// Update plain_bookmarks
this.reconstruct_cached_plain_bookmarks();
if (this.init) {
this.last_accessed = Date.now();
}
return add_result;
}
|
AST#method_declaration#Left add_bookmark AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left bookmark AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left path : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left no_reconstruct_plain_bookmarks ? : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left check_path = AST#expression#Left "" AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left path AST#expression#Right == AST#expression#Left "" AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left check_path = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . get_label AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left check_path = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left path AST#expression#Right + AST#expression#Left "/" AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left item AST#expression#Right AST#binary_expression#Right AST#expression#Right . get_label AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // Add AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left add_result : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . access_bookmark AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left check_path AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { // already exist AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . last_add_path AST#member_expression#Right AST#expression#Right == AST#expression#Left path AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . last_add_path_bookmark AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { // Direct add in cached bookmark AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . last_add_path_bookmark AST#member_expression#Right AST#expression#Right . add_content AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left item AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // console.log('[bunch_of_bookmarks][add_bookmark] Hit Cache!'); AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left add_result = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left add_result = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . add_bookmark_process AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left item AST#expression#Right , AST#expression#Left path AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . last_add_path AST#member_expression#Right = AST#expression#Left path AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left no_reconstruct_plain_bookmarks AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left add_result AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // Update plain_bookmarks AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . reconstruct_cached_plain_bookmarks AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . init AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . last_accessed AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Date AST#expression#Right . now AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left add_result AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
add_bookmark(item: bookmark, path: string, no_reconstruct_plain_bookmarks?: boolean) {
let check_path = "";
if (path == "") {
check_path = item.get_label()
} else {
check_path = path + "/" + item.get_label()
}
let add_result: boolean;
if (this.access_bookmark(check_path)) {
return false;
} else {
if (this.last_add_path == path && this.last_add_path_bookmark) {
this.last_add_path_bookmark.add_content(item);
add_result = true;
} else {
add_result = this.add_bookmark_process(item, path);
this.last_add_path = path;
}
}
if (no_reconstruct_plain_bookmarks) {
return add_result;
}
this.reconstruct_cached_plain_bookmarks();
if (this.init) {
this.last_accessed = Date.now();
}
return add_result;
}
|
https://github.com/awa_Liny/LinysBrowser_NEXT/blob/a5cd96a9aa8114cae4972937f94a8967e55d4a10/home/src/main/ets/hosts/bunch_of_bookmarks.ets#L43-L77
|
5eaf75ae3df8c07d3ee690ceb2fb3fa2df7139ef
|
gitee
|
Piagari/arkts_example.git
|
a63b868eaa2a50dc480d487b84c4650cc6a40fc8
|
hmos_app-main/hmos_app-main/DriverLicenseExam-master/commons/commonLib/src/main/ets/utils/RouterModule.ets
|
arkts
|
getNavParam
|
获取指定栈中指定页面的参数,不支持栈内存在多个同名页面的情况
|
public static getNavParam<T = ESObject>(info: NavRouterInfo): T | undefined {
try {
const paramsArr = RouterModule._stack.getParamByName(info.url) as T[] | undefined[];
if (paramsArr.length && paramsArr[0]) {
return paramsArr[0];
}
} catch (err) {
Logger.error(TAG, 'navigation stack get params failed::' + JSON.stringify(err));
}
return undefined;
}
|
AST#method_declaration#Left public static getNavParam AST#type_parameters#Left < AST#type_parameter#Left T = AST#type_annotation#Left AST#primary_type#Left ESObject AST#primary_type#Right AST#type_annotation#Right AST#type_parameter#Right > AST#type_parameters#Right AST#parameter_list#Left ( AST#parameter#Left info : AST#type_annotation#Left AST#primary_type#Left NavRouterInfo AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left T AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left paramsArr = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left RouterModule AST#expression#Right . _stack AST#member_expression#Right AST#expression#Right . getParamByName AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left info AST#expression#Right . url AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#array_type#Left T [ ] AST#array_type#Right AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right [ AST#expression#Left AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left paramsArr AST#expression#Right . length AST#member_expression#Right AST#expression#Right && AST#expression#Left AST#subscript_expression#Left AST#expression#Left paramsArr AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#subscript_expression#Left AST#expression#Left paramsArr AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'navigation stack get params failed::' AST#expression#Right + AST#expression#Left JSON AST#expression#Right AST#binary_expression#Right AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left undefined AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
public static getNavParam<T = ESObject>(info: NavRouterInfo): T | undefined {
try {
const paramsArr = RouterModule._stack.getParamByName(info.url) as T[] | undefined[];
if (paramsArr.length && paramsArr[0]) {
return paramsArr[0];
}
} catch (err) {
Logger.error(TAG, 'navigation stack get params failed::' + JSON.stringify(err));
}
return undefined;
}
|
https://github.com/Piagari/arkts_example.git/blob/a63b868eaa2a50dc480d487b84c4650cc6a40fc8/hmos_app-main/hmos_app-main/DriverLicenseExam-master/commons/commonLib/src/main/ets/utils/RouterModule.ets#L92-L102
|
08060afde2d57049635624439668530152bbee99
|
github
|
harmonyos_samples/BestPracticeSnippets
|
490ea539a6d4427dd395f3dac3cf4887719f37af
|
ClickResponseOptimization/entry/src/main/ets/common/db/AccountData.ets
|
arkts
|
最佳实践:点击响应优化
|
export default class AccountData {
id: number = -1;
accountType: number = 0;
typeText: string = '';
amount: number = 0;
}
|
AST#export_declaration#Left export default AST#class_declaration#Left class AccountData AST#class_body#Left { AST#property_declaration#Left id : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left accountType : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left typeText : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left amount : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export default class AccountData {
id: number = -1;
accountType: number = 0;
typeText: string = '';
amount: number = 0;
}
|
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/ClickResponseOptimization/entry/src/main/ets/common/db/AccountData.ets#L19-L24
|
7dd8298e804c60efe2e45aff764c4020ea68ec40
|
gitee
|
|
hi-dhl/HarmonyPractice.git
|
0ebaac278d286ab99c4d0d06eb68c95148e89901
|
Basic/entry/src/main/ets/syntax/Exception2.ets
|
arkts
|
<pre>
author: 程序员DHL
date : 2024/1/21
公众号 : ByteCode
desc :
文件名以 ts 的结尾表示 TypeScript
文件名以 ets 的结尾表示 ArkTS
基于 ArkTS 语法
</pre>
|
export class Exception {
testException() {
try {
// ...
} catch (error) {
// 处理异常
}
}
}
|
AST#export_declaration#Left export AST#class_declaration#Left class Exception AST#class_body#Left { AST#method_declaration#Left testException AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { // ... } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { // 处理异常 } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
|
export class Exception {
testException() {
try {
} catch (error) {
}
}
}
|
https://github.com/hi-dhl/HarmonyPractice.git/blob/0ebaac278d286ab99c4d0d06eb68c95148e89901/Basic/entry/src/main/ets/syntax/Exception2.ets#L13-L21
|
7e64ac2df82567ef54ebf8a9ae0a4281f44faddf
|
github
|
|
harmonyos_samples/BestPracticeSnippets
|
490ea539a6d4427dd395f3dac3cf4887719f37af
|
DealStrideSolution/entry/src/main/ets/utils/CameraServiceOne.ets
|
arkts
|
getPreviewProfile
|
[End Case1_start]
|
getPreviewProfile(cameraOutputCapability: camera.CameraOutputCapability): camera.Profile | undefined {
let previewProfiles: Array<camera.Profile> = cameraOutputCapability.previewProfiles;
if (previewProfiles.length < 1) {
return undefined;
}
let index: number = previewProfiles.findIndex((previewProfile: camera.Profile) => {
return previewProfile.size.width === this.previewProfileObj.size.width &&
previewProfile.size.height === this.previewProfileObj.size.height &&
previewProfile.format === this.previewProfileObj.format;
});
if (index === -1) {
return undefined;
}
return previewProfiles[index];
}
|
AST#method_declaration#Left getPreviewProfile AST#parameter_list#Left ( AST#parameter#Left cameraOutputCapability : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left camera . CameraOutputCapability AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#qualified_type#Left camera . Profile AST#qualified_type#Right AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left previewProfiles : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left camera . Profile AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left cameraOutputCapability AST#expression#Right . previewProfiles AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left previewProfiles AST#expression#Right . length AST#member_expression#Right AST#expression#Right < AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left undefined AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left previewProfiles AST#expression#Right . findIndex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left previewProfile : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left camera . Profile AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left previewProfile AST#expression#Right . size AST#member_expression#Right AST#expression#Right . width AST#member_expression#Right AST#expression#Right === AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . previewProfileObj AST#member_expression#Right AST#expression#Right . size AST#member_expression#Right AST#expression#Right . width AST#member_expression#Right AST#expression#Right && AST#expression#Left previewProfile AST#expression#Right AST#binary_expression#Right AST#expression#Right . size AST#member_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right === AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . previewProfileObj AST#member_expression#Right AST#expression#Right . size AST#member_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right && AST#expression#Left previewProfile AST#expression#Right AST#binary_expression#Right AST#expression#Right . format AST#member_expression#Right AST#expression#Right === AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . previewProfileObj AST#member_expression#Right AST#expression#Right . format AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right === AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left undefined AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#subscript_expression#Left AST#expression#Left previewProfiles AST#expression#Right [ AST#expression#Left index AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
|
getPreviewProfile(cameraOutputCapability: camera.CameraOutputCapability): camera.Profile | undefined {
let previewProfiles: Array<camera.Profile> = cameraOutputCapability.previewProfiles;
if (previewProfiles.length < 1) {
return undefined;
}
let index: number = previewProfiles.findIndex((previewProfile: camera.Profile) => {
return previewProfile.size.width === this.previewProfileObj.size.width &&
previewProfile.size.height === this.previewProfileObj.size.height &&
previewProfile.format === this.previewProfileObj.format;
});
if (index === -1) {
return undefined;
}
return previewProfiles[index];
}
|
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/DealStrideSolution/entry/src/main/ets/utils/CameraServiceOne.ets#L104-L118
|
c71f0f5ada5f1d21968935e2e27c23fd39ee694f
|
gitee
|
wangjinyuan/JS-TS-ArkTS-database.git
|
a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26
|
npm/alprazolamdiv/11.5.1/package/src/structures/Attachment.ets
|
arkts
|
应用约束:使用ES模块导出(错误60)
|
export default Attachment;
|
AST#export_declaration#Left export default AST#expression#Left Attachment AST#expression#Right ; AST#export_declaration#Right
|
export default Attachment;
|
https://github.com/wangjinyuan/JS-TS-ArkTS-database.git/blob/a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26/npm/alprazolamdiv/11.5.1/package/src/structures/Attachment.ets#L58-L58
|
ae9109f842a4b10a804e8dd8751732abebb1d38c
|
github
|
|
openharmony/interface_sdk-js
|
c349adc73e2ec1f61f6fca489b5af059e3ed6999
|
api/@ohos.arkui.advanced.ExceptionPrompt.d.ets
|
arkts
|
ExceptionPrompt
|
Declare struct ExceptionPrompt higher-order component.
@syscap SystemCapability.ArkUI.ArkUI.Full
@crossplatform
@since 11
Declare struct ExceptionPrompt higher-order component.
@syscap SystemCapability.ArkUI.ArkUI.Full
@crossplatform
@atomicservice
@since 12
|
@Component
export declare struct ExceptionPrompt {
/**
* Configuration information of ExceptionPrompt.
* @type { PromptOptions }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 11
*/
/**
* Configuration information of ExceptionPrompt.
* @type { PromptOptions }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
@Prop options: PromptOptions;
/**
* Callback when clicking the text on the left.
* @type { ?function }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 11
*/
/**
* Callback when clicking the text on the left.
* @type { ?function }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
onTipClick?: () => void;
/**
* Callback when click the icon button.
* @type { ?function }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 11
*/
/**
* Callback when click the icon button.
* @type { ?function }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
onActionTextClick?: () => void;
/**
* The build function is a member function that must return an ArkTS component type (Element) to represent the component to be rendered as a user interface.
* @type { function }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 11
*/
/**
* The build function is a member function that must return an ArkTS component type (Element) to represent the component to be rendered as a user interface.
* @type { function }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
build(): void;
}
|
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export AST#ERROR#Left declare AST#ERROR#Right struct ExceptionPrompt AST#component_body#Left { /**
* Configuration information of ExceptionPrompt.
* @type { PromptOptions }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 11
*/ /**
* Configuration information of ExceptionPrompt.
* @type { PromptOptions }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right options : AST#type_annotation#Left AST#primary_type#Left PromptOptions AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Callback when clicking the text on the left.
* @type { ?function }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 11
*/ /**
* Callback when clicking the text on the left.
* @type { ?function }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/ AST#property_declaration#Left onTipClick ? : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* Callback when click the icon button.
* @type { ?function }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 11
*/ /**
* Callback when click the icon button.
* @type { ?function }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/ AST#property_declaration#Left onActionTextClick ? : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /**
* The build function is a member function that must return an ArkTS component type (Element) to represent the component to be rendered as a user interface.
* @type { function }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @since 11
*/ /**
* The build function is a member function that must return an ArkTS component type (Element) to represent the component to be rendered as a user interface.
* @type { function }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/ AST#ERROR#Left build ( ) : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right ; AST#ERROR#Right } AST#component_body#Right AST#decorated_export_declaration#Right
|
@Component
export declare struct ExceptionPrompt {
@Prop options: PromptOptions;
onTipClick?: () => void;
onActionTextClick?: () => void;
build(): void;
}
|
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.arkui.advanced.ExceptionPrompt.d.ets#L209-L279
|
8d1afc351368b4861444a8f50ad7899576cd6b92
|
gitee
|
bigbear20240612/birthday_reminder.git
|
647c411a6619affd42eb5d163ff18db4b34b27ff
|
entry/src/main/ets/pages/greetings/GreetingSendPage.ets
|
arkts
|
buildSendMethodOption
|
构建发送方式选项
|
@Builder
buildSendMethodOption(label: string, method: NotificationMethod, icon: string) {
Column({ space: 4 }) {
Text(icon)
.fontSize(24)
.width('24vp')
.height('24vp')
.textAlign(TextAlign.Center)
Text(label)
.fontSize(12)
.fontColor(this.sendMethod === method ? '#007AFF' : '#666666')
}
.width('60vp')
.padding(8)
.borderRadius(8)
.backgroundColor(this.sendMethod === method ? '#e8f4ff' : '#f8f9fa')
.onClick(() => {
this.sendMethod = method;
})
}
|
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildSendMethodOption AST#parameter_list#Left ( AST#parameter#Left label : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left method : AST#type_annotation#Left AST#primary_type#Left NotificationMethod AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left icon : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 4 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left icon AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 24 AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '24vp' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '24vp' AST#expression#Right ) AST#modifier_chain_expression#Left . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left label AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 12 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . sendMethod AST#member_expression#Right AST#expression#Right === AST#expression#Left method AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left '#007AFF' AST#expression#Right : AST#expression#Left '#666666' AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '60vp' AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left 8 AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 8 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . sendMethod AST#member_expression#Right AST#expression#Right === AST#expression#Left method AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left '#e8f4ff' AST#expression#Right : AST#expression#Left '#f8f9fa' AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . sendMethod AST#member_expression#Right = AST#expression#Left method AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
|
@Builder
buildSendMethodOption(label: string, method: NotificationMethod, icon: string) {
Column({ space: 4 }) {
Text(icon)
.fontSize(24)
.width('24vp')
.height('24vp')
.textAlign(TextAlign.Center)
Text(label)
.fontSize(12)
.fontColor(this.sendMethod === method ? '#007AFF' : '#666666')
}
.width('60vp')
.padding(8)
.borderRadius(8)
.backgroundColor(this.sendMethod === method ? '#e8f4ff' : '#f8f9fa')
.onClick(() => {
this.sendMethod = method;
})
}
|
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/greetings/GreetingSendPage.ets#L545-L565
|
af1a25a19777e1d7a9865f0351e69d07fc5bbfac
|
github
|
openharmony/interface_sdk-js
|
c349adc73e2ec1f61f6fca489b5af059e3ed6999
|
api/@ohos.arkui.advanced.TreeView.d.ets
|
arkts
|
on
|
Event registration and processing.
The event will not be destroyed after being processed.
@param { type } event Registered Events.
@param { callback }.
@syscap SystemCapability.ArkUI.ArkUI.Full
@since 10
Event registration and processing.
The event will not be destroyed after being processed.
@param { type } event Registered Events.
@param { callback }.
@syscap SystemCapability.ArkUI.ArkUI.Full
@atomicservice
@since 11
|
on(type: TreeListenType, callback: (callbackParam: CallbackParam) => void): void;
|
AST#method_declaration#Left on AST#parameter_list#Left ( AST#parameter#Left type : AST#type_annotation#Left AST#primary_type#Left TreeListenType AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left callback : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left callbackParam : AST#type_annotation#Left AST#primary_type#Left CallbackParam AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right
|
on(type: TreeListenType, callback: (callbackParam: CallbackParam) => void): void;
|
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.arkui.advanced.TreeView.d.ets#L134-L134
|
2029dcf305d0296478b3f0866faa00607cde1963
|
gitee
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.