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
fmtjava/Ohs_ArkTs_Eyepetizer.git
79578f394ccb926da1455e63b7fe0722df9b9a22
entry/src/main/ets/datasource/BasicDataSource.ets
arkts
抽象类BasicDataSource,使用泛型T,实现接口IDataSource
export abstract class BasicDataSource<T> implements IDataSource { // 监听器数组 private listeners: Array<DataChangeListener> = new Array<DataChangeListener>(); // 数据源,支持泛型的数组 private dataSource: Array<T> = new Array<T>(); // 构造函数,接收一个泛型数组作为参数,用于初始化数据源 constructor(dataSource: Array<T>) { // 初始化数据源 this.dataSource = dataSource; } // 返回数据源的长度 totalCount(): number { return this.dataSource == null ? 0 : this.dataSource.length; } // 获取指定索引的数据 // 判断索引是否合法,如果非法就返回null getData(index: number) { return index >= 0 && index < this.totalCount() ? this.dataSource[index] : null; } // 整体替换数据源 setData(newData: Array<T>) { this.dataSource = newData; this.reloadData(); //通知所有监听器数据已完全替换 } // 添加数据 addData(index: number, data: T): void { this.dataSource.splice(index, 0, data); this.notifyDataAdd(index); } // 追加数据 pushData(data: T): void { this.dataSource.push(data); this.notifyDataAdd(this.dataSource.length - 1); } // 删除数据 deleteData(index: number): void { this.dataSource.splice(index, 1); this.notifyDataDelete(index); } // 修改数据 changeData(index: number, data: T): void { this.dataSource.splice(index, 1, data); this.notifyDataChange(index); } // 重新加载数据 reloadData(): void { this.notifyDataReload(); } // 通知数据添加 notifyDataAdd(index: number) { this.listeners.forEach(listener => { listener.onDataAdd(index) }) } // 通知数据删除 notifyDataDelete(index: number) { this.listeners.forEach(listener => { listener.onDataDelete(index); }) } // 通知数据变更 notifyDataChange(index: number) { this.listeners.forEach(listener => { listener.onDataChange(index); }) } // 通知数据重载 notifyDataReload(): void { this.listeners.forEach(listener => { listener.onDataReloaded(); }) } // 注册数据变化监听器 registerDataChangeListener(listener: DataChangeListener): void { if (this.listeners.indexOf(listener) < 0) { // 没有在listeners里面,就添加 this.listeners.push(listener); } } // 取消注册数据变化监听器 unregisterDataChangeListener(listener: DataChangeListener): void { let index = this.listeners.indexOf(listener); if (index >= 0) { // 在listeners里面,就删除 this.listeners.splice(index, 1); } } // 获取数据源 getDataSource(): Array<T> { return this.dataSource; } }
AST#export_declaration#Left export AST#class_declaration#Left abstract class BasicDataSource AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right > AST#type_parameters#Right AST#implements_clause#Left implements IDataSource AST#implements_clause#Right AST#class_body#Left { // 监听器数组 AST#property_declaration#Left private listeners : 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 DataChangeListener 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 Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left DataChangeListener 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#property_declaration#Left private dataSource : 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 T 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 Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left T 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#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left dataSource : 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 T 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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataSource AST#member_expression#Right = AST#expression#Left dataSource 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#method_declaration#Left totalCount 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 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 this AST#expression#Right . dataSource 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#expression#Left 0 AST#expression#Right : AST#expression#Left this AST#expression#Right AST#conditional_expression#Right AST#expression#Right . dataSource AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right // 获取指定索引的数据 // 判断索引是否合法,如果非法就返回null AST#method_declaration#Left getData AST#parameter_list#Left ( 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#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#conditional_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#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right >= AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left index AST#expression#Right AST#binary_expression#Right AST#expression#Right < AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . totalCount 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#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataSource AST#member_expression#Right AST#expression#Right [ AST#expression#Left index AST#expression#Right ] AST#subscript_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 // 整体替换数据源 AST#method_declaration#Left setData AST#parameter_list#Left ( AST#parameter#Left newData : 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 T 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#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 . dataSource AST#member_expression#Right = AST#expression#Left newData 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 . reloadData 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 // 添加数据 AST#method_declaration#Left addData AST#parameter_list#Left ( 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#Left data : AST#type_annotation#Left AST#primary_type#Left T 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 . dataSource 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 0 AST#expression#Right , AST#expression#Left data 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 this AST#expression#Right . notifyDataAdd 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#builder_function_body#Right AST#method_declaration#Right // 追加数据 AST#method_declaration#Left pushData AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left T 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 . dataSource AST#member_expression#Right AST#expression#Right . push AST#member_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#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 . notifyDataAdd 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 . dataSource 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#builder_function_body#Right AST#method_declaration#Right // 删除数据 AST#method_declaration#Left deleteData AST#parameter_list#Left ( 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#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 . dataSource 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . notifyDataDelete 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#builder_function_body#Right AST#method_declaration#Right // 修改数据 AST#method_declaration#Left changeData AST#parameter_list#Left ( 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#Left data : AST#type_annotation#Left AST#primary_type#Left T 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 . dataSource 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#expression#Left data 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 this AST#expression#Right . notifyDataChange 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#builder_function_body#Right AST#method_declaration#Right // 重新加载数据 AST#method_declaration#Left reloadData 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . notifyDataReload 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 // 通知数据添加 AST#method_declaration#Left notifyDataAdd AST#parameter_list#Left ( 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#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 . listeners AST#member_expression#Right AST#expression#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left listener => 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 listener AST#expression#Right . onDataAdd 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#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right // 通知数据删除 AST#method_declaration#Left notifyDataDelete AST#parameter_list#Left ( 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#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 . listeners AST#member_expression#Right AST#expression#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left listener => 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 listener AST#expression#Right . onDataDelete 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#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right // 通知数据变更 AST#method_declaration#Left notifyDataChange AST#parameter_list#Left ( 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#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 . listeners AST#member_expression#Right AST#expression#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left listener => 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 listener AST#expression#Right . onDataChange 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#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right // 通知数据重载 AST#method_declaration#Left notifyDataReload 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . listeners AST#member_expression#Right AST#expression#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left listener => 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 listener AST#expression#Right . onDataReloaded 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#builder_function_body#Right AST#method_declaration#Right // 注册数据变化监听器 AST#method_declaration#Left registerDataChangeListener AST#parameter_list#Left ( AST#parameter#Left listener : AST#type_annotation#Left AST#primary_type#Left DataChangeListener 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#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 . listeners AST#member_expression#Right AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left listener 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 ) { // 没有在listeners里面,就添加 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 . listeners AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left listener 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 // 取消注册数据变化监听器 AST#method_declaration#Left unregisterDataChangeListener AST#parameter_list#Left ( AST#parameter#Left listener : AST#type_annotation#Left AST#primary_type#Left DataChangeListener 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#variable_declaration#Left let 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 . listeners AST#member_expression#Right AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left listener 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 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { // 在listeners里面,就删除 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 . listeners 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 } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right // 获取数据源 AST#method_declaration#Left getDataSource AST#parameter_list#Left ( ) AST#parameter_list#Right : 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 T 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#member_expression#Left AST#expression#Left this AST#expression#Right . dataSource AST#member_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 abstract class BasicDataSource<T> implements IDataSource { private listeners: Array<DataChangeListener> = new Array<DataChangeListener>(); private dataSource: Array<T> = new Array<T>(); constructor(dataSource: Array<T>) { this.dataSource = dataSource; } totalCount(): number { return this.dataSource == null ? 0 : this.dataSource.length; } getData(index: number) { return index >= 0 && index < this.totalCount() ? this.dataSource[index] : null; } setData(newData: Array<T>) { this.dataSource = newData; this.reloadData(); } addData(index: number, data: T): void { this.dataSource.splice(index, 0, data); this.notifyDataAdd(index); } pushData(data: T): void { this.dataSource.push(data); this.notifyDataAdd(this.dataSource.length - 1); } deleteData(index: number): void { this.dataSource.splice(index, 1); this.notifyDataDelete(index); } changeData(index: number, data: T): void { this.dataSource.splice(index, 1, data); this.notifyDataChange(index); } reloadData(): void { this.notifyDataReload(); } notifyDataAdd(index: number) { this.listeners.forEach(listener => { listener.onDataAdd(index) }) } notifyDataDelete(index: number) { this.listeners.forEach(listener => { listener.onDataDelete(index); }) } notifyDataChange(index: number) { this.listeners.forEach(listener => { listener.onDataChange(index); }) } notifyDataReload(): void { this.listeners.forEach(listener => { listener.onDataReloaded(); }) } registerDataChangeListener(listener: DataChangeListener): void { if (this.listeners.indexOf(listener) < 0) { this.listeners.push(listener); } } unregisterDataChangeListener(listener: DataChangeListener): void { let index = this.listeners.indexOf(listener); if (index >= 0) { this.listeners.splice(index, 1); } } getDataSource(): Array<T> { return this.dataSource; } }
https://github.com/fmtjava/Ohs_ArkTs_Eyepetizer.git/blob/79578f394ccb926da1455e63b7fe0722df9b9a22/entry/src/main/ets/datasource/BasicDataSource.ets#L4-L112
e71002f844128600726582b76292eea32c9d854f
github
IceYuanyyy/OxHornCampus.git
bb5686f77fa36db89687502e35898cda218d601f
entry/src/main/ets/pages/IntroductionPage.ets
arkts
controlImageScale
Control the image scale. @param this @param offset @param state @returns real list offset.
controlImageScale(offset: number, state: ScrollState): number { if (offset > 0 && this.imageHeight > Const.MIN_IMAGE_HEIGHT) { // Scale down the image by offset. let offsetHeight = (Math.abs(offset) * Const.FULL_PERCENT_NUMBER) / Number(this.screenHeight); let heightOffset = this.imageHeight - Const.MIN_IMAGE_HEIGHT > offsetHeight ? offsetHeight : this.imageHeight - Const.MIN_IMAGE_HEIGHT; this.imageHeight = this.imageHeight - heightOffset; this.arrowIconOpacity = this.arrowIconOpacity - heightOffset / (Const.FULL_PERCENT_NUMBER - Const.MIN_IMAGE_HEIGHT); return 0; } if (this.listPosition == Const.LIST_POSITION_BEGIN && offset < 0 && this.imageHeight < Const.FULL_PERCENT_NUMBER) { // // Scale up the image by offset. let offsetHeight = (Math.abs(offset) * Const.FULL_PERCENT_NUMBER) / Number(this.screenHeight); let heightOffset = Const.FULL_PERCENT_NUMBER - this.imageHeight > offsetHeight ? offsetHeight : Const.FULL_PERCENT_NUMBER - this.imageHeight; this.imageHeight = this.imageHeight + heightOffset; this.arrowIconOpacity = this.arrowIconOpacity + heightOffset / (Const.FULL_PERCENT_NUMBER - Const.MIN_IMAGE_HEIGHT); return 0; } if (state === ScrollState.Scroll && offset < Const.LIST_SCROLL_DOWN_THRESHOLD && this.imageHeight === Const.FULL_PERCENT_NUMBER) { return 0; } return offset; }
AST#method_declaration#Left controlImageScale AST#parameter_list#Left ( AST#parameter#Left offset : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left state : AST#type_annotation#Left AST#primary_type#Left ScrollState 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#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 AST#binary_expression#Left 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#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . imageHeight AST#member_expression#Right AST#expression#Right > AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . MIN_IMAGE_HEIGHT AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { // Scale down the image by offset. AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left offsetHeight = AST#expression#Left AST#call_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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . abs AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left offset AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right * AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . FULL_PERCENT_NUMBER AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right / AST#expression#Left Number AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . screenHeight 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 let AST#variable_declarator#Left heightOffset = 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 . imageHeight AST#member_expression#Right AST#expression#Right - AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . MIN_IMAGE_HEIGHT AST#member_expression#Right AST#expression#Right > AST#expression#Left offsetHeight AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right AST#ERROR#Left ? AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left offsetHeight AST#expression#Right AST#ERROR#Left : AST#qualified_type#Left this . imageHeight AST#qualified_type#Right AST#ERROR#Right - AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . MIN_IMAGE_HEIGHT AST#member_expression#Right AST#expression#Right AST#ERROR#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 . imageHeight 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 . imageHeight AST#member_expression#Right AST#expression#Right - AST#expression#Left heightOffset 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 . arrowIconOpacity 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 . arrowIconOpacity AST#member_expression#Right AST#expression#Right - AST#expression#Left AST#binary_expression#Left AST#expression#Left heightOffset 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 Const AST#expression#Right . FULL_PERCENT_NUMBER AST#member_expression#Right AST#expression#Right - AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . MIN_IMAGE_HEIGHT AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right 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#return_statement#Left return AST#expression#Left 0 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#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#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 . listPosition AST#member_expression#Right AST#expression#Right == AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . LIST_POSITION_BEGIN AST#member_expression#Right AST#expression#Right && AST#expression#Left offset AST#expression#Right AST#binary_expression#Right AST#expression#Right < AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . imageHeight AST#member_expression#Right AST#expression#Right < AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . FULL_PERCENT_NUMBER AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { // // Scale up the image by offset. AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left offsetHeight = AST#expression#Left AST#call_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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . abs AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left offset AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right * AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . FULL_PERCENT_NUMBER AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right / AST#expression#Left Number AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . screenHeight 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 let AST#variable_declarator#Left heightOffset = 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 Const AST#expression#Right . FULL_PERCENT_NUMBER AST#member_expression#Right AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . imageHeight AST#member_expression#Right AST#expression#Right > AST#expression#Left offsetHeight AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right AST#ERROR#Left ? AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left offsetHeight AST#expression#Right AST#ERROR#Left : AST#qualified_type#Left Const . FULL_PERCENT_NUMBER AST#qualified_type#Right AST#ERROR#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . imageHeight AST#member_expression#Right AST#expression#Right AST#ERROR#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 . imageHeight 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 . imageHeight AST#member_expression#Right AST#expression#Right + AST#expression#Left heightOffset 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 . arrowIconOpacity 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 . arrowIconOpacity AST#member_expression#Right AST#expression#Right + AST#expression#Left AST#binary_expression#Left AST#expression#Left heightOffset 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 Const AST#expression#Right . FULL_PERCENT_NUMBER AST#member_expression#Right AST#expression#Right - AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . MIN_IMAGE_HEIGHT AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right 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#return_statement#Left return AST#expression#Left 0 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#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#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 state AST#expression#Right === AST#expression#Left ScrollState AST#expression#Right AST#binary_expression#Right AST#expression#Right . Scroll AST#member_expression#Right AST#expression#Right && AST#expression#Left offset AST#expression#Right AST#binary_expression#Right AST#expression#Right < AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . LIST_SCROLL_DOWN_THRESHOLD AST#member_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . imageHeight AST#member_expression#Right AST#expression#Right === AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . FULL_PERCENT_NUMBER AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left 0 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 offset AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
controlImageScale(offset: number, state: ScrollState): number { if (offset > 0 && this.imageHeight > Const.MIN_IMAGE_HEIGHT) { let offsetHeight = (Math.abs(offset) * Const.FULL_PERCENT_NUMBER) / Number(this.screenHeight); let heightOffset = this.imageHeight - Const.MIN_IMAGE_HEIGHT > offsetHeight ? offsetHeight : this.imageHeight - Const.MIN_IMAGE_HEIGHT; this.imageHeight = this.imageHeight - heightOffset; this.arrowIconOpacity = this.arrowIconOpacity - heightOffset / (Const.FULL_PERCENT_NUMBER - Const.MIN_IMAGE_HEIGHT); return 0; } if (this.listPosition == Const.LIST_POSITION_BEGIN && offset < 0 && this.imageHeight < Const.FULL_PERCENT_NUMBER) { let offsetHeight = (Math.abs(offset) * Const.FULL_PERCENT_NUMBER) / Number(this.screenHeight); let heightOffset = Const.FULL_PERCENT_NUMBER - this.imageHeight > offsetHeight ? offsetHeight : Const.FULL_PERCENT_NUMBER - this.imageHeight; this.imageHeight = this.imageHeight + heightOffset; this.arrowIconOpacity = this.arrowIconOpacity + heightOffset / (Const.FULL_PERCENT_NUMBER - Const.MIN_IMAGE_HEIGHT); return 0; } if (state === ScrollState.Scroll && offset < Const.LIST_SCROLL_DOWN_THRESHOLD && this.imageHeight === Const.FULL_PERCENT_NUMBER) { return 0; } return offset; }
https://github.com/IceYuanyyy/OxHornCampus.git/blob/bb5686f77fa36db89687502e35898cda218d601f/entry/src/main/ets/pages/IntroductionPage.ets#L340-L367
34c897a0ab0ed3233f32db483463d8400d576c1a
github
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_crypto_dto/src/main/ets/crypto/util/DynamicSyncUtil.ets
arkts
@Author csx @DateTime 2024/3/20 21:19 @TODO DynamicUtil 动态协商工具类
export class DynamicSyncUtil { /** * 动态协商密钥 * @param pubKey 符合格式的非对称密钥的公钥字符串或Uint8Array字节流 * @param priKey 符合格式的非对称密钥的私钥字符串或Uint8Array字节流 * @param symAlgName 秘钥规格 * @param keyCoding 密钥编码方式(utf8/hex/base64) * @param resultCoding 返回结果编码方式(hex/base64)-默认不传为base64格式 * @returns 共享密钥 */ static dynamicKey(pubKey: string | Uint8Array, priKey: string | Uint8Array, symAlgName: string, keyName: number, keyCoding: buffer.BufferEncoding, resultCoding: buffer.BufferEncoding = 'base64'): OutDTO<string> { //公钥数据 let pubKeyArray: Uint8Array = new Uint8Array(); //私钥数据 let priKeyArray: Uint8Array = new Uint8Array(); //转换公钥 if (typeof pubKey === 'string') { let pk = CryptoSyncUtil.convertPubKeyFromStr(pubKey as string, symAlgName, keyName, keyCoding); pubKeyArray = pk.pubKey.getEncoded().data; } else { pubKeyArray = pubKey as Uint8Array; } //转换私钥 if (typeof priKey === 'string') { let pik = CryptoSyncUtil.convertPriKeyFromStr(priKey as string, symAlgName, keyName, keyCoding); priKeyArray = pik.priKey.getEncoded().data; } else { priKeyArray = priKey as Uint8Array; } //创建密钥生成器 let eccGen = crypto.createAsyKeyGenerator(symAlgName); // 外部传入的公私钥对A let keyPairA = eccGen.convertKeySync({ data: pubKeyArray }, null); // 内部生成的公私钥对B let keyPairB = eccGen.convertKeySync(null, { data: priKeyArray }); let eccKeyAgreement = crypto.createKeyAgreement(symAlgName); // 使用A的公钥和B的私钥进行密钥协商 let secret1 = eccKeyAgreement.generateSecretSync(keyPairB.priKey, keyPairA.pubKey); // 两种协商的结果应当一致 if (secret1.data) { return OutDTO.OKByDataRow<string>('生成共享密钥成功', StrAndUintUtil.unitArray2StrCoding(secret1.data, resultCoding)); } else { return OutDTO.ErrorByDataRow<string>('生成共享密钥失败', '动态协商交换结果不相等,请检查公私钥是否正确!'); } } /** * 消息认证码计算 * @param str 计算字符串 * @param symAlgName 秘钥规格 * @param resultCoding 返回结果编码方式(hex/base64)-默认不传为base64格式 * @returns */ static hmac(str: string, symAlgName: string, resultCoding: buffer.BufferEncoding = 'base64'): OutDTO<string> { //创建消息认证码计算器 let mac = crypto.createMac(symAlgName); let messageData = new Uint8Array(buffer.from(str, 'utf-8').buffer); let updateLength = 200; // 默认以200字节为单位进行分段update let symKeyGenerator = crypto.createSymKeyGenerator('AES256'); // 通过非对称密钥生成器,随机生成非对称密钥 let symKey = symKeyGenerator.generateSymKeySync(); //初始化密钥 mac.initSync(symKey); for (let i = 0; i < messageData.length; i += updateLength) { let updateMessage = messageData.subarray(i, i + updateLength); let updateMessageBlob: crypto.DataBlob = { data: updateMessage }; mac.update(updateMessageBlob); } let macOutput = mac.doFinalSync(); return OutDTO.OKByDataRow<string>(symAlgName + '消息认证码计算数据成功!', StrAndUintUtil.unitArray2StrCoding(macOutput.data, resultCoding)); } }
AST#export_declaration#Left export AST#class_declaration#Left class DynamicSyncUtil AST#class_body#Left { /** * 动态协商密钥 * @param pubKey 符合格式的非对称密钥的公钥字符串或Uint8Array字节流 * @param priKey 符合格式的非对称密钥的私钥字符串或Uint8Array字节流 * @param symAlgName 秘钥规格 * @param keyCoding 密钥编码方式(utf8/hex/base64) * @param resultCoding 返回结果编码方式(hex/base64)-默认不传为base64格式 * @returns 共享密钥 */ AST#method_declaration#Left static dynamicKey AST#parameter_list#Left ( AST#parameter#Left pubKey : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left Uint8Array AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left priKey : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left Uint8Array AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left symAlgName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left keyName : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left keyCoding : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left buffer . BufferEncoding AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left resultCoding : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left buffer . BufferEncoding AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'base64' AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left OutDTO 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 let AST#variable_declarator#Left pubKeyArray : AST#type_annotation#Left AST#primary_type#Left Uint8Array 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 Uint8Array 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#variable_declaration#Left let AST#variable_declarator#Left priKeyArray : AST#type_annotation#Left AST#primary_type#Left Uint8Array 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 Uint8Array 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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left pubKey AST#expression#Right AST#unary_expression#Right AST#expression#Right === AST#expression#Left 'string' 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 pk = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CryptoSyncUtil AST#expression#Right . convertPubKeyFromStr AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left pubKey AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right , AST#expression#Left symAlgName AST#expression#Right , AST#expression#Left keyName AST#expression#Right , AST#expression#Left keyCoding 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 pubKeyArray = 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 pk AST#expression#Right . pubKey AST#member_expression#Right AST#expression#Right . getEncoded AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . data 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 else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left pubKeyArray = AST#expression#Left AST#as_expression#Left AST#expression#Left pubKey AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left Uint8Array 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#statement#Right //转换私钥 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left priKey AST#expression#Right AST#unary_expression#Right AST#expression#Right === AST#expression#Left 'string' 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 pik = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CryptoSyncUtil AST#expression#Right . convertPriKeyFromStr AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left priKey AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right , AST#expression#Left symAlgName AST#expression#Right , AST#expression#Left keyName AST#expression#Right , AST#expression#Left keyCoding 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 priKeyArray = 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 pik AST#expression#Right . priKey AST#member_expression#Right AST#expression#Right . getEncoded AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . data 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 else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left priKeyArray = AST#expression#Left AST#as_expression#Left AST#expression#Left priKey AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left Uint8Array 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#statement#Right //创建密钥生成器 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left eccGen = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left crypto AST#expression#Right . createAsyKeyGenerator AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left symAlgName 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 // 外部传入的公私钥对A AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left keyPairA = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left eccGen AST#expression#Right . convertKeySync 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 data AST#property_name#Right : AST#expression#Left pubKeyArray AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 内部生成的公私钥对B AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left keyPairB = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left eccGen AST#expression#Right . convertKeySync AST#member_expression#Right 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#object_literal#Left { AST#property_assignment#Left AST#property_name#Left data AST#property_name#Right : AST#expression#Left priKeyArray 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#variable_declaration#Left let AST#variable_declarator#Left eccKeyAgreement = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left crypto AST#expression#Right . createKeyAgreement AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left symAlgName 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 // 使用A的公钥和B的私钥进行密钥协商 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left secret1 = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left eccKeyAgreement AST#expression#Right . generateSecretSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left keyPairB AST#expression#Right . priKey AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left keyPairA AST#expression#Right . pubKey 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 AST#member_expression#Left AST#expression#Left secret1 AST#expression#Right . data 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 OutDTO AST#expression#Right . OKByDataRow AST#member_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_arguments#Right AST#argument_list#Left ( AST#expression#Left '生成共享密钥成功' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left StrAndUintUtil AST#expression#Right . unitArray2StrCoding AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left secret1 AST#expression#Right . data AST#member_expression#Right AST#expression#Right , AST#expression#Left resultCoding 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 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 OutDTO AST#expression#Right . ErrorByDataRow AST#member_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_arguments#Right AST#argument_list#Left ( AST#expression#Left '生成共享密钥失败' AST#expression#Right , AST#expression#Left '动态协商交换结果不相等,请检查公私钥是否正确!' 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#block_statement#Right AST#method_declaration#Right /** * 消息认证码计算 * @param str 计算字符串 * @param symAlgName 秘钥规格 * @param resultCoding 返回结果编码方式(hex/base64)-默认不传为base64格式 * @returns */ AST#method_declaration#Left static hmac 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#Left symAlgName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left resultCoding : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left buffer . BufferEncoding AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'base64' AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left OutDTO 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 let AST#variable_declarator#Left mac = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left crypto AST#expression#Right . createMac AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left symAlgName 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 messageData = 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#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left buffer AST#expression#Right . from AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left str AST#expression#Right , AST#expression#Left 'utf-8' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . buffer 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 let AST#variable_declarator#Left updateLength = AST#expression#Left 200 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 默认以200字节为单位进行分段update AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left symKeyGenerator = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left crypto AST#expression#Right . createSymKeyGenerator AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'AES256' 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 symKey = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left symKeyGenerator AST#expression#Right . generateSymKeySync 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 mac AST#expression#Right . initSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left symKey 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#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 messageData AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ; AST#expression#Left AST#assignment_expression#Left i += AST#expression#Left updateLength AST#expression#Right AST#assignment_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left updateMessage = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left messageData AST#expression#Right . subarray AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left i AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right + AST#expression#Left updateLength 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 updateMessageBlob : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left crypto . DataBlob 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 data AST#property_name#Right : AST#expression#Left updateMessage 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left mac AST#expression#Right . update AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left updateMessageBlob 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 macOutput = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left mac AST#expression#Right . doFinalSync 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 OutDTO AST#expression#Right . OKByDataRow AST#member_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_arguments#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left symAlgName AST#expression#Right + AST#expression#Left '消息认证码计算数据成功!' 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 StrAndUintUtil AST#expression#Right . unitArray2StrCoding AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left macOutput AST#expression#Right . data AST#member_expression#Right AST#expression#Right , AST#expression#Left resultCoding 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#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class DynamicSyncUtil { static dynamicKey(pubKey: string | Uint8Array, priKey: string | Uint8Array, symAlgName: string, keyName: number, keyCoding: buffer.BufferEncoding, resultCoding: buffer.BufferEncoding = 'base64'): OutDTO<string> { let pubKeyArray: Uint8Array = new Uint8Array(); let priKeyArray: Uint8Array = new Uint8Array(); if (typeof pubKey === 'string') { let pk = CryptoSyncUtil.convertPubKeyFromStr(pubKey as string, symAlgName, keyName, keyCoding); pubKeyArray = pk.pubKey.getEncoded().data; } else { pubKeyArray = pubKey as Uint8Array; } if (typeof priKey === 'string') { let pik = CryptoSyncUtil.convertPriKeyFromStr(priKey as string, symAlgName, keyName, keyCoding); priKeyArray = pik.priKey.getEncoded().data; } else { priKeyArray = priKey as Uint8Array; } let eccGen = crypto.createAsyKeyGenerator(symAlgName); let keyPairA = eccGen.convertKeySync({ data: pubKeyArray }, null); let keyPairB = eccGen.convertKeySync(null, { data: priKeyArray }); let eccKeyAgreement = crypto.createKeyAgreement(symAlgName); let secret1 = eccKeyAgreement.generateSecretSync(keyPairB.priKey, keyPairA.pubKey); if (secret1.data) { return OutDTO.OKByDataRow<string>('生成共享密钥成功', StrAndUintUtil.unitArray2StrCoding(secret1.data, resultCoding)); } else { return OutDTO.ErrorByDataRow<string>('生成共享密钥失败', '动态协商交换结果不相等,请检查公私钥是否正确!'); } } static hmac(str: string, symAlgName: string, resultCoding: buffer.BufferEncoding = 'base64'): OutDTO<string> { let mac = crypto.createMac(symAlgName); let messageData = new Uint8Array(buffer.from(str, 'utf-8').buffer); let updateLength = 200; let symKeyGenerator = crypto.createSymKeyGenerator('AES256'); let symKey = symKeyGenerator.generateSymKeySync(); mac.initSync(symKey); for (let i = 0; i < messageData.length; i += updateLength) { let updateMessage = messageData.subarray(i, i + updateLength); let updateMessageBlob: crypto.DataBlob = { data: updateMessage }; mac.update(updateMessageBlob); } let macOutput = mac.doFinalSync(); return OutDTO.OKByDataRow<string>(symAlgName + '消息认证码计算数据成功!', StrAndUintUtil.unitArray2StrCoding(macOutput.data, resultCoding)); } }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto_dto/src/main/ets/crypto/util/DynamicSyncUtil.ets#L29-L106
5e67950f3aa101f58ff4450b93bb454cd09c049e
gitee
yiyefangzhou24/hmwechat
27d11056003843c7e331e683478720d8efa49d17
entry/src/main/ets/default/common/components/emojiLayout.ets
arkts
emojiTabContent
emoji表情标签 Tab_item
@Builder emojiTabContent(){ Grid(){ ForEach(this.emojiItems , item=>{ GridItem() { Image($rawfile(item.file)) .height(30) .width(30) } },item => item.tag) } .columnsTemplate('1fr 1fr 1fr 1fr 1fr 1fr 1fr') .width('100%') .height(200) .rowsGap(10) .onScrollIndex((first: number) => { }) .padding({top: 20}) .backgroundColor($r('app.color.grey0')) }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right emojiTabContent AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Grid ( ) AST#container_content_body#Left { 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 . emojiItems AST#member_expression#Right AST#expression#Right , AST#ui_builder_arrow_function#Left item => AST#ui_arrow_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left GridItem ( ) 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#call_expression#Left AST#expression#Left $rawfile AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . file AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left 30 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#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_arrow_function_body#Right AST#ui_builder_arrow_function#Right , AST#expression#Left AST#arrow_function#Left item => AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . tag AST#member_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#for_each_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . columnsTemplate ( AST#expression#Left '1fr 1fr 1fr 1fr 1fr 1fr 1fr' AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 200 AST#expression#Right ) AST#modifier_chain_expression#Left . rowsGap ( AST#expression#Left 10 AST#expression#Right ) AST#modifier_chain_expression#Left . onScrollIndex ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left first : 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#expression#Left AST#object_literal#Left { } AST#object_literal#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 20 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.grey0' 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#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 emojiTabContent(){ Grid(){ ForEach(this.emojiItems , item=>{ GridItem() { Image($rawfile(item.file)) .height(30) .width(30) } },item => item.tag) } .columnsTemplate('1fr 1fr 1fr 1fr 1fr 1fr 1fr') .width('100%') .height(200) .rowsGap(10) .onScrollIndex((first: number) => { }) .padding({top: 20}) .backgroundColor($r('app.color.grey0')) }
https://github.com/yiyefangzhou24/hmwechat/blob/27d11056003843c7e331e683478720d8efa49d17/entry/src/main/ets/default/common/components/emojiLayout.ets#L79-L97
110ee698eea81dd4bd3c3c35389bbcb68661e8ca
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/pages/ContactsPage.ets
arkts
loadContacts
加载联系人数据
private async loadContacts(): Promise<void> { try { this.loading = true; hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, 'Starting to load contacts from ContactService...'); const contacts = await this.contactService.getAllContacts(); hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `ContactService returned ${contacts.length} contacts`); this.contacts = contacts; hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Final result: ${this.contacts.length} contacts loaded`); this.contacts.forEach((contact, index) => { hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Contact ${index + 1}: ${contact.name} (${contact.id}) - ${contact.birthday.isLunar ? 'Lunar' : 'Solar'}`); }); this.applyFilters(); } catch (error) { const err = error as Error; hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to load contacts: ${err.message}`, err.stack); this.contacts = []; this.applyFilters(); } finally { this.loading = false; } }
AST#method_declaration#Left private async loadContacts 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 . loading 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 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 'Starting to load contacts from ContactService...' 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 contacts = 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 . contactService AST#member_expression#Right AST#expression#Right . getAllContacts 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 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 AST#template_literal#Left ` ContactService returned AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left contacts AST#expression#Right . length AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right contacts ` 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 . contacts AST#member_expression#Right = AST#expression#Left contacts 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 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 ` Final result: 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 . contacts AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right contacts loaded ` 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 AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . contacts AST#member_expression#Right AST#expression#Right . forEach 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 contact AST#parameter#Right , AST#parameter#Left index 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 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 AST#template_literal#Left ` Contact AST#template_substitution#Left $ { AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right } AST#template_substitution#Right : AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left contact 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 contact AST#expression#Right . id AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ) - AST#template_substitution#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 contact AST#expression#Right . birthday AST#member_expression#Right AST#expression#Right . isLunar AST#member_expression#Right AST#expression#Right ? AST#expression#Left 'Lunar' AST#expression#Right : AST#expression#Left 'Solar' AST#expression#Right AST#conditional_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#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 this AST#expression#Right . applyFilters 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#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left err = AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left Error 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#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 load contacts: 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#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . stack 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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . contacts AST#member_expression#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_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 this AST#expression#Right . applyFilters 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#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 . loading 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 loadContacts(): Promise<void> { try { this.loading = true; hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, 'Starting to load contacts from ContactService...'); const contacts = await this.contactService.getAllContacts(); hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `ContactService returned ${contacts.length} contacts`); this.contacts = contacts; hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Final result: ${this.contacts.length} contacts loaded`); this.contacts.forEach((contact, index) => { hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Contact ${index + 1}: ${contact.name} (${contact.id}) - ${contact.birthday.isLunar ? 'Lunar' : 'Solar'}`); }); this.applyFilters(); } catch (error) { const err = error as Error; hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to load contacts: ${err.message}`, err.stack); this.contacts = []; this.applyFilters(); } finally { this.loading = false; } }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/ContactsPage.ets#L55-L79
73a49d90cc7021d579a3f15c4a6f17c8e9b2bb16
github
openharmony/arkui_ace_engine
30c7d1ee12fbedf0fabece54291d75897e2ad44f
frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/arkui/src/index.ets
arkts
Copyright (c) 2022-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 * from "./generated"
AST#export_declaration#Left export * from "./generated" AST#export_declaration#Right
export * from "./generated"
https://github.com/openharmony/arkui_ace_engine/blob/30c7d1ee12fbedf0fabece54291d75897e2ad44f/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/arkui/src/index.ets#L15-L15
bfa6511e3fbd4d8ce8cc2f634fd8a09535471fed
gitee
openharmony/developtools_profiler
73d26bb5acfcafb2b1f4f94ead5640241d1e5f73
host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/data/DataSet.ets
arkts
getValues
/** * This method is deprecated. * Use getEntries() instead. * * @return @Deprecated
public getValues(): JArrayList<T> { return this.mEntries; }
AST#method_declaration#Left public getValues AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left JArrayList AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left T 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#member_expression#Left AST#expression#Left this AST#expression#Right . mEntries AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
public getValues(): JArrayList<T> { return this.mEntries; }
https://github.com/openharmony/developtools_profiler/blob/73d26bb5acfcafb2b1f4f94ead5640241d1e5f73/host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/data/DataSet.ets#L144-L146
17d1f9657b602db79d48ea70092e7fb7407c816a
gitee
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/common/managers/SystemSizeManager.ets
arkts
SystemSizeManager
系统栏与可用区域管理工具 功能:动态计算排除系统栏后的可用区域尺寸
@ObservedV2 export class SystemSizeManager { private static instance: SystemSizeManager; private windowObj: window.Window | null = null; // 系统栏高度(像素单位) @Trace private _statusBarHeightPx: number = 0; @Trace private _bottomNavBarHeightPx: number = 0; @Trace private _indicatorHeightPx: number = 0; // 窗口原始尺寸(像素单位) @Trace private _windowWidthPx: number = 0; @Trace private _windowHeightPx: number = 0; private constructor() { // 将实例连接到 AppStorageV2,用于响应式更新 // AppStorageV2.connect(this, () => this); } /** * 获取单例实例 */ public static get shared(): SystemSizeManager { if (!SystemSizeManager.instance) { SystemSizeManager.instance = new SystemSizeManager(); } return SystemSizeManager.instance; } /** * 初始化窗口实例 * @param windowStage 窗口阶段对象 */ public init(windowStage: window.WindowStage): void { // 获取主窗口对象 this.windowObj = windowStage.getMainWindowSync(); // 设置窗口为全屏布局(内容绘制区域覆盖系统栏) // this.windowObj.setWindowLayoutFullScreen(true); // 初始化窗口尺寸和系统栏信息 this.updateWindowMetrics(); // 注册窗口监听事件 this.registerListeners(); } //=== 公开属性 ===// /** * 获取可用宽度(单位:vp) */ public get availableWidth(): number { // 全屏模式下宽度无需扣除系统栏 return px2vp(this._windowWidthPx); } /** * 获取可用高度(单位:vp) * 会自动扣除状态栏 + 底部导航栏(或指示器)的高度 */ public get availableHeight(): number { const totalSystemBarHeight = this._statusBarHeightPx + Math.max(this._bottomNavBarHeightPx, this._indicatorHeightPx); return px2vp(this._windowHeightPx - totalSystemBarHeight); } //=== 私有方法 ===// /** * 更新窗口尺寸和系统栏高度信息 */ private updateWindowMetrics(): void { if (!this.windowObj) return; // 获取窗口原始尺寸(同步方式) const props = this.windowObj.getWindowProperties(); this._windowWidthPx = props.windowRect.width; this._windowHeightPx = props.windowRect.height; // 获取系统状态栏和底部导航栏的避让区域 const systemArea = this.windowObj.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM); this._statusBarHeightPx = systemArea.topRect.height; this._bottomNavBarHeightPx = systemArea.bottomRect.height; // 获取手势指示器避让区域(部分设备存在) const indicatorArea = this.windowObj.getWindowAvoidArea( window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR ); this._indicatorHeightPx = indicatorArea.bottomRect.height; } /** * 注册窗口变化监听器 */ private registerListeners(): void { // 监听窗口尺寸变化 this.windowObj?.on('windowSizeChange', (rect) => { this._windowWidthPx = rect.width; this._windowHeightPx = rect.height; }); // 监听避让区域(系统栏)变化 this.windowObj?.on('avoidAreaChange', (data: window.AvoidAreaOptions) => { if (data.type === window.AvoidAreaType.TYPE_SYSTEM) { this._statusBarHeightPx = data.area.topRect.height; this._bottomNavBarHeightPx = data.area.bottomRect.height; } else if (data.type === window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR) { this._indicatorHeightPx = data.area.bottomRect.height; } }); } }
AST#decorated_export_declaration#Left AST#decorator#Left @ ObservedV2 AST#decorator#Right export class SystemSizeManager AST#class_body#Left { AST#property_declaration#Left private static instance : AST#type_annotation#Left AST#primary_type#Left SystemSizeManager AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left private windowObj : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#qualified_type#Left window . Window 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#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#property_declaration#Right // 系统栏高度(像素单位) AST#property_declaration#Left AST#decorator#Left @ Trace AST#decorator#Right private _statusBarHeightPx : 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 @ Trace AST#decorator#Right private _bottomNavBarHeightPx : 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 @ Trace AST#decorator#Right private _indicatorHeightPx : 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 @ Trace AST#decorator#Right private _windowWidthPx : 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 @ Trace AST#decorator#Right private _windowHeightPx : 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#constructor_declaration#Left private constructor AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { // 将实例连接到 AppStorageV2,用于响应式更新 // AppStorageV2.connect(this, () => this); } 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 SystemSizeManager 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 SystemSizeManager 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 SystemSizeManager 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 SystemSizeManager 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 SystemSizeManager AST#expression#Right . instance AST#member_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right /** * 初始化窗口实例 * @param windowStage 窗口阶段对象 */ AST#method_declaration#Left public init AST#parameter_list#Left ( AST#parameter#Left windowStage : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . WindowStage 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . windowObj AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowStage AST#expression#Right . getMainWindowSync 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 // 设置窗口为全屏布局(内容绘制区域覆盖系统栏) // this.windowObj.setWindowLayoutFullScreen(true); // 初始化窗口尺寸和系统栏信息 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 . updateWindowMetrics 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . registerListeners 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 //=== 公开属性 ===// /** * 获取可用宽度(单位:vp) */ AST#method_declaration#Left public get AST#ERROR#Left availableWidth AST#ERROR#Right 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#call_expression#Left AST#expression#Left px2vp AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . _windowWidthPx 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#method_declaration#Right /** * 获取可用高度(单位:vp) * 会自动扣除状态栏 + 底部导航栏(或指示器)的高度 */ AST#method_declaration#Left public get AST#ERROR#Left availableHeight AST#ERROR#Right 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#variable_declaration#Left const AST#variable_declarator#Left totalSystemBarHeight = 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 . _statusBarHeightPx AST#member_expression#Right AST#expression#Right + AST#expression#Left Math AST#expression#Right AST#binary_expression#Right AST#expression#Right . max 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 . _bottomNavBarHeightPx AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . _indicatorHeightPx 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#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left px2vp AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . _windowHeightPx AST#member_expression#Right AST#expression#Right - AST#expression#Left totalSystemBarHeight AST#expression#Right AST#binary_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#method_declaration#Right //=== 私有方法 ===// /** * 更新窗口尺寸和系统栏高度信息 */ AST#method_declaration#Left private updateWindowMetrics 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#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 . windowObj AST#member_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right // 获取窗口原始尺寸(同步方式) AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left props = 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 . windowObj AST#member_expression#Right AST#expression#Right . getWindowProperties 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . _windowWidthPx AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left props AST#expression#Right . windowRect AST#member_expression#Right AST#expression#Right . width 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 . _windowHeightPx AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left props AST#expression#Right . windowRect AST#member_expression#Right AST#expression#Right . height 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#variable_declaration#Left const AST#variable_declarator#Left systemArea = 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 . windowObj AST#member_expression#Right AST#expression#Right . getWindowAvoidArea 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 window AST#expression#Right . AvoidAreaType AST#member_expression#Right AST#expression#Right . TYPE_SYSTEM 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . _statusBarHeightPx AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left systemArea AST#expression#Right . topRect AST#member_expression#Right AST#expression#Right . height 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 . _bottomNavBarHeightPx AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left systemArea AST#expression#Right . bottomRect AST#member_expression#Right AST#expression#Right . height 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#variable_declaration#Left const AST#variable_declarator#Left indicatorArea = 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 . windowObj AST#member_expression#Right AST#expression#Right . getWindowAvoidArea 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 window AST#expression#Right . AvoidAreaType AST#member_expression#Right AST#expression#Right . TYPE_NAVIGATION_INDICATOR 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . _indicatorHeightPx AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left indicatorArea AST#expression#Right . bottomRect AST#member_expression#Right AST#expression#Right . height 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#method_declaration#Right /** * 注册窗口变化监听器 */ AST#method_declaration#Left private registerListeners 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . windowObj AST#member_expression#Right AST#expression#Right ?. on AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'windowSizeChange' AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left rect 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 . _windowWidthPx AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left rect AST#expression#Right . width 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 . _windowHeightPx AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left rect AST#expression#Right . height 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#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 . windowObj AST#member_expression#Right AST#expression#Right ?. on AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'avoidAreaChange' AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . AvoidAreaOptions 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#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . type AST#member_expression#Right AST#expression#Right === AST#expression#Left window AST#expression#Right AST#binary_expression#Right AST#expression#Right . AvoidAreaType AST#member_expression#Right AST#expression#Right . TYPE_SYSTEM 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 . _statusBarHeightPx AST#member_expression#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 data AST#expression#Right . area AST#member_expression#Right AST#expression#Right . topRect AST#member_expression#Right AST#expression#Right . height 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 . _bottomNavBarHeightPx AST#member_expression#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 data AST#expression#Right . area AST#member_expression#Right AST#expression#Right . bottomRect AST#member_expression#Right AST#expression#Right . height 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 else 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 data AST#expression#Right . type AST#member_expression#Right AST#expression#Right === AST#expression#Left window AST#expression#Right AST#binary_expression#Right AST#expression#Right . AvoidAreaType AST#member_expression#Right AST#expression#Right . TYPE_NAVIGATION_INDICATOR 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 . _indicatorHeightPx AST#member_expression#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 data AST#expression#Right . area AST#member_expression#Right AST#expression#Right . bottomRect AST#member_expression#Right AST#expression#Right . height 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#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
@ObservedV2 export class SystemSizeManager { private static instance: SystemSizeManager; private windowObj: window.Window | null = null; @Trace private _statusBarHeightPx: number = 0; @Trace private _bottomNavBarHeightPx: number = 0; @Trace private _indicatorHeightPx: number = 0; @Trace private _windowWidthPx: number = 0; @Trace private _windowHeightPx: number = 0; private constructor() { } public static get shared(): SystemSizeManager { if (!SystemSizeManager.instance) { SystemSizeManager.instance = new SystemSizeManager(); } return SystemSizeManager.instance; } public init(windowStage: window.WindowStage): void { this.windowObj = windowStage.getMainWindowSync(); this.updateWindowMetrics(); this.registerListeners(); } public get availableWidth(): number { return px2vp(this._windowWidthPx); } public get availableHeight(): number { const totalSystemBarHeight = this._statusBarHeightPx + Math.max(this._bottomNavBarHeightPx, this._indicatorHeightPx); return px2vp(this._windowHeightPx - totalSystemBarHeight); } private updateWindowMetrics(): void { if (!this.windowObj) return; const props = this.windowObj.getWindowProperties(); this._windowWidthPx = props.windowRect.width; this._windowHeightPx = props.windowRect.height; const systemArea = this.windowObj.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM); this._statusBarHeightPx = systemArea.topRect.height; this._bottomNavBarHeightPx = systemArea.bottomRect.height; const indicatorArea = this.windowObj.getWindowAvoidArea( window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR ); this._indicatorHeightPx = indicatorArea.bottomRect.height; } private registerListeners(): void { this.windowObj?.on('windowSizeChange', (rect) => { this._windowWidthPx = rect.width; this._windowHeightPx = rect.height; }); this.windowObj?.on('avoidAreaChange', (data: window.AvoidAreaOptions) => { if (data.type === window.AvoidAreaType.TYPE_SYSTEM) { this._statusBarHeightPx = data.area.topRect.height; this._bottomNavBarHeightPx = data.area.bottomRect.height; } else if (data.type === window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR) { this._indicatorHeightPx = data.area.bottomRect.height; } }); } }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/managers/SystemSizeManager.ets#L7-L118
3fd755a4fc0550ac574590c71f4bb9681c189fd3
github
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/NotificationUtil.ets
arkts
getErrorMsg
获取错误msg @param code @param defaultMsg
public static getErrorMsg(code: number, defaultMsg: string) { if (201 == code) { return '权限校验失败!' } else if (202 == code) { return '系统API权限校验失败!' } else if (401 == code) { return '参数检查失败!' } else if (801 == code) { return '该设备不支持此API!' } else if (1600001 == code) { return '应用通知,内部错误!' } else if (1600002 == code) { return '序列化或反序列化错误!' } else if (1600003 == code) { return '应用连接通知服务失败!' } else if (1600004 == code) { return '请开启应用通知开关!' } else if (1600005 == code) { return '通知渠道关闭!' } else if (1600006 == code) { return '通知删除失败!' } else if (1600007 == code) { return '通知不存在!' } else if (1600008 == code) { return '用户不存在!' } else if (1600009 == code) { return '通知发布频度超过限制!' } else if (1600010 == code) { return '分布式操作失败!' } else if (1600011 == code) { return '读模板配置文件错误!' } else if (1600012 == code) { return '内存空间不够!' } else if (17700001 == code) { return '包名不存在!' } else { return defaultMsg } }
AST#method_declaration#Left public static getErrorMsg AST#parameter_list#Left ( AST#parameter#Left code : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left defaultMsg : 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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left 201 AST#expression#Right == AST#expression#Left code 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#expression#Right AST#return_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 202 AST#expression#Right == AST#expression#Left code 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 '系统API权限校验失败!' AST#expression#Right AST#return_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 401 AST#expression#Right == AST#expression#Left code 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#expression#Right AST#return_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 801 AST#expression#Right == AST#expression#Left code 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 '该设备不支持此API!' AST#expression#Right AST#return_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 1600001 AST#expression#Right == AST#expression#Left code 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#expression#Right AST#return_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 1600002 AST#expression#Right == AST#expression#Left code 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#expression#Right AST#return_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 1600003 AST#expression#Right == AST#expression#Left code 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#expression#Right AST#return_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 1600004 AST#expression#Right == AST#expression#Left code 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#expression#Right AST#return_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 1600005 AST#expression#Right == AST#expression#Left code 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#expression#Right AST#return_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 1600006 AST#expression#Right == AST#expression#Left code 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#expression#Right AST#return_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 1600007 AST#expression#Right == AST#expression#Left code 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#expression#Right AST#return_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 1600008 AST#expression#Right == AST#expression#Left code 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#expression#Right AST#return_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 1600009 AST#expression#Right == AST#expression#Left code 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#expression#Right AST#return_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 1600010 AST#expression#Right == AST#expression#Left code 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#expression#Right AST#return_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 1600011 AST#expression#Right == AST#expression#Left code 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#expression#Right AST#return_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 1600012 AST#expression#Right == AST#expression#Left code 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#expression#Right AST#return_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 17700001 AST#expression#Right == AST#expression#Left code 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#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left defaultMsg AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
public static getErrorMsg(code: number, defaultMsg: string) { if (201 == code) { return '权限校验失败!' } else if (202 == code) { return '系统API权限校验失败!' } else if (401 == code) { return '参数检查失败!' } else if (801 == code) { return '该设备不支持此API!' } else if (1600001 == code) { return '应用通知,内部错误!' } else if (1600002 == code) { return '序列化或反序列化错误!' } else if (1600003 == code) { return '应用连接通知服务失败!' } else if (1600004 == code) { return '请开启应用通知开关!' } else if (1600005 == code) { return '通知渠道关闭!' } else if (1600006 == code) { return '通知删除失败!' } else if (1600007 == code) { return '通知不存在!' } else if (1600008 == code) { return '用户不存在!' } else if (1600009 == code) { return '通知发布频度超过限制!' } else if (1600010 == code) { return '分布式操作失败!' } else if (1600011 == code) { return '读模板配置文件错误!' } else if (1600012 == code) { return '内存空间不够!' } else if (17700001 == code) { return '包名不存在!' } else { return defaultMsg } }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/NotificationUtil.ets#L555-L593
782b5299705fe0349622c9ca1eb0d9bbe9a45bab
gitee
openharmony/interface_sdk-js
c349adc73e2ec1f61f6fca489b5af059e3ed6999
api/@ohos.atomicservice.AtomicServiceNavigation.d.ets
arkts
AtomicServiceNavigation
Defines AtomicServiceNavigation. @struct { AtomicServiceNavigation } @syscap SystemCapability.ArkUI.ArkUI.Full @atomicservice @since 12
@Component export declare struct AtomicServiceNavigation { /** * the information of route page.Providers methods for controlling destination page in the stack. * * @type { ?NavPathStack }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ @State navPathStack?: NavPathStack; /** * the content of Navigation. * * @type { ?Callback<void> }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ @BuilderParam navigationContent?: Callback<void>; /** * Sets the Navigation title. * * @type { ?ResourceStr }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ @Prop title?: ResourceStr; /** * The color of Navigation's TitleBar. * * @type { ?TitleOptions }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ @Prop titleOptions?: TitleOptions; /** * The background with gradient colors of Navigation. * * @type { ?GradientBackground }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 18 */ @Prop gradientBackground?: GradientBackground; /** * Hide navigation title bar. * * @type { ?boolean }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ @Prop hideTitleBar?: boolean; /** * Sets the width of navigation bar. * * @type { ?Length }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ @Prop navBarWidth?: Length; /** * Sets the mode of navigation. * * @type { ?NavigationMode }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ @Prop mode?: NavigationMode; /** * The builder of navDestination. * * @type { ?NavDestinationBuilder }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ @BuilderParam navDestinationBuilder?: NavDestinationBuilder; /** * Sets the minimum width and the maximum width of navigation bar. * * @type { ?[Dimension, Dimension] }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ @Prop navBarWidthRange?: [ Dimension, Dimension ]; /** * Sets the minimum width of content. * * @type { ?Dimension }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ @Prop minContentWidth?: Dimension; /** * Trigger callback when the visibility of navigation bar change. * * @type { ?Callback<boolean> }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ stateChangeCallback?: Callback<boolean>; /** * Trigger callback when navigation mode changes. * * @type { ?Callback<NavigationMode> }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ modeChangeCallback?: Callback<NavigationMode>; /** * The layout style users defined and inserted. * * @type { ?(CustomBuilder | Array<NavigationMenuItem>) }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 18 */ @BuilderParam menus?: CustomBuilder | Array<NavigationMenuItem>; /** * Set side bar options. * * @type { ?SideBarOptions }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 18 */ @Prop sideBarOptions?: SideBarOptions; /** * Set side bar content. * * @type { ?Callback<void> }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 18 */ @BuilderParam sideBarContent?: Callback<void>; }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export AST#ERROR#Left declare AST#ERROR#Right struct AtomicServiceNavigation AST#component_body#Left { /** * the information of route page.Providers methods for controlling destination page in the stack. * * @type { ?NavPathStack }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right navPathStack ? : AST#type_annotation#Left AST#primary_type#Left NavPathStack AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * the content of Navigation. * * @type { ?Callback<void> }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#property_declaration#Left AST#decorator#Left @ BuilderParam AST#decorator#Right navigationContent ? : 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 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#property_declaration#Right /** * Sets the Navigation title. * * @type { ?ResourceStr }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right title ? : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * The color of Navigation's TitleBar. * * @type { ?TitleOptions }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right titleOptions ? : AST#type_annotation#Left AST#primary_type#Left TitleOptions AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * The background with gradient colors of Navigation. * * @type { ?GradientBackground }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 18 */ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right gradientBackground ? : AST#type_annotation#Left AST#primary_type#Left GradientBackground AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Hide navigation title bar. * * @type { ?boolean }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right hideTitleBar ? : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Sets the width of navigation bar. * * @type { ?Length }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right navBarWidth ? : AST#type_annotation#Left AST#primary_type#Left Length AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Sets the mode of navigation. * * @type { ?NavigationMode }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right mode ? : AST#type_annotation#Left AST#primary_type#Left NavigationMode AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * The builder of navDestination. * * @type { ?NavDestinationBuilder }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#property_declaration#Left AST#decorator#Left @ BuilderParam AST#decorator#Right navDestinationBuilder ? : AST#type_annotation#Left AST#primary_type#Left NavDestinationBuilder AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Sets the minimum width and the maximum width of navigation bar. * * @type { ?[Dimension, Dimension] }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right navBarWidthRange ? : AST#type_annotation#Left AST#primary_type#Left AST#tuple_type#Left [ AST#type_annotation#Left AST#primary_type#Left Dimension AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left Dimension AST#primary_type#Right AST#type_annotation#Right ] AST#tuple_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Sets the minimum width of content. * * @type { ?Dimension }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right minContentWidth ? : AST#type_annotation#Left AST#primary_type#Left Dimension AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Trigger callback when the visibility of navigation bar change. * * @type { ?Callback<boolean> }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#property_declaration#Left stateChangeCallback ? : 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 boolean 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 /** * Trigger callback when navigation mode changes. * * @type { ?Callback<NavigationMode> }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#property_declaration#Left modeChangeCallback ? : 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 NavigationMode 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 /** * The layout style users defined and inserted. * * @type { ?(CustomBuilder | Array<NavigationMenuItem>) }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 18 */ AST#property_declaration#Left AST#decorator#Left @ BuilderParam AST#decorator#Right menus ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left CustomBuilder AST#primary_type#Right | AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left NavigationMenuItem AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Set side bar options. * * @type { ?SideBarOptions }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 18 */ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right sideBarOptions ? : AST#type_annotation#Left AST#primary_type#Left SideBarOptions AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Set side bar content. * * @type { ?Callback<void> }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 18 */ AST#property_declaration#Left AST#decorator#Left @ BuilderParam AST#decorator#Right sideBarContent ? : 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 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#property_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Component export declare struct AtomicServiceNavigation { @State navPathStack?: NavPathStack; @BuilderParam navigationContent?: Callback<void>; @Prop title?: ResourceStr; @Prop titleOptions?: TitleOptions; @Prop gradientBackground?: GradientBackground; @Prop hideTitleBar?: boolean; @Prop navBarWidth?: Length; @Prop mode?: NavigationMode; @BuilderParam navDestinationBuilder?: NavDestinationBuilder; @Prop navBarWidthRange?: [ Dimension, Dimension ]; @Prop minContentWidth?: Dimension; stateChangeCallback?: Callback<boolean>; modeChangeCallback?: Callback<NavigationMode>; @BuilderParam menus?: CustomBuilder | Array<NavigationMenuItem>; @Prop sideBarOptions?: SideBarOptions; @BuilderParam sideBarContent?: Callback<void>; }
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.atomicservice.AtomicServiceNavigation.d.ets#L145-L308
0d39fb39e9ba5be7af1dd332e8d26cbc98484148
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
entry/src/main/ets/component/TipLayout.ets
arkts
TipLayout
自定义底部菜单组件
@Preview @ComponentV2 export struct TipLayout { @Require @Param options: TipOptions; aboutToAppear(): void { this.options.backgroundColor = this.options.backgroundColor ?? $r('app.color.main_background'); this.options.backgroundBlurStyle = this.options.backgroundBlurStyle ?? BlurStyle.COMPONENT_ULTRA_THICK; } build() { Column() { Image($r('app.media.dialog_tip')) .width(100) .alignSelf(ItemAlign.Center) .margin({ top: 32 }) Text(this.options.title) .fontColor($r('app.color.color15')) .fontWeight(FontWeight.Bold) .textAlign(TextAlign.Center) .align(Alignment.TopStart) .margin({ top: 6 }) Text(this.options.content) .textAlign(TextAlign.Center) .alignSelf(ItemAlign.Center) .margin(18) .fontSize(14) Button("确定") .width(200) .height(36) .align(Alignment.Center) .alignSelf(ItemAlign.Center) .backgroundColor($r('app.color.color15')) .margin({ top: 5, bottom: 35 }) .onClick(() => { if (this.options.onAction) { this.options.onAction(DialogAction.SURE, this.options.dialogId ?? ""); } }) } .width(`calc(100% - 50vp)`) .constraintSize({ maxWidth: 400 }) .backgroundColor(this.options.backgroundColor) .backgroundBlurStyle(this.options.backgroundBlurStyle) .borderRadius(12) .clip(true) } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Preview AST#decorator#Right AST#decorator#Left @ ComponentV2 AST#decorator#Right export struct TipLayout 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 TipOptions AST#primary_type#Right AST#type_annotation#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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . backgroundColor AST#member_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 . options AST#member_expression#Right AST#expression#Right . backgroundColor AST#member_expression#Right AST#expression#Right ?? AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.main_background' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#binary_expression#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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . backgroundBlurStyle AST#member_expression#Right = 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 this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . backgroundBlurStyle AST#member_expression#Right AST#expression#Right ?? AST#expression#Left BlurStyle AST#expression#Right AST#binary_expression#Right AST#expression#Right . COMPONENT_ULTRA_THICK AST#member_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 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.dialog_tip' AST#expression#Right ) AST#resource_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 . alignSelf ( AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Center 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 top AST#property_name#Right : AST#expression#Left 32 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#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#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . title AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.color15' 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 FontWeight AST#expression#Right . Bold 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#Left . align ( AST#expression#Left AST#member_expression#Left AST#expression#Left Alignment AST#expression#Right . TopStart 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 top AST#property_name#Right : AST#expression#Left 6 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#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#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . content AST#member_expression#Right AST#expression#Right ) AST#ui_component#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#Left . alignSelf ( AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left 18 AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 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 Button ( AST#expression#Left "确定" AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 200 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 36 AST#expression#Right ) AST#modifier_chain_expression#Left . align ( AST#expression#Left AST#member_expression#Left AST#expression#Left Alignment AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . alignSelf ( AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Center 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.color15' AST#expression#Right ) AST#resource_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 top AST#property_name#Right : AST#expression#Left 5 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 35 AST#expression#Right AST#property_assignment#Right } AST#object_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#block_statement#Left { 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 this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . onAction 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . onAction AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left DialogAction AST#expression#Right . SURE 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 . options AST#member_expression#Right AST#expression#Right . dialogId 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#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#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#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#template_literal#Left ` calc(100% - 50vp) ` AST#template_literal#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 400 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( 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 . 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 this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . backgroundBlurStyle AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 12 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#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
@Preview @ComponentV2 export struct TipLayout { @Require @Param options: TipOptions; aboutToAppear(): void { this.options.backgroundColor = this.options.backgroundColor ?? $r('app.color.main_background'); this.options.backgroundBlurStyle = this.options.backgroundBlurStyle ?? BlurStyle.COMPONENT_ULTRA_THICK; } build() { Column() { Image($r('app.media.dialog_tip')) .width(100) .alignSelf(ItemAlign.Center) .margin({ top: 32 }) Text(this.options.title) .fontColor($r('app.color.color15')) .fontWeight(FontWeight.Bold) .textAlign(TextAlign.Center) .align(Alignment.TopStart) .margin({ top: 6 }) Text(this.options.content) .textAlign(TextAlign.Center) .alignSelf(ItemAlign.Center) .margin(18) .fontSize(14) Button("确定") .width(200) .height(36) .align(Alignment.Center) .alignSelf(ItemAlign.Center) .backgroundColor($r('app.color.color15')) .margin({ top: 5, bottom: 35 }) .onClick(() => { if (this.options.onAction) { this.options.onAction(DialogAction.SURE, this.options.dialogId ?? ""); } }) } .width(`calc(100% - 50vp)`) .constraintSize({ maxWidth: 400 }) .backgroundColor(this.options.backgroundColor) .backgroundBlurStyle(this.options.backgroundBlurStyle) .borderRadius(12) .clip(true) } }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/entry/src/main/ets/component/TipLayout.ets#L13-L64
a5692baa915afdf5ab0b907426201c0d0592801f
gitee
Piagari/arkts_example.git
a63b868eaa2a50dc480d487b84c4650cc6a40fc8
hmos_app-main/hmos_app-main/legado-Harmony-master/entry/src/main/ets/pages/view/BookEditor/BookEditorPage.ets
arkts
SelectComponent
保存或重置书籍编辑内容组件
@Builder SelectComponent() { Flex({justifyContent: FlexAlign.SpaceBetween}){ Button(){ Text('重置') .fontSize(16) .fontColor(this.BtnConfirmColor) } .backgroundColor(this.BtnCancelColor) .width(152) .height(38) .onClick(()=>{ }) Button(){ Text('保存') .fontSize(16) .fontColor(Color.White) } .borderRadius(7) .backgroundColor(this.BtnConfirmColor) .width(152) .height(38) .onClick(()=>{ }) } .height(64) .padding({left: 20, right: 20, top: 12, bottom: 12}) }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right SelectComponent AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_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 . SpaceBetween 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 Button ( ) 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#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . BtnConfirmColor 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#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . BtnCancelColor AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left 152 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 38 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 { } 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#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 Button ( ) 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#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 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#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 . borderRadius ( AST#expression#Left 7 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . BtnConfirmColor AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left 152 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 38 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 { } 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#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 64 AST#expression#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 20 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 20 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 12 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#builder_function_body#Right AST#method_declaration#Right
@Builder SelectComponent() { Flex({justifyContent: FlexAlign.SpaceBetween}){ Button(){ Text('重置') .fontSize(16) .fontColor(this.BtnConfirmColor) } .backgroundColor(this.BtnCancelColor) .width(152) .height(38) .onClick(()=>{ }) Button(){ Text('保存') .fontSize(16) .fontColor(Color.White) } .borderRadius(7) .backgroundColor(this.BtnConfirmColor) .width(152) .height(38) .onClick(()=>{ }) } .height(64) .padding({left: 20, right: 20, top: 12, bottom: 12}) }
https://github.com/Piagari/arkts_example.git/blob/a63b868eaa2a50dc480d487b84c4650cc6a40fc8/hmos_app-main/hmos_app-main/legado-Harmony-master/entry/src/main/ets/pages/view/BookEditor/BookEditorPage.ets#L77-L105
16c824b953d2951d4de6942e06375e3a85f0df85
github
1lck/MindFlow.git
f05fab0891716cb852946ac02ed08dd2c0b9155a
front/entry/src/main/ets/pages/tabs/MineTab.ets
arkts
getIconColor
获取图标背景色
getIconColor(index: number): string { const colors = [ Theme.primary, Theme.secondary, Theme.accent, '#4FC3F7', '#9F85FF', '#FFB74D' ]; return colors[index % colors.length]; }
AST#method_declaration#Left getIconColor AST#parameter_list#Left ( 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#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 const AST#variable_declarator#Left colors = AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left Theme AST#expression#Right . primary AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left Theme AST#expression#Right . secondary AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left Theme AST#expression#Right . accent AST#member_expression#Right AST#expression#Right , AST#expression#Left '#4FC3F7' AST#expression#Right , AST#expression#Left '#9F85FF' AST#expression#Right , AST#expression#Left '#FFB74D' 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#return_statement#Left return AST#expression#Left AST#subscript_expression#Left AST#expression#Left colors AST#expression#Right [ AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right % AST#expression#Left colors AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_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
getIconColor(index: number): string { const colors = [ Theme.primary, Theme.secondary, Theme.accent, '#4FC3F7', '#9F85FF', '#FFB74D' ]; return colors[index % colors.length]; }
https://github.com/1lck/MindFlow.git/blob/f05fab0891716cb852946ac02ed08dd2c0b9155a/front/entry/src/main/ets/pages/tabs/MineTab.ets#L239-L249
3b5660fd1e013dd8f24146caf6bffc3ee0b207af
github
Piagari/arkts_example.git
a63b868eaa2a50dc480d487b84c4650cc6a40fc8
hmos_app-main/hmos_app-main/legado-Harmony-master/entry/src/main/ets/common/LazyIDataSource/BasicDataSource.ets
arkts
clear
清空数据
public clear(){ this.originDataArray = []; this.notifyDataReload(); }
AST#method_declaration#Left public clear AST#parameter_list#Left ( ) 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 . originDataArray AST#member_expression#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#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 this AST#expression#Right . notifyDataReload 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
public clear(){ this.originDataArray = []; this.notifyDataReload(); }
https://github.com/Piagari/arkts_example.git/blob/a63b868eaa2a50dc480d487b84c4650cc6a40fc8/hmos_app-main/hmos_app-main/legado-Harmony-master/entry/src/main/ets/common/LazyIDataSource/BasicDataSource.ets#L25-L28
fe5d547a1adc56df8b9392c28bc9713c615f8004
github
Joker-x-dev/HarmonyKit.git
f97197ce157df7f303244fba42e34918306dfb08
feature/main/src/main/ets/view/ExpandPage.ets
arkts
构建扩展页面 @returns {void} 无返回值
build() { AppNavDestination({ title: $r("app.string.expand"), viewModel: this.vm, paddingValue: { top: this.windowSafeAreaState.topInset, left: this.windowSafeAreaState.leftInset, right: this.windowSafeAreaState.rightInset, } }) { this.ExpandContent(); } }
AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left AppNavDestination ( AST#component_parameters#Left { AST#component_parameter#Left title : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.expand" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left viewModel : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . vm AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left paddingValue : 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . windowSafeAreaState AST#member_expression#Right AST#expression#Right . topInset 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . windowSafeAreaState AST#member_expression#Right AST#expression#Right . leftInset 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . windowSafeAreaState AST#member_expression#Right AST#expression#Right . rightInset AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , } AST#object_literal#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_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 . ExpandContent 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#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() { AppNavDestination({ title: $r("app.string.expand"), viewModel: this.vm, paddingValue: { top: this.windowSafeAreaState.topInset, left: this.windowSafeAreaState.leftInset, right: this.windowSafeAreaState.rightInset, } }) { this.ExpandContent(); } }
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/feature/main/src/main/ets/view/ExpandPage.ets#L29-L41
0b96198bdeb2938e0236a9f621ee2321b5d17a37
github
openharmony/arkui_ace_engine
30c7d1ee12fbedf0fabece54291d75897e2ad44f
frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/arkui/src/Storage.ets
arkts
Define LocalStorage. @since 9
export class LocalStorage { private static shared?: LocalStorage /** @internal */ readonly map: StorageMap /** * Constructor. * @since 9 */ constructor
AST#export_declaration#Left export AST#ERROR#Left class LocalStorage { AST#property_declaration#Left private static shared ? : AST#type_annotation#Left AST#primary_type#Left LocalStorage AST#primary_type#Right AST#type_annotation#Right /** @internal */ AST#property_declaration#Right readonly map : StorageMap AST#ERROR#Right /** * Constructor. * @since 9 */ AST#variable_declaration#Left const AST#variable_declarator#Left ructor AST#variable_declarator#Right AST#variable_declaration#Right AST#export_declaration#Right
export class LocalStorage { private static shared?: LocalStorage readonly map: StorageMap constructor
https://github.com/openharmony/arkui_ace_engine/blob/30c7d1ee12fbedf0fabece54291d75897e2ad44f/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/arkui/src/Storage.ets#L429-L437
1715c96983dc43576f6f806ab59d6edc2f915df2
gitee
zqaini002/YaoYaoLingXian.git
5095b12cbeea524a87c42d0824b1702978843d39
YaoYaoLingXian/entry/src/main/ets/services/TaskService.ets
arkts
获取任务的进度记录 @param taskId 任务ID @returns 进度记录列表
export function getTaskProgress(taskId: number): Promise<Progress[]> { try { return request<Progress[]>( RequestMethod.GET, `/progress/task/${taskId}` ); } catch (error) { console.error(`获取任务进度记录失败: ${error instanceof Error ? error.message : String(error)}`); throw new Error(`获取任务进度记录失败: ${error instanceof Error ? error.message : String(error)}`); } }
AST#export_declaration#Left export AST#function_declaration#Left function getTaskProgress AST#parameter_list#Left ( AST#parameter#Left taskId : 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#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Progress [ ] 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#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left request AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Progress [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left RequestMethod AST#expression#Right . GET AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` /progress/task/ AST#template_substitution#Left $ { AST#expression#Left taskId 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#return_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 AST#template_literal#Left ` 获取任务进度记录失败: AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#conditional_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#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . message AST#member_expression#Right AST#expression#Right : AST#expression#Left String AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error 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#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 ` 获取任务进度记录失败: AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#conditional_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#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . message AST#member_expression#Right AST#expression#Right : AST#expression#Left String AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error 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#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#function_declaration#Right AST#export_declaration#Right
export function getTaskProgress(taskId: number): Promise<Progress[]> { try { return request<Progress[]>( RequestMethod.GET, `/progress/task/${taskId}` ); } catch (error) { console.error(`获取任务进度记录失败: ${error instanceof Error ? error.message : String(error)}`); throw new Error(`获取任务进度记录失败: ${error instanceof Error ? error.message : String(error)}`); } }
https://github.com/zqaini002/YaoYaoLingXian.git/blob/5095b12cbeea524a87c42d0824b1702978843d39/YaoYaoLingXian/entry/src/main/ets/services/TaskService.ets#L120-L130
9fe616ecc212874951e947e0ff96e866266a2198
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/videotrimmer/src/main/ets/model/WorkListDataSource.ets
arkts
addData
在指定索引位置增加一个元素 @param index
public addData(index: number, data: WorkItem): void { this.dataList.splice(index, 0, data); this.notifyDataAdd(index); }
AST#method_declaration#Left public addData AST#parameter_list#Left ( 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#Left data : AST#type_annotation#Left AST#primary_type#Left WorkItem 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 . dataList 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 0 AST#expression#Right , AST#expression#Left data 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 this AST#expression#Right . notifyDataAdd 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#builder_function_body#Right AST#method_declaration#Right
public addData(index: number, data: WorkItem): void { this.dataList.splice(index, 0, data); this.notifyDataAdd(index); }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/videotrimmer/src/main/ets/model/WorkListDataSource.ets#L42-L45
4b103e4d54c2c6a7894d9fa2616ed3c14156c88c
gitee
openharmony/arkui_ace_engine
30c7d1ee12fbedf0fabece54291d75897e2ad44f
frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/arkui/src/handwritten/ContentModifierHooks.ets
arkts
@memo
export function hookSelectContentModifier( receiver: ArkSelectComponent, value?: ContentModifier<MenuItemConfiguration>) { const wrappedBuilder = value?.applyContent() if (!wrappedBuilder) { return } const menuItemBuilder = (parentNode: KPointer, config: MenuItemConfiguration): KPointer => { return CallbackTransformer.transformToPeerFromCustomBuilder( memoWrapper(wrappedBuilder!.builder, [config])) } if (value) { ContentModifierHelper.contentModifierMenuItem(receiver.getPeer().peer.ptr, value!, menuItemBuilder) } }
AST#export_declaration#Left export AST#function_declaration#Left function hookSelectContentModifier AST#parameter_list#Left ( AST#parameter#Left receiver : AST#type_annotation#Left AST#primary_type#Left ArkSelectComponent AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left value ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left ContentModifier AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left MenuItemConfiguration 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#variable_declaration#Left const AST#variable_declarator#Left wrappedBuilder = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left value AST#expression#Right ?. applyContent 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#unary_expression#Left ! AST#expression#Left wrappedBuilder AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#object_literal#Left { AST#ERROR#Left return AST#ERROR#Right } AST#object_literal#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left menuItemBuilder = AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left parentNode : AST#type_annotation#Left AST#primary_type#Left KPointer AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left config : AST#type_annotation#Left AST#primary_type#Left MenuItemConfiguration AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left KPointer 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CallbackTransformer AST#expression#Right . transformToPeerFromCustomBuilder AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left memoWrapper AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#non_null_assertion_expression#Left AST#expression#Left wrappedBuilder AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right . builder AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left config AST#expression#Right ] AST#array_literal#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#ERROR#Left } if AST#ERROR#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#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 ContentModifierHelper AST#property_assignment#Right AST#object_literal#Right AST#expression#Right . contentModifierMenuItem 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 AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left receiver AST#expression#Right . getPeer AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . peer AST#member_expression#Right AST#expression#Right . ptr AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#non_null_assertion_expression#Left AST#expression#Left value AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right , AST#expression#Left menuItemBuilder 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#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export function hookSelectContentModifier( receiver: ArkSelectComponent, value?: ContentModifier<MenuItemConfiguration>) { const wrappedBuilder = value?.applyContent() if (!wrappedBuilder) { return } const menuItemBuilder = (parentNode: KPointer, config: MenuItemConfiguration): KPointer => { return CallbackTransformer.transformToPeerFromCustomBuilder( memoWrapper(wrappedBuilder!.builder, [config])) } if (value) { ContentModifierHelper.contentModifierMenuItem(receiver.getPeer().peer.ptr, value!, menuItemBuilder) } }
https://github.com/openharmony/arkui_ace_engine/blob/30c7d1ee12fbedf0fabece54291d75897e2ad44f/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/arkui/src/handwritten/ContentModifierHooks.ets#L194-L207
6ba940325f45561f975c04860b15937193b8f9b3
gitee
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
core/ui/src/main/ets/component/image/Avatar.ets
arkts
Avatar
@file 头像组件(基于 IBestAvatar 封装) @author Joker.X
@ComponentV2 export struct Avatar { /** * 头像地址 */ @Param src: ResourceStr | PixelMap | DrawableDescriptor = ""; /** * 头像大小(单位:vp) */ @Param avatarSize: number = 40; /** * 点击回调 */ @Param onTap: (() => void) | undefined = undefined; /** * 构建头像组件 * @returns {void} 无返回值 */ build(): void { IBestAvatar({ src: this.src, shape: "circle", avatarSize: this.avatarSize, onAvatarClick: (): void => this.handleAvatarTap() }); } /** * 处理头像点击 * @returns {void} 无返回值 */ private handleAvatarTap(): void { if (this.onTap) { this.onTap(); } } }
AST#decorated_export_declaration#Left AST#decorator#Left @ ComponentV2 AST#decorator#Right export struct Avatar AST#component_body#Left { /** * 头像地址 */ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right src : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left ResourceStr AST#primary_type#Right | AST#primary_type#Left PixelMap AST#primary_type#Right | AST#primary_type#Left DrawableDescriptor AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left "" AST#expression#Right ; AST#property_declaration#Right /** * 头像大小(单位:vp) */ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right avatarSize : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 40 AST#expression#Right ; AST#property_declaration#Right /** * 点击回调 */ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right onTap : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#parenthesized_type#Left ( 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#parenthesized_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 undefined AST#expression#Right ; AST#property_declaration#Right /** * 构建头像组件 * @returns {void} 无返回值 */ AST#build_method#Left build ( ) : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#build_body#Left { AST#ui_custom_component_statement#Left IBestAvatar ( AST#component_parameters#Left { AST#component_parameter#Left src : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . src AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left shape : AST#expression#Left "circle" AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left avatarSize : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . avatarSize AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left onAvatarClick : AST#expression#Left AST#arrow_function#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#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . handleAvatarTap AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) ; AST#ui_custom_component_statement#Right } AST#build_body#Right AST#build_method#Right /** * 处理头像点击 * @returns {void} 无返回值 */ AST#method_declaration#Left private handleAvatarTap 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 . onTap 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 this AST#expression#Right . onTap 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 } AST#component_body#Right AST#decorated_export_declaration#Right
@ComponentV2 export struct Avatar { @Param src: ResourceStr | PixelMap | DrawableDescriptor = ""; @Param avatarSize: number = 40; @Param onTap: (() => void) | undefined = undefined; build(): void { IBestAvatar({ src: this.src, shape: "circle", avatarSize: this.avatarSize, onAvatarClick: (): void => this.handleAvatarTap() }); } private handleAvatarTap(): void { if (this.onTap) { this.onTap(); } } }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/ui/src/main/ets/component/image/Avatar.ets#L7-L47
9c97223627b9fea8def6e03768994f0c9912422a
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/notification/NotificationService.ets
arkts
requestPermission
请求通知权限
public async requestPermission(): Promise<boolean> { try { hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, '[NotificationService] Requesting notification permission...'); // 模拟权限请求 return true; } catch (error) { hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `[NotificationService] Failed to request permission: ${error}`); return false; } }
AST#method_declaration#Left public async requestPermission 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 boolean 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 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 '[NotificationService] Requesting notification permission...' 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#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 ` [NotificationService] Failed to request permission: 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#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#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
public async requestPermission(): Promise<boolean> { try { hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, '[NotificationService] Requesting notification permission...'); return true; } catch (error) { hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `[NotificationService] Failed to request permission: ${error}`); return false; } }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/notification/NotificationService.ets#L128-L138
ad2d2320c8af3715648b0661467707b93e5cdcc1
github
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_ui/src/main/ets/ui/prompt/ConfirmUtil.ets
arkts
ConfirmUtil
@Author csx @DateTime 2024/3/27 19:56 @TODO ConfirmUtil @Use 详细使用方法以及文档详见ohpm官网,地址https://ohpm.openharmony.cn/#/cn/detail/@yunkss%2Fef_ui
@Component export struct ConfirmUtil { @Prop @Watch("change") options: ConfirmOptions = new ConfirmOptions(); private isChecked: boolean = false; /** * 自定义Tips */ private dialogControllerProgress: CustomDialogController = new CustomDialogController({ builder: ConfirmDialog({ title: this.options.title, content: this.options.content, checkTips: this.options.checkTips != undefined ? this.options.checkTips : '禁止后不再提醒', isChecked: this.isChecked, primaryButton: { value: this.options.btnList ? this.options.btnList[0] : '禁止', background: UiConst.DIALOG_OK_COLOR, fontColor: UiConst.ALERT_OK_COLOR, action: () => { this.isChecked = true; this.options.clickCallBack(0, this.isChecked); } }, secondaryButton: { value: this.options.btnList && this.options.btnList.length > 1 ? this.options.btnList[1] : '允许', background: UiConst.DIALOG_CANCEL_COLOR, fontColor: UiConst.ALERT_OK_COLOR, action: () => { this.isChecked = false; this.options.clickCallBack(1, this.isChecked); } } }), autoCancel: false, alignment: this.options.alignment != undefined ? this.options.alignment : DialogAlignment.Center, offset: this.options.offset != undefined ? this.options.offset : this.options.alignment == DialogAlignment.Bottom || this.options.alignment == DialogAlignment.BottomEnd || this.options.alignment == DialogAlignment.BottomStart ? { dx: 0, dy: -20 } : this.options.alignment == DialogAlignment.Top || this.options.alignment == DialogAlignment.TopStart || this.options.alignment == DialogAlignment.TopEnd ? { dx: 0, dy: 50 } : { dx: 0, dy: 0 }, customStyle: true, gridCount: 10, maskRect: { x: 0, y: 0, width: '100%', height: '100%' }, // maskColor: UiConst.DIALOG_CANCEL_COLOR, openAnimation: { duration: 500, tempo: 0.7, curve: Curve.EaseInOut }, closeAnimation: { duration: 500, tempo: 0.7, curve: Curve.FastOutLinearIn }, showInSubWindow: false, isModal: true }) change() { if (!this.options.title) { this.options.title = '操作确认'; }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct ConfirmUtil AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right AST#decorator#Left @ Watch ( AST#expression#Left "change" AST#expression#Right ) AST#decorator#Right options : AST#type_annotation#Left AST#primary_type#Left ConfirmOptions 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 ConfirmOptions 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 private isChecked : 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 /** * 自定义Tips */ AST#property_declaration#Left private dialogControllerProgress : AST#type_annotation#Left AST#primary_type#Left CustomDialogController AST#primary_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#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 ConfirmDialog 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#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 . title AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left content 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 . options AST#member_expression#Right AST#expression#Right . content AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left checkTips AST#property_name#Right : 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 . options AST#member_expression#Right AST#expression#Right . checkTips AST#member_expression#Right AST#expression#Right != AST#expression#Left undefined AST#expression#Right AST#binary_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 . options AST#member_expression#Right AST#expression#Right . checkTips AST#member_expression#Right AST#expression#Right : AST#expression#Left '禁止后不再提醒' AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left isChecked AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isChecked AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left primaryButton AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left value AST#property_name#Right : 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 . options AST#member_expression#Right AST#expression#Right . btnList AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#subscript_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 . btnList 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#expression#Right AST#conditional_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left background AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left UiConst AST#expression#Right . DIALOG_OK_COLOR AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left fontColor AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left UiConst AST#expression#Right . ALERT_OK_COLOR AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left action 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 . isChecked 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . clickCallBack AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isChecked 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#arrow_function#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left secondaryButton AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left value AST#property_name#Right : 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#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 this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . btnList AST#member_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . options AST#member_expression#Right AST#expression#Right . btnList 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 AST#subscript_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 . btnList AST#member_expression#Right AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right : AST#expression#Left '允许' AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left background AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left UiConst AST#expression#Right . DIALOG_CANCEL_COLOR AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left fontColor AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left UiConst AST#expression#Right . ALERT_OK_COLOR AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left action 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 . isChecked 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#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 . options AST#member_expression#Right AST#expression#Right . clickCallBack AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 1 AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isChecked 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#arrow_function#Right AST#expression#Right AST#property_assignment#Right } AST#object_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#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left autoCancel AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#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 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 . options AST#member_expression#Right AST#expression#Right . alignment AST#member_expression#Right AST#expression#Right != AST#expression#Left undefined AST#expression#Right AST#binary_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 . options AST#member_expression#Right AST#expression#Right . alignment AST#member_expression#Right AST#expression#Right : AST#expression#Left DialogAlignment AST#expression#Right AST#conditional_expression#Right AST#expression#Right . Center AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offset AST#property_name#Right : 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#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#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#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#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#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#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 . options AST#member_expression#Right AST#expression#Right . offset AST#member_expression#Right AST#expression#Right != AST#expression#Left undefined AST#expression#Right AST#binary_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 . options AST#member_expression#Right AST#expression#Right . offset AST#member_expression#Right AST#expression#Right : AST#expression#Left this AST#expression#Right AST#conditional_expression#Right AST#expression#Right . options AST#member_expression#Right AST#expression#Right . alignment AST#member_expression#Right AST#expression#Right == AST#expression#Left DialogAlignment AST#expression#Right AST#binary_expression#Right AST#expression#Right . Bottom AST#member_expression#Right AST#expression#Right || AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . options AST#member_expression#Right AST#expression#Right . alignment AST#member_expression#Right AST#expression#Right == AST#expression#Left DialogAlignment AST#expression#Right AST#binary_expression#Right AST#expression#Right . BottomEnd AST#member_expression#Right AST#expression#Right || AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . options AST#member_expression#Right AST#expression#Right . alignment AST#member_expression#Right AST#expression#Right == AST#expression#Left DialogAlignment AST#expression#Right AST#binary_expression#Right AST#expression#Right . BottomStart AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left dx AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left dy AST#property_name#Right : AST#expression#Left AST#unary_expression#Left - AST#expression#Left 20 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right : AST#expression#Left this AST#expression#Right AST#conditional_expression#Right AST#expression#Right . options AST#member_expression#Right AST#expression#Right . alignment AST#member_expression#Right AST#expression#Right == AST#expression#Left DialogAlignment AST#expression#Right AST#binary_expression#Right AST#expression#Right . Top AST#member_expression#Right AST#expression#Right || AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . options AST#member_expression#Right AST#expression#Right . alignment AST#member_expression#Right AST#expression#Right == AST#expression#Left DialogAlignment AST#expression#Right AST#binary_expression#Right AST#expression#Right . TopStart AST#member_expression#Right AST#expression#Right || AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . options AST#member_expression#Right AST#expression#Right . alignment AST#member_expression#Right AST#expression#Right == AST#expression#Left DialogAlignment AST#expression#Right AST#binary_expression#Right AST#expression#Right . TopEnd AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left dx AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left dy AST#property_name#Right : AST#expression#Left 50 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left dx AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left dy AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left customStyle 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 gridCount AST#property_name#Right : AST#expression#Left 10 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left maskRect AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left '100%' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left height AST#property_name#Right : AST#expression#Left '100%' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right , // maskColor: UiConst.DIALOG_CANCEL_COLOR, AST#property_assignment#Left AST#property_name#Left openAnimation AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left duration AST#property_name#Right : AST#expression#Left 500 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left tempo AST#property_name#Right : AST#expression#Left 0.7 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#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left closeAnimation AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left duration AST#property_name#Right : AST#expression#Left 500 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left tempo AST#property_name#Right : AST#expression#Left 0.7 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 . FastOutLinearIn AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left showInSubWindow AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left isModal 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#ERROR#Left change 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 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 . options AST#member_expression#Right AST#expression#Right . title 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left this AST#property_assignment#Right AST#object_literal#Right AST#expression#Right . options AST#member_expression#Right AST#expression#Right . title AST#member_expression#Right = AST#expression#Left '操作确认' AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#property_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Component export struct ConfirmUtil { @Prop @Watch("change") options: ConfirmOptions = new ConfirmOptions(); private isChecked: boolean = false; private dialogControllerProgress: CustomDialogController = new CustomDialogController({ builder: ConfirmDialog({ title: this.options.title, content: this.options.content, checkTips: this.options.checkTips != undefined ? this.options.checkTips : '禁止后不再提醒', isChecked: this.isChecked, primaryButton: { value: this.options.btnList ? this.options.btnList[0] : '禁止', background: UiConst.DIALOG_OK_COLOR, fontColor: UiConst.ALERT_OK_COLOR, action: () => { this.isChecked = true; this.options.clickCallBack(0, this.isChecked); } }, secondaryButton: { value: this.options.btnList && this.options.btnList.length > 1 ? this.options.btnList[1] : '允许', background: UiConst.DIALOG_CANCEL_COLOR, fontColor: UiConst.ALERT_OK_COLOR, action: () => { this.isChecked = false; this.options.clickCallBack(1, this.isChecked); } } }), autoCancel: false, alignment: this.options.alignment != undefined ? this.options.alignment : DialogAlignment.Center, offset: this.options.offset != undefined ? this.options.offset : this.options.alignment == DialogAlignment.Bottom || this.options.alignment == DialogAlignment.BottomEnd || this.options.alignment == DialogAlignment.BottomStart ? { dx: 0, dy: -20 } : this.options.alignment == DialogAlignment.Top || this.options.alignment == DialogAlignment.TopStart || this.options.alignment == DialogAlignment.TopEnd ? { dx: 0, dy: 50 } : { dx: 0, dy: 0 }, customStyle: true, gridCount: 10, maskRect: { x: 0, y: 0, width: '100%', height: '100%' }, openAnimation: { duration: 500, tempo: 0.7, curve: Curve.EaseInOut }, closeAnimation: { duration: 500, tempo: 0.7, curve: Curve.FastOutLinearIn }, showInSubWindow: false, isModal: true }) change() { if (!this.options.title) { this.options.title = '操作确认'; }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_ui/src/main/ets/ui/prompt/ConfirmUtil.ets#L26-L80
14bf90e5ce976c537746ffd7bcb352339dd1a943
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/FormatUtil.ets
arkts
getPhoneFormat
对电话号码进行格式化 @param phone country string 表示电话号码所属国家或地区代码。 options PhoneNumberFormatOptions 电话号码格式化对象的相关选项。默认值:NATIONAL。 @returns
static getPhoneFormat(phone: string, country: string = "CN", option?: i18n.PhoneNumberFormatOptions): string { const phoneNumberFormat: i18n.PhoneNumberFormat = new i18n.PhoneNumberFormat(country, option); return phoneNumberFormat.format(phone); }
AST#method_declaration#Left static getPhoneFormat AST#parameter_list#Left ( AST#parameter#Left phone : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left country : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "CN" AST#expression#Right AST#parameter#Right , AST#parameter#Left option ? : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left i18n . PhoneNumberFormatOptions 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 string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left phoneNumberFormat : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left i18n . PhoneNumberFormat 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 i18n AST#expression#Right AST#new_expression#Right AST#expression#Right . PhoneNumberFormat AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left country AST#expression#Right , AST#expression#Left option 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left phoneNumberFormat AST#expression#Right . format AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left phone 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 getPhoneFormat(phone: string, country: string = "CN", option?: i18n.PhoneNumberFormatOptions): string { const phoneNumberFormat: i18n.PhoneNumberFormat = new i18n.PhoneNumberFormat(country, option); return phoneNumberFormat.format(phone); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/FormatUtil.ets#L50-L53
3cf63d3b09c078a4bb2eeeb27eef7abc5a3568a4
gitee
openharmony/interface_sdk-js
c349adc73e2ec1f61f6fca489b5af059e3ed6999
api/@ohos.atomicservice.AtomicServiceWeb.d.ets
arkts
AtomicServiceWebController
Provides methods for controlling the AtomicServiceWeb controller. @syscap SystemCapability.ArkUI.ArkUI.Full @atomicservice @since 12
@Observed export declare class AtomicServiceWebController { /** * Gets the default user agent. * * @returns { string } Return user agent information. * @throws { BusinessError } 17100001 - Init error. The AtomicServiceWebController must be associated with a * AtomicServiceWeb component. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ getUserAgent(): string; /** * Get custom user agent. * * @returns { string } Get custom User agent information. * @throws { BusinessError } 17100001 - Init error. The AtomicServiceWebController must be associated with a * AtomicServiceWeb component. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ getCustomUserAgent(): string; /** * Set custom user agent. * * @param { string } userAgent - User custom agent information. * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. * <br>2. Incorrect parameter types. * @throws { BusinessError } 17100001 - Init error. The AtomicServiceWebController must be associated with a * AtomicServiceWeb component. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ setCustomUserAgent(userAgent: string): void; /** * Refreshes the current URL. * * @throws { BusinessError } 17100001 - Init error. The AtomicServiceWebController must be associated with a * AtomicServiceWeb component. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ refresh(): void; /** * Goes forward in the history of the web page. * * @throws { BusinessError } 17100001 - Init error. The AtomicServiceWebController must be associated with a * AtomicServiceWeb component. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ forward(): void; /** * Goes back in the history of the web page. * * @throws { BusinessError } 17100001 - Init error. The AtomicServiceWebController must be associated with a * AtomicServiceWeb component. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ backward(): void; /** * Checks whether the web page can go forward. * * @returns { boolean } True if the web page can go forward else false. * @throws { BusinessError } 17100001 - Init error. The AtomicServiceWebController must be associated with a * AtomicServiceWeb component. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ accessForward(): boolean; /** * Checks whether the web page can go back. * * @returns { boolean } True if the web page can go back else false. * @throws { BusinessError } 17100001 - Init error. The AtomicServiceWebController must be associated with a * AtomicServiceWeb component. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ accessBackward(): boolean; /** * Checks whether the web page can go back or forward the given number of steps. * * @param { number } step - The number of steps. * @returns { boolean } True if the web page can go back else false. * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. * <br>2. Incorrect parameter types. 3.Parameter verification failed. * @throws { BusinessError } 17100001 - Init error. The AtomicServiceWebController must be associated with a * AtomicServiceWeb component. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ accessStep(step: number): boolean; /** * Loads the URL. * * @param { string | Resource } url - The URL to load. * @param { Array<WebHeader> } [headers] - Additional HTTP request header for URL. * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. * <br>2. Incorrect parameter types. 3.Parameter verification failed. * @throws { BusinessError } 17100001 - Init error. The AtomicServiceWebController must be associated with a * AtomicServiceWeb component. * @throws { BusinessError } 17100002 - Invalid url. * @throws { BusinessError } 17100003 - Invalid resource path or file type. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ loadUrl(url: string | Resource, headers?: Array<WebHeader>): void; }
AST#decorated_export_declaration#Left AST#decorator#Left @ Observed AST#decorator#Right export AST#ERROR#Left declare AST#ERROR#Right class AtomicServiceWebController AST#class_body#Left { /** * Gets the default user agent. * * @returns { string } Return user agent information. * @throws { BusinessError } 17100001 - Init error. The AtomicServiceWebController must be associated with a * AtomicServiceWeb component. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#method_declaration#Left getUserAgent 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#method_declaration#Right /** * Get custom user agent. * * @returns { string } Get custom User agent information. * @throws { BusinessError } 17100001 - Init error. The AtomicServiceWebController must be associated with a * AtomicServiceWeb component. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#method_declaration#Left getCustomUserAgent 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#method_declaration#Right /** * Set custom user agent. * * @param { string } userAgent - User custom agent information. * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. * <br>2. Incorrect parameter types. * @throws { BusinessError } 17100001 - Init error. The AtomicServiceWebController must be associated with a * AtomicServiceWeb component. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#method_declaration#Left setCustomUserAgent AST#parameter_list#Left ( AST#parameter#Left userAgent : 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#method_declaration#Right /** * Refreshes the current URL. * * @throws { BusinessError } 17100001 - Init error. The AtomicServiceWebController must be associated with a * AtomicServiceWeb component. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#method_declaration#Left refresh 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#method_declaration#Right /** * Goes forward in the history of the web page. * * @throws { BusinessError } 17100001 - Init error. The AtomicServiceWebController must be associated with a * AtomicServiceWeb component. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#method_declaration#Left forward 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#method_declaration#Right /** * Goes back in the history of the web page. * * @throws { BusinessError } 17100001 - Init error. The AtomicServiceWebController must be associated with a * AtomicServiceWeb component. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#method_declaration#Left backward 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#method_declaration#Right /** * Checks whether the web page can go forward. * * @returns { boolean } True if the web page can go forward else false. * @throws { BusinessError } 17100001 - Init error. The AtomicServiceWebController must be associated with a * AtomicServiceWeb component. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#method_declaration#Left accessForward 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#method_declaration#Right /** * Checks whether the web page can go back. * * @returns { boolean } True if the web page can go back else false. * @throws { BusinessError } 17100001 - Init error. The AtomicServiceWebController must be associated with a * AtomicServiceWeb component. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#method_declaration#Left accessBackward 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#method_declaration#Right /** * Checks whether the web page can go back or forward the given number of steps. * * @param { number } step - The number of steps. * @returns { boolean } True if the web page can go back else false. * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. * <br>2. Incorrect parameter types. 3.Parameter verification failed. * @throws { BusinessError } 17100001 - Init error. The AtomicServiceWebController must be associated with a * AtomicServiceWeb component. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#method_declaration#Left accessStep AST#parameter_list#Left ( AST#parameter#Left step : 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#method_declaration#Right /** * Loads the URL. * * @param { string | Resource } url - The URL to load. * @param { Array<WebHeader> } [headers] - Additional HTTP request header for URL. * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. * <br>2. Incorrect parameter types. 3.Parameter verification failed. * @throws { BusinessError } 17100001 - Init error. The AtomicServiceWebController must be associated with a * AtomicServiceWeb component. * @throws { BusinessError } 17100002 - Invalid url. * @throws { BusinessError } 17100003 - Invalid resource path or file type. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#method_declaration#Left loadUrl AST#parameter_list#Left ( AST#parameter#Left url : 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#parameter#Right , AST#parameter#Left headers ? : 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 WebHeader 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#method_declaration#Right } AST#class_body#Right AST#decorated_export_declaration#Right
@Observed export declare class AtomicServiceWebController { getUserAgent(): string; getCustomUserAgent(): string; setCustomUserAgent(userAgent: string): void; refresh(): void; forward(): void; backward(): void; accessForward(): boolean; accessBackward(): boolean; accessStep(step: number): boolean; loadUrl(url: string | Resource, headers?: Array<WebHeader>): void; }
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.atomicservice.AtomicServiceWeb.d.ets#L343-L471
5792a31f4971b7d370ea8774bb23fc2fa79f7fcb
gitee
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
NavigationRouter/RouterModule/src/main/ets/utils/RouterModule.ets
arkts
popToName
[Start static_popToName] 直接跳转到指定路由
public static popToName(routerName: string, builderName: string): void { RouterModule.getRouter(routerName).popToName(builderName); }
AST#method_declaration#Left public static popToName AST#parameter_list#Left ( AST#parameter#Left routerName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , 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 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 RouterModule AST#expression#Right . getRouter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left routerName AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . popToName 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#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
public static popToName(routerName: string, builderName: string): void { RouterModule.getRouter(routerName).popToName(builderName); }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/NavigationRouter/RouterModule/src/main/ets/utils/RouterModule.ets#L76-L78
74049b9b93ba079058ef2fd388f1e9e44c5cade6
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/videotrimmer/src/main/ets/videotrimmer/RangeSeekBarView.ets
arkts
onRangeValueChanged
选取时间变动事件
onRangeValueChanged() { let x0: number = this.scroller.currentOffset().xOffset; let start: number = x0 + this.leftThumbRect[2] - this.leftThumbWidth; let end: number = start + this.transparentWidth; let startTime: number = start * CommonConstants.US_ONE_SECOND / this.msPxAvg; this.leftText = this.showThumbText(startTime); let endTime: number = end * CommonConstants.US_ONE_SECOND / this.msPxAvg; this.rightText = this.showThumbText(endTime); if (this.mRangSeekBarListener) { this.mRangSeekBarListener.onRangeSeekBarValuesChanged(startTime, endTime); } }
AST#method_declaration#Left onRangeValueChanged AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left x0 : 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scroller AST#member_expression#Right AST#expression#Right . currentOffset AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . xOffset 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 start : 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#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left x0 AST#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . leftThumbRect AST#member_expression#Right AST#expression#Right [ AST#expression#Left 2 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . leftThumbWidth 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 end : 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#binary_expression#Left AST#expression#Left start AST#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . transparentWidth 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 startTime : 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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left start AST#expression#Right * AST#expression#Left CommonConstants AST#expression#Right AST#binary_expression#Right AST#expression#Right . US_ONE_SECOND AST#member_expression#Right AST#expression#Right / AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . msPxAvg AST#member_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 . leftText 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 . showThumbText AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left startTime 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#variable_declaration#Left let AST#variable_declarator#Left endTime : 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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left end AST#expression#Right * AST#expression#Left CommonConstants AST#expression#Right AST#binary_expression#Right AST#expression#Right . US_ONE_SECOND AST#member_expression#Right AST#expression#Right / AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . msPxAvg AST#member_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 . rightText 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 . showThumbText AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left endTime 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#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mRangSeekBarListener 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . mRangSeekBarListener AST#member_expression#Right AST#expression#Right . onRangeSeekBarValuesChanged AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left startTime AST#expression#Right , AST#expression#Left endTime 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
onRangeValueChanged() { let x0: number = this.scroller.currentOffset().xOffset; let start: number = x0 + this.leftThumbRect[2] - this.leftThumbWidth; let end: number = start + this.transparentWidth; let startTime: number = start * CommonConstants.US_ONE_SECOND / this.msPxAvg; this.leftText = this.showThumbText(startTime); let endTime: number = end * CommonConstants.US_ONE_SECOND / this.msPxAvg; this.rightText = this.showThumbText(endTime); if (this.mRangSeekBarListener) { this.mRangSeekBarListener.onRangeSeekBarValuesChanged(startTime, endTime); } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/videotrimmer/src/main/ets/videotrimmer/RangeSeekBarView.ets#L361-L374
cbe1afe3f8c239c75045918ef9a03782948ece9a
gitee
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
OptimizationAppDelay/entry/src/main/ets/pages/TabsNegativeExample.ets
arkts
[EndExclude tabs_negative_example]
build() { Column() { // [StartExclude tabs_negative_example] Row({ space: 10 }) { ForEach(this.list, (item: string, index: number) => { Text(item) .textAlign(TextAlign.Center) .fontSize(16) .height(32) .layoutWeight(1) .fontColor(this.currentIndex === index ? Color.White : Color.Black) .backgroundColor(this.currentIndex === index ? Color.Blue : '#f2f2f2') .borderRadius(16) .onClick(() => { this.controller.changeIndex(index); this.currentIndex = index; }) }, (item: string, index: number) => JSON.stringify(item) + index) } .margin(10) // [EndExclude tabs_negative_example] Tabs({ barPosition: BarPosition.Start, controller: this.controller }) { // [StartExclude tabs_negative_example] TabContent() { this.customContent(Color.Green) } TabContent() { this.customContent(Color.Blue) } TabContent() { this.customContent(Color.Yellow) } TabContent() { this.customContent(Color.Pink) } // [EndExclude tabs_negative_example] } .barHeight(0) .layoutWeight(1) .animationDuration(1000) .scrollable(false) } .width('100%') }
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 { // [StartExclude tabs_negative_example] AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 10 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { 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 . list 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 Text ( AST#expression#Left item AST#expression#Right ) AST#ui_component#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#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 32 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 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 . currentIndex AST#member_expression#Right AST#expression#Right === AST#expression#Left index AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . White AST#member_expression#Right AST#expression#Right : AST#expression#Left Color AST#expression#Right AST#conditional_expression#Right AST#expression#Right . Black AST#member_expression#Right 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 . currentIndex AST#member_expression#Right AST#expression#Right === AST#expression#Left index AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Blue AST#member_expression#Right AST#expression#Right : AST#expression#Left '#f2f2f2' AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 16 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . controller AST#member_expression#Right AST#expression#Right . changeIndex 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#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 index 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#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_arrow_function_body#Right AST#ui_builder_arrow_function#Right , AST#expression#Left AST#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#expression#Left AST#binary_expression#Left 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 item AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left index AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#for_each_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . margin ( AST#expression#Left 10 AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // [EndExclude tabs_negative_example] AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Tabs ( AST#component_parameters#Left { AST#component_parameter#Left barPosition : AST#expression#Left AST#member_expression#Left AST#expression#Left BarPosition AST#expression#Right . Start AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left controller : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . controller AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { // [StartExclude tabs_negative_example] AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left TabContent ( ) AST#container_content_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 . customContent 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 . Green AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } 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 TabContent ( ) AST#container_content_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 . customContent 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 . Blue AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } 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 TabContent ( ) AST#container_content_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 . customContent 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 . Yellow AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } 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 TabContent ( ) AST#container_content_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 . customContent 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 . Pink AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // [EndExclude tabs_negative_example] } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . barHeight ( AST#expression#Left 0 AST#expression#Right ) AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Left . animationDuration ( AST#expression#Left 1000 AST#expression#Right ) AST#modifier_chain_expression#Left . scrollable ( AST#expression#Left AST#boolean_literal#Left false AST#boolean_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#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#build_body#Right AST#build_method#Right
build() { Column() { Row({ space: 10 }) { ForEach(this.list, (item: string, index: number) => { Text(item) .textAlign(TextAlign.Center) .fontSize(16) .height(32) .layoutWeight(1) .fontColor(this.currentIndex === index ? Color.White : Color.Black) .backgroundColor(this.currentIndex === index ? Color.Blue : '#f2f2f2') .borderRadius(16) .onClick(() => { this.controller.changeIndex(index); this.currentIndex = index; }) }, (item: string, index: number) => JSON.stringify(item) + index) } .margin(10) Tabs({ barPosition: BarPosition.Start, controller: this.controller }) { TabContent() { this.customContent(Color.Green) } TabContent() { this.customContent(Color.Blue) } TabContent() { this.customContent(Color.Yellow) } TabContent() { this.customContent(Color.Pink) } } .barHeight(0) .layoutWeight(1) .animationDuration(1000) .scrollable(false) } .width('100%') }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/OptimizationAppDelay/entry/src/main/ets/pages/TabsNegativeExample.ets#L42-L92
98b3abb1436f1eca7cff60443e0b43132e3ef0fd
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/functionalscenes/src/main/ets/model/WaterFlowDataSource.ets
arkts
getData
获取索引对应的数据 @param index 数组索引 @returns
public getData(index: number): SceneModuleInfo { return this.dataArray[index]; }
AST#method_declaration#Left public getData AST#parameter_list#Left ( 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#type_annotation#Left AST#primary_type#Left SceneModuleInfo AST#primary_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 . dataArray AST#member_expression#Right 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
public getData(index: number): SceneModuleInfo { return this.dataArray[index]; }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/functionalscenes/src/main/ets/model/WaterFlowDataSource.ets#L36-L38
d733404f72a3eafaa6b71c101d650ff0b85ae140
gitee
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
ETSUI/TransitionAnimation/entry/src/main/ets/common/constants/CommonConstants.ets
arkts
Share page url.
export const SHARE_PAGE_URL = 'pages/SharePage';
AST#export_declaration#Left export AST#variable_declaration#Left const AST#variable_declarator#Left SHARE_PAGE_URL = AST#expression#Left 'pages/SharePage' AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#export_declaration#Right
export const SHARE_PAGE_URL = 'pages/SharePage';
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/ETSUI/TransitionAnimation/entry/src/main/ets/common/constants/CommonConstants.ets#L120-L120
699c0a4359b722025f05a23a53d74c165273bd50
gitee
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_crypto_dto/src/main/ets/crypto/encryption/SM3.ets
arkts
digest
SM3摘要 @param str 带摘要的字符串 @returns 摘要后的字符串
static async digest(str: string): Promise<OutDTO<string>> { return CryptoUtil.digest(str, 'SM3'); }
AST#method_declaration#Left static async digest 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 AST#generic_type#Left OutDTO 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#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 'SM3' 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 digest(str: string): Promise<OutDTO<string>> { return CryptoUtil.digest(str, 'SM3'); }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto_dto/src/main/ets/crypto/encryption/SM3.ets#L32-L34
77d950825d35dfd77266912bfdb7c693d4c4f845
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template10/Index.ets
arkts
pop
overwrite and overload function of NavPathStack
pop(animated?: boolean | undefined): NavPathInfo | undefined pop(result: Object, animated?: boolean | undefined): NavPathInfo | undefined pop(result?: Object, animated?: boolean | undefined): NavPathInfo | undefined { console.log('[derive-test] reached DerivedNavPathStack\'s pop'); return super.pop(result, animated); }
AST#method_declaration#Left pop AST#parameter_list#Left ( AST#parameter#Left animated ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left boolean AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#ERROR#Left : AST#ERROR#Left AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left NavPathInfo AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right pop AST#ERROR#Right AST#parameter_list#Left ( AST#parameter#Left result : AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left animated ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left boolean AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#ERROR#Left AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left NavPathInfo AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right pop AST#ERROR#Right AST#parameter_list#Left ( AST#parameter#Left result ? : AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left animated ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left boolean AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#ERROR#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left NavPathInfo 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#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 '[derive-test] reached DerivedNavPathStack\'s pop' 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left super AST#expression#Right . pop AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left result AST#expression#Right , AST#expression#Left animated 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
pop(animated?: boolean | undefined): NavPathInfo | undefined pop(result: Object, animated?: boolean | undefined): NavPathInfo | undefined pop(result?: Object, animated?: boolean | undefined): NavPathInfo | undefined { console.log('[derive-test] reached DerivedNavPathStack\'s pop'); return super.pop(result, animated); }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/ArkUISample/Navigation/entry/src/main/ets/pages/navigation/template10/Index.ets#L42-L47
1b8560565ff75f5f1586b37415f6612803dd2f63
gitee
openharmony/developtools_profiler
73d26bb5acfcafb2b1f4f94ead5640241d1e5f73
host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/utils/ViewPortHandler.ets
arkts
Class that contains information about the charts current viewport settings, including offsets, scale & translation levels, ... @author Philipp Jahoda
export default class ViewPortHandler { /** * matrix used for touch events */ public mMatrixTouch: Matrix = new Matrix(); /** * this rectangle defines the area in which graph values can be drawn */ protected mContentRect = new MyRect(); protected mChartWidth: number = 0; protected mChartHeight: number = 0; /** * minimum scale value on the y-axis */ private mMinScaleY: number = 1; /** * maximum scale value on the y-axis */ private mMaxScaleY: number = Number.MAX_VALUE; /** * minimum scale value on the x-axis */ private mMinScaleX: number = 1; /** * maximum scale value on the x-axis */ private mMaxScaleX: number = Number.MAX_VALUE; /** * contains the current scale factor of the x-axis */ private mScaleX: number = 1; /** * contains the current scale factor of the y-axis */ private mScaleY: number = 1; /** * current translation (drag distance) on the x-axis */ private mTransX: number = 0; /** * current translation (drag distance) on the y-axis */ private mTransY: number = 0; /** * offset that allows the chart to be dragged over its bounds on the x-axis */ private mTransOffsetX: number = 0; /** * offset that allows the chart to be dragged over its bounds on the x-axis */ private mTransOffsetY: number = 0; /** * Sets the width and height of the chart. * * @param width * @param height */ public setChartDimens(width: number, height: number) { var offsetLeft = this.offsetLeft(); var offsetTop = this.offsetTop(); var offsetRight = this.offsetRight(); var offsetBottom = this.offsetBottom(); this.mChartHeight = height; this.mChartWidth = width; this.restrainViewPort(offsetLeft, offsetTop, offsetRight, offsetBottom); } public hasChartDimens(): boolean { if (this.mChartHeight > 0 && this.mChartWidth > 0) { return true; } else { return false; } } public restrainViewPort(offsetLeft: number, offsetTop: number, offsetRight: number, offsetBottom: number) { this.mContentRect.set(offsetLeft, offsetTop, this.mChartWidth - offsetRight, this.mChartHeight - offsetBottom); } public offsetLeft(): number { return this.mContentRect.left; } public offsetRight(): number { return this.mChartWidth - this.mContentRect.right; } public offsetTop(): number { return this.mContentRect.top; } public offsetBottom(): number { return this.mChartHeight - this.mContentRect.bottom; } public contentTop(): number { return this.mContentRect.top; } public contentLeft(): number { return this.mContentRect.left; } public contentRight(): number { return this.mContentRect.right; } public contentBottom(): number { return this.mContentRect.bottom; } public contentWidth(): number { return this.mContentRect.width(); } public contentHeight(): number { return this.mContentRect.height(); } public getContentRect(): MyRect { return this.mContentRect; } public getContentCenter(): MPPointF { return MPPointF.getInstance(this.mContentRect.centerX(), this.mContentRect.centerY()); } public getChartHeight(): number { return this.mChartHeight; } public getChartWidth(): number { return this.mChartWidth; } /** * Returns the smallest extension of the content rect (width or height). * * @return */ public getSmallestContentExtension(): number { return Math.min(this.mContentRect.width(), this.mContentRect.height()); } /** * ################ ################ ################ ################ */ /** CODE BELOW THIS RELATED TO SCALING AND GESTURES */ /** * Zooms in by 1.4f, x and y are the coordinates (in pixels) of the zoom * center. * * @param x * @param y */ public zoomIn(x: number, y: number, outputMatrix?: Matrix): Matrix { var save: Matrix = outputMatrix == null || outputMatrix == undefined ? new Matrix() : outputMatrix; save.reset(); save.set(this.mMatrixTouch); save.postScale(1.4, 1.4, x, y); return save; } public zoomOut(x: number, y: number, outputMatrix: Matrix) { outputMatrix.reset(); outputMatrix.set(this.mMatrixTouch); outputMatrix.postScale(0.7, 0.7, x, y); } /** * Zooms out to original size. * @param outputMatrix */ public resetZoom(outputMatrix: Matrix) { outputMatrix.reset(); outputMatrix.set(this.mMatrixTouch); outputMatrix.postScale(1.0, 1.0, 0.0, 0.0); } /** * Post-scales by the specified scale factors. * * @param scaleX * @param scaleY * @return */ public zoom(scaleX: number, scaleY: number, x?: number, y?: number, outputMatrix?: Matrix): Matrix { var save: Matrix = outputMatrix != null && outputMatrix != undefined ? outputMatrix : new Matrix(); save.reset(); save.set(this.mMatrixTouch); if (x != undefined && x != null && y != undefined && y != null) { save.postScale(scaleX, scaleY, x, y); } else { save.postScale(scaleX, scaleY); } return save; } /** * Sets the scale factor to the specified values. * * @param scaleX * @param scaleY * @return */ public setZoom(scaleX: number, scaleY: number, x?: number, y?: number): Matrix { var save: Matrix = new Matrix(); save.reset(); save.set(this.mMatrixTouch); if (x != undefined && y != undefined) { save.setScale(scaleX, scaleY, x, y); } else { save.setScale(scaleX, scaleY); } return save; } protected valsBufferForFitScreen: number[] = new Array<number>(9); /** * Resets all zooming and dragging and makes the chart fit exactly it's * bounds. Output Matrix is available for those who wish to cache the object. */ public fitScreen(outputMatrix?: Matrix): Matrix { var save: Matrix = outputMatrix == null || outputMatrix == undefined ? new Matrix() : outputMatrix; this.mMinScaleX = 1; this.mMinScaleY = 1; save.set(this.mMatrixTouch); var vals: number[] = save.getValues(); // reset all translations and scaling vals[Matrix.MTRANS_X] = 0; vals[Matrix.MTRANS_Y] = 0; vals[Matrix.MSCALE_X] = 1; vals[Matrix.MSCALE_Y] = 1; save.setValues(vals); return save; } /** * Post-translates to the specified points. Less Performant. * * @param transformedPts * @return */ public translate(transformedPts: number[], outputMatrix: Matrix): Matrix { var save: Matrix = outputMatrix != null && outputMatrix != undefined ? outputMatrix : new Matrix(); save.reset(); save.set(this.mMatrixTouch); const x: number = transformedPts[0] - this.offsetLeft(); const y: number = transformedPts[1] - this.offsetTop(); save.postTranslate(-x, -y); return save; } protected mCenterViewPortMatrixBuffer: Matrix = new Matrix(); /** * Centers the viewport around the specified position (x-index and y-value) * in the chart. Centering the viewport outside the bounds of the chart is * not possible. Makes most sense in combination with the * setScaleMinima(...) method. * * @param transformedPts the position to center view viewport to * @param view * @return save */ public centerViewPort(transformedPts: number[], view: Chart<any>) { let save: Matrix = this.mCenterViewPortMatrixBuffer; save.reset(); save.set(this.mMatrixTouch); const x: number = transformedPts[0] - this.offsetLeft(); const y: number = transformedPts[1] - this.offsetTop(); save.postTranslate(-x, -y); this.refresh(save, view, true); } /** * buffer for storing the 9 matrix values of a 3x3 matrix */ protected matrixBuffer: number[] = new Array<number>(9); /** * call this method to refresh the graph with a given matrix * * @param newMatrix * @return */ public refresh(newMatrix: Matrix, chart: Chart<any>, invalidate: boolean): Matrix { this.mMatrixTouch.set(newMatrix); // make sure scale and translation are within their bounds this.limitTransAndScale(this.mMatrixTouch, this.mContentRect); if (invalidate) { chart.invalidate(); } newMatrix.set(this.mMatrixTouch); return newMatrix; } /** * limits the maximum scale and X translation of the given matrix * * @param matrix */ public limitTransAndScale(matrix: Matrix, content: MyRect) { this.matrixBuffer = matrix.getValues(); var curTransX: number = this.matrixBuffer[Matrix.MTRANS_X]; var curScaleX: number = this.matrixBuffer[Matrix.MSCALE_X]; var curTransY: number = this.matrixBuffer[Matrix.MTRANS_Y]; var curScaleY: number = this.matrixBuffer[Matrix.MSCALE_Y]; // min scale-x is 1f this.mScaleX = Math.min(Math.max(this.mMinScaleX, curScaleX), this.mMaxScaleX); // min scale-y is 1f this.mScaleY = Math.min(Math.max(this.mMinScaleY, curScaleY), this.mMaxScaleY); var width: number = 0; var height: number = 0; if (content != null) { width = content.width(); height = content.height(); } var maxTransX: number = -width * (this.mScaleX - 1); this.mTransX = Math.min(Math.max(curTransX, maxTransX - this.mTransOffsetX), this.mTransOffsetX); var maxTransY: number = height * (this.mScaleY - 1); this.mTransY = Math.max(Math.min(curTransY, maxTransY + this.mTransOffsetY), -this.mTransOffsetY); this.matrixBuffer[Matrix.MTRANS_X] = this.mTransX; this.matrixBuffer[Matrix.MSCALE_X] = this.mScaleX;
AST#export_declaration#Left export default AST#ERROR#Left class ViewPortHandler { /** * matrix used for touch events */ AST#property_declaration#Left public mMatrixTouch : AST#type_annotation#Left AST#primary_type#Left Matrix 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 Matrix 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 /** * this rectangle defines the area in which graph values can be drawn */ AST#property_declaration#Left protected mContentRect = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left MyRect 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 protected mChartWidth : 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 protected mChartHeight : 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 /** * minimum scale value on the y-axis */ AST#property_declaration#Left private mMinScaleY : 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 /** * maximum scale value on the y-axis */ AST#property_declaration#Left private mMaxScaleY : 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 Number AST#expression#Right . MAX_VALUE AST#member_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * minimum scale value on the x-axis */ AST#property_declaration#Left private mMinScaleX : 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 /** * maximum scale value on the x-axis */ AST#property_declaration#Left private mMaxScaleX : 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 Number AST#expression#Right . MAX_VALUE AST#member_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * contains the current scale factor of the x-axis */ AST#property_declaration#Left private mScaleX : 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 /** * contains the current scale factor of the y-axis */ AST#property_declaration#Left private mScaleY : 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 /** * current translation (drag distance) on the x-axis */ AST#property_declaration#Left private mTransX : 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 /** * current translation (drag distance) on the y-axis */ AST#property_declaration#Left private mTransY : 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 /** * offset that allows the chart to be dragged over its bounds on the x-axis */ AST#property_declaration#Left private mTransOffsetX : 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 /** * offset that allows the chart to be dragged over its bounds on the x-axis */ AST#property_declaration#Left private mTransOffsetY : 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 /** * Sets the width and height of the chart. * * @param width * @param height */ AST#method_declaration#Left public setChartDimens AST#parameter_list#Left ( AST#parameter#Left width : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left height : 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#variable_declaration#Left var AST#variable_declarator#Left offsetLeft = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . offsetLeft 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 var AST#variable_declarator#Left offsetTop = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . offsetTop 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 var AST#variable_declarator#Left offsetRight = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . offsetRight 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 var AST#variable_declarator#Left offsetBottom = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . offsetBottom 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mChartHeight AST#member_expression#Right = AST#expression#Left height 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 . mChartWidth AST#member_expression#Right = AST#expression#Left width 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 . restrainViewPort AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left offsetLeft AST#expression#Right , AST#expression#Left offsetTop AST#expression#Right , AST#expression#Left offsetRight AST#expression#Right , AST#expression#Left offsetBottom 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 AST#method_declaration#Left public hasChartDimens 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#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 this AST#expression#Right . mChartHeight AST#member_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . mChartWidth 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#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 else 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#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left public restrainViewPort AST#parameter_list#Left ( AST#parameter#Left offsetLeft : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left offsetTop : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left offsetRight : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left offsetBottom : 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 . mContentRect AST#member_expression#Right AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left offsetLeft AST#expression#Right , AST#expression#Left offsetTop AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mChartWidth AST#member_expression#Right AST#expression#Right - AST#expression#Left offsetRight AST#expression#Right AST#binary_expression#Right AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mChartHeight AST#member_expression#Right AST#expression#Right - AST#expression#Left offsetBottom 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#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left public offsetLeft 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . mContentRect AST#member_expression#Right AST#expression#Right . left AST#member_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 offsetRight 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 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 . mChartWidth AST#member_expression#Right AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . mContentRect AST#member_expression#Right AST#expression#Right . right AST#member_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 offsetTop 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . mContentRect AST#member_expression#Right AST#expression#Right . top AST#member_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 offsetBottom 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 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 . mChartHeight AST#member_expression#Right AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . mContentRect AST#member_expression#Right AST#expression#Right . bottom AST#member_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 contentTop 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . mContentRect AST#member_expression#Right AST#expression#Right . top AST#member_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 contentLeft 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . mContentRect AST#member_expression#Right AST#expression#Right . left AST#member_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 contentRight 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . mContentRect AST#member_expression#Right AST#expression#Right . right AST#member_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 contentBottom 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . mContentRect AST#member_expression#Right AST#expression#Right . bottom AST#member_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 contentWidth 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mContentRect AST#member_expression#Right AST#expression#Right . width 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 AST#method_declaration#Left public contentHeight 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mContentRect AST#member_expression#Right AST#expression#Right . height 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 AST#method_declaration#Left public getContentRect AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left MyRect 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 . mContentRect AST#member_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 getContentCenter AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left MPPointF 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 MPPointF AST#expression#Right . getInstance 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#member_expression#Left AST#expression#Left this AST#expression#Right . mContentRect AST#member_expression#Right AST#expression#Right . centerX 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mContentRect AST#member_expression#Right AST#expression#Right . centerY 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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left public getChartHeight 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 . mChartHeight AST#member_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 getChartWidth 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 . mChartWidth AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * Returns the smallest extension of the content rect (width or height). * * @return */ AST#method_declaration#Left public getSmallestContentExtension 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . min 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#member_expression#Left AST#expression#Left this AST#expression#Right . mContentRect AST#member_expression#Right AST#expression#Right . width 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mContentRect AST#member_expression#Right AST#expression#Right . height 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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * ################ ################ ################ ################ */ /** CODE BELOW THIS RELATED TO SCALING AND GESTURES */ /** * Zooms in by 1.4f, x and y are the coordinates (in pixels) of the zoom * center. * * @param x * @param y */ AST#method_declaration#Left public zoomIn 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 outputMatrix ? : AST#type_annotation#Left AST#primary_type#Left Matrix AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left Matrix AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left var AST#variable_declarator#Left save : AST#type_annotation#Left AST#primary_type#Left Matrix AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left outputMatrix 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#expression#Left AST#binary_expression#Left AST#expression#Left outputMatrix AST#expression#Right == AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Matrix 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#expression#Left outputMatrix 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left save AST#expression#Right . reset 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 save 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 this AST#expression#Right . mMatrixTouch 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left save AST#expression#Right . postScale AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 1.4 AST#expression#Right , AST#expression#Left 1.4 AST#expression#Right , AST#expression#Left x AST#expression#Right , AST#expression#Left y 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 save AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left public zoomOut 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 outputMatrix : AST#type_annotation#Left AST#primary_type#Left Matrix 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 outputMatrix AST#expression#Right . reset 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left outputMatrix 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 this AST#expression#Right . mMatrixTouch 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 outputMatrix AST#expression#Right . postScale AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0.7 AST#expression#Right , AST#expression#Left 0.7 AST#expression#Right , AST#expression#Left x AST#expression#Right , AST#expression#Left y 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 /** * Zooms out to original size. * @param outputMatrix */ AST#method_declaration#Left public resetZoom AST#parameter_list#Left ( AST#parameter#Left outputMatrix : AST#type_annotation#Left AST#primary_type#Left Matrix 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 outputMatrix AST#expression#Right . reset 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left outputMatrix 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 this AST#expression#Right . mMatrixTouch 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 outputMatrix AST#expression#Right . postScale AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 1.0 AST#expression#Right , AST#expression#Left 1.0 AST#expression#Right , AST#expression#Left 0.0 AST#expression#Right , AST#expression#Left 0.0 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 /** * Post-scales by the specified scale factors. * * @param scaleX * @param scaleY * @return */ AST#method_declaration#Left public zoom AST#parameter_list#Left ( AST#parameter#Left scaleX : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left scaleY : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , 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 outputMatrix ? : AST#type_annotation#Left AST#primary_type#Left Matrix AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left Matrix AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left var AST#variable_declarator#Left save : AST#type_annotation#Left AST#primary_type#Left Matrix AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left outputMatrix 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#expression#Left AST#binary_expression#Left AST#expression#Left outputMatrix AST#expression#Right != AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right AST#ERROR#Left ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left outputMatrix AST#expression#Right AST#ERROR#Left : AST#ERROR#Left new Matrix AST#ERROR#Right AST#parameter_list#Left ( ) AST#parameter_list#Right ; save AST#ERROR#Right . reset AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#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 save 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 this AST#expression#Right . mMatrixTouch 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 AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left x AST#expression#Right != AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left x 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#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left y AST#expression#Right != AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left y 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#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 save AST#expression#Right . postScale AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left scaleX AST#expression#Right , AST#expression#Left scaleY AST#expression#Right , AST#expression#Left x AST#expression#Right , AST#expression#Left y 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 save AST#expression#Right . postScale AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left scaleX AST#expression#Right , AST#expression#Left scaleY 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 save AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * Sets the scale factor to the specified values. * * @param scaleX * @param scaleY * @return */ AST#method_declaration#Left public setZoom AST#parameter_list#Left ( AST#parameter#Left scaleX : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left scaleY : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , 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_list#Right : AST#type_annotation#Left AST#primary_type#Left Matrix AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left var AST#variable_declarator#Left save : AST#type_annotation#Left AST#primary_type#Left Matrix 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 Matrix 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 save AST#expression#Right . reset 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 save 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 this AST#expression#Right . mMatrixTouch 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 AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left x AST#expression#Right != AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left y AST#expression#Right != AST#expression#Left undefined AST#expression#Right AST#binary_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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left save AST#expression#Right . setScale AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left scaleX AST#expression#Right , AST#expression#Left scaleY AST#expression#Right , AST#expression#Left x AST#expression#Right , AST#expression#Left y 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 save AST#expression#Right . setScale AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left scaleX AST#expression#Right , AST#expression#Left scaleY 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 save AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#property_declaration#Left protected valsBufferForFitScreen : 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#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#expression#Left 9 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * Resets all zooming and dragging and makes the chart fit exactly it's * bounds. Output Matrix is available for those who wish to cache the object. */ AST#method_declaration#Left public fitScreen AST#parameter_list#Left ( AST#parameter#Left outputMatrix ? : AST#type_annotation#Left AST#primary_type#Left Matrix AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left Matrix AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left var AST#variable_declarator#Left save : AST#type_annotation#Left AST#primary_type#Left Matrix AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left outputMatrix 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#expression#Left AST#binary_expression#Left AST#expression#Left outputMatrix AST#expression#Right == AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Matrix 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#expression#Left outputMatrix 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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mMinScaleX 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#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mMinScaleY 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#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left save 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 this AST#expression#Right . mMatrixTouch 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#variable_declaration#Left var AST#variable_declarator#Left vals : 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#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left save AST#expression#Right . getValues 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 // reset all translations and scaling AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left vals AST#expression#Right [ AST#expression#Left AST#member_expression#Left AST#expression#Left Matrix AST#expression#Right . MTRANS_X AST#member_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left = AST#ERROR#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left 0 AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left vals AST#expression#Right [ AST#expression#Left AST#member_expression#Left AST#expression#Left Matrix AST#expression#Right . MTRANS_Y AST#member_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left = AST#ERROR#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left 0 AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left vals AST#expression#Right [ AST#expression#Left AST#member_expression#Left AST#expression#Left Matrix AST#expression#Right . MSCALE_X AST#member_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left = AST#ERROR#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left 1 AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left vals AST#expression#Right [ AST#expression#Left AST#member_expression#Left AST#expression#Left Matrix AST#expression#Right . MSCALE_Y AST#member_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left = AST#ERROR#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left 1 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 save AST#expression#Right . setValues AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left vals 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 save AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * Post-translates to the specified points. Less Performant. * * @param transformedPts * @return */ AST#method_declaration#Left public translate AST#parameter_list#Left ( AST#parameter#Left transformedPts : 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#Left outputMatrix : AST#type_annotation#Left AST#primary_type#Left Matrix AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left Matrix AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left var AST#variable_declarator#Left save : AST#type_annotation#Left AST#primary_type#Left Matrix AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left outputMatrix 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#expression#Left AST#binary_expression#Left AST#expression#Left outputMatrix AST#expression#Right != AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right AST#ERROR#Left ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left outputMatrix AST#expression#Right AST#ERROR#Left : AST#ERROR#Left new Matrix AST#ERROR#Right AST#parameter_list#Left ( ) AST#parameter_list#Right ; save AST#ERROR#Right . reset AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#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 save 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 this AST#expression#Right . mMatrixTouch 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#variable_declaration#Left const AST#variable_declarator#Left x : 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#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left transformedPts AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . offsetLeft 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 y : 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#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left transformedPts AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . offsetTop 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 save AST#expression#Right . postTranslate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#unary_expression#Left - AST#expression#Left x AST#expression#Right AST#unary_expression#Right AST#expression#Right , AST#expression#Left AST#unary_expression#Left - AST#expression#Left y AST#expression#Right AST#unary_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 save AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#property_declaration#Left protected mCenterViewPortMatrixBuffer : AST#type_annotation#Left AST#primary_type#Left Matrix 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 Matrix 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 /** * Centers the viewport around the specified position (x-index and y-value) * in the chart. Centering the viewport outside the bounds of the chart is * not possible. Makes most sense in combination with the * setScaleMinima(...) method. * * @param transformedPts the position to center view viewport to * @param view * @return save */ AST#method_declaration#Left public centerViewPort AST#parameter_list#Left ( AST#parameter#Left transformedPts : 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#Left view : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Chart AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left any 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#variable_declaration#Left let AST#variable_declarator#Left save : AST#type_annotation#Left AST#primary_type#Left Matrix AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mCenterViewPortMatrixBuffer AST#member_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 save AST#expression#Right . reset 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 save 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 this AST#expression#Right . mMatrixTouch 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#variable_declaration#Left const AST#variable_declarator#Left x : 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#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left transformedPts AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . offsetLeft 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 y : 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#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left transformedPts AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . offsetTop 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 save AST#expression#Right . postTranslate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#unary_expression#Left - AST#expression#Left x AST#expression#Right AST#unary_expression#Right AST#expression#Right , AST#expression#Left AST#unary_expression#Left - AST#expression#Left y AST#expression#Right AST#unary_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 . refresh AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left save AST#expression#Right , AST#expression#Left view 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 ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * buffer for storing the 9 matrix values of a 3x3 matrix */ AST#property_declaration#Left protected matrixBuffer : 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#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#expression#Left 9 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * call this method to refresh the graph with a given matrix * * @param newMatrix * @return */ AST#method_declaration#Left public refresh AST#parameter_list#Left ( AST#parameter#Left newMatrix : AST#type_annotation#Left AST#primary_type#Left Matrix AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left chart : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Chart AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left any 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#Left invalidate : 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#type_annotation#Left AST#primary_type#Left Matrix 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 . mMatrixTouch AST#member_expression#Right AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left newMatrix AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right // make sure scale and translation are within their bounds 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 . limitTransAndScale 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 . mMatrixTouch AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mContentRect AST#member_expression#Right 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 invalidate AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left chart AST#expression#Right . invalidate 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left newMatrix 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 this AST#expression#Right . mMatrixTouch 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 return AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left newMatrix AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right /** * limits the maximum scale and X translation of the given matrix * * @param matrix */ AST#property_declaration#Left public limitTransAndScale AST#ERROR#Left AST#parameter_list#Left ( AST#parameter#Left matrix : AST#type_annotation#Left AST#primary_type#Left Matrix AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left content : AST#type_annotation#Left AST#primary_type#Left MyRect 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . matrixBuffer AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left matrix AST#expression#Right . getValues 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 var AST#variable_declarator#Left curTransX : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . matrixBuffer AST#member_expression#Right AST#expression#Right [ AST#expression#Left AST#member_expression#Left AST#expression#Left Matrix AST#expression#Right . MTRANS_X AST#member_expression#Right 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#variable_declaration#Left var AST#variable_declarator#Left curScaleX : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . matrixBuffer AST#member_expression#Right AST#expression#Right [ AST#expression#Left AST#member_expression#Left AST#expression#Left Matrix AST#expression#Right . MSCALE_X AST#member_expression#Right 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#variable_declaration#Left var AST#variable_declarator#Left curTransY : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . matrixBuffer AST#member_expression#Right AST#expression#Right [ AST#expression#Left AST#member_expression#Left AST#expression#Left Matrix AST#expression#Right . MTRANS_Y AST#member_expression#Right 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#variable_declaration#Left var AST#variable_declarator#Left curScaleY : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . matrixBuffer AST#member_expression#Right AST#expression#Right [ AST#expression#Left AST#member_expression#Left AST#expression#Left Matrix AST#expression#Right . MSCALE_Y AST#member_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // min scale-x is 1f 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 . mScaleX AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . min 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 Math AST#expression#Right . max 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 . mMinScaleX AST#member_expression#Right AST#expression#Right , AST#expression#Left curScaleX AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mMaxScaleX 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#expression_statement#Right AST#statement#Right // min scale-y is 1f 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 . mScaleY AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . min 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 Math AST#expression#Right . max 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 . mMinScaleY AST#member_expression#Right AST#expression#Right , AST#expression#Left curScaleY AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mMaxScaleY 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#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left var AST#variable_declarator#Left width : 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left var AST#variable_declarator#Left height : 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#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 content 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 width = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left content AST#expression#Right . width 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#assignment_expression#Left height = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left content AST#expression#Right . height 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#variable_declaration#Left var AST#variable_declarator#Left maxTransX : 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#unary_expression#Left - AST#expression#Left width AST#expression#Right AST#unary_expression#Right AST#expression#Right * 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 . mScaleX 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#binary_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 . mTransX AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . min 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 Math AST#expression#Right . max AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left curTransX AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left maxTransX AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . mTransOffsetX AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mTransOffsetX 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#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left var AST#variable_declarator#Left maxTransY : 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 height AST#expression#Right * 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 . mScaleY 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#binary_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 . mTransY AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . max 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 Math AST#expression#Right . min AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left curTransY AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left maxTransY AST#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . mTransOffsetY AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#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 . mTransOffsetY 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#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . matrixBuffer AST#member_expression#Right AST#expression#Right [ AST#expression#Left AST#member_expression#Left AST#expression#Left Matrix AST#expression#Right . MTRANS_X AST#member_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mTransX AST#member_expression#Right AST#expression#Right ; AST#property_declaration#Right this . matrixBuffer AST#ERROR#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left Matrix AST#expression#Right . MSCALE_X AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#ERROR#Left = this AST#ERROR#Right . mScaleX AST#member_expression#Right AST#expression#Right ; AST#export_declaration#Right
export default class ViewPortHandler { public mMatrixTouch: Matrix = new Matrix(); protected mContentRect = new MyRect(); protected mChartWidth: number = 0; protected mChartHeight: number = 0; private mMinScaleY: number = 1; private mMaxScaleY: number = Number.MAX_VALUE; private mMinScaleX: number = 1; private mMaxScaleX: number = Number.MAX_VALUE; private mScaleX: number = 1; private mScaleY: number = 1; private mTransX: number = 0; private mTransY: number = 0; private mTransOffsetX: number = 0; private mTransOffsetY: number = 0; public setChartDimens(width: number, height: number) { var offsetLeft = this.offsetLeft(); var offsetTop = this.offsetTop(); var offsetRight = this.offsetRight(); var offsetBottom = this.offsetBottom(); this.mChartHeight = height; this.mChartWidth = width; this.restrainViewPort(offsetLeft, offsetTop, offsetRight, offsetBottom); } public hasChartDimens(): boolean { if (this.mChartHeight > 0 && this.mChartWidth > 0) { return true; } else { return false; } } public restrainViewPort(offsetLeft: number, offsetTop: number, offsetRight: number, offsetBottom: number) { this.mContentRect.set(offsetLeft, offsetTop, this.mChartWidth - offsetRight, this.mChartHeight - offsetBottom); } public offsetLeft(): number { return this.mContentRect.left; } public offsetRight(): number { return this.mChartWidth - this.mContentRect.right; } public offsetTop(): number { return this.mContentRect.top; } public offsetBottom(): number { return this.mChartHeight - this.mContentRect.bottom; } public contentTop(): number { return this.mContentRect.top; } public contentLeft(): number { return this.mContentRect.left; } public contentRight(): number { return this.mContentRect.right; } public contentBottom(): number { return this.mContentRect.bottom; } public contentWidth(): number { return this.mContentRect.width(); } public contentHeight(): number { return this.mContentRect.height(); } public getContentRect(): MyRect { return this.mContentRect; } public getContentCenter(): MPPointF { return MPPointF.getInstance(this.mContentRect.centerX(), this.mContentRect.centerY()); } public getChartHeight(): number { return this.mChartHeight; } public getChartWidth(): number { return this.mChartWidth; } public getSmallestContentExtension(): number { return Math.min(this.mContentRect.width(), this.mContentRect.height()); } public zoomIn(x: number, y: number, outputMatrix?: Matrix): Matrix { var save: Matrix = outputMatrix == null || outputMatrix == undefined ? new Matrix() : outputMatrix; save.reset(); save.set(this.mMatrixTouch); save.postScale(1.4, 1.4, x, y); return save; } public zoomOut(x: number, y: number, outputMatrix: Matrix) { outputMatrix.reset(); outputMatrix.set(this.mMatrixTouch); outputMatrix.postScale(0.7, 0.7, x, y); } public resetZoom(outputMatrix: Matrix) { outputMatrix.reset(); outputMatrix.set(this.mMatrixTouch); outputMatrix.postScale(1.0, 1.0, 0.0, 0.0); } public zoom(scaleX: number, scaleY: number, x?: number, y?: number, outputMatrix?: Matrix): Matrix { var save: Matrix = outputMatrix != null && outputMatrix != undefined ? outputMatrix : new Matrix(); save.reset(); save.set(this.mMatrixTouch); if (x != undefined && x != null && y != undefined && y != null) { save.postScale(scaleX, scaleY, x, y); } else { save.postScale(scaleX, scaleY); } return save; } public setZoom(scaleX: number, scaleY: number, x?: number, y?: number): Matrix { var save: Matrix = new Matrix(); save.reset(); save.set(this.mMatrixTouch); if (x != undefined && y != undefined) { save.setScale(scaleX, scaleY, x, y); } else { save.setScale(scaleX, scaleY); } return save; } protected valsBufferForFitScreen: number[] = new Array<number>(9); public fitScreen(outputMatrix?: Matrix): Matrix { var save: Matrix = outputMatrix == null || outputMatrix == undefined ? new Matrix() : outputMatrix; this.mMinScaleX = 1; this.mMinScaleY = 1; save.set(this.mMatrixTouch); var vals: number[] = save.getValues(); vals[Matrix.MTRANS_X] = 0; vals[Matrix.MTRANS_Y] = 0; vals[Matrix.MSCALE_X] = 1; vals[Matrix.MSCALE_Y] = 1; save.setValues(vals); return save; } public translate(transformedPts: number[], outputMatrix: Matrix): Matrix { var save: Matrix = outputMatrix != null && outputMatrix != undefined ? outputMatrix : new Matrix(); save.reset(); save.set(this.mMatrixTouch); const x: number = transformedPts[0] - this.offsetLeft(); const y: number = transformedPts[1] - this.offsetTop(); save.postTranslate(-x, -y); return save; } protected mCenterViewPortMatrixBuffer: Matrix = new Matrix(); public centerViewPort(transformedPts: number[], view: Chart<any>) { let save: Matrix = this.mCenterViewPortMatrixBuffer; save.reset(); save.set(this.mMatrixTouch); const x: number = transformedPts[0] - this.offsetLeft(); const y: number = transformedPts[1] - this.offsetTop(); save.postTranslate(-x, -y); this.refresh(save, view, true); } protected matrixBuffer: number[] = new Array<number>(9); public refresh(newMatrix: Matrix, chart: Chart<any>, invalidate: boolean): Matrix { this.mMatrixTouch.set(newMatrix); this.limitTransAndScale(this.mMatrixTouch, this.mContentRect); if (invalidate) { chart.invalidate(); } newMatrix.set(this.mMatrixTouch); return newMatrix; } public limitTransAndScale(matrix: Matrix, content: MyRect) { this.matrixBuffer = matrix.getValues(); var curTransX: number = this.matrixBuffer[Matrix.MTRANS_X]; var curScaleX: number = this.matrixBuffer[Matrix.MSCALE_X]; var curTransY: number = this.matrixBuffer[Matrix.MTRANS_Y]; var curScaleY: number = this.matrixBuffer[Matrix.MSCALE_Y]; this.mScaleX = Math.min(Math.max(this.mMinScaleX, curScaleX), this.mMaxScaleX); this.mScaleY = Math.min(Math.max(this.mMinScaleY, curScaleY), this.mMaxScaleY); var width: number = 0; var height: number = 0; if (content != null) { width = content.width(); height = content.height(); } var maxTransX: number = -width * (this.mScaleX - 1); this.mTransX = Math.min(Math.max(curTransX, maxTransX - this.mTransOffsetX), this.mTransOffsetX); var maxTransY: number = height * (this.mScaleY - 1); this.mTransY = Math.max(Math.min(curTransY, maxTransY + this.mTransOffsetY), -this.mTransOffsetY); this.matrixBuffer[Matrix.MTRANS_X] = this.mTransX; this.matrixBuffer[Matrix.MSCALE_X] = this.mScaleX;
https://github.com/openharmony/developtools_profiler/blob/73d26bb5acfcafb2b1f4f94ead5640241d1e5f73/host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/utils/ViewPortHandler.ets#L28-L387
3f732e10425c87db6365b00f94e67c3563c249ac
gitee
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/models/managers/subscription/SubscriptionInfoManager.ets
arkts
loadPreference
加载本地配置
private loadPreference(): void { try { const prefs = SubscriptionInfoPrefKeys._getPrefs(); this._isWaitingRefreshToServer = prefs.getSync(SubscriptionInfoPrefKeys.kWaitingRefresh, false) as boolean; } catch (err) { DebugLog.d(`SubscriptionInfoManager.loadPreference error: ${err}`); this._isWaitingRefreshToServer = false; } }
AST#method_declaration#Left private loadPreference 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#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left prefs = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left SubscriptionInfoPrefKeys AST#expression#Right . _getPrefs 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . _isWaitingRefreshToServer AST#member_expression#Right = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left prefs AST#expression#Right . getSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left SubscriptionInfoPrefKeys AST#expression#Right . kWaitingRefresh AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left boolean 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 ( 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 DebugLog AST#expression#Right . d AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` SubscriptionInfoManager.loadPreference error: AST#template_substitution#Left $ { AST#expression#Left err 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 . _isWaitingRefreshToServer 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 loadPreference(): void { try { const prefs = SubscriptionInfoPrefKeys._getPrefs(); this._isWaitingRefreshToServer = prefs.getSync(SubscriptionInfoPrefKeys.kWaitingRefresh, false) as boolean; } catch (err) { DebugLog.d(`SubscriptionInfoManager.loadPreference error: ${err}`); this._isWaitingRefreshToServer = false; } }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/managers/subscription/SubscriptionInfoManager.ets#L67-L75
3598a74081e64de41535c1f6ac478e4c2ca607ee
github
zl3624/harmonyos_network_samples
b8664f8bf6ef5c5a60830fe616c6807e83c21f96
code/rcp/RCPCertVerify/entry/src/main/ets/pages/Index.ets
arkts
doHttpRequest
发起http请求
doHttpRequest() { let rcpCfg = this.buildRcpCfg() let rcpSession: rcp.Session = rcp.createSession(rcpCfg) rcpSession.get(this.httpsUrl).then((response) => { if (response.body != undefined) { let result = buf2String(response.body) this.msgHistory += '请求响应信息: ' + result + "\r\n"; } }).catch((err: BusinessError) => { this.msgHistory += `err: err code is ${err.code}, err message is ${JSON.stringify(err)}\r\n`; }) }
AST#method_declaration#Left doHttpRequest AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left rcpCfg = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . buildRcpCfg 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 rcpSession : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left rcp . Session 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#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 rcp AST#expression#Right . createSession AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left rcpCfg AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left rcpSession AST#ERROR#Right . get 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 . httpsUrl AST#member_expression#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#Left response 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 response AST#expression#Right . body 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#variable_declaration#Left let AST#variable_declarator#Left result = AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left buf2String AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . body AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left this AST#ERROR#Right . msgHistory AST#member_expression#Right += AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left '请求响应信息: ' AST#expression#Right + AST#expression#Left result AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left "\r\n" AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#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#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 ` err: err 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 , err message is AST#template_substitution#Left $ { 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#template_substitution#Right \r \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#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
doHttpRequest() { let rcpCfg = this.buildRcpCfg() let rcpSession: rcp.Session = rcp.createSession(rcpCfg) rcpSession.get(this.httpsUrl).then((response) => { if (response.body != undefined) { let result = buf2String(response.body) this.msgHistory += '请求响应信息: ' + result + "\r\n"; } }).catch((err: BusinessError) => { this.msgHistory += `err: err code is ${err.code}, err message is ${JSON.stringify(err)}\r\n`; }) }
https://github.com/zl3624/harmonyos_network_samples/blob/b8664f8bf6ef5c5a60830fe616c6807e83c21f96/code/rcp/RCPCertVerify/entry/src/main/ets/pages/Index.ets#L183-L194
bcc72dd6a760ef4178fbdb7ff9d7a35875a5f21a
gitee
openharmony/interface_sdk-js
c349adc73e2ec1f61f6fca489b5af059e3ed6999
api/arkui/component/gesture.d.ets
arkts
Defines RotationGesture. @extends Gesture @syscap SystemCapability.ArkUI.ArkUI.Full @crossplatform @atomicservice @since 20
export declare class RotationGesture extends Gesture { /** * Set the value. * * @param { function } factory * @param { RotationGestureHandlerOptions } value * @returns { RotationGesture } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * * @since 20 */ static $_instantiate(factory: () => RotationGesture, value?: RotationGestureHandlerOptions): RotationGesture; /** * Rotation gesture recognition success callback. * * @param { Callback<GestureEvent> } event * @returns { RotationGesture } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * * @since 20 */ onActionStart(event: Callback<GestureEvent>): RotationGesture; /** * Callback when the Rotation gesture is moving. * * @param { Callback<GestureEvent> } event * @returns { RotationGesture } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * * @since 20 */ onActionUpdate(event: Callback<GestureEvent>): RotationGesture; /** * The Rotation gesture is successfully recognized. When the finger is lifted, the callback is triggered. * * @param { Callback<GestureEvent> } event * @returns { RotationGesture } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * * @since 20 */ onActionEnd(event: Callback<GestureEvent>): RotationGesture; /** * The Rotation gesture is successfully recognized and a callback is triggered when the touch cancel event * is received. * * @param { Callback<void> } event * @returns { RotationGesture } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * * @since 20 */ onActionCancel(event: Callback<void>): RotationGesture; }
AST#export_declaration#Left export AST#ERROR#Left declare AST#ERROR#Right AST#class_declaration#Left class RotationGesture extends AST#type_annotation#Left AST#primary_type#Left Gesture AST#primary_type#Right AST#type_annotation#Right AST#class_body#Left { /** * Set the value. * * @param { function } factory * @param { RotationGestureHandlerOptions } value * @returns { RotationGesture } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * * @since 20 */ AST#method_declaration#Left static $_instantiate AST#parameter_list#Left ( AST#parameter#Left factory : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left RotationGesture AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left value ? : AST#type_annotation#Left AST#primary_type#Left RotationGestureHandlerOptions AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left RotationGesture AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right /** * Rotation gesture recognition success callback. * * @param { Callback<GestureEvent> } event * @returns { RotationGesture } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * * @since 20 */ AST#method_declaration#Left onActionStart AST#parameter_list#Left ( AST#parameter#Left event : 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 GestureEvent 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 RotationGesture AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right /** * Callback when the Rotation gesture is moving. * * @param { Callback<GestureEvent> } event * @returns { RotationGesture } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * * @since 20 */ AST#method_declaration#Left onActionUpdate AST#parameter_list#Left ( AST#parameter#Left event : 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 GestureEvent 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 RotationGesture AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right /** * The Rotation gesture is successfully recognized. When the finger is lifted, the callback is triggered. * * @param { Callback<GestureEvent> } event * @returns { RotationGesture } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * * @since 20 */ AST#method_declaration#Left onActionEnd AST#parameter_list#Left ( AST#parameter#Left event : 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 GestureEvent 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 RotationGesture AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right /** * The Rotation gesture is successfully recognized and a callback is triggered when the touch cancel event * is received. * * @param { Callback<void> } event * @returns { RotationGesture } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * * @since 20 */ AST#method_declaration#Left onActionCancel AST#parameter_list#Left ( AST#parameter#Left event : 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 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#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left RotationGesture AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export declare class RotationGesture extends Gesture { static $_instantiate(factory: () => RotationGesture, value?: RotationGestureHandlerOptions): RotationGesture; onActionStart(event: Callback<GestureEvent>): RotationGesture; onActionUpdate(event: Callback<GestureEvent>): RotationGesture; onActionEnd(event: Callback<GestureEvent>): RotationGesture; onActionCancel(event: Callback<void>): RotationGesture; }
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/arkui/component/gesture.d.ets#L652-L715
36f0af699da023ed0add5f459c515f795cb8fe85
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
harmonyos/src/main/ets/common/types/SettingsTypes.ets
arkts
通知渠道配置接口
export interface NotificationChannelConfig { enabled: boolean; importance: NotificationImportance; showBadge: boolean; sound: boolean; vibration: boolean; lightColor?: string; }
AST#export_declaration#Left export AST#interface_declaration#Left interface NotificationChannelConfig AST#object_type#Left { AST#type_member#Left enabled : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left importance : AST#type_annotation#Left AST#primary_type#Left NotificationImportance AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left showBadge : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left sound : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left vibration : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left lightColor ? : AST#type_annotation#Left AST#primary_type#Left string 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 NotificationChannelConfig { enabled: boolean; importance: NotificationImportance; showBadge: boolean; sound: boolean; vibration: boolean; lightColor?: string; }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/harmonyos/src/main/ets/common/types/SettingsTypes.ets#L300-L307
8c1547c05a3d9751bc0a4b8cee90d5438c498b1e
github
sithvothykiv/dialog_hub.git
b676c102ef2d05f8994d170abe48dcc40cd39005
custom_dialog/src/main/ets/core/DialogHub.ets
arkts
弹窗中心DialogHub @author pll @create 2025-05-20 @modify 2025-05-30
export class DialogHub { private static isInit = false; /** * 默认配置 */ static config: DialogConfig = new DialogConfig(); /** * 设置默认统一样式 * @param configs 配置 */ static init(configs: (config: DialogConfig) => void): void { if (DialogHub.isInit) { // 后续有监听,这边要开启,如:多端适配监听屏幕变化xs、md、lg等 return } configs(DialogHub.config); DialogHub.isInit = true //TODO: 是否根据 xs md lg 各自保存一份DialogConfig,即:<'xs'|'md'|'lg', DialogConfig> } // /* ---------------------- 系统弹窗[Start] ------------------------ */ /** * 【系统】确认弹窗(支持标题、内容、按钮、复选框) * @description 该弹窗自动适配 系统ConfirmDialog 和 AlertDialog(无check) * @returns */ static getConfirm(uiContext?: UIContext): ConfirmBuilderProxy { return new ConfirmBuilderProxy(uiContext); } /** * 【系统】提示弹窗(支持设置图标、标题、内容、按钮、复选框) * @returns */ static getTips(uiContext?: UIContext): TipsBuilderProxy { return new TipsBuilderProxy(uiContext); } /** * 【系统】单选弹窗(支持设置标题、内容、确认按钮、单选列表内容设置) * @returns */ static getSelect(title: ResourceStr, confirm: ButtonOptions, radioContent: Array<SheetInfo>, uiContext?: UIContext): SelectBuilderProxy { return new SelectBuilderProxy(title, confirm, radioContent, uiContext) } /** * 【系统】显示吐司(该方法可设置样式) * @param options * @returns */ static getToast(message: ResourceStr): ToastDialog { return new ToastDialog(message) } /** * 【系统】显示吐司(可在init内预设toast样式) * @param message 吐司内容 */ static showToast(message: string | Resource) { ToastDialog.show(message); } // 待支持popover系统弹窗 // /* ---------------------- 系统弹窗[End] ------------------------ */ /** * 吐司 + 图标 * @description 图标与文字可垂直 或 水平排列 * @returns */ static getToastIcon(uiContext?: UIContext): ToastIconBuilderProxy { return new ToastIconBuilderProxy(uiContext) } /** * 显示单行文本输入弹框 * @returns */ static getTextInput(uiContext?: UIContext): TextInputBuilderProxy { return new TextInputBuilderProxy(uiContext) } /** * 显示多行文本输入弹框 * @returns */ static getTextArea(uiContext?: UIContext): TextAreaBuilderProxy { return new TextAreaBuilderProxy(uiContext) } /** * 显示自定义内容弹框 * @returns */ static getCustom(uiContext?: UIContext): CustomContentBuilderProxy { return new CustomContentBuilderProxy(uiContext); } /** * 显示底部操作菜单弹框 * @param sheets 菜单项 * @returns */ static getActionSheet(sheets: Array<ActionSheetItemOptions> | Array<ResourceStr>, uiContext?: UIContext): ActionSheetBuilderProxy { return new ActionSheetBuilderProxy(sheets, uiContext); } /** * 文本选择 弹窗 * @param sheets 菜单项 * @returns */ static getTextPicker(uiContext?: UIContext): TextPickerBuilderProxy { return new TextPickerBuilderProxy(uiContext) } /** * 日期选择 弹窗 * @returns */ static getDatePicker(uiContext?: UIContext): DatePickerBuilderProxy { return new DatePickerBuilderProxy(uiContext) } /** * 功能引导 弹窗(如:指定组件、指定区域 高亮显示) * @returns */ static getGuide(uiContext?: UIContext): GuideBuilderProxy { return new GuideBuilderProxy(uiContext) } /** * 加载中弹窗 * @returns */ static getLoading(content?: string, uiContext?: UIContext): LoadingBuilderProxy { return new LoadingBuilderProxy(content, uiContext) } /** * 显示加载中弹窗 * @param options 弹窗配置 */ static showLoading(options?: ILoadingOptions) /** * 显示加载中弹窗 * @param content 内容 * @param dialogId 弹窗id * @param options 加载弹窗配置 */ static showLoading(content?: string | Resource, dialogId?: string, options?: ILoadingOptions) /** * 显示加载中弹窗 * @param contentOrOptions 内容或者配置 * @param dialogId 弹窗id * @param options 加载弹窗配置 */ static showLoading(contentOrOptions?: string | Resource | ILoadingOptions, dialogId?: string, options?: ILoadingOptions) { if (typeof contentOrOptions === 'object') { contentOrOptions = contentOrOptions as ILoadingOptions LoadingDialog.showLoading(contentOrOptions.content, contentOrOptions.dialogId, contentOrOptions) } else { LoadingDialog.showLoading(contentOrOptions as string, dialogId, options) } } /** * 加载进度弹窗 * @returns */ static getLoadingProgress(uiContext?: UIContext): LoadingProgressBuilderProxy { return new LoadingProgressBuilderProxy(uiContext) } /** * 图片弹窗(支持在线图片、本地图片展示) * @description 在线图片支持下载后展示(也可展示时下载-弱网时将先出现遮罩后,再显示图片) * @returns */ static getImage(imageURI: ResourceStr): ImageDialogBuilderProxy { return new ImageDialogBuilderProxy(imageURI) } //ImageDialogBuilderProxy /** * 当前弹窗是否显示 * @param dialogId 目前弹框id */ static isShowing(dialogId: string): boolean { return dialogCoreHandler.exist(dialogId); } /** * 关闭弹框 * @param dialogId 目前弹框id,为空时默认最后打开的弹窗 */ static closeDialog(dialogId?: string, reason: CloseReason = CloseReason.CLOSE_BUTTON) { dialogCoreHandler.closeCustomDialog(dialogId ?? "", reason); } // /** @ComponentV2不支持 WithTheme组件 // * 获取深色/浅色 模式 // * @returns // */ // static getThemeColorMode(): ThemeColorMode { // return DialogHub.config.dialogTheme.themeColorMode; // } // // /** // * 设置深色/浅色 模式 // * @returns // */ // static setThemeColorMode(mode: ThemeColorMode): void { // DialogHub.config.dialogTheme.themeColorMode = mode // } // /** * 获取UIAbilityContext * @returns */ static getUIAbilityContext(): common.UIAbilityContext { if (DialogHub.config?.uiAbilityContext) { return DialogHub.config?.uiAbilityContext; } return getContext() as common.UIAbilityContext; //兜底 } /** * 生成弹框id */ static generateId() { return dialogCoreHandler.generateDialogId(); } }
AST#export_declaration#Left export AST#class_declaration#Left class DialogHub AST#class_body#Left { AST#property_declaration#Left private static isInit = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#property_declaration#Right /** * 默认配置 */ AST#property_declaration#Left static config : AST#type_annotation#Left AST#primary_type#Left DialogConfig 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 DialogConfig 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 /** * 设置默认统一样式 * @param configs 配置 */ AST#method_declaration#Left static init AST#parameter_list#Left ( AST#parameter#Left configs : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left config : AST#type_annotation#Left AST#primary_type#Left DialogConfig 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#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 DialogHub AST#expression#Right . isInit AST#member_expression#Right AST#expression#Right ) { // 后续有监听,这边要开启,如:多端适配监听屏幕变化xs、md、lg等 AST#ERROR#Left return AST#ERROR#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#ui_custom_component_statement#Left configs ( AST#expression#Left AST#member_expression#Left AST#expression#Left DialogHub AST#expression#Right . config AST#member_expression#Right AST#expression#Right ) ; AST#ui_custom_component_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left DialogHub AST#expression#Right . isInit 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 //TODO: 是否根据 xs md lg 各自保存一份DialogConfig,即:<'xs'|'md'|'lg', DialogConfig> } AST#builder_function_body#Right AST#method_declaration#Right // /* ---------------------- 系统弹窗[Start] ------------------------ */ /** * 【系统】确认弹窗(支持标题、内容、按钮、复选框) * @description 该弹窗自动适配 系统ConfirmDialog 和 AlertDialog(无check) * @returns */ AST#method_declaration#Left static getConfirm AST#parameter_list#Left ( AST#parameter#Left uiContext ? : AST#type_annotation#Left AST#primary_type#Left UIContext AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left ConfirmBuilderProxy 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#new_expression#Left new AST#expression#Left ConfirmBuilderProxy AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left uiContext 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 getTips AST#parameter_list#Left ( AST#parameter#Left uiContext ? : AST#type_annotation#Left AST#primary_type#Left UIContext AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left TipsBuilderProxy 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#new_expression#Left new AST#expression#Left TipsBuilderProxy AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left uiContext 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 getSelect AST#parameter_list#Left ( 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#Left confirm : AST#type_annotation#Left AST#primary_type#Left ButtonOptions AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left radioContent : 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 SheetInfo 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#Left uiContext ? : AST#type_annotation#Left AST#primary_type#Left UIContext AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left SelectBuilderProxy 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#new_expression#Left new AST#expression#Left SelectBuilderProxy AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left title AST#expression#Right , AST#expression#Left confirm AST#expression#Right , AST#expression#Left radioContent AST#expression#Right , AST#expression#Left uiContext 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 /** * 【系统】显示吐司(该方法可设置样式) * @param options * @returns */ AST#method_declaration#Left static getToast AST#parameter_list#Left ( AST#parameter#Left message : 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#type_annotation#Left AST#primary_type#Left ToastDialog 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#new_expression#Left new AST#expression#Left ToastDialog AST#expression#Right AST#new_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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 【系统】显示吐司(可在init内预设toast样式) * @param message 吐司内容 */ AST#method_declaration#Left static showToast AST#parameter_list#Left ( AST#parameter#Left message : 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#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 ToastDialog AST#expression#Right . show 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#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right // 待支持popover系统弹窗 // /* ---------------------- 系统弹窗[End] ------------------------ */ /** * 吐司 + 图标 * @description 图标与文字可垂直 或 水平排列 * @returns */ AST#method_declaration#Left static getToastIcon AST#parameter_list#Left ( AST#parameter#Left uiContext ? : AST#type_annotation#Left AST#primary_type#Left UIContext AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left ToastIconBuilderProxy 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#new_expression#Left new AST#expression#Left ToastIconBuilderProxy AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left uiContext 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 getTextInput AST#parameter_list#Left ( AST#parameter#Left uiContext ? : AST#type_annotation#Left AST#primary_type#Left UIContext AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left TextInputBuilderProxy 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#new_expression#Left new AST#expression#Left TextInputBuilderProxy AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left uiContext 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 getTextArea AST#parameter_list#Left ( AST#parameter#Left uiContext ? : AST#type_annotation#Left AST#primary_type#Left UIContext AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left TextAreaBuilderProxy 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#new_expression#Left new AST#expression#Left TextAreaBuilderProxy AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left uiContext 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 getCustom AST#parameter_list#Left ( AST#parameter#Left uiContext ? : AST#type_annotation#Left AST#primary_type#Left UIContext AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left CustomContentBuilderProxy 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#new_expression#Left new AST#expression#Left CustomContentBuilderProxy AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left uiContext 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 /** * 显示底部操作菜单弹框 * @param sheets 菜单项 * @returns */ AST#method_declaration#Left static getActionSheet AST#parameter_list#Left ( AST#parameter#Left sheets : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left ActionSheetItemOptions AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right | AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left uiContext ? : AST#type_annotation#Left AST#primary_type#Left UIContext AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left ActionSheetBuilderProxy 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#new_expression#Left new AST#expression#Left ActionSheetBuilderProxy AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sheets AST#expression#Right , AST#expression#Left uiContext 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 /** * 文本选择 弹窗 * @param sheets 菜单项 * @returns */ AST#method_declaration#Left static getTextPicker AST#parameter_list#Left ( AST#parameter#Left uiContext ? : AST#type_annotation#Left AST#primary_type#Left UIContext AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left TextPickerBuilderProxy 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#new_expression#Left new AST#expression#Left TextPickerBuilderProxy AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left uiContext 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 getDatePicker AST#parameter_list#Left ( AST#parameter#Left uiContext ? : AST#type_annotation#Left AST#primary_type#Left UIContext AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left DatePickerBuilderProxy 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#new_expression#Left new AST#expression#Left DatePickerBuilderProxy AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left uiContext 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 getGuide AST#parameter_list#Left ( AST#parameter#Left uiContext ? : AST#type_annotation#Left AST#primary_type#Left UIContext AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left GuideBuilderProxy 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#new_expression#Left new AST#expression#Left GuideBuilderProxy AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left uiContext 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 getLoading AST#parameter_list#Left ( AST#parameter#Left content ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left uiContext ? : AST#type_annotation#Left AST#primary_type#Left UIContext AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left LoadingBuilderProxy 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#new_expression#Left new AST#expression#Left LoadingBuilderProxy AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left content AST#expression#Right , AST#expression#Left uiContext 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 /** * 显示加载中弹窗 * @param options 弹窗配置 */ AST#method_declaration#Left static showLoading AST#parameter_list#Left ( AST#parameter#Left options ? : AST#type_annotation#Left AST#primary_type#Left ILoadingOptions AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right /** * 显示加载中弹窗 * @param content 内容 * @param dialogId 弹窗id * @param options 加载弹窗配置 */ AST#method_declaration#Right AST#method_declaration#Left static showLoading AST#parameter_list#Left ( AST#parameter#Left 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#parameter#Right , AST#parameter#Left dialogId ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left options ? : AST#type_annotation#Left AST#primary_type#Left ILoadingOptions AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right /** * 显示加载中弹窗 * @param contentOrOptions 内容或者配置 * @param dialogId 弹窗id * @param options 加载弹窗配置 */ AST#method_declaration#Right AST#method_declaration#Left static showLoading AST#parameter_list#Left ( AST#parameter#Left contentOrOptions ? : 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#primary_type#Left ILoadingOptions AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left dialogId ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left options ? : AST#type_annotation#Left AST#primary_type#Left ILoadingOptions 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#unary_expression#Left typeof AST#expression#Left contentOrOptions AST#expression#Right AST#unary_expression#Right AST#expression#Right === AST#expression#Left 'object' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left contentOrOptions = AST#expression#Left AST#as_expression#Left AST#expression#Left contentOrOptions AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left ILoadingOptions 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LoadingDialog AST#expression#Right . showLoading AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left contentOrOptions AST#expression#Right . content AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left contentOrOptions AST#expression#Right . dialogId AST#member_expression#Right AST#expression#Right , AST#expression#Left contentOrOptions 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 LoadingDialog AST#expression#Right . showLoading AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left contentOrOptions AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right , AST#expression#Left dialogId AST#expression#Right , AST#expression#Left options 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 /** * 加载进度弹窗 * @returns */ AST#method_declaration#Left static getLoadingProgress AST#parameter_list#Left ( AST#parameter#Left uiContext ? : AST#type_annotation#Left AST#primary_type#Left UIContext AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left LoadingProgressBuilderProxy 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#new_expression#Left new AST#expression#Left LoadingProgressBuilderProxy AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left uiContext 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 /** * 图片弹窗(支持在线图片、本地图片展示) * @description 在线图片支持下载后展示(也可展示时下载-弱网时将先出现遮罩后,再显示图片) * @returns */ AST#method_declaration#Left static getImage AST#parameter_list#Left ( AST#parameter#Left imageURI : 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#type_annotation#Left AST#primary_type#Left ImageDialogBuilderProxy 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#new_expression#Left new AST#expression#Left ImageDialogBuilderProxy AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left imageURI 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 //ImageDialogBuilderProxy /** * 当前弹窗是否显示 * @param dialogId 目前弹框id */ AST#method_declaration#Left static isShowing AST#parameter_list#Left ( AST#parameter#Left dialogId : 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 dialogCoreHandler AST#expression#Right . exist AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left dialogId 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 /** * 关闭弹框 * @param dialogId 目前弹框id,为空时默认最后打开的弹窗 */ AST#method_declaration#Left static closeDialog AST#parameter_list#Left ( AST#parameter#Left dialogId ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left reason : AST#type_annotation#Left AST#primary_type#Left CloseReason AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left CloseReason AST#expression#Right . CLOSE_BUTTON 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 dialogCoreHandler AST#expression#Right . closeCustomDialog AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left dialogId AST#expression#Right ?? AST#expression#Left "" AST#expression#Right AST#binary_expression#Right AST#expression#Right , AST#expression#Left reason 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 // /** @ComponentV2不支持 WithTheme组件 // * 获取深色/浅色 模式 // * @returns // */ // static getThemeColorMode(): ThemeColorMode { // return DialogHub.config.dialogTheme.themeColorMode; // } // // /** // * 设置深色/浅色 模式 // * @returns // */ // static setThemeColorMode(mode: ThemeColorMode): void { // DialogHub.config.dialogTheme.themeColorMode = mode // } // /** * 获取UIAbilityContext * @returns */ AST#method_declaration#Left static getUIAbilityContext AST#parameter_list#Left ( ) AST#parameter_list#Right : 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#block_statement#Left { 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 DialogHub AST#expression#Right . config AST#member_expression#Right AST#expression#Right ?. uiAbilityContext AST#member_expression#Right AST#expression#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 DialogHub AST#expression#Right . config AST#member_expression#Right AST#expression#Right ?. uiAbilityContext AST#member_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#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#return_statement#Right AST#statement#Right //兜底 } AST#block_statement#Right AST#method_declaration#Right /** * 生成弹框id */ AST#method_declaration#Left static generateId AST#parameter_list#Left ( ) 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 dialogCoreHandler AST#expression#Right . generateDialogId 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 } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class DialogHub { private static isInit = false; static config: DialogConfig = new DialogConfig(); static init(configs: (config: DialogConfig) => void): void { if (DialogHub.isInit) { return } configs(DialogHub.config); DialogHub.isInit = true } static getConfirm(uiContext?: UIContext): ConfirmBuilderProxy { return new ConfirmBuilderProxy(uiContext); } static getTips(uiContext?: UIContext): TipsBuilderProxy { return new TipsBuilderProxy(uiContext); } static getSelect(title: ResourceStr, confirm: ButtonOptions, radioContent: Array<SheetInfo>, uiContext?: UIContext): SelectBuilderProxy { return new SelectBuilderProxy(title, confirm, radioContent, uiContext) } static getToast(message: ResourceStr): ToastDialog { return new ToastDialog(message) } static showToast(message: string | Resource) { ToastDialog.show(message); } static getToastIcon(uiContext?: UIContext): ToastIconBuilderProxy { return new ToastIconBuilderProxy(uiContext) } static getTextInput(uiContext?: UIContext): TextInputBuilderProxy { return new TextInputBuilderProxy(uiContext) } static getTextArea(uiContext?: UIContext): TextAreaBuilderProxy { return new TextAreaBuilderProxy(uiContext) } static getCustom(uiContext?: UIContext): CustomContentBuilderProxy { return new CustomContentBuilderProxy(uiContext); } static getActionSheet(sheets: Array<ActionSheetItemOptions> | Array<ResourceStr>, uiContext?: UIContext): ActionSheetBuilderProxy { return new ActionSheetBuilderProxy(sheets, uiContext); } static getTextPicker(uiContext?: UIContext): TextPickerBuilderProxy { return new TextPickerBuilderProxy(uiContext) } static getDatePicker(uiContext?: UIContext): DatePickerBuilderProxy { return new DatePickerBuilderProxy(uiContext) } static getGuide(uiContext?: UIContext): GuideBuilderProxy { return new GuideBuilderProxy(uiContext) } static getLoading(content?: string, uiContext?: UIContext): LoadingBuilderProxy { return new LoadingBuilderProxy(content, uiContext) } static showLoading(options?: ILoadingOptions) static showLoading(content?: string | Resource, dialogId?: string, options?: ILoadingOptions) static showLoading(contentOrOptions?: string | Resource | ILoadingOptions, dialogId?: string, options?: ILoadingOptions) { if (typeof contentOrOptions === 'object') { contentOrOptions = contentOrOptions as ILoadingOptions LoadingDialog.showLoading(contentOrOptions.content, contentOrOptions.dialogId, contentOrOptions) } else { LoadingDialog.showLoading(contentOrOptions as string, dialogId, options) } } static getLoadingProgress(uiContext?: UIContext): LoadingProgressBuilderProxy { return new LoadingProgressBuilderProxy(uiContext) } static getImage(imageURI: ResourceStr): ImageDialogBuilderProxy { return new ImageDialogBuilderProxy(imageURI) } static isShowing(dialogId: string): boolean { return dialogCoreHandler.exist(dialogId); } static closeDialog(dialogId?: string, reason: CloseReason = CloseReason.CLOSE_BUTTON) { dialogCoreHandler.closeCustomDialog(dialogId ?? "", reason); } /** * 设置深色/浅色 模式 static setThemeColorMode(mode: ThemeColorMode): void { DialogHub.config.dialogTheme.themeColorMode = mode static getUIAbilityContext(): common.UIAbilityContext { if (DialogHub.config?.uiAbilityContext) { return DialogHub.config?.uiAbilityContext; } return getContext() as common.UIAbilityContext; 兜底 } static generateId() { return dialogCoreHandler.generateDialogId(); } }
https://github.com/sithvothykiv/dialog_hub.git/blob/b676c102ef2d05f8994d170abe48dcc40cd39005/custom_dialog/src/main/ets/core/DialogHub.ets#L32-L275
37edb1d3719bdb7f165e3b421346857697d7f127
github
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_ui/src/main/ets/ui/base/PreviewUtil.ets
arkts
openPreview
打开预览 @param type 预览类型 @param uri 预览uri @returns
private static async openPreview(type: string, uri: string): Promise<void> { //获取上下文 let uiContext = getContext() as common.UIAbilityContext; //预览格式判断 let result = PreviewUtil.rightFileSuffix(type, uri); if (result.getSuccess()) { //获取文件信息 let fileUriObject = new fileUri.FileUri(uri); //文件名 let fileName = fileUriObject.name; //预览文件信息 let fileInfo: filePreview.PreviewInfo = { title: fileName, uri: uri, mimeType: result.getDataRow() }; //悬浮窗口的属性值,包含了悬浮窗大小以及位置信息。2in1端不填写则展示默认大小窗口,手机和平板设备填写无效。 let displayInfo: filePreview.DisplayInfo = { x: 100, y: 100, width: 800, height: 800 }; //打开预览 await filePreview.openPreview(uiContext, fileInfo, displayInfo); } else { ToastUtil.showToast(result.getMsg()); } }
AST#method_declaration#Left private static async openPreview AST#parameter_list#Left ( AST#parameter#Left type : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left uri : 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 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#variable_declaration#Left let AST#variable_declarator#Left uiContext = 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 let AST#variable_declarator#Left result = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left PreviewUtil AST#expression#Right . rightFileSuffix AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left type AST#expression#Right , AST#expression#Left uri 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . getSuccess 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 let AST#variable_declarator#Left fileUriObject = 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 fileUri AST#expression#Right AST#new_expression#Right AST#expression#Right . FileUri AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left uri 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 fileName = AST#expression#Left AST#member_expression#Left AST#expression#Left fileUriObject AST#expression#Right . name 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 fileInfo : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left filePreview . PreviewInfo 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 title AST#property_name#Right : AST#expression#Left fileName AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left uri AST#property_name#Right : AST#expression#Left uri AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left mimeType AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . getDataRow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right 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 //悬浮窗口的属性值,包含了悬浮窗大小以及位置信息。2in1端不填写则展示默认大小窗口,手机和平板设备填写无效。 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left displayInfo : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left filePreview . DisplayInfo 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 x AST#property_name#Right : AST#expression#Left 100 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left 100 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left 800 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left height AST#property_name#Right : AST#expression#Left 800 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#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 filePreview AST#expression#Right AST#await_expression#Right AST#expression#Right . openPreview AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left uiContext AST#expression#Right , AST#expression#Left fileInfo AST#expression#Right , AST#expression#Left displayInfo 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 ToastUtil AST#expression#Right . showToast 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 result AST#expression#Right . getMsg 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#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private static async openPreview(type: string, uri: string): Promise<void> { let uiContext = getContext() as common.UIAbilityContext; let result = PreviewUtil.rightFileSuffix(type, uri); if (result.getSuccess()) { let fileUriObject = new fileUri.FileUri(uri); let fileName = fileUriObject.name; let fileInfo: filePreview.PreviewInfo = { title: fileName, uri: uri, mimeType: result.getDataRow() }; let displayInfo: filePreview.DisplayInfo = { x: 100, y: 100, width: 800, height: 800 }; await filePreview.openPreview(uiContext, fileInfo, displayInfo); } else { ToastUtil.showToast(result.getMsg()); } }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_ui/src/main/ets/ui/base/PreviewUtil.ets#L77-L105
0d06c6a18d2ad5ddbb1d9caa6d5cc7daaf8efa67
gitee
EL233/WeChat-HarmonyOS.git
b5fa65556eb5f5698a92ec289ffd9ebe4cc5bb3e
entry/src/main/ets/view/component/Dialog.ets
arkts
updateDialog
更新自定义对话框
updateDialog(options: object) { if (this.contentNode !== null && this.contentNode !== undefined) { this.ctx?.getPromptAction() .updateCustomDialog(this.contentNode, options) .then(() => { hilog.info(0xFF00, 'PersonalInformation', '%{public}s', 'UpdateCustomDialog complete'); // 记录日志,对话框更新完成 }) .catch((error: BusinessError) => { let message = (error as BusinessError).message; // 获取错误消息 let code = (error as BusinessError).code; // 获取错误代码 hilog.error(0xFF00, 'PersonalInformation', '%{public}s', `UpdateCustomDialog args error code is ${code}, message is ${message}`); // 记录错误日志 }); } }
AST#method_declaration#Left updateDialog AST#parameter_list#Left ( AST#parameter#Left options : 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#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#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . contentNode 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#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . contentNode 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#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 . ctx AST#member_expression#Right AST#expression#Right ?. getPromptAction AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . updateCustomDialog 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 . contentNode AST#member_expression#Right AST#expression#Right , AST#expression#Left options 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 hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0xFF00 AST#expression#Right , AST#expression#Left 'PersonalInformation' AST#expression#Right , AST#expression#Left '%{public}s' AST#expression#Right , AST#expression#Left 'UpdateCustomDialog complete' 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 error : 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#variable_declaration#Left let AST#variable_declarator#Left message = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . message 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 code = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . code AST#member_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 hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0xFF00 AST#expression#Right , AST#expression#Left 'PersonalInformation' AST#expression#Right , AST#expression#Left '%{public}s' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` UpdateCustomDialog args error code is AST#template_substitution#Left $ { AST#expression#Left code AST#expression#Right } AST#template_substitution#Right , message is AST#template_substitution#Left $ { AST#expression#Left message 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#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
updateDialog(options: object) { if (this.contentNode !== null && this.contentNode !== undefined) { this.ctx?.getPromptAction() .updateCustomDialog(this.contentNode, options) .then(() => { hilog.info(0xFF00, 'PersonalInformation', '%{public}s', 'UpdateCustomDialog complete'); }) .catch((error: BusinessError) => { let message = (error as BusinessError).message; let code = (error as BusinessError).code; hilog.error(0xFF00, 'PersonalInformation', '%{public}s', `UpdateCustomDialog args error code is ${code}, message is ${message}`); }); } }
https://github.com/EL233/WeChat-HarmonyOS.git/blob/b5fa65556eb5f5698a92ec289ffd9ebe4cc5bb3e/entry/src/main/ets/view/component/Dialog.ets#L65-L79
2fca4d8c9c95a5f1e79ba8c3a980ffaa8d6d8b42
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/DocsSample/ArkUISample/UIExtensionAndAccessibility/entry/src/main/ets/pages/IsolatedComponent/Isolated.ets
arkts
sampleVerifyAbc
对abc文件进行校验,并拷贝到指定沙箱路径下
function sampleVerifyAbc(abcPaths: Array<string>, deleteOriginalFiles: boolean) { try { bundleManager.verifyAbc(abcPaths, deleteOriginalFiles, (err) => { if (err) { console.error('VerifyAbc failed, error message: ' + err.message); } else { console.info('VerifyAbc successfully.'); } }); } catch (err) { let message = (err as BusinessError).message; console.error('VerifyAbc failed, error message: ' + message); } }
AST#function_declaration#Left function sampleVerifyAbc AST#parameter_list#Left ( AST#parameter#Left abcPaths : 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 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#parameter#Right , AST#parameter#Left deleteOriginalFiles : 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#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 bundleManager AST#expression#Right . verifyAbc AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left abcPaths AST#expression#Right , AST#expression#Left deleteOriginalFiles AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err 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 console 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 'VerifyAbc failed, error message: ' AST#expression#Right + AST#expression#Left err AST#expression#Right AST#binary_expression#Right AST#expression#Right . message 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 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 'VerifyAbc successfully.' 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#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left message = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left err AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . message AST#member_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 console 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 'VerifyAbc failed, error message: ' AST#expression#Right + AST#expression#Left message 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#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right
function sampleVerifyAbc(abcPaths: Array<string>, deleteOriginalFiles: boolean) { try { bundleManager.verifyAbc(abcPaths, deleteOriginalFiles, (err) => { if (err) { console.error('VerifyAbc failed, error message: ' + err.message); } else { console.info('VerifyAbc successfully.'); } }); } catch (err) { let message = (err as BusinessError).message; console.error('VerifyAbc failed, error message: ' + message); } }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/ArkUISample/UIExtensionAndAccessibility/entry/src/main/ets/pages/IsolatedComponent/Isolated.ets#L21-L34
8553cdd67000fe82b81d7ae6f375b3bd39cdcede
gitee
sithvothykiv/dialog_hub.git
b676c102ef2d05f8994d170abe48dcc40cd39005
custom_dialog/src/main/ets/component/DatePickerDialogView.ets
arkts
onChangeData
更新数据源 @param type 1-年、2-月、3-日、4-时、5-分、6-秒
onChangeData(type: number) { if (type <= 2 && this.containMonth) { this.day = DateHelper.getResetDay(this.year, this.month, this.day); } this.selectDate = DateHelper.getDateByStr(this.containYear, this.containMonth, this.containDay, this.containHour, this.containMinute, this.containSecond, this.year, this.month, this.day, this.hour, this.minute, this.second); if (type <= 1 && this.containYear) { let temp1 = DateHelper.getRanges(this.containMonth, 2, this.startDate, this.endDate, this.selectDate); if (temp1.toString() !== this.months.toString()) { this.months = temp1; } this.month = DateHelper.getSelectValue(this.months, this.month); } if (type <= 2 && this.containMonth) { let temp2 = DateHelper.getRanges(this.containDay, 3, this.startDate, this.endDate, this.selectDate); if (temp2.toString() !== this.days.toString()) { this.days = temp2; } this.day = DateHelper.getSelectValue(this.days, this.day); } if (type <= 3 && this.containDay) { let temp3 = DateHelper.getRanges(this.containHour, 4, this.startDate, this.endDate, this.selectDate); if (temp3.toString() !== this.hours.toString()) { this.hours = temp3; } this.hour = DateHelper.getSelectValue(this.hours, this.hour); } if (type <= 4 && this.containHour) { let temp4 = DateHelper.getRanges(this.containMinute, 5, this.startDate, this.endDate, this.selectDate); if (temp4.toString() !== this.minutes.toString()) { this.minutes = temp4; } this.minute = DateHelper.getSelectValue(this.minutes, this.minute); } if (type <= 5 && this.containMinute) { let temp5 = DateHelper.getRanges(this.containSecond, 6, this.startDate, this.endDate, this.selectDate); if (temp5.toString() !== this.seconds.toString()) { this.seconds = temp5; } this.second = DateHelper.getSelectValue(this.seconds, this.second); } }
AST#method_declaration#Left onChangeData AST#parameter_list#Left ( AST#parameter#Left type : 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#ui_control_flow#Left AST#ui_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 type AST#expression#Right <= AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . containMonth 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 this AST#expression#Right . day AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DateHelper AST#expression#Right . getResetDay 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 . year AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . month AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . day 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#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectDate AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DateHelper AST#expression#Right . getDateByStr 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 . containYear AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . containMonth AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . containDay AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . containHour AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . containMinute AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . containSecond AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . year AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . month AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . day AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . hour AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . minute AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . second 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#expression_statement#Right AST#ui_control_flow#Left AST#ui_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 type AST#expression#Right <= AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . containYear AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left let AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left temp1 = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DateHelper AST#expression#Right . getRanges 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 . containMonth AST#member_expression#Right AST#expression#Right , AST#expression#Left 2 AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . startDate AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . endDate AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectDate 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#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 AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left temp1 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#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . months AST#member_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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . months AST#member_expression#Right = AST#expression#Left temp1 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 AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . month AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DateHelper AST#expression#Right . getSelectValue 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 . months AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . month 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#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#ui_control_flow#Left AST#ui_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 type AST#expression#Right <= AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . containMonth AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left let AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left temp2 = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DateHelper AST#expression#Right . getRanges 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 . containDay AST#member_expression#Right AST#expression#Right , AST#expression#Left 3 AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . startDate AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . endDate AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectDate 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#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 AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left temp2 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#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . days AST#member_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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . days AST#member_expression#Right = AST#expression#Left temp2 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 AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . day AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DateHelper AST#expression#Right . getSelectValue 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 . days AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . day 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#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#ui_control_flow#Left AST#ui_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 type AST#expression#Right <= AST#expression#Left 3 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . containDay AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left let AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left temp3 = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DateHelper AST#expression#Right . getRanges 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 . containHour AST#member_expression#Right AST#expression#Right , AST#expression#Left 4 AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . startDate AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . endDate AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectDate 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#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 AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left temp3 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#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . hours AST#member_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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . hours AST#member_expression#Right = AST#expression#Left temp3 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 AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . hour AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DateHelper AST#expression#Right . getSelectValue 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 . hours AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . hour 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#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#ui_control_flow#Left AST#ui_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 type AST#expression#Right <= AST#expression#Left 4 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . containHour AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left let AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left temp4 = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DateHelper AST#expression#Right . getRanges 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 . containMinute AST#member_expression#Right AST#expression#Right , AST#expression#Left 5 AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . startDate AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . endDate AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectDate 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#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 AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left temp4 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#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . minutes AST#member_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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . minutes AST#member_expression#Right = AST#expression#Left temp4 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 AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . minute AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DateHelper AST#expression#Right . getSelectValue 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 . minutes AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . minute 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#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#ui_control_flow#Left AST#ui_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 type AST#expression#Right <= AST#expression#Left 5 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . containMinute AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left let AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left temp5 = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DateHelper AST#expression#Right . getRanges 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 . containSecond AST#member_expression#Right AST#expression#Right , AST#expression#Left 6 AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . startDate AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . endDate AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectDate 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#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 AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left temp5 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#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . seconds AST#member_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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . seconds AST#member_expression#Right = AST#expression#Left temp5 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 AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . second AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DateHelper AST#expression#Right . getSelectValue 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 . seconds AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . second 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#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
onChangeData(type: number) { if (type <= 2 && this.containMonth) { this.day = DateHelper.getResetDay(this.year, this.month, this.day); } this.selectDate = DateHelper.getDateByStr(this.containYear, this.containMonth, this.containDay, this.containHour, this.containMinute, this.containSecond, this.year, this.month, this.day, this.hour, this.minute, this.second); if (type <= 1 && this.containYear) { let temp1 = DateHelper.getRanges(this.containMonth, 2, this.startDate, this.endDate, this.selectDate); if (temp1.toString() !== this.months.toString()) { this.months = temp1; } this.month = DateHelper.getSelectValue(this.months, this.month); } if (type <= 2 && this.containMonth) { let temp2 = DateHelper.getRanges(this.containDay, 3, this.startDate, this.endDate, this.selectDate); if (temp2.toString() !== this.days.toString()) { this.days = temp2; } this.day = DateHelper.getSelectValue(this.days, this.day); } if (type <= 3 && this.containDay) { let temp3 = DateHelper.getRanges(this.containHour, 4, this.startDate, this.endDate, this.selectDate); if (temp3.toString() !== this.hours.toString()) { this.hours = temp3; } this.hour = DateHelper.getSelectValue(this.hours, this.hour); } if (type <= 4 && this.containHour) { let temp4 = DateHelper.getRanges(this.containMinute, 5, this.startDate, this.endDate, this.selectDate); if (temp4.toString() !== this.minutes.toString()) { this.minutes = temp4; } this.minute = DateHelper.getSelectValue(this.minutes, this.minute); } if (type <= 5 && this.containMinute) { let temp5 = DateHelper.getRanges(this.containSecond, 6, this.startDate, this.endDate, this.selectDate); if (temp5.toString() !== this.seconds.toString()) { this.seconds = temp5; } this.second = DateHelper.getSelectValue(this.seconds, this.second); } }
https://github.com/sithvothykiv/dialog_hub.git/blob/b676c102ef2d05f8994d170abe48dcc40cd39005/custom_dialog/src/main/ets/component/DatePickerDialogView.ets#L91-L132
3541debf88f466aeaf825774b3427dc8055e0b54
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/common/utils/array/ArrayStringUtils.ets
arkts
containsWords
判断是否含有词语
static containsWords(str: string): boolean { return str.includes(" ") ? str.split(" ").filter(item => item.length > 1).length > 0 : false; }
AST#method_declaration#Left static containsWords 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 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#conditional_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . includes 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#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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . split 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 . filter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left item => AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left item 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#arrow_function#Right AST#expression#Right ) 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#expression#Left AST#boolean_literal#Left false AST#boolean_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 containsWords(str: string): boolean { return str.includes(" ") ? str.split(" ").filter(item => item.length > 1).length > 0 : false; }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/utils/array/ArrayStringUtils.ets#L103-L107
640096deb62f8850f91fe5dca33a25164e332dcb
github
CMoments/HarmonOS-arkTS-YunShangChuanDa.git
895985b9b6013c906bf88eaea6e32e03ddf2a9db
project code/entry/src/main/ets/pages/HealthIndexPage.ets
arkts
tabBar
当前选中的tab是第几个
@Builder tabBar(item:TabModel){ Column(){ Image(this.tabModels[this.currentSelect].name == item.name ? item.activeImg : item.img) .width(24) .height(24) Text(item.name).fontColor(this.tabModels[this.currentSelect].name == item.name ? "#027CFF" :"#A2A2A2") .fontSize(12) } }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right tabBar AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left TabModel 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#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#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . tabModels AST#member_expression#Right AST#expression#Right [ AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentSelect AST#member_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . name AST#member_expression#Right AST#expression#Right == AST#expression#Left item AST#expression#Right AST#binary_expression#Right AST#expression#Right . name AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . activeImg AST#member_expression#Right AST#expression#Right : AST#expression#Left item AST#expression#Right AST#conditional_expression#Right AST#expression#Right . img AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 24 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 24 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 Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . name AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontColor ( 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#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . tabModels AST#member_expression#Right AST#expression#Right [ AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentSelect AST#member_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . name AST#member_expression#Right AST#expression#Right == AST#expression#Left item AST#expression#Right AST#binary_expression#Right AST#expression#Right . name AST#member_expression#Right AST#expression#Right ? AST#expression#Left "#027CFF" AST#expression#Right : AST#expression#Left "#A2A2A2" AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 12 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#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
@Builder tabBar(item:TabModel){ Column(){ Image(this.tabModels[this.currentSelect].name == item.name ? item.activeImg : item.img) .width(24) .height(24) Text(item.name).fontColor(this.tabModels[this.currentSelect].name == item.name ? "#027CFF" :"#A2A2A2") .fontSize(12) } }
https://github.com/CMoments/HarmonOS-arkTS-YunShangChuanDa.git/blob/895985b9b6013c906bf88eaea6e32e03ddf2a9db/project code/entry/src/main/ets/pages/HealthIndexPage.ets#L27-L36
2b1740be0e577f0442c0ce1ebc2424174ad67ae1
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/common/components/Sounds/Player/CAudioPlayer.ets
arkts
generateAudioData
生成音频数据(核心方法) @param text 音频资源URI
private async generateAudioData(text: string): Promise<AudioData | null> { const csound = await CSoundHelper.startDownloadOrGenerateSound(text) if (!csound || csound.data === null || csound.idxx === null) { return null } const idxx = csound.idxx; // 使用AudioTool创建播放器 const avPlayer = await AudioTool.createAudioPlayer( csound.data, csound.idxx, async (state: string) => { switch (state) { case 'playing': this.isPlaying = true; break; case 'completed': await this.onAudioFinished(idxx); break; case 'error': console.error('播放器错误'); this.stopAndClear(); break; }
AST#method_declaration#Left private async generateAudioData 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_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 AudioData 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#variable_declaration#Left const AST#variable_declarator#Left csound = 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 CSoundHelper AST#expression#Right AST#await_expression#Right AST#expression#Right . startDownloadOrGenerateSound 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#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 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#unary_expression#Left ! AST#expression#Left csound AST#expression#Right AST#unary_expression#Right AST#expression#Right || AST#expression#Left csound AST#expression#Right AST#binary_expression#Right AST#expression#Right . data 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#expression#Left csound AST#expression#Right AST#binary_expression#Right AST#expression#Right . idxx 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#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#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left idxx = AST#expression#Left AST#member_expression#Left AST#expression#Left csound AST#expression#Right . idxx AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 使用AudioTool创建播放器 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left avPlayer = 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 AudioTool AST#expression#Right AST#await_expression#Right AST#expression#Right . createAudioPlayer AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left csound AST#expression#Right . data AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left csound AST#expression#Right . idxx AST#member_expression#Right AST#expression#Right , AST#ERROR#Left async AST#parameter_list#Left ( AST#parameter#Left state : 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#ERROR#Left => { AST#ERROR#Left AST#property_name#Left switch AST#property_name#Right AST#parameter_list#Left ( AST#parameter#Left state AST#parameter#Right ) AST#parameter_list#Right AST#ERROR#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left 'playing' AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Right : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left this . isPlaying AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = true ; AST#ERROR#Right AST#statement#Left AST#break_statement#Left break ; AST#break_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left 'completed' AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left : AST#ERROR#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 this AST#expression#Right AST#await_expression#Right AST#expression#Right . onAudioFinished AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left idxx 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#break_statement#Left break ; AST#break_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left 'error' AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Right : AST#qualified_type#Left console . error AST#qualified_type#Right ( AST#ERROR#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 this AST#expression#Right . stopAndClear 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#break_statement#Left break ; AST#break_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private async generateAudioData(text: string): Promise<AudioData | null> { const csound = await CSoundHelper.startDownloadOrGenerateSound(text) if (!csound || csound.data === null || csound.idxx === null) { return null } const idxx = csound.idxx; const avPlayer = await AudioTool.createAudioPlayer( csound.data, csound.idxx, async (state: string) => { switch (state) { case 'playing': this.isPlaying = true; break; case 'completed': await this.onAudioFinished(idxx); break; case 'error': console.error('播放器错误'); this.stopAndClear(); break; }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/components/Sounds/Player/CAudioPlayer.ets#L103-L130
12b166528ba5b0d4cbde0d0d0c112c720192ce61
github
liuchao0739/arkTS_universal_starter.git
0ca845f5ae0e78db439dc09f712d100c0dd46ed3
entry/src/main/ets/core/storage/StorageManager.ets
arkts
setNumber
设置数字值
static async setNumber(key: string, value: number): Promise<void> { const instance = StorageManager.getInstance(); if (!instance.dataPreferences) { await instance.init(); } try { await instance.dataPreferences?.put(key, value); await instance.dataPreferences?.flush(); } catch (e) { Logger.error('StorageManager', `Failed to set number: ${String(e)}`); } }
AST#method_declaration#Left static async setNumber 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 value : 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#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#variable_declaration#Left const AST#variable_declarator#Left instance = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left StorageManager 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 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#unary_expression#Left ! AST#expression#Left instance AST#expression#Right AST#unary_expression#Right AST#expression#Right . dataPreferences 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 AST#await_expression#Left await AST#expression#Left instance AST#expression#Right AST#await_expression#Right 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#if_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#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left instance AST#expression#Right AST#await_expression#Right AST#expression#Right . dataPreferences AST#member_expression#Right AST#expression#Right ?. put AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right , AST#expression#Left value 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 AST#await_expression#Left await AST#expression#Left instance AST#expression#Right AST#await_expression#Right AST#expression#Right . dataPreferences AST#member_expression#Right AST#expression#Right ?. flush 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#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 'StorageManager' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Failed to set number: AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left String 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#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
static async setNumber(key: string, value: number): Promise<void> { const instance = StorageManager.getInstance(); if (!instance.dataPreferences) { await instance.init(); } try { await instance.dataPreferences?.put(key, value); await instance.dataPreferences?.flush(); } catch (e) { Logger.error('StorageManager', `Failed to set number: ${String(e)}`); } }
https://github.com/liuchao0739/arkTS_universal_starter.git/blob/0ca845f5ae0e78db439dc09f712d100c0dd46ed3/entry/src/main/ets/core/storage/StorageManager.ets#L108-L119
a6ae3fa3ca6ed92a52ce101df71cabc659b07c3a
github
openharmony/interface_sdk-js
c349adc73e2ec1f61f6fca489b5af059e3ed6999
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/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.file.PhotoPickerComponent.d.ets#L917-L935
97f93dadd02df48c05ba4414a24e2f58789e8a56
gitee
openharmony/developtools_profiler
73d26bb5acfcafb2b1f4f94ead5640241d1e5f73
host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/utils/JList.ets
arkts
Copyright (C) 2022 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 JList<T> { public dataSouce: Array<T>; public listSize: number; // 列表的大小 public pos: number; // 列表中当前的位置 constructor() { this.dataSouce = []; this.listSize = 0; // 列表的大小 this.pos = 0; // 列表中当前的位置 } /** * 在列表的末尾添加新元素 * @param {*} element 要添加的元素 */ append(element: T) { this.dataSouce[this.listSize++] = element; }
AST#export_declaration#Left export AST#class_declaration#Left class JList AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right > AST#type_parameters#Right AST#class_body#Left { AST#property_declaration#Left public dataSouce : 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 T 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 AST#property_declaration#Left public listSize : 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 pos : 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_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 . dataSouce AST#member_expression#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_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 . listSize 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 . pos 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#block_statement#Right AST#constructor_declaration#Right /** * 在列表的末尾添加新元素 * @param {*} element 要添加的元素 */ AST#property_declaration#Left append AST#ERROR#Left AST#parameter_list#Left ( AST#parameter#Left element : AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right { AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataSouce AST#member_expression#Right AST#expression#Right [ AST#expression#Left AST#update_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . listSize AST#member_expression#Right AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#ERROR#Right = AST#expression#Left element AST#expression#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class JList<T> { public dataSouce: Array<T>; public listSize: number; public pos: number; constructor() { this.dataSouce = []; this.listSize = 0; this.pos = 0; } append(element: T) { this.dataSouce[this.listSize++] = element; }
https://github.com/openharmony/developtools_profiler/blob/73d26bb5acfcafb2b1f4f94ead5640241d1e5f73/host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/utils/JList.ets#L16-L34
cbd0145bd817c676eed015733615c2d93cec2d6c
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/ai/SimpleAIService.ets
arkts
splitTextIntoChunks
将文本分割为合适的显示块
private splitTextIntoChunks(text: string, mode: StreamMode): string[] { if (mode === StreamMode.TYPING) { // 打字模式:按词分割 return text.split(/(\s+|[,。!?;:])/).filter(chunk => chunk.length > 0); } else { // 流式模式:按短语分割(每3-8个字符一组) const chunks: string[] = []; let currentChunk = ''; for (const char of text) { currentChunk += char; // 在标点符号或达到最大长度时分块 if (/[,。!?;:\s]/.test(char) || currentChunk.length >= 8) { chunks.push(currentChunk); currentChunk = ''; } } if (currentChunk) { chunks.push(currentChunk); } return chunks; } }
AST#method_declaration#Left private splitTextIntoChunks 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 mode : AST#type_annotation#Left AST#primary_type#Left StreamMode 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#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left mode AST#expression#Right === AST#expression#Left StreamMode AST#expression#Right AST#binary_expression#Right AST#expression#Right . TYPING 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 AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left text AST#expression#Right . split AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#ERROR#Left / AST#expression#Left AST#parenthesized_expression#Left ( AST#ERROR#Left \s AST#ERROR#Right AST#expression#Left AST#unary_expression#Left + AST#ERROR#Left | AST#ERROR#Right AST#expression#Left AST#array_literal#Left [ AST#ERROR#Left ,。!?;: AST#ERROR#Right ] AST#array_literal#Right AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right / AST#ERROR#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . filter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left chunk => AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left chunk 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#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 else AST#block_statement#Left { // 流式模式:按短语分割(每3-8个字符一组) AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left chunks : 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#variable_declaration#Left let AST#variable_declarator#Left currentChunk = 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 ( const char of AST#expression#Left text AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left currentChunk += AST#expression#Left char 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#ERROR#Left / AST#ERROR#Right 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#array_literal#Left [ AST#ERROR#Left ,。!?;:\s AST#ERROR#Right ] AST#array_literal#Right AST#expression#Right / AST#expression#Left AST#expression#Right AST#binary_expression#Right AST#expression#Right . test AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left char AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right || AST#expression#Left currentChunk AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right >= AST#expression#Left 8 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 chunks AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left currentChunk 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 currentChunk = AST#expression#Left '' 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#for_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left currentChunk 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 chunks AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left currentChunk 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 chunks 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#method_declaration#Right
private splitTextIntoChunks(text: string, mode: StreamMode): string[] { if (mode === StreamMode.TYPING) { return text.split(/(\s+|[,。!?;:])/).filter(chunk => chunk.length > 0); } else { const chunks: string[] = []; let currentChunk = ''; for (const char of text) { currentChunk += char; if (/[,。!?;:\s]/.test(char) || currentChunk.length >= 8) { chunks.push(currentChunk); currentChunk = ''; } } if (currentChunk) { chunks.push(currentChunk); } return chunks; } }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/ai/SimpleAIService.ets#L388-L413
fbb67c9baef043c7e4fef689e73ada404784112b
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/ai/AIAssistantService.ets
arkts
clearConversationHistory
清除对话历史
clearConversationHistory(sessionId?: string): void { const currentSessionId = sessionId || this.currentSessionId; const context = this.conversations.get(currentSessionId); if (context) { context.history = []; hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Conversation history cleared for session: ${currentSessionId}`); } }
AST#method_declaration#Left clearConversationHistory AST#parameter_list#Left ( AST#parameter#Left sessionId ? : 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#variable_declaration#Left const AST#variable_declarator#Left currentSessionId = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left sessionId AST#expression#Right || AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . currentSessionId 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 context = 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 . conversations AST#member_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left currentSessionId 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 context 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 context AST#expression#Right . history AST#member_expression#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_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 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 ` Conversation history cleared for session: AST#template_substitution#Left $ { AST#expression#Left currentSessionId 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#method_declaration#Right
clearConversationHistory(sessionId?: string): void { const currentSessionId = sessionId || this.currentSessionId; const context = this.conversations.get(currentSessionId); if (context) { context.history = []; hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Conversation history cleared for session: ${currentSessionId}`); } }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/ai/AIAssistantService.ets#L439-L447
e5ee4e3d0af96a305acba77255662047b5e61730
github
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/NotificationUtil.ets
arkts
addSlot
创建指定类型的通知渠道。 @param type 要创建的通知渠道的类型
static async addSlot(type: notificationManager.SlotType) { return notificationManager.addSlot(type); }
AST#method_declaration#Left static async addSlot AST#parameter_list#Left ( AST#parameter#Left type : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left notificationManager . SlotType 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left notificationManager AST#expression#Right . addSlot AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left type 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 addSlot(type: notificationManager.SlotType) { return notificationManager.addSlot(type); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/NotificationUtil.ets#L362-L364
135afa68516879ca4160106d8f7af6e3959216da
gitee
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/models/datas/word/WordDetail.ets
arkts
WordDetail 单词详情数据模型(继承 Word)
export class WordDetail extends Word { // pronEn : string | null = null; // pronUs : string | null = null; // titleCn2 : string | null = null; // titleCn3 : string | null = null; wordImage : string | null = null; wordChange : string | null = null; synWords : string | null = null; asynWords : string | null = null; // exampleEn1 : string | null = null; // exampleCn1 : string | null = null; exampleEn2 : string | null = null; exampleCn2 : string | null = null; exampleEn3 : string | null = null; exampleCn3 : string | null = null; usedPhrase : string | null = null; en2En : string | null = null; discriminate : string | null = null; private discriminate2 : string | null = null; // 去除重复后的缓存结果 override async getWordDetail(): Promise<WordDetail | null> { return this } // // /** // * 将多个中文释义合并为一个字符串(去重) // */ // getTitleCnsJoined(): string { // const titles: string[] = []; // // if (this.titleCn1) { // titles.push(this.titleCn1); // } // if (this.titleCn2) { // titles.push(this.titleCn2); // } // if (this.titleCn3) { // titles.push(this.titleCn3); // } // // return AppUtility.getJoinedStringByRemovingDuplications( // titles, // Constants.TitleTextJp.wordsMaxPart // ); // } /** * 从词形变化中提取英文单词 */ getWordChangeEnWords(): string[] { return StringDealUtility.matchEnWords(this.wordChange); } /** * 获取需要高亮 / 标记的文本集合 */ getMarkTexts(): string[] { const markTexts: string[] = []; // 来自词形变化 markTexts.push(...this.getWordChangeEnWords()); // 将短语拆分(空格 & "-") if (this.titleEn) { const wordTexts = this.titleEn.replace(/-/g, " ").split(" "); for (const str of wordTexts) { markTexts.push(str); } // 原始短语 markTexts.push(this.titleEn); } return markTexts; } // ============================================================ // MARK: - Discriminate 处理 // ============================================================ /** * 获取去重后的辨析说明(带缓存) */ getDiscriminateRemovedDuplications(): string | null { if (!this.discriminate2) { this.discriminate2 = this.removedDuplicationsForDiscriminate(); } return this.discriminate2; } /** * 对 discriminate 文本进行去重处理 */ private removedDuplicationsForDiscriminate(): string | null { if (!this.discriminate || this.discriminate.length === 0) { return this.discriminate; } // ------------------------------------------------------------ // 这些 / 這些 / 这两 / 這兩 前加换行,便于后续去重 // ------------------------------------------------------------ let desc = this.discriminate .replace("这些", "\n这些") .replace("這些", "\n這些") .replace("这两", "\n这两") .replace("這兩", "\n這兩"); // ------------------------------------------------------------ // 处理类似:2. 3. 这类编号,确保从第二项开始换行 // ------------------------------------------------------------ class NumberedLineTransform implements MapTransform { transform(partStr: string | null): string | null { if (!partStr || partStr.length <= 1) { return partStr; } const dotIndex = partStr.indexOf("."); if (dotIndex > 0) { const numIndex = dotIndex - 1; const head = partStr.substring(numIndex, dotIndex); if (NumberUtility.isInt(head)) { const num = parseInt(head, 10); if (num > 1) { return partStr.replace(`${head}.`, `\n${head}.`); } } } return partStr; } } const transformInstance = new NumberedLineTransform(); desc = StringMapUtility.map(desc, "\n", transformInstance); // ------------------------------------------------------------ // 以换行符为单位去除重复项 // ------------------------------------------------------------ return StringMapUtility.removedDuplications(desc, "\n"); } }
AST#export_declaration#Left export AST#class_declaration#Left class WordDetail extends AST#type_annotation#Left AST#primary_type#Left Word AST#primary_type#Right AST#type_annotation#Right AST#class_body#Left { // pronEn : string | null = null; // pronUs : string | null = null; // titleCn2 : string | null = null; // titleCn3 : string | null = null; AST#property_declaration#Left wordImage : 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#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left wordChange : 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#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left synWords : 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#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left asynWords : 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#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#property_declaration#Right // exampleEn1 : string | null = null; // exampleCn1 : string | null = null; AST#property_declaration#Left exampleEn2 : 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#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left exampleCn2 : 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#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left exampleEn3 : 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#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left exampleCn3 : 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#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left usedPhrase : 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#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left en2En : 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#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left discriminate : 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#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private discriminate2 : 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#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#property_declaration#Right // 去除重复后的缓存结果 AST#property_declaration#Left override AST#property_declaration#Right AST#method_declaration#Left async getWordDetail 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#union_type#Left AST#primary_type#Left WordDetail 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#return_statement#Left return AST#expression#Left this AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right // // /** // * 将多个中文释义合并为一个字符串(去重) // */ // getTitleCnsJoined(): string { // const titles: string[] = []; // // if (this.titleCn1) { // titles.push(this.titleCn1); // } // if (this.titleCn2) { // titles.push(this.titleCn2); // } // if (this.titleCn3) { // titles.push(this.titleCn3); // } // // return AppUtility.getJoinedStringByRemovingDuplications( // titles, // Constants.TitleTextJp.wordsMaxPart // ); // } /** * 从词形变化中提取英文单词 */ AST#method_declaration#Left getWordChangeEnWords AST#parameter_list#Left ( ) 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#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left StringDealUtility AST#expression#Right . matchEnWords 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 . wordChange 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#method_declaration#Right /** * 获取需要高亮 / 标记的文本集合 */ AST#method_declaration#Left getMarkTexts AST#parameter_list#Left ( ) 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#variable_declaration#Left const AST#variable_declarator#Left markTexts : 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left markTexts AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#spread_element#Left ... AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getWordChangeEnWords AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#spread_element#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 this AST#expression#Right . titleEn AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left wordTexts = 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 . titleEn AST#member_expression#Right AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#ERROR#Left / AST#ERROR#Right AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#unary_expression#Left - AST#expression#Left AST#expression#Right AST#unary_expression#Right AST#expression#Right / AST#expression#Left g AST#expression#Right AST#binary_expression#Right AST#expression#Right , AST#expression#Left " " AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . split 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#for_statement#Left for ( const str of AST#expression#Left wordTexts 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 markTexts AST#expression#Right . push 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#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 markTexts AST#expression#Right . push 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 . titleEn 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#statement#Left AST#return_statement#Left return AST#expression#Left markTexts AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right // ============================================================ // MARK: - Discriminate 处理 // ============================================================ /** * 获取去重后的辨析说明(带缓存) */ AST#method_declaration#Left getDiscriminateRemovedDuplications AST#parameter_list#Left ( ) 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#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 this AST#expression#Right AST#unary_expression#Right AST#expression#Right . discriminate2 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 this AST#expression#Right . discriminate2 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 . removedDuplicationsForDiscriminate 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#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 this AST#expression#Right . discriminate2 AST#member_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right /** * 对 discriminate 文本进行去重处理 */ AST#method_declaration#Left private removedDuplicationsForDiscriminate AST#parameter_list#Left ( ) 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#if_statement#Left if ( 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#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . discriminate AST#member_expression#Right AST#expression#Right || AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . discriminate 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#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 . discriminate AST#member_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#variable_declaration#Left let AST#variable_declarator#Left desc = 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 . discriminate AST#member_expression#Right AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "这些" AST#expression#Right , AST#expression#Left "\n这些" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "這些" AST#expression#Right , AST#expression#Left "\n這些" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "这两" AST#expression#Right , AST#expression#Left "\n这两" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "這兩" AST#expression#Right , AST#expression#Left "\n這兩" 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 // ------------------------------------------------------------ // 处理类似:2. 3. 这类编号,确保从第二项开始换行 // ------------------------------------------------------------ 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 NumberedLineTransform 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 MapTransform AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left transform AST#property_name#Right AST#parameter_list#Left ( AST#parameter#Left partStr : 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#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#unary_expression#Left ! AST#expression#Left partStr AST#expression#Right AST#unary_expression#Right AST#expression#Right || AST#expression#Left partStr AST#expression#Right AST#binary_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#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left partStr 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 dotIndex = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left partStr AST#expression#Right . indexOf 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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left dotIndex 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 numIndex = AST#expression#Left AST#binary_expression#Left AST#expression#Left dotIndex AST#expression#Right - AST#expression#Left 1 AST#expression#Right AST#binary_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 head = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left partStr AST#expression#Right . substring AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left numIndex AST#expression#Right , AST#expression#Left dotIndex 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left NumberUtility AST#expression#Right . isInt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left head AST#expression#Right ) 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 num = AST#expression#Left AST#call_expression#Left AST#expression#Left parseInt AST#expression#Right AST#argument_list#Left ( AST#expression#Left head AST#expression#Right , AST#expression#Left 10 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 num 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 AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left partStr AST#expression#Right . replace 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 head AST#expression#Right } AST#template_substitution#Right . ` AST#template_literal#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` \n AST#template_substitution#Left $ { AST#expression#Left head 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#return_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#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left partStr AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left transformInstance = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left NumberedLineTransform 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#assignment_expression#Left desc = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left StringMapUtility AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left desc AST#expression#Right , AST#expression#Left "\n" AST#expression#Right , AST#expression#Left transformInstance 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#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left StringMapUtility AST#expression#Right . removedDuplications AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left desc AST#expression#Right , AST#expression#Left "\n" 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 WordDetail extends Word { wordImage : string | null = null; wordChange : string | null = null; synWords : string | null = null; asynWords : string | null = null; exampleEn2 : string | null = null; exampleCn2 : string | null = null; exampleEn3 : string | null = null; exampleCn3 : string | null = null; usedPhrase : string | null = null; en2En : string | null = null; discriminate : string | null = null; private discriminate2 : string | null = null; override async getWordDetail(): Promise<WordDetail | null> { return this } /** * 将多个中文释义合并为一个字符串(去重) */ getTitleCnsJoined(): string { const titles: string[] = []; if (this.titleCn1) { titles.push(this.titleCn1); } if (this.titleCn2) { titles.push(this.titleCn2); } if (this.titleCn3) { titles.push(this.titleCn3); } return AppUtility.getJoinedStringByRemovingDuplications( titles, Constants.TitleTextJp.wordsMaxPart ); } getWordChangeEnWords(): string[] { return StringDealUtility.matchEnWords(this.wordChange); } getMarkTexts(): string[] { const markTexts: string[] = []; 来自词形变化 markTexts.push(...this.getWordChangeEnWords()); 将短语拆分(空格 & "-") if (this.titleEn) { const wordTexts = this.titleEn.replace(/-/g, " ").split(" "); for (const str of wordTexts) { markTexts.push(str); } 原始短语 markTexts.push(this.titleEn); } return markTexts; } ============================================================ MARK: - Discriminate 处理 ============================================================ getDiscriminateRemovedDuplications(): string | null { if (!this.discriminate2) { this.discriminate2 = this.removedDuplicationsForDiscriminate(); } return this.discriminate2; } private removedDuplicationsForDiscriminate(): string | null { if (!this.discriminate || this.discriminate.length === 0) { return this.discriminate; } ------------------------------------------------------------ 这些 / 這些 / 这两 / 這兩 前加换行,便于后续去重 ------------------------------------------------------------ let desc = this.discriminate .replace("这些", "\n这些") .replace("這些", "\n這些") .replace("这两", "\n这两") .replace("這兩", "\n這兩"); ------------------------------------------------------------ 处理类似:2. 3. 这类编号,确保从第二项开始换行 ------------------------------------------------------------ class NumberedLineTransform implements MapTransform { transform(partStr: string | null): string | null { if (!partStr || partStr.length <= 1) { return partStr; } const dotIndex = partStr.indexOf("."); if (dotIndex > 0) { const numIndex = dotIndex - 1; const head = partStr.substring(numIndex, dotIndex); if (NumberUtility.isInt(head)) { const num = parseInt(head, 10); if (num > 1) { return partStr.replace(`${head}.`, `\n${head}.`); } } } return partStr; } } const transformInstance = new NumberedLineTransform(); desc = StringMapUtility.map(desc, "\n", transformInstance); ------------------------------------------------------------ 以换行符为单位去除重复项 ------------------------------------------------------------ return StringMapUtility.removedDuplications(desc, "\n"); } }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/datas/word/WordDetail.ets#L12-L160
35a1b40ee253326d4fb0ee1544a6d7f195d307ee
github
bigbear20240612/planner_build-.git
89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1
entry/src/main/ets/viewmodel/SimpleOfflineManager.ets
arkts
网络状态枚举
export enum NetworkStatus { ONLINE = 'online', OFFLINE = 'offline', UNKNOWN = 'unknown' }
AST#export_declaration#Left export AST#enum_declaration#Left enum NetworkStatus AST#enum_body#Left { AST#enum_member#Left ONLINE = AST#expression#Left 'online' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left OFFLINE = AST#expression#Left 'offline' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left UNKNOWN = AST#expression#Left 'unknown' AST#expression#Right AST#enum_member#Right } AST#enum_body#Right AST#enum_declaration#Right AST#export_declaration#Right
export enum NetworkStatus { ONLINE = 'online', OFFLINE = 'offline', UNKNOWN = 'unknown' }
https://github.com/bigbear20240612/planner_build-.git/blob/89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1/entry/src/main/ets/viewmodel/SimpleOfflineManager.ets#L6-L10
42326723e75c08a6568fc2426db138c5a6734cae
github
YueHua46/ArkTS_Learn.git
5c08d3016421c69c299f7cb757df686f277889ac
entry/src/main/ets/pages/RankPage.ets
arkts
onPageHide
4.onPageHide(页面消失)
onPageHide() {}
AST#method_declaration#Left onPageHide AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { } AST#builder_function_body#Right AST#method_declaration#Right
onPageHide() {}
https://github.com/YueHua46/ArkTS_Learn.git/blob/5c08d3016421c69c299f7cb757df686f277889ac/entry/src/main/ets/pages/RankPage.ets#L31-L31
e06c9e2ddb81798cecf7f123c7b05a3caed1639b
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/SuperFeature/DistributedAppDev/DistributedFilemanager/Library/src/main/ets/utils/Logger.ets
arkts
Common log for all features.
export class Logger { private domain: number; private prefix: string; private format: string = '%{public}s, %{public}s'; constructor(prefix: string) { this.prefix = prefix; this.domain = 0xFF00; } debug(...args: string[]): void { hilog.debug(this.domain, this.prefix, this.format, args); } info(...args: string[]): void { hilog.info(this.domain, this.prefix, this.format, args); } warn(...args: string[]): void { hilog.warn(this.domain, this.prefix, this.format, args); } error(...args: string[]): void { hilog.error(this.domain, this.prefix, this.format, args); } fatal(...args: string[]): void { hilog.fatal(this.domain, this.prefix, this.format, args); } isLoggable(level: number): void { hilog.isLoggable(this.domain, this.prefix, level); } }
AST#export_declaration#Left export AST#class_declaration#Left class Logger AST#class_body#Left { AST#property_declaration#Left private domain : 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 private prefix : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left private format : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '%{public}s, %{public}s' AST#expression#Right ; AST#property_declaration#Right AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left prefix : 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 this AST#expression#Right . prefix AST#member_expression#Right = AST#expression#Left prefix 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 . domain AST#member_expression#Right = AST#expression#Left 0xFF00 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#method_declaration#Left debug 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#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 hilog 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 . 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 AST#method_declaration#Left info 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#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 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 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 AST#method_declaration#Left warn 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#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 hilog AST#expression#Right . warn 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 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#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 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 AST#method_declaration#Left fatal 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#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 hilog AST#expression#Right . fatal 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 AST#method_declaration#Left isLoggable AST#parameter_list#Left ( AST#parameter#Left level : 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . isLoggable 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 level 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 Logger { private domain: number; private prefix: string; private format: string = '%{public}s, %{public}s'; constructor(prefix: string) { this.prefix = prefix; this.domain = 0xFF00; } debug(...args: string[]): void { hilog.debug(this.domain, this.prefix, this.format, args); } info(...args: string[]): void { hilog.info(this.domain, this.prefix, this.format, args); } warn(...args: string[]): void { hilog.warn(this.domain, this.prefix, this.format, args); } error(...args: string[]): void { hilog.error(this.domain, this.prefix, this.format, args); } fatal(...args: string[]): void { hilog.fatal(this.domain, this.prefix, this.format, args); } isLoggable(level: number): void { hilog.isLoggable(this.domain, this.prefix, level); } }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/SuperFeature/DistributedAppDev/DistributedFilemanager/Library/src/main/ets/utils/Logger.ets#L20-L53
0327fe03f1c8e4b074f28593dbc88ebe573d5d6a
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/videotrimmer/src/main/ets/videotrimmer/VideoTrimmerView.ets
arkts
watchVideoTrimmerOption
裁剪选项变动时停止播放刷新界面
watchVideoTrimmerOption() { this.configUIInfo(); this.isPausePreview = true; this.waitLoadedInitAVPlayer(); }
AST#method_declaration#Left watchVideoTrimmerOption 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 this AST#expression#Right . configUIInfo 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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isPausePreview 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . waitLoadedInitAVPlayer 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
watchVideoTrimmerOption() { this.configUIInfo(); this.isPausePreview = true; this.waitLoadedInitAVPlayer(); }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/videotrimmer/src/main/ets/videotrimmer/VideoTrimmerView.ets#L45-L49
8cd16c2cd630ee612375dce2af7d88f8b26975fb
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/SystemFeature/DeviceManagement/DeviceManagementCollection/feature/capabilities/src/main/ets/components/devicemanager/InputDeviceDataDialog.ets
arkts
InputDeviceDataDialog
输入设备详情弹窗
@CustomDialog export struct InputDeviceDataDialog { @Link mDeviceInfo: InputDeviceInfo mController?: CustomDialogController; cancel?: () => void build() { Scroll() { Column() { Text(this.mDeviceInfo.name) .fontColor($r('sys.color.ohos_id_color_text_primary')) .fontSize($r('sys.float.ohos_id_text_size_dialog_tittle')) .fontWeight(FontWeight.Medium) .width('100%') .margin({ bottom: px2vp(48) }) DeviceData({ title: $r('app.string.input_device_id'), context: this.mDeviceInfo.id.toString() }) DeviceData({ title: $r('app.string.input_device_uniq'), context: this.mDeviceInfo.uniq }) DeviceData({ title: $r('app.string.input_device_style'), context: this.mDeviceInfo.sources.join(',') }) DeviceData({ title: $r('app.string.input_device_axis_ranges'), }) ForEach(this.mDeviceInfo.axisRanges, (item: inputDevice.AxisRange) => { Column() { DeviceData({ title: $r('app.string.input_device_source_style'), context: item.source }) DeviceData({ title: $r('app.string.input_device_axis_type'), context: item.axis }) DeviceData({ title: $r('app.string.input_device_max'), context: item.max.toString() }) DeviceData({ title: $r('app.string.input_device_min'), context: item.min.toString() }) DeviceData({ title: $r('app.string.input_device_fuzz'), context: item.fuzz.toString() }) DeviceData({ title: $r('app.string.input_device_flat'), context: item.flat.toString() }) DeviceData({ title: $r('app.string.input_device_resolution'), context: item.resolution.toString() }) } .width('97%') .justifyContent(FlexAlign.End) .alignItems(HorizontalAlign.Center) }) DeviceData({ title: $r('app.string.input_device_bus'), context: this.mDeviceInfo.bus.toString() }) DeviceData({ title: $r('app.string.input_device_product'), context: this.mDeviceInfo.product.toString() }) DeviceData({ title: $r('app.string.input_device_vendor'), context: this.mDeviceInfo.vendor.toString() }) DeviceData({ title: $r('app.string.input_device_version'), context: this.mDeviceInfo.version.toString(), isShowDivider: false }) } .justifyContent(FlexAlign.Center) .alignItems(HorizontalAlign.End) .padding(px2vp(24)) } } }
AST#decorated_export_declaration#Left AST#decorator#Left @ CustomDialog AST#decorator#Right export struct InputDeviceDataDialog AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ Link AST#decorator#Right mDeviceInfo : AST#type_annotation#Left AST#primary_type#Left InputDeviceInfo AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left mController ? : CustomDialogController AST#ERROR#Right ; AST#property_declaration#Right AST#property_declaration#Left cancel ? : 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 Scroll ( ) 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#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mDeviceInfo AST#member_expression#Right AST#expression#Right . name AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'sys.color.ohos_id_color_text_primary' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'sys.float.ohos_id_text_size_dialog_tittle' 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 FontWeight AST#expression#Right . Medium AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left px2vp AST#expression#Right AST#argument_list#Left ( AST#expression#Left 48 AST#expression#Right ) AST#argument_list#Right AST#call_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#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 DeviceData ( AST#component_parameters#Left { AST#component_parameter#Left title : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.input_device_id' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left context : 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 this AST#expression#Right . mDeviceInfo AST#member_expression#Right AST#expression#Right . id AST#member_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#component_parameter#Right } AST#component_parameters#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 DeviceData ( AST#component_parameters#Left { AST#component_parameter#Left title : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.input_device_uniq' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left context : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mDeviceInfo AST#member_expression#Right AST#expression#Right . uniq 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#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left DeviceData ( AST#component_parameters#Left { AST#component_parameter#Left title : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.input_device_style' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left context : 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 this AST#expression#Right . mDeviceInfo AST#member_expression#Right AST#expression#Right . sources AST#member_expression#Right AST#expression#Right . join 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#component_parameter#Right } AST#component_parameters#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 DeviceData ( AST#component_parameters#Left { AST#component_parameter#Left title : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.input_device_axis_ranges' AST#expression#Right ) AST#resource_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#ui_control_flow#Left AST#for_each_statement#Left ForEach ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mDeviceInfo AST#member_expression#Right AST#expression#Right . axisRanges 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 AST#qualified_type#Left inputDevice . AxisRange AST#qualified_type#Right 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 Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left DeviceData ( AST#component_parameters#Left { AST#component_parameter#Left title : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.input_device_source_style' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left context : AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . source 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#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left DeviceData ( AST#component_parameters#Left { AST#component_parameter#Left title : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.input_device_axis_type' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left context : AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . axis 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#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left DeviceData ( AST#component_parameters#Left { AST#component_parameter#Left title : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.input_device_max' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left context : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . max AST#member_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#component_parameter#Right } AST#component_parameters#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 DeviceData ( AST#component_parameters#Left { AST#component_parameter#Left title : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.input_device_min' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left context : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . min AST#member_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#component_parameter#Right } AST#component_parameters#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 DeviceData ( AST#component_parameters#Left { AST#component_parameter#Left title : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.input_device_fuzz' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left context : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . fuzz AST#member_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#component_parameter#Right } AST#component_parameters#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 DeviceData ( AST#component_parameters#Left { AST#component_parameter#Left title : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.input_device_flat' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left context : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . flat AST#member_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#component_parameter#Right } AST#component_parameters#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 DeviceData ( AST#component_parameters#Left { AST#component_parameter#Left title : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.input_device_resolution' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left context : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . resolution AST#member_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#component_parameter#Right } AST#component_parameters#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 '97%' AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . End AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left HorizontalAlign 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#ui_arrow_function_body#Right AST#ui_builder_arrow_function#Right ) AST#for_each_statement#Right AST#ui_control_flow#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left DeviceData ( AST#component_parameters#Left { AST#component_parameter#Left title : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.input_device_bus' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left context : 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 this AST#expression#Right . mDeviceInfo AST#member_expression#Right AST#expression#Right . bus AST#member_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#component_parameter#Right } AST#component_parameters#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 DeviceData ( AST#component_parameters#Left { AST#component_parameter#Left title : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.input_device_product' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left context : 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 this AST#expression#Right . mDeviceInfo AST#member_expression#Right AST#expression#Right . product AST#member_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#component_parameter#Right } AST#component_parameters#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 DeviceData ( AST#component_parameters#Left { AST#component_parameter#Left title : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.input_device_vendor' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left context : 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 this AST#expression#Right . mDeviceInfo AST#member_expression#Right AST#expression#Right . vendor AST#member_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#component_parameter#Right } AST#component_parameters#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 DeviceData ( AST#component_parameters#Left { AST#component_parameter#Left title : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.input_device_version' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left context : 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 this AST#expression#Right . mDeviceInfo AST#member_expression#Right AST#expression#Right . version AST#member_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#component_parameter#Right , AST#component_parameter#Left isShowDivider : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#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#container_content_body#Right AST#ui_component#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#Left . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left HorizontalAlign AST#expression#Right . End AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#call_expression#Left AST#expression#Left px2vp 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 ) 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#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@CustomDialog export struct InputDeviceDataDialog { @Link mDeviceInfo: InputDeviceInfo mController?: CustomDialogController; cancel?: () => void build() { Scroll() { Column() { Text(this.mDeviceInfo.name) .fontColor($r('sys.color.ohos_id_color_text_primary')) .fontSize($r('sys.float.ohos_id_text_size_dialog_tittle')) .fontWeight(FontWeight.Medium) .width('100%') .margin({ bottom: px2vp(48) }) DeviceData({ title: $r('app.string.input_device_id'), context: this.mDeviceInfo.id.toString() }) DeviceData({ title: $r('app.string.input_device_uniq'), context: this.mDeviceInfo.uniq }) DeviceData({ title: $r('app.string.input_device_style'), context: this.mDeviceInfo.sources.join(',') }) DeviceData({ title: $r('app.string.input_device_axis_ranges'), }) ForEach(this.mDeviceInfo.axisRanges, (item: inputDevice.AxisRange) => { Column() { DeviceData({ title: $r('app.string.input_device_source_style'), context: item.source }) DeviceData({ title: $r('app.string.input_device_axis_type'), context: item.axis }) DeviceData({ title: $r('app.string.input_device_max'), context: item.max.toString() }) DeviceData({ title: $r('app.string.input_device_min'), context: item.min.toString() }) DeviceData({ title: $r('app.string.input_device_fuzz'), context: item.fuzz.toString() }) DeviceData({ title: $r('app.string.input_device_flat'), context: item.flat.toString() }) DeviceData({ title: $r('app.string.input_device_resolution'), context: item.resolution.toString() }) } .width('97%') .justifyContent(FlexAlign.End) .alignItems(HorizontalAlign.Center) }) DeviceData({ title: $r('app.string.input_device_bus'), context: this.mDeviceInfo.bus.toString() }) DeviceData({ title: $r('app.string.input_device_product'), context: this.mDeviceInfo.product.toString() }) DeviceData({ title: $r('app.string.input_device_vendor'), context: this.mDeviceInfo.vendor.toString() }) DeviceData({ title: $r('app.string.input_device_version'), context: this.mDeviceInfo.version.toString(), isShowDivider: false }) } .justifyContent(FlexAlign.Center) .alignItems(HorizontalAlign.End) .padding(px2vp(24)) } } }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/SystemFeature/DeviceManagement/DeviceManagementCollection/feature/capabilities/src/main/ets/components/devicemanager/InputDeviceDataDialog.ets#L20-L125
e8e4c7f6c0a10664a0283a785edc7c20ee74f572
gitee
Joker-x-dev/HarmonyKit.git
f97197ce157df7f303244fba42e34918306dfb08
entry/src/main/ets/navigation/NavigationHost.ets
arkts
导航目标构建器 @returns 路由构建器
build() { Navigation(this.navPathStack) { MainPage() } .hideTitleBar(true) .mode(NavigationMode.Stack) .navDestination(this.PagesMap) }
AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Navigation ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . navPathStack AST#member_expression#Right AST#expression#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left MainPage ( ) 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 . hideTitleBar ( AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . mode ( AST#expression#Left AST#member_expression#Left AST#expression#Left NavigationMode AST#expression#Right . Stack AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . navDestination ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . PagesMap 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
build() { Navigation(this.navPathStack) { MainPage() } .hideTitleBar(true) .mode(NavigationMode.Stack) .navDestination(this.PagesMap) }
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/entry/src/main/ets/navigation/NavigationHost.ets#L36-L43
8efde986b173c856ec99dacffdd9188a5da4c5bd
github
sithvothykiv/dialog_hub.git
b676c102ef2d05f8994d170abe48dcc40cd39005
custom_dialog/src/main/ets/model/style/ITextStyle.ets
arkts
文本样式
export interface ITextStyle { /** * 自定义样式标识(用来区分样式 ID) * @description 如果已设置 ID,还设置其他样式,如:borderRadius、height、fontWeight、fontSize等,将以当前对象字段优先 */ customStyleId?: string /** * 字体颜色 */ fontColor?: ResourceColor; /** * 字体粗细 */ fontWeight?: FontWeight; /** * 字号 */ fontSize?: number; /** * 行高 可选 * @description 默认为 20 */ lineHeight?: Length /** * 最大行数 */ maxLines?: number /** * 文本溢出方式 */ textOverflow?: TextOverflow /** * 文本对齐方式 */ margin?: Margin /** * 文本内边距 */ padding?: Padding | Length /** * 文本对齐方式 */ textAlign?: TextAlign /** * 文本宽度 */ width?: Length /** * 文本高度 */ height?: Length /** * 按钮背景颜色(可选) */ background?: ResourceColor; /** * 按钮边框样式(可选) */ border?: BorderOptions; /** * 按钮圆角半径(可选) */ borderRadius?: Length | BorderRadiuses }
AST#export_declaration#Left export AST#interface_declaration#Left interface ITextStyle AST#object_type#Left { /** * 自定义样式标识(用来区分样式 ID) * @description 如果已设置 ID,还设置其他样式,如:borderRadius、height、fontWeight、fontSize等,将以当前对象字段优先 */ AST#type_member#Left customStyleId ? : 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 fontColor ? : AST#type_annotation#Left AST#primary_type#Left ResourceColor AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * 字体粗细 */ AST#type_member#Left fontWeight ? : AST#type_annotation#Left AST#primary_type#Left FontWeight AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * 字号 */ AST#type_member#Left fontSize ? : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * 行高 可选 * @description 默认为 20 */ AST#type_member#Left lineHeight ? : AST#type_annotation#Left AST#primary_type#Left Length AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right /** * 最大行数 */ AST#type_member#Left maxLines ? : 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 textOverflow ? : AST#type_annotation#Left AST#primary_type#Left TextOverflow AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right /** * 文本对齐方式 */ AST#type_member#Left margin ? : AST#type_annotation#Left AST#primary_type#Left Margin AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right /** * 文本内边距 */ AST#type_member#Left padding ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Padding AST#primary_type#Right | AST#primary_type#Left Length AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#type_member#Right /** * 文本对齐方式 */ AST#type_member#Left textAlign ? : AST#type_annotation#Left AST#primary_type#Left TextAlign AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right /** * 文本宽度 */ AST#type_member#Left width ? : AST#type_annotation#Left AST#primary_type#Left Length AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right /** * 文本高度 */ AST#type_member#Left height ? : AST#type_annotation#Left AST#primary_type#Left Length AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right /** * 按钮背景颜色(可选) */ AST#type_member#Left background ? : AST#type_annotation#Left AST#primary_type#Left ResourceColor AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * 按钮边框样式(可选) */ AST#type_member#Left border ? : AST#type_annotation#Left AST#primary_type#Left BorderOptions AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * 按钮圆角半径(可选) */ AST#type_member#Left borderRadius ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Length AST#primary_type#Right | AST#primary_type#Left BorderRadiuses AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#type_member#Right } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
export interface ITextStyle { customStyleId?: string fontColor?: ResourceColor; fontWeight?: FontWeight; fontSize?: number; lineHeight?: Length maxLines?: number textOverflow?: TextOverflow margin?: Margin padding?: Padding | Length textAlign?: TextAlign width?: Length height?: Length background?: ResourceColor; border?: BorderOptions; borderRadius?: Length | BorderRadiuses }
https://github.com/sithvothykiv/dialog_hub.git/blob/b676c102ef2d05f8994d170abe48dcc40cd39005/custom_dialog/src/main/ets/model/style/ITextStyle.ets#L4-L72
25612133acdc3881ac22ceb394f0b46f1d88933c
github
Puiching-Memory/HOMOAPP_Q5.git
53e36a21984de7bf41b6fafc840fde013236b9d2
entry/src/main/ets/components/MusicPlayerBar.ets
arkts
MusicPlayerBar
音乐播放控制条 提供进度显示、控制以及简单的响度可视化动画
@ComponentV2 export struct MusicPlayerBar { private globalMusic: GlobalMusic = AppStorageV2.connect(GlobalMusic, 'GlobalMusic', () => new GlobalMusic())!; // 增加频域可视化的数据点数量 @Local private barHeights: number[] = new Array(24).fill(6); private timerId: number = -1; aboutToAppear() { this.startAnimation(); } aboutToDisappear() { if (this.timerId !== -1) { clearInterval(this.timerId); } } // 简单的模拟动画 private startAnimation() { this.timerId = setInterval(() => { this.barHeights = this.barHeights.map((_, index) => this.getBarHeight(index)); }, 120); // 稍微加快刷新率更流畅 } // 获取当前的动态高度 private getBarHeight(index: number): number { // 基础高度 6vp,确保无论如何都能看到一点 const BASE_H = 6; if (!this.globalMusic.isPlay && !this.globalMusic.isLoading) { return BASE_H; } // 如果在加载中,显示一种特定的跳动 if (this.globalMusic.isLoading) { return BASE_H + Math.abs(Math.sin(Date.now() / 200 + index)) * 10; } // 如果有真实的频谱/波形数据 if (this.globalMusic.waveform && this.globalMusic.waveform.length > 0) { const len = this.globalMusic.waveform.length; const progress = this.globalMusic.duration > 0 ? (this.globalMusic.time / this.globalMusic.duration) : 0; const centerIndex = Math.floor(progress * len); const offset = index - Math.floor(this.barHeights.length / 2); const targetIndex = (centerIndex + offset + len) % len; const waveformValue = this.globalMusic.waveform[targetIndex] || 0.1; const enhancedValue = Math.pow(waveformValue, 1.2); const flicker = Math.random() * 4; return BASE_H + enhancedValue * 22 + flicker; } // 回退方案:随机跳动 return BASE_H + Math.random() * 12; } // 格式化时间 private formatTime(ms: number): string { const totalSeconds = Math.floor(ms / 1000); const minutes = Math.floor(totalSeconds / 60); const seconds = totalSeconds % 60; return `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`; } build() { Column() { // 整体卡片容器,增加边距和投影 Column() { // 1. 顶部加载/进度指示器 (折叠时显示为极细线条) if (this.globalMusic.isBarCollapsed) { Progress({ value: this.globalMusic.time, total: this.globalMusic.duration, type: ProgressType.Linear }) .width('100%') .height(2) .color('#5CD6FF') .backgroundColor('#1A355E') .transition({ type: TransitionType.All, opacity: 0 }) } // 2. 顶部切换手柄,增加交互面积 Row() { Rect() .width(32) .height(4) .radius(2) .fill($r('app.color.text_secondary')) .opacity(0.3) } .width('100%') .height(20) .justifyContent(FlexAlign.Center) .onClick(() => { this.getUIContext()?.animateTo({ duration: 400, curve: Curve.FastOutSlowIn }, () => { this.globalMusic.isBarCollapsed = !this.globalMusic.isBarCollapsed; }) }) // 3. 内容主体 Row() { // 左侧:封面与歌曲信息区域 (占据绝大部分空间) Row({ space: 12 }) { Stack({ alignContent: Alignment.Center }) { Image(this.globalMusic.img || $r('app.media.startIcon')) .width(this.globalMusic.isBarCollapsed ? 42 : 56) .height(this.globalMusic.isBarCollapsed ? 42 : 56) .borderRadius(this.globalMusic.isBarCollapsed ? 8 : 12) .animation({ duration: 400 }) if (this.globalMusic.isLoading) { LoadingProgress() .width(20) .height(20) .color('#5CD6FF') } } Column({ space: 4 }) { Text(this.globalMusic.name || '未在播放') .fontSize(this.globalMusic.isBarCollapsed ? 14 : 17) .fontWeight(FontWeight.Bold) .fontColor($r('app.color.text_primary')) .maxLines(1) .textOverflow({ overflow: TextOverflow.Ellipsis }) Text(this.globalMusic.author || '环境白噪音') .fontSize(this.globalMusic.isBarCollapsed ? 11 : 13) .fontColor($r('app.color.text_secondary')) .maxLines(1) .textOverflow({ overflow: TextOverflow.Ellipsis }) } .alignItems(HorizontalAlign.Start) .layoutWeight(1) // 确保文字区域可以自适应撑开 } .layoutWeight(1) // 右侧:控制按钮组 (保持固定宽度) Row({ space: this.globalMusic.isBarCollapsed ? 8 : 14 }) { if (!this.globalMusic.isBarCollapsed) { SymbolGlyph($r('sys.symbol.backward_end_fill')) .fontSize(22) .fontColor(['#5CD6FF']) .onClick(() => avPlayerManage.preSong()) .transition(TransitionEffect.OPACITY.combine(TransitionEffect.scale({ x: 0.5, y: 0.5 }))) } // 播放/暂停按钮 Stack() { Circle() .width(this.globalMusic.isBarCollapsed ? 38 : 44) .height(this.globalMusic.isBarCollapsed ? 38 : 44) .fill('#1A355E') .opacity(0.6) SymbolGlyph(this.globalMusic.isPlay ? $r('sys.symbol.pause_fill') : $r('sys.symbol.play_fill')) .fontSize(this.globalMusic.isBarCollapsed ? 22 : 26) .fontColor(['#5CD6FF']) } .onClick(() => avPlayerManage.stopOrContinueSong()) if (!this.globalMusic.isBarCollapsed) { SymbolGlyph($r('sys.symbol.forward_end_fill')) .fontSize(22) .fontColor(['#5CD6FF']) .onClick(() => avPlayerManage.nextSong()) .transition(TransitionEffect.OPACITY.combine(TransitionEffect.scale({ x: 0.5, y: 0.5 }))) } } .margin({ left: 8 }) } .width('100%') .padding({ left: 12, right: 12, bottom: this.globalMusic.isBarCollapsed ? 12 : 10 }) // 4. 展开状态下的视觉增强区 (波形图和进度条) if (!this.globalMusic.isBarCollapsed) { Column() { // 将波形图移到这里,居中显示,不干扰文字 Row({ space: 3 }) { ForEach(this.barHeights, (h: number, index: number) => { Rect() .width(2.5) .height(h * 0.7) // 稍微调矮一点,作为视觉点缀 .fill('#5CD6FF') .opacity(index % 2 === 0 ? 0.5 : 0.3) .radius(1.5) }, (h: number, index: number) => `exp_bar_${index}_${h}`) } .width('100%') .height(26) .justifyContent(FlexAlign.Center) .margin({ top: 4, bottom: 4 }) .transition(TransitionEffect.OPACITY.combine(TransitionEffect.scale({ x: 0.8, y: 0.8 }))) Slider({ value: this.globalMusic.time, min: 0, max: this.globalMusic.duration, style: SliderStyle.OutSet }) .width('100%') .blockColor('#5CD6FF') .selectedColor('#5CD6FF') .trackColor('#27518B') .trackThickness(4) .padding({ left: 10, right: 10 }) .onChange((value: number, mode: SliderChangeMode) => { if (mode === SliderChangeMode.End) { avPlayerManage.jumpToPlay(value); } }) Row() { Text(this.formatTime(this.globalMusic.time)) .fontSize(10) .fontColor($r('app.color.text_secondary')) Blank() Text(this.formatTime(this.globalMusic.duration)) .fontSize(10) .fontColor($r('app.color.text_secondary')) } .width('100%') .padding({ left: 14, right: 14, bottom: 12 }) } .padding({ left: 4, right: 4 }) .transition(TransitionEffect.asymmetric( TransitionEffect.OPACITY.combine(TransitionEffect.move(TransitionEdge.TOP)), TransitionEffect.OPACITY.combine(TransitionEffect.move(TransitionEdge.TOP)) )) } } .backgroundColor($r('app.color.surface_card')) .backgroundBlurStyle(BlurStyle.Thin) .borderRadius(this.globalMusic.isBarCollapsed ? 20 : 32) .borderWidth(1) .borderColor($r('app.color.surface_card_border')) .shadow({ radius: 20, color: 'rgba(0,0,0,0.4)', offsetX: 0, offsetY: 8 }) } .width('100%') .padding({ left: 12, right: 12, bottom: 8 }) } }
AST#decorated_export_declaration#Left AST#decorator#Left @ ComponentV2 AST#decorator#Right export struct MusicPlayerBar AST#component_body#Left { AST#property_declaration#Left private globalMusic : AST#type_annotation#Left AST#primary_type#Left GlobalMusic AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#non_null_assertion_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorageV2 AST#expression#Right . connect AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left GlobalMusic AST#expression#Right , AST#expression#Left 'GlobalMusic' AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left GlobalMusic 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#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right ; AST#property_declaration#Right // 增加频域可视化的数据点数量 AST#property_declaration#Left AST#decorator#Left @ Local AST#decorator#Right private barHeights : 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#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#argument_list#Left ( AST#expression#Left 24 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 6 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private timerId : 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#method_declaration#Left aboutToAppear 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 this AST#expression#Right . startAnimation 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 AST#method_declaration#Left aboutToDisappear AST#parameter_list#Left ( ) 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#member_expression#Left AST#expression#Left this AST#expression#Right . timerId AST#member_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#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left clearInterval ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . timerId AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right // 简单的模拟动画 AST#method_declaration#Left private startAnimation AST#parameter_list#Left ( ) 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 . timerId AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left setInterval 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 . barHeights 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 . barHeights 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 _ AST#parameter#Right , AST#parameter#Left index AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getBarHeight 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#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#block_statement#Right AST#arrow_function#Right AST#expression#Right , AST#expression#Left 120 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 // 获取当前的动态高度 AST#method_declaration#Left private getBarHeight AST#parameter_list#Left ( 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#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { // 基础高度 6vp,确保无论如何都能看到一点 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left BASE_H = AST#expression#Left 6 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 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 . globalMusic AST#member_expression#Right AST#expression#Right . isPlay AST#member_expression#Right AST#expression#Right && AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . globalMusic AST#member_expression#Right AST#expression#Right . isLoading AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left BASE_H 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#member_expression#Left AST#expression#Left this AST#expression#Right . globalMusic AST#member_expression#Right AST#expression#Right . isLoading AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return 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#binary_expression#Left AST#expression#Left BASE_H AST#expression#Right + AST#expression#Left Math AST#expression#Right AST#binary_expression#Right AST#expression#Right . abs 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 Math AST#expression#Right . sin 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 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#expression#Left 200 AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left index AST#expression#Right AST#binary_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#Left 10 AST#expression#Right AST#binary_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#if_statement#Left if ( 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 this AST#expression#Right . globalMusic AST#member_expression#Right AST#expression#Right . waveform AST#member_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . globalMusic AST#member_expression#Right AST#expression#Right . waveform 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#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left len = 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 . globalMusic AST#member_expression#Right AST#expression#Right . waveform 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#variable_declaration#Left const AST#variable_declarator#Left progress = 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 . globalMusic AST#member_expression#Right AST#expression#Right . duration AST#member_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#parenthesized_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 this AST#expression#Right . globalMusic AST#member_expression#Right AST#expression#Right . time AST#member_expression#Right AST#expression#Right / AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . globalMusic AST#member_expression#Right AST#expression#Right . duration AST#member_expression#Right AST#expression#Right ) AST#parenthesized_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 centerIndex = 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 progress AST#expression#Right * AST#expression#Left len 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 const AST#variable_declarator#Left offset = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right - AST#expression#Left Math AST#expression#Right AST#binary_expression#Right 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#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . barHeights 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#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 targetIndex = 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#binary_expression#Left AST#expression#Left centerIndex AST#expression#Right + AST#expression#Left offset AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left len AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right % AST#expression#Left len AST#expression#Right AST#binary_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 waveformValue = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . globalMusic AST#member_expression#Right AST#expression#Right . waveform AST#member_expression#Right AST#expression#Right [ AST#expression#Left targetIndex AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right || AST#expression#Left 0.1 AST#expression#Right AST#binary_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 enhancedValue = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . pow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left waveformValue AST#expression#Right , AST#expression#Left 1.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#variable_declaration#Left const AST#variable_declarator#Left flicker = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . random 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 4 AST#expression#Right AST#binary_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#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left BASE_H AST#expression#Right + AST#expression#Left AST#binary_expression#Left AST#expression#Left enhancedValue AST#expression#Right * AST#expression#Left 22 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left flicker AST#expression#Right AST#binary_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#binary_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 BASE_H AST#expression#Right + AST#expression#Left Math AST#expression#Right AST#binary_expression#Right AST#expression#Right . random 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 12 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 // 格式化时间 AST#method_declaration#Left private formatTime AST#parameter_list#Left ( AST#parameter#Left ms : 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 const AST#variable_declarator#Left totalSeconds = 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 ms AST#expression#Right / AST#expression#Left 1000 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 const AST#variable_declarator#Left minutes = 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 totalSeconds AST#expression#Right / AST#expression#Left 60 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 const AST#variable_declarator#Left seconds = AST#expression#Left AST#binary_expression#Left AST#expression#Left totalSeconds AST#expression#Right % AST#expression#Left 60 AST#expression#Right AST#binary_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 AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left minutes 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 . padStart AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 2 AST#expression#Right , AST#expression#Left '0' 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 AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left seconds 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 . padStart AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 2 AST#expression#Right , AST#expression#Left '0' 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 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 Column ( ) AST#container_content_body#Left { // 1. 顶部加载/进度指示器 (折叠时显示为极细线条) AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . globalMusic AST#member_expression#Right AST#expression#Right . isBarCollapsed AST#member_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Progress ( AST#component_parameters#Left { AST#component_parameter#Left value : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . globalMusic AST#member_expression#Right AST#expression#Right . time AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left total : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . globalMusic AST#member_expression#Right AST#expression#Right . duration AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left type : AST#expression#Left AST#member_expression#Left AST#expression#Left ProgressType AST#expression#Right . Linear AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#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 2 AST#expression#Right ) AST#modifier_chain_expression#Left . color ( AST#expression#Left '#5CD6FF' AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#1A355E' AST#expression#Right ) AST#modifier_chain_expression#Left . transition ( 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 TransitionType AST#expression#Right . All AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left opacity 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#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 // 2. 顶部切换手柄,增加交互面积 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 Rect ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 32 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 4 AST#expression#Right ) AST#modifier_chain_expression#Left . radius ( AST#expression#Left 2 AST#expression#Right ) AST#modifier_chain_expression#Left . fill ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.text_secondary' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . opacity ( AST#expression#Left 0.3 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#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 20 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#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#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 ?. animateTo 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 duration AST#property_name#Right : AST#expression#Left 400 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 . FastOutSlowIn 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . globalMusic AST#member_expression#Right AST#expression#Right . isBarCollapsed AST#member_expression#Right = 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 . globalMusic AST#member_expression#Right AST#expression#Right . isBarCollapsed 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#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#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 3. 内容主体 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 Row ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 12 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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . globalMusic AST#member_expression#Right AST#expression#Right . img AST#member_expression#Right AST#expression#Right || AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.startIcon' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( 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 . globalMusic AST#member_expression#Right AST#expression#Right . isBarCollapsed AST#member_expression#Right AST#expression#Right ? AST#expression#Left 42 AST#expression#Right : AST#expression#Left 56 AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( 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 . globalMusic AST#member_expression#Right AST#expression#Right . isBarCollapsed AST#member_expression#Right AST#expression#Right ? AST#expression#Left 42 AST#expression#Right : AST#expression#Left 56 AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( 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 . globalMusic AST#member_expression#Right AST#expression#Right . isBarCollapsed AST#member_expression#Right AST#expression#Right ? AST#expression#Left 8 AST#expression#Right : AST#expression#Left 12 AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . animation ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left duration AST#property_name#Right : AST#expression#Left 400 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#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . globalMusic AST#member_expression#Right AST#expression#Right . isLoading AST#member_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left LoadingProgress ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 20 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 20 AST#expression#Right ) AST#modifier_chain_expression#Left . color ( AST#expression#Left '#5CD6FF' 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#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 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 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 . globalMusic AST#member_expression#Right AST#expression#Right . name AST#member_expression#Right AST#expression#Right || AST#expression#Left '未在播放' AST#expression#Right AST#binary_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#member_expression#Left AST#expression#Left this AST#expression#Right . globalMusic AST#member_expression#Right AST#expression#Right . isBarCollapsed AST#member_expression#Right AST#expression#Right ? AST#expression#Left 14 AST#expression#Right : AST#expression#Left 17 AST#expression#Right AST#conditional_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#Left . fontColor ( 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#modifier_chain_expression#Left . maxLines ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Left . textOverflow ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left overflow AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left TextOverflow AST#expression#Right . Ellipsis 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#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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . globalMusic AST#member_expression#Right AST#expression#Right . author AST#member_expression#Right AST#expression#Right || AST#expression#Left '环境白噪音' AST#expression#Right AST#binary_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#member_expression#Left AST#expression#Left this AST#expression#Right . globalMusic AST#member_expression#Right AST#expression#Right . isBarCollapsed AST#member_expression#Right AST#expression#Right ? AST#expression#Left 11 AST#expression#Right : AST#expression#Left 13 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.text_secondary' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . maxLines ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Left . textOverflow ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left overflow AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left TextOverflow AST#expression#Right . Ellipsis 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#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 . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left HorizontalAlign AST#expression#Right . Start 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#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 确保文字区域可以自适应撑开 } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 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 Row ( AST#component_parameters#Left { AST#component_parameter#Left space : 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 . globalMusic AST#member_expression#Right AST#expression#Right . isBarCollapsed AST#member_expression#Right AST#expression#Right ? AST#expression#Left 8 AST#expression#Right : AST#expression#Left 14 AST#expression#Right AST#conditional_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#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 . globalMusic AST#member_expression#Right AST#expression#Right . isBarCollapsed AST#member_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left SymbolGlyph ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'sys.symbol.backward_end_fill' AST#expression#Right ) AST#resource_expression#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 . fontColor ( AST#expression#Left AST#array_literal#Left [ AST#expression#Left '#5CD6FF' AST#expression#Right ] AST#array_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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left avPlayerManage AST#expression#Right . preSong AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Left . transition ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left TransitionEffect AST#expression#Right . OPACITY AST#member_expression#Right AST#expression#Right . combine 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 TransitionEffect AST#expression#Right . scale 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 x AST#property_name#Right : AST#expression#Left 0.5 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left 0.5 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#argument_list#Right AST#call_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#ui_if_statement#Right AST#ui_control_flow#Right // 播放/暂停按钮 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 Circle ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( 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 . globalMusic AST#member_expression#Right AST#expression#Right . isBarCollapsed AST#member_expression#Right AST#expression#Right ? AST#expression#Left 38 AST#expression#Right : AST#expression#Left 44 AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( 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 . globalMusic AST#member_expression#Right AST#expression#Right . isBarCollapsed AST#member_expression#Right AST#expression#Right ? AST#expression#Left 38 AST#expression#Right : AST#expression#Left 44 AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fill ( AST#expression#Left '#1A355E' AST#expression#Right ) AST#modifier_chain_expression#Left . opacity ( AST#expression#Left 0.6 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 SymbolGlyph ( 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 . globalMusic AST#member_expression#Right AST#expression#Right . isPlay AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'sys.symbol.pause_fill' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'sys.symbol.play_fill' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#conditional_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#member_expression#Left AST#expression#Left this AST#expression#Right . globalMusic AST#member_expression#Right AST#expression#Right . isBarCollapsed AST#member_expression#Right AST#expression#Right ? AST#expression#Left 22 AST#expression#Right : AST#expression#Left 26 AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#array_literal#Left [ AST#expression#Left '#5CD6FF' AST#expression#Right ] AST#array_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 . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left avPlayerManage AST#expression#Right . stopOrContinueSong AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( 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 . globalMusic AST#member_expression#Right AST#expression#Right . isBarCollapsed AST#member_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left SymbolGlyph ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'sys.symbol.forward_end_fill' AST#expression#Right ) AST#resource_expression#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 . fontColor ( AST#expression#Left AST#array_literal#Left [ AST#expression#Left '#5CD6FF' AST#expression#Right ] AST#array_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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left avPlayerManage AST#expression#Right . nextSong AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Left . transition ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left TransitionEffect AST#expression#Right . OPACITY AST#member_expression#Right AST#expression#Right . combine 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 TransitionEffect AST#expression#Right . scale 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 x AST#property_name#Right : AST#expression#Left 0.5 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left 0.5 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#argument_list#Right AST#call_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#ui_if_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#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 8 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#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#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 12 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : 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 . globalMusic AST#member_expression#Right AST#expression#Right . isBarCollapsed AST#member_expression#Right AST#expression#Right ? AST#expression#Left 12 AST#expression#Right : AST#expression#Left 10 AST#expression#Right AST#conditional_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 // 4. 展开状态下的视觉增强区 (波形图和进度条) AST#ui_control_flow#Left AST#ui_if_statement#Left if ( 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 . globalMusic AST#member_expression#Right AST#expression#Right . isBarCollapsed AST#member_expression#Right AST#expression#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 Row ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 3 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { 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 . barHeights AST#member_expression#Right AST#expression#Right , AST#ui_builder_arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left h : AST#type_annotation#Left AST#primary_type#Left number 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 Rect ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 2.5 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#binary_expression#Left AST#expression#Left h AST#expression#Right * AST#expression#Left 0.7 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) // 稍微调矮一点,作为视觉点缀 AST#modifier_chain_expression#Left . fill ( AST#expression#Left '#5CD6FF' AST#expression#Right ) AST#modifier_chain_expression#Left . opacity ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right % AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left 0.5 AST#expression#Right : AST#expression#Left 0.3 AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . radius ( AST#expression#Left 1.5 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#ui_arrow_function_body#Right AST#ui_builder_arrow_function#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left h : AST#type_annotation#Left AST#primary_type#Left number 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#expression#Left AST#template_literal#Left ` exp_bar_ AST#template_substitution#Left $ { AST#expression#Left index AST#expression#Right } AST#template_substitution#Right _ AST#template_substitution#Left $ { AST#expression#Left h AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#for_each_statement#Right AST#ui_control_flow#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 26 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#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 4 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 4 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . transition ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left TransitionEffect AST#expression#Right . OPACITY AST#member_expression#Right AST#expression#Right . combine 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 TransitionEffect AST#expression#Right . scale 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 x AST#property_name#Right : AST#expression#Left 0.8 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left 0.8 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#argument_list#Right AST#call_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#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Slider ( AST#component_parameters#Left { AST#component_parameter#Left value : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . globalMusic AST#member_expression#Right AST#expression#Right . time AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left min : AST#expression#Left 0 AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left max : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . globalMusic AST#member_expression#Right AST#expression#Right . duration AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left style : AST#expression#Left AST#member_expression#Left AST#expression#Left SliderStyle AST#expression#Right . OutSet AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . blockColor ( AST#expression#Left '#5CD6FF' AST#expression#Right ) AST#modifier_chain_expression#Left . selectedColor ( AST#expression#Left '#5CD6FF' AST#expression#Right ) AST#modifier_chain_expression#Left . trackColor ( AST#expression#Left '#27518B' AST#expression#Right ) AST#modifier_chain_expression#Left . trackThickness ( AST#expression#Left 4 AST#expression#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 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 . onChange ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left mode : AST#type_annotation#Left AST#primary_type#Left SliderChangeMode 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#binary_expression#Left AST#expression#Left mode AST#expression#Right === AST#expression#Left SliderChangeMode AST#expression#Right AST#binary_expression#Right AST#expression#Right . End 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 avPlayerManage AST#expression#Right . jumpToPlay 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#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#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#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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . formatTime 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 . globalMusic AST#member_expression#Right AST#expression#Right . time AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_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 AST#resource_expression#Left $r ( AST#expression#Left 'app.color.text_secondary' AST#expression#Right ) AST#resource_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#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Blank ( ) 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 Text ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . formatTime 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 . globalMusic AST#member_expression#Right AST#expression#Right . duration AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_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 AST#resource_expression#Left $r ( AST#expression#Left 'app.color.text_secondary' AST#expression#Right ) AST#resource_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 '100%' AST#expression#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 14 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 14 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 12 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 . padding ( 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#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#modifier_chain_expression#Left . transition ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left TransitionEffect AST#expression#Right . asymmetric 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#member_expression#Left AST#expression#Left TransitionEffect AST#expression#Right . OPACITY AST#member_expression#Right AST#expression#Right . combine 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 TransitionEffect AST#expression#Right . move AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left TransitionEdge AST#expression#Right . TOP 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#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left TransitionEffect AST#expression#Right . OPACITY AST#member_expression#Right AST#expression#Right . combine 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 TransitionEffect AST#expression#Right . move AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left TransitionEdge AST#expression#Right . TOP 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#argument_list#Right AST#call_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_if_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.surface_card' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundBlurStyle ( AST#expression#Left AST#member_expression#Left AST#expression#Left BlurStyle AST#expression#Right . Thin AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( 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 . globalMusic AST#member_expression#Right AST#expression#Right . isBarCollapsed AST#member_expression#Right AST#expression#Right ? AST#expression#Left 20 AST#expression#Right : AST#expression#Left 32 AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderWidth ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Left . borderColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.surface_card_border' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . shadow ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left radius AST#property_name#Right : AST#expression#Left 20 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left 'rgba(0,0,0,0.4)' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offsetX AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offsetY AST#property_name#Right : AST#expression#Left 8 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#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 . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 8 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#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@ComponentV2 export struct MusicPlayerBar { private globalMusic: GlobalMusic = AppStorageV2.connect(GlobalMusic, 'GlobalMusic', () => new GlobalMusic())!; @Local private barHeights: number[] = new Array(24).fill(6); private timerId: number = -1; aboutToAppear() { this.startAnimation(); } aboutToDisappear() { if (this.timerId !== -1) { clearInterval(this.timerId); } } private startAnimation() { this.timerId = setInterval(() => { this.barHeights = this.barHeights.map((_, index) => this.getBarHeight(index)); }, 120); } private getBarHeight(index: number): number { const BASE_H = 6; if (!this.globalMusic.isPlay && !this.globalMusic.isLoading) { return BASE_H; } if (this.globalMusic.isLoading) { return BASE_H + Math.abs(Math.sin(Date.now() / 200 + index)) * 10; } if (this.globalMusic.waveform && this.globalMusic.waveform.length > 0) { const len = this.globalMusic.waveform.length; const progress = this.globalMusic.duration > 0 ? (this.globalMusic.time / this.globalMusic.duration) : 0; const centerIndex = Math.floor(progress * len); const offset = index - Math.floor(this.barHeights.length / 2); const targetIndex = (centerIndex + offset + len) % len; const waveformValue = this.globalMusic.waveform[targetIndex] || 0.1; const enhancedValue = Math.pow(waveformValue, 1.2); const flicker = Math.random() * 4; return BASE_H + enhancedValue * 22 + flicker; } return BASE_H + Math.random() * 12; } private formatTime(ms: number): string { const totalSeconds = Math.floor(ms / 1000); const minutes = Math.floor(totalSeconds / 60); const seconds = totalSeconds % 60; return `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`; } build() { Column() { Column() { if (this.globalMusic.isBarCollapsed) { Progress({ value: this.globalMusic.time, total: this.globalMusic.duration, type: ProgressType.Linear }) .width('100%') .height(2) .color('#5CD6FF') .backgroundColor('#1A355E') .transition({ type: TransitionType.All, opacity: 0 }) } Row() { Rect() .width(32) .height(4) .radius(2) .fill($r('app.color.text_secondary')) .opacity(0.3) } .width('100%') .height(20) .justifyContent(FlexAlign.Center) .onClick(() => { this.getUIContext()?.animateTo({ duration: 400, curve: Curve.FastOutSlowIn }, () => { this.globalMusic.isBarCollapsed = !this.globalMusic.isBarCollapsed; }) }) Row() { Row({ space: 12 }) { Stack({ alignContent: Alignment.Center }) { Image(this.globalMusic.img || $r('app.media.startIcon')) .width(this.globalMusic.isBarCollapsed ? 42 : 56) .height(this.globalMusic.isBarCollapsed ? 42 : 56) .borderRadius(this.globalMusic.isBarCollapsed ? 8 : 12) .animation({ duration: 400 }) if (this.globalMusic.isLoading) { LoadingProgress() .width(20) .height(20) .color('#5CD6FF') } } Column({ space: 4 }) { Text(this.globalMusic.name || '未在播放') .fontSize(this.globalMusic.isBarCollapsed ? 14 : 17) .fontWeight(FontWeight.Bold) .fontColor($r('app.color.text_primary')) .maxLines(1) .textOverflow({ overflow: TextOverflow.Ellipsis }) Text(this.globalMusic.author || '环境白噪音') .fontSize(this.globalMusic.isBarCollapsed ? 11 : 13) .fontColor($r('app.color.text_secondary')) .maxLines(1) .textOverflow({ overflow: TextOverflow.Ellipsis }) } .alignItems(HorizontalAlign.Start) .layoutWeight(1) } .layoutWeight(1) Row({ space: this.globalMusic.isBarCollapsed ? 8 : 14 }) { if (!this.globalMusic.isBarCollapsed) { SymbolGlyph($r('sys.symbol.backward_end_fill')) .fontSize(22) .fontColor(['#5CD6FF']) .onClick(() => avPlayerManage.preSong()) .transition(TransitionEffect.OPACITY.combine(TransitionEffect.scale({ x: 0.5, y: 0.5 }))) } Stack() { Circle() .width(this.globalMusic.isBarCollapsed ? 38 : 44) .height(this.globalMusic.isBarCollapsed ? 38 : 44) .fill('#1A355E') .opacity(0.6) SymbolGlyph(this.globalMusic.isPlay ? $r('sys.symbol.pause_fill') : $r('sys.symbol.play_fill')) .fontSize(this.globalMusic.isBarCollapsed ? 22 : 26) .fontColor(['#5CD6FF']) } .onClick(() => avPlayerManage.stopOrContinueSong()) if (!this.globalMusic.isBarCollapsed) { SymbolGlyph($r('sys.symbol.forward_end_fill')) .fontSize(22) .fontColor(['#5CD6FF']) .onClick(() => avPlayerManage.nextSong()) .transition(TransitionEffect.OPACITY.combine(TransitionEffect.scale({ x: 0.5, y: 0.5 }))) } } .margin({ left: 8 }) } .width('100%') .padding({ left: 12, right: 12, bottom: this.globalMusic.isBarCollapsed ? 12 : 10 }) if (!this.globalMusic.isBarCollapsed) { Column() { Row({ space: 3 }) { ForEach(this.barHeights, (h: number, index: number) => { Rect() .width(2.5) .height(h * 0.7) .fill('#5CD6FF') .opacity(index % 2 === 0 ? 0.5 : 0.3) .radius(1.5) }, (h: number, index: number) => `exp_bar_${index}_${h}`) } .width('100%') .height(26) .justifyContent(FlexAlign.Center) .margin({ top: 4, bottom: 4 }) .transition(TransitionEffect.OPACITY.combine(TransitionEffect.scale({ x: 0.8, y: 0.8 }))) Slider({ value: this.globalMusic.time, min: 0, max: this.globalMusic.duration, style: SliderStyle.OutSet }) .width('100%') .blockColor('#5CD6FF') .selectedColor('#5CD6FF') .trackColor('#27518B') .trackThickness(4) .padding({ left: 10, right: 10 }) .onChange((value: number, mode: SliderChangeMode) => { if (mode === SliderChangeMode.End) { avPlayerManage.jumpToPlay(value); } }) Row() { Text(this.formatTime(this.globalMusic.time)) .fontSize(10) .fontColor($r('app.color.text_secondary')) Blank() Text(this.formatTime(this.globalMusic.duration)) .fontSize(10) .fontColor($r('app.color.text_secondary')) } .width('100%') .padding({ left: 14, right: 14, bottom: 12 }) } .padding({ left: 4, right: 4 }) .transition(TransitionEffect.asymmetric( TransitionEffect.OPACITY.combine(TransitionEffect.move(TransitionEdge.TOP)), TransitionEffect.OPACITY.combine(TransitionEffect.move(TransitionEdge.TOP)) )) } } .backgroundColor($r('app.color.surface_card')) .backgroundBlurStyle(BlurStyle.Thin) .borderRadius(this.globalMusic.isBarCollapsed ? 20 : 32) .borderWidth(1) .borderColor($r('app.color.surface_card_border')) .shadow({ radius: 20, color: 'rgba(0,0,0,0.4)', offsetX: 0, offsetY: 8 }) } .width('100%') .padding({ left: 12, right: 12, bottom: 8 }) } }
https://github.com/Puiching-Memory/HOMOAPP_Q5.git/blob/53e36a21984de7bf41b6fafc840fde013236b9d2/entry/src/main/ets/components/MusicPlayerBar.ets#L9-L258
a5cf77230a16a5a28a1ad1bff1eb4a8061db59a5
github
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/StrUtil.ets
arkts
isBlank
判断字符串是否为空和空白符(空白符包括空格、制表符、全角空格和不间断空格)。true为空,否则false @param str @returns
static isBlank(str: string | undefined | null): boolean { if ((str === undefined) || (str === null)) { return true; } let trimStr = StrUtil.trimAll(str); return trimStr.length === 0; }
AST#method_declaration#Left static isBlank 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 undefined 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 boolean 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#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left str AST#expression#Right === AST#expression#Left undefined 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 str 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#parenthesized_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 true 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 let AST#variable_declarator#Left trimStr = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left StrUtil AST#expression#Right . trimAll 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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left trimStr 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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static isBlank(str: string | undefined | null): boolean { if ((str === undefined) || (str === null)) { return true; } let trimStr = StrUtil.trimAll(str); return trimStr.length === 0; }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/StrUtil.ets#L73-L79
4cfce26e50447e0b624e6f5e1e6fadf552a1705d
gitee
Million-mo/tree-sitter-arkts.git
2fd0ad75e2d848709edcf4be038f27b178114ef6
examples/decorators_complete.ets
arkts
onLocalStateChange
@Computed装饰器通常用于getter方法,这里暂时注释 @Computed get displayValue(): string { return this.localState + this.inputValue; }
@Monitor('localState') onLocalStateChange() { // @Monitor - 状态变量修改监听 console.log('Local state changed'); }
AST#method_declaration#Left AST#decorator#Left @ Monitor ( AST#expression#Left 'localState' AST#expression#Right ) AST#decorator#Right onLocalStateChange AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { // @Monitor - 状态变量修改监听 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 'Local state changed' 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
@Monitor('localState') onLocalStateChange() { console.log('Local state changed'); }
https://github.com/Million-mo/tree-sitter-arkts.git/blob/2fd0ad75e2d848709edcf4be038f27b178114ef6/examples/decorators_complete.ets#L110-L113
1c569a9772be0b564d17c1e58fb47bca38f41240
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/pages/SearchPage.ets
arkts
getStyleLabel
获取样式标签
private getStyleLabel(style: string): string { switch (style) { case 'warm': return '温馨'; case 'formal': return '正式'; case 'humorous': return '幽默'; case 'poetic': return '诗意'; case 'simple': return '简洁'; default: return '简洁'; } }
AST#method_declaration#Left private getStyleLabel AST#parameter_list#Left ( AST#parameter#Left style : 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#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left switch ( AST#expression#Left style AST#expression#Right ) AST#container_content_body#Left { AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left 'warm' AST#expression#Right AST#expression_statement#Right AST#ERROR#Left : return AST#ERROR#Right AST#expression_statement#Left AST#expression#Left '温馨' AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left 'formal' AST#expression#Right AST#expression_statement#Right AST#ERROR#Left : return AST#ERROR#Right AST#expression_statement#Left AST#expression#Left '正式' AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left 'humorous' AST#expression#Right AST#expression_statement#Right AST#ERROR#Left : return AST#ERROR#Right AST#expression_statement#Left AST#expression#Left '幽默' AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left 'poetic' AST#expression#Right AST#expression_statement#Right AST#ERROR#Left : return AST#ERROR#Right AST#expression_statement#Left AST#expression#Left '诗意' AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left 'simple' AST#expression#Right AST#expression_statement#Right AST#ERROR#Left : return AST#ERROR#Right AST#expression_statement#Left AST#expression#Left '简洁' AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left default AST#expression#Right AST#expression_statement#Right AST#ERROR#Left : return AST#ERROR#Right AST#expression_statement#Left AST#expression#Left '简洁' AST#expression#Right ; AST#expression_statement#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#method_declaration#Right
private getStyleLabel(style: string): string { switch (style) { case 'warm': return '温馨'; case 'formal': return '正式'; case 'humorous': return '幽默'; case 'poetic': return '诗意'; case 'simple': return '简洁'; default: return '简洁'; } }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/SearchPage.ets#L656-L671
a2c3f38253d7d5db3ee7ba3c8335543637b06a35
github
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/SnapshotUtil.ets
arkts
getSync
获取已加载的组件的截图,传入组件的组件id,找到对应组件进行截图。 @param id 目标组件的组件标识,组件的唯一标识id @param options 截图相关的自定义参数。 @returns
static getSync(id: string, options?: componentSnapshot.SnapshotOptions): image.PixelMap { return componentSnapshot.getSync(id, options); }
AST#method_declaration#Left static getSync AST#parameter_list#Left ( AST#parameter#Left id : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left options ? : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left componentSnapshot . SnapshotOptions 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#qualified_type#Left image . PixelMap 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 componentSnapshot AST#expression#Right . getSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left id AST#expression#Right , AST#expression#Left options 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 getSync(id: string, options?: componentSnapshot.SnapshotOptions): image.PixelMap { return componentSnapshot.getSync(id, options); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/SnapshotUtil.ets#L44-L46
3ec196c20f90d7bcde0f8992ab432f8f81359853
gitee
wuyuanwuhui99/harmony-arkts-music-app-ui.git
fc75b993b76293666f9122f527ea3bc6caf7f75c
entry/src/main/ets/utils/PreferenceModel.ets
arkts
getPreference
获取key对应的value
async getPreference(key:string){ let value = "" if (preference === null) { await this.getPreferencesFromStorage() } try { value = <string> await preference.get(key, null) } catch (err) { console.error(err) } return value; }
AST#method_declaration#Left async getPreference 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_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left value = 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 preference 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#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 . getPreferencesFromStorage 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#if_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 value AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left = 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#ERROR#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 preference AST#expression#Right AST#await_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key 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#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 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#statement#Left AST#return_statement#Left return AST#expression#Left value AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async getPreference(key:string){ let value = "" if (preference === null) { await this.getPreferencesFromStorage() } try { value = <string> await preference.get(key, null) } catch (err) { console.error(err) } return value; }
https://github.com/wuyuanwuhui99/harmony-arkts-music-app-ui.git/blob/fc75b993b76293666f9122f527ea3bc6caf7f75c/entry/src/main/ets/utils/PreferenceModel.ets#L40-L51
07508494db84f1a54b836fdac81b1d1a468012ba
github
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
Weather/common/src/main/ets/mock/RequestData.ets
arkts
getHeaderDate
获取首页顶部显示信息
function getHeaderDate(cityIndex: number, city?: City) { // 生成空气质量对象 let air: AirData | undefined = undefined; let headerData: HeaderData | undefined = undefined; try { air = new AirData(weather[cityIndex].aqi.air, resourceManager!.getStringSync((weather[cityIndex].aqi.airLevel as Resource).id)); headerData = new HeaderData(city ? city.name : resourceManager!.getStringSync((weather[cityIndex].city as Resource).id), weather[cityIndex].data[1].tem, resourceManager!.getStringSync((weather[cityIndex].data[1].wea as Resource).id), weather[cityIndex].data[1].tem1, weather[cityIndex].data[1].tem2, getTypeIcon(resourceManager!.getStringSync((weather[cityIndex].data[1].wea as Resource).id)), air, resourceManager!.getStringSync((weather[cityIndex].data[1].airTips as Resource).id)); } catch (error) { hilog.error(0x0000, 'RequestData', '%{public}s', `getStringSync failed, error code: ${error.code}, message: ${error.message}.`); } return headerData; }
AST#function_declaration#Left function getHeaderDate AST#parameter_list#Left ( AST#parameter#Left cityIndex : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left city ? : AST#type_annotation#Left AST#primary_type#Left City 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 air : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AirData 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 headerData : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left HeaderData 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#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left air = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left AirData AST#expression#Right AST#new_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 AST#subscript_expression#Left AST#expression#Left weather AST#expression#Right [ AST#expression#Left cityIndex AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . aqi AST#member_expression#Right AST#expression#Right . air 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#non_null_assertion_expression#Left AST#expression#Left resourceManager AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right . getStringSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left weather AST#expression#Right [ AST#expression#Left cityIndex AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . aqi AST#member_expression#Right AST#expression#Right . airLevel AST#member_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . id 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 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left headerData = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left HeaderData 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#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left city AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left city AST#expression#Right . name AST#member_expression#Right AST#expression#Right : AST#expression#Left AST#non_null_assertion_expression#Left AST#expression#Left resourceManager AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right . getStringSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left weather AST#expression#Right [ AST#expression#Left cityIndex AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . city AST#member_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . id AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left weather AST#expression#Right [ AST#expression#Left cityIndex AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . data AST#member_expression#Right AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . tem 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#non_null_assertion_expression#Left AST#expression#Left resourceManager AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right . getStringSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left weather AST#expression#Right [ AST#expression#Left cityIndex AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . data AST#member_expression#Right AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . wea AST#member_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . id AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left weather AST#expression#Right [ AST#expression#Left cityIndex AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . data AST#member_expression#Right AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . tem1 AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left weather AST#expression#Right [ AST#expression#Left cityIndex AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . data AST#member_expression#Right AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . tem2 AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left getTypeIcon 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#non_null_assertion_expression#Left AST#expression#Left resourceManager AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right . getStringSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left weather AST#expression#Right [ AST#expression#Left cityIndex AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . data AST#member_expression#Right AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . wea AST#member_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . id 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#Left air AST#expression#Right , 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 resourceManager AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right . getStringSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left weather AST#expression#Right [ AST#expression#Left cityIndex AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . data AST#member_expression#Right AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . airTips AST#member_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . id 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 } 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 0x0000 AST#expression#Right , AST#expression#Left 'RequestData' AST#expression#Right , AST#expression#Left '%{public}s' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` getStringSync failed, error code: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , message: 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#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 headerData AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right
function getHeaderDate(cityIndex: number, city?: City) { let air: AirData | undefined = undefined; let headerData: HeaderData | undefined = undefined; try { air = new AirData(weather[cityIndex].aqi.air, resourceManager!.getStringSync((weather[cityIndex].aqi.airLevel as Resource).id)); headerData = new HeaderData(city ? city.name : resourceManager!.getStringSync((weather[cityIndex].city as Resource).id), weather[cityIndex].data[1].tem, resourceManager!.getStringSync((weather[cityIndex].data[1].wea as Resource).id), weather[cityIndex].data[1].tem1, weather[cityIndex].data[1].tem2, getTypeIcon(resourceManager!.getStringSync((weather[cityIndex].data[1].wea as Resource).id)), air, resourceManager!.getStringSync((weather[cityIndex].data[1].airTips as Resource).id)); } catch (error) { hilog.error(0x0000, 'RequestData', '%{public}s', `getStringSync failed, error code: ${error.code}, message: ${error.message}.`); } return headerData; }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/Weather/common/src/main/ets/mock/RequestData.ets#L86-L104
57a08d31323fe1398ffb2bb8e13a103ef6a8234e
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/crypto/AES.ets
arkts
encryptGCMSync
加密(GCM模式),同步 @param data 加密或者解密的数据。data不能为null。 @param symKey 指定加密或解密的密钥。 @param gcmParams 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 @param transformation 待生成Cipher的算法名称(含密钥长度)、加密模式以及填充方法的组合(AES256|GCM|PKCS7、AES192|GCM|PKCS7、AES128|GCM|PKCS7)。 @returns
static encryptGCMSync(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, gcmParams: cryptoFramework.GcmParamsSpec, transformation: string = 'AES256|GCM|PKCS7'): cryptoFramework.DataBlob { let cipher = cryptoFramework.createCipher(transformation); cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, gcmParams); let encryptUpdate = cipher.updateSync(data); //GCM模式加密doFinal时传入空,获得tag数据,并更新至gcmParams对象中。 gcmParams.authTag = cipher.doFinalSync(null); return encryptUpdate; }
AST#method_declaration#Left static encryptGCMSync 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 gcmParams : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . GcmParamsSpec AST#qualified_type#Right AST#primary_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 'AES256|GCM|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#variable_declaration#Left let AST#variable_declarator#Left cipher = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . createCipher AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left transformation 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 cipher AST#expression#Right . initSync 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 cryptoFramework AST#expression#Right . CryptoMode AST#member_expression#Right AST#expression#Right . ENCRYPT_MODE AST#member_expression#Right AST#expression#Right , AST#expression#Left symKey AST#expression#Right , AST#expression#Left gcmParams 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 encryptUpdate = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cipher AST#expression#Right . updateSync AST#member_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 //GCM模式加密doFinal时传入空,获得tag数据,并更新至gcmParams对象中。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left gcmParams AST#expression#Right . authTag AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cipher AST#expression#Right . doFinalSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( 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#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left encryptUpdate AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static encryptGCMSync(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, gcmParams: cryptoFramework.GcmParamsSpec, transformation: string = 'AES256|GCM|PKCS7'): cryptoFramework.DataBlob { let cipher = cryptoFramework.createCipher(transformation); cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, gcmParams); let encryptUpdate = cipher.updateSync(data); gcmParams.authTag = cipher.doFinalSync(null); return encryptUpdate; }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/crypto/AES.ets#L54-L62
306dd96d8340f7ecd0ddbdbe2d9f92dcd0fe81e1
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
harmonyos/src/main/ets/pages/greetings/GreetingSendPage.ets
arkts
buildOccasionChip
构建场合标签
@Builder buildOccasionChip(label: string, occasion: GreetingOccasion) { Button(label) .type(ButtonType.Capsule) .fontSize(14) .fontColor(this.selectedOccasion === occasion ? '#ffffff' : '#666666') .backgroundColor(this.selectedOccasion === occasion ? '#007AFF' : '#f0f0f0') .height(32) .onClick(() => { this.selectedOccasion = occasion; this.generateAISuggestions(); }) }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildOccasionChip 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 occasion : AST#type_annotation#Left AST#primary_type#Left GreetingOccasion 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 Button ( AST#expression#Left label AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . type ( AST#expression#Left AST#member_expression#Left AST#expression#Left ButtonType AST#expression#Right . Capsule AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 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 . selectedOccasion AST#member_expression#Right AST#expression#Right === AST#expression#Left occasion AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left '#ffffff' AST#expression#Right : AST#expression#Left '#666666' AST#expression#Right AST#conditional_expression#Right 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 . selectedOccasion AST#member_expression#Right AST#expression#Right === AST#expression#Left occasion AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left '#007AFF' AST#expression#Right : AST#expression#Left '#f0f0f0' AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 32 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 . selectedOccasion AST#member_expression#Right = AST#expression#Left occasion 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 . generateAISuggestions 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#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#builder_function_body#Right AST#method_declaration#Right
@Builder buildOccasionChip(label: string, occasion: GreetingOccasion) { Button(label) .type(ButtonType.Capsule) .fontSize(14) .fontColor(this.selectedOccasion === occasion ? '#ffffff' : '#666666') .backgroundColor(this.selectedOccasion === occasion ? '#007AFF' : '#f0f0f0') .height(32) .onClick(() => { this.selectedOccasion = occasion; this.generateAISuggestions(); }) }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/harmonyos/src/main/ets/pages/greetings/GreetingSendPage.ets#L557-L569
82aca5b86d7322b637df2b329ded0bac914eb21f
github
iotjin/JhHarmonyDemo.git
819e6c3b1db9984c042a181967784550e171b2e8
JhCommon/src/main/ets/JhCommon/components/JhDialog.ets
arkts
showCustomDialog
中间自定义弹框 @param options
public static showCustomDialog(options: JhDialogOptions) { DialogHelper.showCustomContentDialog({ title: options.title ?? _title, contentBuilder: options.contentBuilder, contentAreaPadding: options.contentAreaPadding, autoCancel: false, // 点击遮障层时,是否关闭弹窗,true表示关闭弹窗。 backCancel: false, // 点击返回键或手势返回时,是否关闭弹窗;实现onWillDismiss函数时,该参数不起作用。 actionCancel: options.clickBtnClose ?? true, // 点击操作按钮时,是否关闭弹窗。false表示不关闭弹窗。 buttons: [ options.hiddenCancel ? null : { value: options.leftText ?? _cancelText, fontColor: _cancelTextColor, buttonStyle: _btnStyle }, { value: options.rightText ?? _confirmText, fontColor: _confirmTextColor, buttonStyle: _btnStyle }, ], onAction: (action, dialogId, content) => { if (action == DialogAction.ONE) { options.onCancel?.(action, dialogId, content) } else { options.onConfirm?.(action, dialogId, content) } } }) }
AST#method_declaration#Left public static showCustomDialog AST#parameter_list#Left ( AST#parameter#Left options : AST#type_annotation#Left AST#primary_type#Left JhDialogOptions 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 DialogHelper AST#expression#Right . showCustomContentDialog 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 title AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . title AST#member_expression#Right AST#expression#Right ?? AST#expression#Left _title AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left contentBuilder AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . contentBuilder AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left contentAreaPadding AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . contentAreaPadding AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left autoCancel AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , // 点击遮障层时,是否关闭弹窗,true表示关闭弹窗。 AST#property_assignment#Left AST#property_name#Left backCancel AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , // 点击返回键或手势返回时,是否关闭弹窗;实现onWillDismiss函数时,该参数不起作用。 AST#property_assignment#Left AST#property_name#Left actionCancel AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . clickBtnClose AST#member_expression#Right AST#expression#Right ?? AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right , // 点击操作按钮时,是否关闭弹窗。false表示不关闭弹窗。 AST#property_assignment#Left AST#property_name#Left buttons AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . hiddenCancel AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left value AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . leftText AST#member_expression#Right AST#expression#Right ?? AST#expression#Left _cancelText AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left fontColor AST#property_name#Right : AST#expression#Left _cancelTextColor AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left buttonStyle AST#property_name#Right : AST#expression#Left _btnStyle AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left value AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . rightText AST#member_expression#Right AST#expression#Right ?? AST#expression#Left _confirmText AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left fontColor AST#property_name#Right : AST#expression#Left _confirmTextColor AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left buttonStyle AST#property_name#Right : AST#expression#Left _btnStyle AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , ] AST#array_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left onAction AST#property_name#Right : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left action AST#parameter#Right , AST#parameter#Left dialogId AST#parameter#Right , AST#parameter#Left content 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#binary_expression#Left AST#expression#Left action AST#expression#Right == AST#expression#Left DialogAction AST#expression#Right AST#binary_expression#Right AST#expression#Right . ONE 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 options AST#expression#Right . onCancel AST#member_expression#Right AST#expression#Right ?. AST#argument_list#Left ( AST#expression#Left action AST#expression#Right , AST#expression#Left dialogId AST#expression#Right , AST#expression#Left content 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 options AST#expression#Right . onConfirm AST#member_expression#Right AST#expression#Right ?. AST#argument_list#Left ( AST#expression#Left action AST#expression#Right , AST#expression#Left dialogId AST#expression#Right , AST#expression#Left content 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_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#builder_function_body#Right AST#method_declaration#Right
public static showCustomDialog(options: JhDialogOptions) { DialogHelper.showCustomContentDialog({ title: options.title ?? _title, contentBuilder: options.contentBuilder, contentAreaPadding: options.contentAreaPadding, autoCancel: false, backCancel: false, actionCancel: options.clickBtnClose ?? true, buttons: [ options.hiddenCancel ? null : { value: options.leftText ?? _cancelText, fontColor: _cancelTextColor, buttonStyle: _btnStyle }, { value: options.rightText ?? _confirmText, fontColor: _confirmTextColor, buttonStyle: _btnStyle }, ], onAction: (action, dialogId, content) => { if (action == DialogAction.ONE) { options.onCancel?.(action, dialogId, content) } else { options.onConfirm?.(action, dialogId, content) } } }) }
https://github.com/iotjin/JhHarmonyDemo.git/blob/819e6c3b1db9984c042a181967784550e171b2e8/JhCommon/src/main/ets/JhCommon/components/JhDialog.ets#L277-L305
7075097f85ea5699a9726c66e723b51e79f2782b
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/app/constants/AppTheme.ets
arkts
绿色主题
export class ThemeGreen implements Theme { color: ColorPalette = new ColorGreen() }
AST#export_declaration#Left export AST#class_declaration#Left class ThemeGreen AST#implements_clause#Left implements Theme AST#implements_clause#Right AST#class_body#Left { AST#property_declaration#Left color : AST#type_annotation#Left AST#primary_type#Left ColorPalette 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 ColorGreen 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#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class ThemeGreen implements Theme { color: ColorPalette = new ColorGreen() }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/app/constants/AppTheme.ets#L56-L58
2ed2201b79e75f6202208ab449cacae6a1d10645
github
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/PreferencesUtil.ets
arkts
getNumberSync
获取number类型的缓存值 @param key @returns
static getNumberSync(key: string, defValue: number = 0, preferenceName: string = PreferencesUtil.defaultPreferenceName): number { return PreferencesUtil.getSync(key, defValue, preferenceName) as number; }
AST#method_declaration#Left static getNumberSync 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 defValue : 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#Left preferenceName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left PreferencesUtil AST#expression#Right . defaultPreferenceName AST#member_expression#Right AST#expression#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#return_statement#Left return AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left PreferencesUtil AST#expression#Right . getSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right , AST#expression#Left defValue AST#expression#Right , AST#expression#Left preferenceName AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static getNumberSync(key: string, defValue: number = 0, preferenceName: string = PreferencesUtil.defaultPreferenceName): number { return PreferencesUtil.getSync(key, defValue, preferenceName) as number; }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/PreferencesUtil.ets#L151-L154
20d879f558adf74e4476ce52991d1e5cd289008e
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/PreferencesUtil.ets
arkts
clear
清除缓存的Preferences实例中的所有数据 @param preferenceName @returns
static async clear(preferenceName: string = PreferencesUtil.defaultPreferenceName): Promise<void> { let preferences = await PreferencesUtil.getPreferences(preferenceName); //获取实例 await preferences.clear(); return preferences.flush() //此处一定要flush,要不然不能永久序列化到本地 }
AST#method_declaration#Left static async clear AST#parameter_list#Left ( AST#parameter#Left preferenceName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left PreferencesUtil AST#expression#Right . defaultPreferenceName AST#member_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#variable_declaration#Left let AST#variable_declarator#Left preferences = 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 PreferencesUtil AST#expression#Right AST#await_expression#Right AST#expression#Right . getPreferences AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left preferenceName 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 preferences AST#expression#Right AST#await_expression#Right AST#expression#Right . clear 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 preferences AST#expression#Right . flush AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right //此处一定要flush,要不然不能永久序列化到本地 AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static async clear(preferenceName: string = PreferencesUtil.defaultPreferenceName): Promise<void> { let preferences = await PreferencesUtil.getPreferences(preferenceName); await preferences.clear(); return preferences.flush() }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/PreferencesUtil.ets#L251-L255
1b32b38240ef4ef902ee74ab9948253c679d1462
gitee
openharmony-tpc/ImageKnife
bc55de9e2edd79ed4646ce37177ad94b432874f7
library/src/main/ets/key/DefaultEngineKey.ets
arkts
generateMemoryKey
生成内存缓存key
generateMemoryKey(loadSrc: string | PixelMap | Resource, requestSource: ImageKnifeRequestSource, imageKnifeOption: ImageKnifeOption,isAnimator?: boolean, width?: number, height?: number): string { let key = (isAnimator == true ? 'Animator=' : 'loadSrc==') + (typeof loadSrc == 'string' ? loadSrc : JSON.stringify(loadSrc)) + ';' if (requestSource === ImageKnifeRequestSource.SRC) { if (imageKnifeOption.signature !== undefined && imageKnifeOption.signature !== '') { key += 'signature=' + imageKnifeOption.signature + ';' }
AST#method_declaration#Left generateMemoryKey AST#parameter_list#Left ( AST#parameter#Left loadSrc : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left PixelMap AST#primary_type#Right | AST#primary_type#Left Resource AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left requestSource : AST#type_annotation#Left AST#primary_type#Left ImageKnifeRequestSource AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left imageKnifeOption : AST#type_annotation#Left AST#primary_type#Left ImageKnifeOption AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left isAnimator ? : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left width ? : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left height ? : 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 key = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left isAnimator AST#expression#Right == AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left 'Animator=' AST#expression#Right : AST#expression#Left 'loadSrc==' AST#expression#Right AST#conditional_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 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#binary_expression#Left AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left loadSrc AST#expression#Right AST#unary_expression#Right AST#expression#Right == AST#expression#Left 'string' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#ERROR#Left ? AST#ERROR#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left loadSrc AST#expression#Right AST#ERROR#Left : AST#ERROR#Left AST#qualified_type#Left JSON . stringify AST#qualified_type#Right AST#type_annotation#Left AST#primary_type#Left AST#parenthesized_type#Left ( AST#type_annotation#Left AST#primary_type#Left loadSrc AST#primary_type#Right AST#type_annotation#Right ) AST#parenthesized_type#Right AST#primary_type#Right AST#type_annotation#Right ) + ';' if AST#ERROR#Right ( requestSource AST#ERROR#Right === AST#expression#Left ImageKnifeRequestSource AST#expression#Right AST#binary_expression#Right AST#expression#Right . SRC AST#member_expression#Right AST#expression#Right ) AST#ERROR#Right { AST#property_name#Left if AST#property_name#Right ( imageKnifeOption AST#ERROR#Right . signature AST#member_expression#Right AST#expression#Right !== AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left imageKnifeOption AST#expression#Right AST#binary_expression#Right AST#expression#Right . signature AST#member_expression#Right AST#expression#Right !== AST#expression#Left '' 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#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#ERROR#Left { AST#ERROR#Left AST#property_name#Left key AST#property_name#Right += AST#ERROR#Right AST#property_name#Left 'signature=' AST#property_name#Right AST#ERROR#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left + AST#expression#Left imageKnifeOption AST#expression#Right AST#unary_expression#Right AST#expression#Right . signature AST#member_expression#Right AST#expression#Right + AST#expression#Left ';' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
generateMemoryKey(loadSrc: string | PixelMap | Resource, requestSource: ImageKnifeRequestSource, imageKnifeOption: ImageKnifeOption,isAnimator?: boolean, width?: number, height?: number): string { let key = (isAnimator == true ? 'Animator=' : 'loadSrc==') + (typeof loadSrc == 'string' ? loadSrc : JSON.stringify(loadSrc)) + ';' if (requestSource === ImageKnifeRequestSource.SRC) { if (imageKnifeOption.signature !== undefined && imageKnifeOption.signature !== '') { key += 'signature=' + imageKnifeOption.signature + ';' }
https://github.com/openharmony-tpc/ImageKnife/blob/bc55de9e2edd79ed4646ce37177ad94b432874f7/library/src/main/ets/key/DefaultEngineKey.ets#L25-L31
51403fc8e529af2d6407c1a81a914fb398827244
gitee
Application-Security-Automation/Arktan.git
3ad9cb05235e38b00cd5828476aa59a345afa1c0
dataset/accuracy/path_sensitive/explicit_jump_control/break_001_T.ets
arkts
Introduction 显式跳转控制-break
export function break_001_T(taint_src : string) { let res = '' for (let i = 0; i < 10; i++) { if (i === 3) { res = taint_src } taint.Sink(res) } }
AST#export_declaration#Left export AST#function_declaration#Left function break_001_T AST#parameter_list#Left ( AST#parameter#Left taint_src : 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#variable_declaration#Left let AST#variable_declarator#Left res = 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#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left 10 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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right === AST#expression#Left 3 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 res = AST#expression#Left taint_src 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 taint AST#expression#Right . Sink AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left res 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#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export function break_001_T(taint_src : string) { let res = '' for (let i = 0; i < 10; i++) { if (i === 3) { res = taint_src } taint.Sink(res) } }
https://github.com/Application-Security-Automation/Arktan.git/blob/3ad9cb05235e38b00cd5828476aa59a345afa1c0/dataset/accuracy/path_sensitive/explicit_jump_control/break_001_T.ets#L6-L14
cd947f75f6c30cd651de5a93a68a1e599ac047c4
github
wasd09090030/MyHongmengProject.git
a8ed386b658ceeac69ef5bc42a92d78c7980821c
entry/src/main/ets/components/review/ReviewToolbar.ets
arkts
ReviewToolbar
工具栏组件
@Builder export function ReviewToolbar( onRefresh: () => void, onTestTask: () => void ) { Row({ space: 12 }) { // 测试按钮:添加模拟任务 Button() { Row({ space: 6 }) { SymbolGlyph($r('sys.symbol.plus_circle')) .fontSize(18) Text('测试任务') .fontSize(14) .fontColor('#ff34c759') } } .height(36) .padding({ left: 16, right: 16 }) .backgroundColor('#F1F3F5') .borderRadius(18) .onClick(() => { onTestTask(); }) Blank() Button() { Row({ space: 6 }) { SymbolGlyph($r('sys.symbol.arrow_clockwise')) .fontSize(18) Text('刷新统计') .fontSize(14) .fontColor('#ff2a89e7') } } .height(36) .padding({ left: 16, right: 16 }) .backgroundColor('#F1F3F5') .borderRadius(18) .onClick(() => { onRefresh(); }) } .width('100%') }
AST#decorated_export_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right export function ReviewToolbar AST#parameter_list#Left ( AST#parameter#Left onRefresh : 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#parameter#Right , AST#parameter#Left onTestTask : 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#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#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 12 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 Button ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 6 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 SymbolGlyph ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'sys.symbol.plus_circle' AST#expression#Right ) AST#resource_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#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#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 '#ff34c759' 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#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 36 AST#expression#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 16 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#F1F3F5' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 18 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#call_expression#Left AST#expression#Left onTestTask 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#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#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Blank ( ) 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 Button ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 6 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 SymbolGlyph ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'sys.symbol.arrow_clockwise' AST#expression#Right ) AST#resource_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#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#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 '#ff2a89e7' 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#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 36 AST#expression#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 16 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#F1F3F5' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 18 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#call_expression#Left AST#expression#Left onRefresh 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#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 . 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#decorated_export_declaration#Right
@Builder export function ReviewToolbar( onRefresh: () => void, onTestTask: () => void ) { Row({ space: 12 }) { Button() { Row({ space: 6 }) { SymbolGlyph($r('sys.symbol.plus_circle')) .fontSize(18) Text('测试任务') .fontSize(14) .fontColor('#ff34c759') } } .height(36) .padding({ left: 16, right: 16 }) .backgroundColor('#F1F3F5') .borderRadius(18) .onClick(() => { onTestTask(); }) Blank() Button() { Row({ space: 6 }) { SymbolGlyph($r('sys.symbol.arrow_clockwise')) .fontSize(18) Text('刷新统计') .fontSize(14) .fontColor('#ff2a89e7') } } .height(36) .padding({ left: 16, right: 16 }) .backgroundColor('#F1F3F5') .borderRadius(18) .onClick(() => { onRefresh(); }) } .width('100%') }
https://github.com/wasd09090030/MyHongmengProject.git/blob/a8ed386b658ceeac69ef5bc42a92d78c7980821c/entry/src/main/ets/components/review/ReviewToolbar.ets#L11-L55
7401003f34121e9a60b702171cb5440fb5e88b98
github
openharmony/developtools_profiler
73d26bb5acfcafb2b1f4f94ead5640241d1e5f73
host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/renderer/XAxisRenderer.ets
arkts
computeAxisValues
@Override
protected computeAxisValues(min: number, max: number) { super.computeAxisValues(min, max); this.computeSize(); }
AST#method_declaration#Left protected computeAxisValues AST#parameter_list#Left ( AST#parameter#Left min : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left max : 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 super AST#expression#Right . computeAxisValues AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left min AST#expression#Right , AST#expression#Left max 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 this AST#expression#Right . computeSize 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
protected computeAxisValues(min: number, max: number) { super.computeAxisValues(min, max); this.computeSize(); }
https://github.com/openharmony/developtools_profiler/blob/73d26bb5acfcafb2b1f4f94ead5640241d1e5f73/host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/renderer/XAxisRenderer.ets#L76-L79
c6f97e5e630617ea1f10dac13dabedec4a33da5f
gitee
goldbrown/pomodora-clock-app.git
6e2aef2d9517624a11c299930f6dda052421fd18
entry/src/main/ets/constant/RoutePath.ets
arkts
路由表管理
export class RoutePath { static readonly SplashPage = "pages/SplashPage" static readonly MainPage = "pages/MainPage" static readonly CategoryPage = "pages/CategoryPage" static readonly ContainerPage = "pages/container/ContainerPage" static readonly TopicDetailPage = "pages/topicDetail/TopicDetailPage" static readonly DetailPage = "pages/commonDetail/DetailPage" static readonly CategoryDetailPage = "pages/categoryDetail/CategoryDetailPage" static readonly TestPage = "pages/test/TestPage" static readonly TestHorizontalPage = "pages/test/TestHorizontalPage" static readonly TestHorizontalPage2 = "pages/test/TestHorizontalPage2" static readonly CoordinatePage = "pages/hot/CoordinatePage" static readonly IndexPage = "pages/IndexPage" }
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 CategoryPage = AST#expression#Left "pages/CategoryPage" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left static readonly ContainerPage = AST#expression#Left "pages/container/ContainerPage" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left static readonly TopicDetailPage = AST#expression#Left "pages/topicDetail/TopicDetailPage" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left static readonly DetailPage = AST#expression#Left "pages/commonDetail/DetailPage" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left static readonly CategoryDetailPage = AST#expression#Left "pages/categoryDetail/CategoryDetailPage" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left static readonly TestPage = AST#expression#Left "pages/test/TestPage" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left static readonly TestHorizontalPage = AST#expression#Left "pages/test/TestHorizontalPage" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left static readonly TestHorizontalPage2 = AST#expression#Left "pages/test/TestHorizontalPage2" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left static readonly CoordinatePage = AST#expression#Left "pages/hot/CoordinatePage" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left static readonly IndexPage = AST#expression#Left "pages/IndexPage" 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 CategoryPage = "pages/CategoryPage" static readonly ContainerPage = "pages/container/ContainerPage" static readonly TopicDetailPage = "pages/topicDetail/TopicDetailPage" static readonly DetailPage = "pages/commonDetail/DetailPage" static readonly CategoryDetailPage = "pages/categoryDetail/CategoryDetailPage" static readonly TestPage = "pages/test/TestPage" static readonly TestHorizontalPage = "pages/test/TestHorizontalPage" static readonly TestHorizontalPage2 = "pages/test/TestHorizontalPage2" static readonly CoordinatePage = "pages/hot/CoordinatePage" static readonly IndexPage = "pages/IndexPage" }
https://github.com/goldbrown/pomodora-clock-app.git/blob/6e2aef2d9517624a11c299930f6dda052421fd18/entry/src/main/ets/constant/RoutePath.ets#L4-L18
c1ff60643d9311027ffe4d2662fdc4ff318df4d7
github
queueit/harmony-sdk.git
ba7b4b38c03730bfbe305789acba6db0012d5f5c
entry/src/main/ets/pages/DemoWithProtectedAPIPage.ets
arkts
createQueueListener
--- QueueListener Implementation ---
private createQueueListener(): QueueListener { return { onQueuePassed: (info: QueuePassedInfo) => { this.queueViewManager?.hideQueue(); promptAction.showToast({ message: "Passed queue! Retrying product fetch..." }); // Add the new token to the repository this.productRepository.addQueueToken(info.queueItToken); // Now, automatically retry the fetch this.fetchProduct(); }, onQueueViewWillOpen: () => { promptAction.showToast({ message: 'Queue view will open' }); }, onQueueDisabled: (info: QueueDisabledInfo) => { this.queueViewManager?.hideQueue(); promptAction.showToast({ message: "Queue is disabled. Retrying..." }); this.productRepository.addQueueToken(info.queueItToken); this.fetchProduct(); }, onQueueItUnavailable: () => { this.queueViewManager?.hideQueue(); this.productFetchError = "Queue was unavailable during redirect."; }, onError: (error: QueueError, errorMessage: string) => { this.queueViewManager?.hideQueue(); this.productFetchError = `Queue error: ${errorMessage}`; }, onWebViewClosed: () => { promptAction.showToast({ message: "Queue was cancelled." }); }, }; }
AST#method_declaration#Left private createQueueListener AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left QueueListener AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left onQueuePassed AST#property_name#Right : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left info : AST#type_annotation#Left AST#primary_type#Left QueuePassedInfo 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 this AST#expression#Right . queueViewManager AST#member_expression#Right AST#expression#Right ?. hideQueue 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 promptAction 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 "Passed queue! Retrying product fetch..." 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 // Add the new token to the repository 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 . productRepository AST#member_expression#Right AST#expression#Right . addQueueToken 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 . queueItToken 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 // Now, automatically retry the fetch 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 . fetchProduct 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 onQueueViewWillOpen 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 promptAction 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 'Queue view will open' 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#arrow_function#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left onQueueDisabled AST#property_name#Right : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left info : AST#type_annotation#Left AST#primary_type#Left QueueDisabledInfo 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 this AST#expression#Right . queueViewManager AST#member_expression#Right AST#expression#Right ?. hideQueue 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 promptAction 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 "Queue is disabled. Retrying..." 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#member_expression#Left AST#expression#Left this AST#expression#Right . productRepository AST#member_expression#Right AST#expression#Right . addQueueToken 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 . queueItToken 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . fetchProduct 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 onQueueItUnavailable 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . queueViewManager AST#member_expression#Right AST#expression#Right ?. hideQueue 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . productFetchError AST#member_expression#Right = AST#expression#Left "Queue was unavailable during redirect." 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#property_assignment#Left AST#property_name#Left onError AST#property_name#Right : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left error : AST#type_annotation#Left AST#primary_type#Left QueueError AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left errorMessage : 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . queueViewManager AST#member_expression#Right AST#expression#Right ?. hideQueue 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . productFetchError AST#member_expression#Right = AST#expression#Left AST#template_literal#Left ` Queue error: AST#template_substitution#Left $ { AST#expression#Left errorMessage 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#arrow_function#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left onWebViewClosed 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 promptAction 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 "Queue was cancelled." 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#arrow_function#Right 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
private createQueueListener(): QueueListener { return { onQueuePassed: (info: QueuePassedInfo) => { this.queueViewManager?.hideQueue(); promptAction.showToast({ message: "Passed queue! Retrying product fetch..." }); this.productRepository.addQueueToken(info.queueItToken); this.fetchProduct(); }, onQueueViewWillOpen: () => { promptAction.showToast({ message: 'Queue view will open' }); }, onQueueDisabled: (info: QueueDisabledInfo) => { this.queueViewManager?.hideQueue(); promptAction.showToast({ message: "Queue is disabled. Retrying..." }); this.productRepository.addQueueToken(info.queueItToken); this.fetchProduct(); }, onQueueItUnavailable: () => { this.queueViewManager?.hideQueue(); this.productFetchError = "Queue was unavailable during redirect."; }, onError: (error: QueueError, errorMessage: string) => { this.queueViewManager?.hideQueue(); this.productFetchError = `Queue error: ${errorMessage}`; }, onWebViewClosed: () => { promptAction.showToast({ message: "Queue was cancelled." }); }, }; }
https://github.com/queueit/harmony-sdk.git/blob/ba7b4b38c03730bfbe305789acba6db0012d5f5c/entry/src/main/ets/pages/DemoWithProtectedAPIPage.ets#L56-L87
2e297c49a926f10e8bcf3794c8aa24c1d05f0faf
github
awa_Liny/LinysBrowser_NEXT
a5cd96a9aa8114cae4972937f94a8967e55d4a10
home/src/main/ets/utils/url_tools.ets
arkts
Translates a link with meow:// to resource:// @param link The link. @returns The translated link.
export function url_meow_to_resource(url: string) { let result: string = url; if (!url) { return result; } // No process for empty inputs if (url.length > 7) { if (url.substring(0, 7) == "meow://") { // if is meow:// scheme let index = built_ins.indexOf(url); if (index != -1) { // if this link exists result = urls[index]; } else { // if this link of meow:// scheme doesn't exist } } } return result; }
AST#export_declaration#Left export AST#function_declaration#Left function url_meow_to_resource AST#parameter_list#Left ( AST#parameter#Left url : 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#variable_declaration#Left let AST#variable_declarator#Left result : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left url 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 url AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#block_statement#Left { 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#if_statement#Right AST#statement#Right // No process for empty inputs 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 url AST#expression#Right . length AST#member_expression#Right AST#expression#Right > AST#expression#Left 7 AST#expression#Right AST#binary_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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left url AST#expression#Right . substring AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left 7 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right == AST#expression#Left "meow://" AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { // if is meow:// scheme AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left index = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left built_ins AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 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 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 { // if this link exists AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left result = AST#expression#Left AST#subscript_expression#Left AST#expression#Left urls AST#expression#Right [ AST#expression#Left index 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 else AST#block_statement#Left { // if this link of meow:// scheme doesn't exist } AST#block_statement#Right AST#if_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#return_statement#Left return AST#expression#Left result AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export function url_meow_to_resource(url: string) { let result: string = url; if (!url) { return result; } if (url.length > 7) { if (url.substring(0, 7) == "meow://") { let index = built_ins.indexOf(url); if (index != -1) { result = urls[index]; } else { } } } return result; }
https://github.com/awa_Liny/LinysBrowser_NEXT/blob/a5cd96a9aa8114cae4972937f94a8967e55d4a10/home/src/main/ets/utils/url_tools.ets#L248-L269
a62494c69fab0083a734e5925fa8574950a89b80
gitee
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/app/views/LinkView.ets
arkts
在系统浏览器中打开链接
export function openInSystemBrowser(url: string): void { try { let want: Want = { action: 'ohos.want.action.viewData', uri: url, parameters: { // 可选:传递额外参数 } }; let context = getContext(getAppContext()) as common.UIAbilityContext; context.startAbility(want).catch(()=> { console.error('打开浏览器失败:'); }); } catch (error) { console.error('打开浏览器异常:', error); } }
AST#export_declaration#Left export AST#function_declaration#Left function openInSystemBrowser AST#parameter_list#Left ( AST#parameter#Left url : 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 want : AST#type_annotation#Left AST#primary_type#Left Want 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 'ohos.want.action.viewData' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left uri AST#property_name#Right : AST#expression#Left url AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left parameters AST#property_name#Right : AST#expression#Left AST#object_literal#Left { // 可选:传递额外参数 } AST#object_literal#Right 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 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#expression#Left AST#call_expression#Left AST#expression#Left getAppContext 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 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#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 context AST#expression#Right . startAbility 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 . 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_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#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#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 '打开浏览器异常:' 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#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export function openInSystemBrowser(url: string): void { try { let want: Want = { action: 'ohos.want.action.viewData', uri: url, parameters: { } }; let context = getContext(getAppContext()) as common.UIAbilityContext; context.startAbility(want).catch(()=> { console.error('打开浏览器失败:'); }); } catch (error) { console.error('打开浏览器异常:', error); } }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/app/views/LinkView.ets#L120-L137
23df0d63dc1571b1e3a181d5a940c153331d053a
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/pages/share/SharePage.ets
arkts
initializePage
初始化页面
async initializePage() { try { // 获取可用的分享平台 this.availablePlatforms = await this.socialShareService.getAvailableSharePlatforms(); // 获取分享模板 this.shareTemplates = this.socialShareService.getShareTemplates(); // 生成默认分享内容 this.generateShareContent(); } catch (error) { console.error('Failed to initialize share page:', error); } }
AST#method_declaration#Left async initializePage 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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . availablePlatforms 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 AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . socialShareService AST#member_expression#Right AST#expression#Right . getAvailableSharePlatforms 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . shareTemplates 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 . socialShareService AST#member_expression#Right AST#expression#Right . getShareTemplates 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 this AST#expression#Right . generateShareContent 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#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 initialize share page:' 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#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async initializePage() { try { this.availablePlatforms = await this.socialShareService.getAvailableSharePlatforms(); this.shareTemplates = this.socialShareService.getShareTemplates(); this.generateShareContent(); } catch (error) { console.error('Failed to initialize share page:', error); } }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/share/SharePage.ets#L39-L53
3cb5ce06b0ebd2540ff87b5771825c87ed5d384a
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/common/types/CommonTypes.ets
arkts
颜色配置接口
export interface ColorConfig { primary: string; secondary: string; accent: string; background: string; surface: string; error: string; warning: string; success: string; info: string; text: TextColorConfig; }
AST#export_declaration#Left export AST#interface_declaration#Left interface ColorConfig AST#object_type#Left { AST#type_member#Left primary : 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 secondary : 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 accent : 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 background : 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 surface : 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 error : 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 warning : 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 success : 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 info : 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 text : AST#type_annotation#Left AST#primary_type#Left TextColorConfig 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 ColorConfig { primary: string; secondary: string; accent: string; background: string; surface: string; error: string; warning: string; success: string; info: string; text: TextColorConfig; }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/types/CommonTypes.ets#L222-L233
b83135caedf26528f6bde5c106bde3ede5702355
github
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/GlobalContext.ets
arkts
clear
清除缓存数据
public clear() { return this._objects.clear(); }
AST#method_declaration#Left public clear AST#parameter_list#Left ( ) 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . _objects AST#member_expression#Right AST#expression#Right . clear 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
public clear() { return this._objects.clear(); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/GlobalContext.ets#L75-L77
4ad18d82517d55b6a31e4d1b53f3c334556a047f
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/BasicFeature/Media/CustomScan/customscan/src/main/ets/viewmodel/CustomScanViewModel.ets
arkts
restartCustomScan
重新启动扫码 @returns {void}
async restartCustomScan(): Promise<void> { logger.info('restartCustomScan'); // 关闭存在的扫描结果对话框 this.closeScanResult(); // 根据窗口尺寸调整展示组件尺寸 await this.updateCameraCompSize(); // 调整相机surface尺寸 this.cameraCompSizeUpdateCb(this.cameraCompWidth, this.cameraCompHeight, this.cameraCompOffsetX, this.cameraCompOffsetY); // 释放扫码资源 await this.releaseCustomScan(); // 初始化相机资源并启动 this.initCustomScan(); }
AST#method_declaration#Left async restartCustomScan 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 logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'restartCustomScan' 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 this AST#expression#Right . closeScanResult 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#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 . updateCameraCompSize 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 // 调整相机surface尺寸 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 . cameraCompSizeUpdateCb 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 . cameraCompWidth AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cameraCompHeight AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cameraCompOffsetX AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cameraCompOffsetY 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#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . releaseCustomScan 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . initCustomScan 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
async restartCustomScan(): Promise<void> { logger.info('restartCustomScan'); this.closeScanResult(); await this.updateCameraCompSize(); this.cameraCompSizeUpdateCb(this.cameraCompWidth, this.cameraCompHeight, this.cameraCompOffsetX, this.cameraCompOffsetY); await this.releaseCustomScan(); this.initCustomScan(); }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/BasicFeature/Media/CustomScan/customscan/src/main/ets/viewmodel/CustomScanViewModel.ets#L374-L389
41f35094c6af964d2abb826d8ff5d6e4a95403c7
gitee
jjjjjjava/ffmpeg_tools.git
6c73f7540bc7ca3f0d5b3edd7a6c10cb84a26161
example/BasicUsage.ets
arkts
rtsp
============================================================ 网络流 ============================================================ RTSP 录制
rtsp(): void { const cmd = FFmpegFactory.downloadRtsp('rtsp://192.168.1.100/stream', '/record.mp4', 60); this.run(cmd); }
AST#method_declaration#Left rtsp 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 const AST#variable_declarator#Left cmd = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left FFmpegFactory AST#expression#Right . downloadRtsp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'rtsp://192.168.1.100/stream' AST#expression#Right , AST#expression#Left '/record.mp4' AST#expression#Right , AST#expression#Left 60 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 this AST#expression#Right . run AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left cmd 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
rtsp(): void { const cmd = FFmpegFactory.downloadRtsp('rtsp://192.168.1.100/stream', '/record.mp4', 60); this.run(cmd); }
https://github.com/jjjjjjava/ffmpeg_tools.git/blob/6c73f7540bc7ca3f0d5b3edd7a6c10cb84a26161/example/BasicUsage.ets#L71-L74
f5bb5a53e5bfeb96e79e6238379b1678450f33e1
github
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
ETSUI/TransitionAnimation/entry/src/main/ets/common/constants/CommonConstants.ets
arkts
Border radius of row.
export const BORDER_RADIUS = 32;
AST#export_declaration#Left export AST#variable_declaration#Left const AST#variable_declarator#Left BORDER_RADIUS = AST#expression#Left 32 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#export_declaration#Right
export const BORDER_RADIUS = 32;
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/ETSUI/TransitionAnimation/entry/src/main/ets/common/constants/CommonConstants.ets#L125-L125
5cac13d23b0d4f83119c7249a35f979f9c6eb09e
gitee
zqaini002/YaoYaoLingXian.git
5095b12cbeea524a87c42d0824b1702978843d39
YaoYaoLingXian/entry/src/main/ets/pages/Index.ets
arkts
initAndCheckLogin
初始化并检查登录状态
private async initAndCheckLogin() { try { console.info('Index页面: 开始检查登录状态'); // 1. 先检查用户会话是否已初始化 if (!this.userSession.isInitialized()) { console.info('Index页面: 会话未初始化,进行初始化'); try { // 使用await等待初始化完成 await this.userSession.init(); console.info('Index页面: 会话初始化完成'); } catch (error) { console.error('Index页面: 初始化用户会话失败:', error); // 初始化失败,跳转到登录页面 this.navigateToLogin('会话初始化失败,请重新登录'); return; } } // 2. 检查用户是否已登录 console.info('Index页面: 检查是否已登录'); if (this.userSession.isLoggedIn()) { console.info('Index页面: 用户已登录,显示首页'); // 已登录,允许访问首页 this.isUserLoggedIn = true; this.isInitializing = false; } else { console.info('Index页面: 用户未登录,跳转到登录页'); // 未登录,跳转到登录页 this.navigateToLogin('请先登录'); } } catch (error) { console.error('Index页面: 检查登录状态出错:', error); // 出错时跳转到登录页面 this.navigateToLogin('系统出错,请重新登录'); } }
AST#method_declaration#Left private async initAndCheckLogin 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#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 'Index页面: 开始检查登录状态' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 1. 先检查用户会话是否已初始化 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#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . userSession AST#member_expression#Right AST#expression#Right . isInitialized 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#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 'Index页面: 会话未初始化,进行初始化' 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 { // 使用await等待初始化完成 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 . userSession AST#member_expression#Right 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#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 '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#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 'Index页面: 初始化用户会话失败:' 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 this AST#expression#Right . navigateToLogin 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#return_statement#Left return ; 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#if_statement#Right AST#statement#Right // 2. 检查用户是否已登录 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 'Index页面: 检查是否已登录' 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . userSession AST#member_expression#Right AST#expression#Right . isLoggedIn 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#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 'Index页面: 用户已登录,显示首页' 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 . isUserLoggedIn 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 . isInitializing 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 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 'Index页面: 用户未登录,跳转到登录页' 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 . navigateToLogin 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#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 'Index页面: 检查登录状态出错:' 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 this AST#expression#Right . navigateToLogin 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#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private async initAndCheckLogin() { try { console.info('Index页面: 开始检查登录状态'); if (!this.userSession.isInitialized()) { console.info('Index页面: 会话未初始化,进行初始化'); try { await this.userSession.init(); console.info('Index页面: 会话初始化完成'); } catch (error) { console.error('Index页面: 初始化用户会话失败:', error); this.navigateToLogin('会话初始化失败,请重新登录'); return; } } console.info('Index页面: 检查是否已登录'); if (this.userSession.isLoggedIn()) { console.info('Index页面: 用户已登录,显示首页'); this.isUserLoggedIn = true; this.isInitializing = false; } else { console.info('Index页面: 用户未登录,跳转到登录页'); this.navigateToLogin('请先登录'); } } catch (error) { console.error('Index页面: 检查登录状态出错:', error); this.navigateToLogin('系统出错,请重新登录'); } }
https://github.com/zqaini002/YaoYaoLingXian.git/blob/5095b12cbeea524a87c42d0824b1702978843d39/YaoYaoLingXian/entry/src/main/ets/pages/Index.ets#L35-L70
669c24ea6bcad8d1fd03b6c164626b864477ba5e
github
waylau/harmonyos-tutorial
74e23dfa769317f8f057cc77c2d09f0b1f2e0773
samples/ArkTSPreferences/entry/src/main/ets/common/PreferencesUtil.ets
arkts
getPreferencesFromStorage
调用getPreferences方法读取指定首选项持久化文件, 将数据加载到Preferences实例,用于数据操作
async getPreferencesFromStorage() { await preferences.getPreferences(context, options).then((data) => { this.dataPreferences = data; console.info(`Succeeded in getting preferences`); }).catch((err: BusinessError) => { console.error(`Failed to get preferences, Cause:` + err); }); }
AST#method_declaration#Left async getPreferencesFromStorage 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#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#await_expression#Left await AST#expression#Left preferences AST#expression#Right AST#await_expression#Right AST#expression#Right . getPreferences AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right , AST#expression#Left options 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 data 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 . dataPreferences AST#member_expression#Right = AST#expression#Left data 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 . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` Succeeded in getting preferences ` 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#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 console 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#template_literal#Left ` Failed to get preferences, Cause: ` AST#template_literal#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#builder_function_body#Right AST#method_declaration#Right
async getPreferencesFromStorage() { await preferences.getPreferences(context, options).then((data) => { this.dataPreferences = data; console.info(`Succeeded in getting preferences`); }).catch((err: BusinessError) => { console.error(`Failed to get preferences, Cause:` + err); }); }
https://github.com/waylau/harmonyos-tutorial/blob/74e23dfa769317f8f057cc77c2d09f0b1f2e0773/samples/ArkTSPreferences/entry/src/main/ets/common/PreferencesUtil.ets#L16-L23
f4ffcb042ec4b33ab9f8766615de77b9ac879e35
gitee
openharmony/update_update_app
0157b7917e2f48e914b5585991e8b2f4bc25108a
feature/ota/src/main/ets/dialog/DialogHelper.ets
arkts
defaultKnowDialog
默认提示弹框 @param title 标题 @param message 内容 @param operator 回调
function defaultKnowDialog(title: string | Resource, message: string | Resource, operator ?: DialogOperator): void { showDialog(title, message, $r('app.string.button_know'), operator); }
AST#function_declaration#Left function defaultKnowDialog AST#parameter_list#Left ( AST#parameter#Left title : 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#parameter#Right , AST#parameter#Left message : 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#parameter#Right , AST#parameter#Left operator ? : AST#type_annotation#Left AST#primary_type#Left DialogOperator 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left showDialog AST#expression#Right AST#argument_list#Left ( AST#expression#Left title AST#expression#Right , AST#expression#Left message AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.button_know' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left operator 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 defaultKnowDialog(title: string | Resource, message: string | Resource, operator ?: DialogOperator): void { showDialog(title, message, $r('app.string.button_know'), operator); }
https://github.com/openharmony/update_update_app/blob/0157b7917e2f48e914b5585991e8b2f4bc25108a/feature/ota/src/main/ets/dialog/DialogHelper.ets#L144-L146
d94025dc3af5f06eef9ede71673104905eb1997c
gitee
salehelper/algorithm_arkts.git
61af15272038646775a4745fca98a48ba89e1f4e
entry/src/main/ets/strings/RabinKarp.ets
arkts
findAllMatches
在文本中查找模式串的所有出现位置 @param text 文本字符串 @param pattern 模式串 @returns 所有匹配位置的数组
static findAllMatches(text: string, pattern: string): number[] { return RabinKarp.findAll(text, pattern); }
AST#method_declaration#Left static findAllMatches 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 pattern : 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#array_type#Left number [ ] 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 RabinKarp AST#expression#Right . findAll AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left text AST#expression#Right , AST#expression#Left pattern 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 findAllMatches(text: string, pattern: string): number[] { return RabinKarp.findAll(text, pattern); }
https://github.com/salehelper/algorithm_arkts.git/blob/61af15272038646775a4745fca98a48ba89e1f4e/entry/src/main/ets/strings/RabinKarp.ets#L139-L141
2001457341fe7ab746fa96eecc3ac1f78fa94043
github
tomorrowKreswell/Ledger.git
1f2783ae70b8540d677af8a27f29db1b4089ea69
ledger/entry/src/main/ets/common/utils/DateUtils.ets
arkts
获取本年的日期范围
export function getDateRangeOfThisYear(date: Date | number) { // 获取本年的第一天和下一年的第一天 const beginDate = getFirstDateOfThisYear(date) const nextYear = new Date(beginDate.getTime()) nextYear.setFullYear(nextYear.getFullYear() + 1) // 返回日期范围对象 return { beginDate: beginDate.getTime(), endDate: nextYear.getTime() - 1 }; }
AST#export_declaration#Left export AST#function_declaration#Left function getDateRangeOfThisYear AST#parameter_list#Left ( AST#parameter#Left date : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Date AST#primary_type#Right | AST#primary_type#Left number 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#variable_declaration#Left const AST#variable_declarator#Left beginDate = AST#expression#Left AST#call_expression#Left AST#expression#Left getFirstDateOfThisYear AST#expression#Right AST#argument_list#Left ( AST#expression#Left date 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 nextYear = 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 AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left beginDate 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#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left nextYear AST#ERROR#Right . setFullYear AST#member_expression#Right AST#expression#Right AST#argument_list#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 nextYear AST#expression#Right . getFullYear 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 1 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#object_literal#Left { AST#property_assignment#Left AST#property_name#Left beginDate AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left beginDate 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#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left endDate AST#property_name#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 nextYear 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#expression#Left 1 AST#expression#Right AST#binary_expression#Right 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#function_declaration#Right AST#export_declaration#Right
export function getDateRangeOfThisYear(date: Date | number) { const beginDate = getFirstDateOfThisYear(date) const nextYear = new Date(beginDate.getTime()) nextYear.setFullYear(nextYear.getFullYear() + 1) return { beginDate: beginDate.getTime(), endDate: nextYear.getTime() - 1 }; }
https://github.com/tomorrowKreswell/Ledger.git/blob/1f2783ae70b8540d677af8a27f29db1b4089ea69/ledger/entry/src/main/ets/common/utils/DateUtils.ets#L136-L143
eb2c44c8c9e283cee07c1f35010c6078a915b014
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
harmonyos/src/main/ets/services/analytics/AdvancedAnalyticsService.ets
arkts
trackEvent
记录用户行为事件
async trackEvent( eventType: string, eventCategory: string, properties: Record<string, any> = {}, userId: string = 'anonymous', duration?: number ): Promise<void> { try { if (!this.collectBehaviorData) return; const event: UserBehaviorEvent = { id: `event_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`, userId, eventType, eventCategory, properties, sessionId: this.getCurrentSessionId(), deviceInfo: this.getDeviceInfo(), timestamp: new Date().toISOString(), duration }; this.behaviorEvents.push(event); // 批量存储 if (this.behaviorEvents.length >= this.batchSize) { await this.flushEvents(); } // 实时分析 this.processEventInRealTime(event); } catch (error) { hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to track event: ${error}`); } }
AST#method_declaration#Left async trackEvent AST#parameter_list#Left ( AST#parameter#Left eventType : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left eventCategory : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left properties : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Record 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 any 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#object_literal#Left { } AST#object_literal#Right AST#expression#Right AST#parameter#Right , AST#parameter#Left userId : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'anonymous' AST#expression#Right AST#parameter#Right , AST#parameter#Left duration ? : 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#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#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 . collectBehaviorData AST#member_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left event : AST#type_annotation#Left AST#primary_type#Left UserBehaviorEvent AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left id AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` event_ AST#template_substitution#Left $ { 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#template_substitution#Right _ AST#template_substitution#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 Math AST#expression#Right . random AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) 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 36 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . substr AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 2 AST#expression#Right , AST#expression#Left 9 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#property_assignment#Right , AST#property_assignment#Left userId AST#property_assignment#Right , AST#property_assignment#Left eventType AST#property_assignment#Right , AST#property_assignment#Left eventCategory AST#property_assignment#Right , AST#property_assignment#Left properties AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left sessionId AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getCurrentSessionId AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left deviceInfo AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getDeviceInfo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left timestamp AST#property_name#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 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 . toISOString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left duration 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#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 . behaviorEvents AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left event 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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . behaviorEvents AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right >= AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . batchSize 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 AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . flushEvents 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#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 this AST#expression#Right . processEventInRealTime AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left event 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 track event: 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
async trackEvent( eventType: string, eventCategory: string, properties: Record<string, any> = {}, userId: string = 'anonymous', duration?: number ): Promise<void> { try { if (!this.collectBehaviorData) return; const event: UserBehaviorEvent = { id: `event_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`, userId, eventType, eventCategory, properties, sessionId: this.getCurrentSessionId(), deviceInfo: this.getDeviceInfo(), timestamp: new Date().toISOString(), duration }; this.behaviorEvents.push(event); if (this.behaviorEvents.length >= this.batchSize) { await this.flushEvents(); } this.processEventInRealTime(event); } catch (error) { hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to track event: ${error}`); } }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/harmonyos/src/main/ets/services/analytics/AdvancedAnalyticsService.ets#L334-L370
a41068981904aa9711b1143b00edb3a3c09aabf4
github
openharmony-tpc/ohos_mpchart
4fb43a7137320ef2fee2634598f53d93975dfb4a
library/src/main/ets/components/charts/ScatterChartModel.ets
arkts
getScatterData
@Override
public getScatterData(): ScatterData | null { if (this.mData) { return this.mData; } else { return null; } }
AST#method_declaration#Left public getScatterData AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left ScatterData 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#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mData AST#member_expression#Right AST#expression#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 . mData 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#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#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
public getScatterData(): ScatterData | null { if (this.mData) { return this.mData; } else { return null; } }
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/charts/ScatterChartModel.ets#L78-L84
8e65d2240f9403aef9d448b278fdbf89f348f6d3
gitee
iichen-bycode/ArkTsWanandroid.git
ad128756a6c703d9a72cf7f6da128c27fc63bd00
entry/src/main/ets/event/EventKeys.ets
arkts
事件的EventNum
export class EventKeys { //展示loading的事件处理EventID static readonly LOADING_DIALOG_EVENT = 0x10000 static readonly ON_MAIN_PAGE_HIDE = 0x10001 static readonly ON_MAIN_PAGE_SHOW = 0x10002 static readonly LOGIN_OUT = 0x10003 static readonly LOGIN_IN = 0x10004 }
AST#export_declaration#Left export AST#class_declaration#Left class EventKeys AST#class_body#Left { //展示loading的事件处理EventID AST#property_declaration#Left static readonly LOADING_DIALOG_EVENT = AST#expression#Left 0x10000 AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left static readonly ON_MAIN_PAGE_HIDE = AST#expression#Left 0x10001 AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left static readonly ON_MAIN_PAGE_SHOW = AST#expression#Left 0x10002 AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left static readonly LOGIN_OUT = AST#expression#Left 0x10003 AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left static readonly LOGIN_IN = AST#expression#Left 0x10004 AST#expression#Right AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class EventKeys { static readonly LOADING_DIALOG_EVENT = 0x10000 static readonly ON_MAIN_PAGE_HIDE = 0x10001 static readonly ON_MAIN_PAGE_SHOW = 0x10002 static readonly LOGIN_OUT = 0x10003 static readonly LOGIN_IN = 0x10004 }
https://github.com/iichen-bycode/ArkTsWanandroid.git/blob/ad128756a6c703d9a72cf7f6da128c27fc63bd00/entry/src/main/ets/event/EventKeys.ets#L4-L11
96c70d6c6e59bd4092dfd2dadedf0f93ba5ff2cc
github
salehelper/algorithm_arkts.git
61af15272038646775a4745fca98a48ba89e1f4e
entry/src/main/ets/strings/KMP.ets
arkts
findFirstMatch
查找模式串在文本中的第一个出现位置 @param text 文本字符串 @param pattern 模式串 @returns 第一个匹配位置,如果未找到则返回 -1
static findFirstMatch(text: string, pattern: string): number { if (!text || !pattern || pattern.length === 0) { return -1; } const lps = KMP.computeLPS(pattern); const m = pattern.length; const n = text.length; let i = 0; let j = 0; while (i < n) { if (pattern[j] === text[i]) { i++; j++; } if (j === m) { return i - j; } else if (i < n && pattern[j] !== text[i]) { if (j !== 0) { j = lps[j - 1]; } else { i++; } } } return -1; }
AST#method_declaration#Left static findFirstMatch 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 pattern : 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#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#unary_expression#Left ! AST#expression#Left text AST#expression#Right AST#unary_expression#Right AST#expression#Right || AST#expression#Left AST#unary_expression#Left ! AST#expression#Left pattern AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left pattern AST#expression#Right AST#binary_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#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_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#variable_declaration#Left const AST#variable_declarator#Left lps = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left KMP AST#expression#Right . computeLPS AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left pattern 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 m = AST#expression#Left AST#member_expression#Left AST#expression#Left pattern 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 const AST#variable_declarator#Left n = AST#expression#Left AST#member_expression#Left AST#expression#Left text 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 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 let AST#variable_declarator#Left j = AST#expression#Left 0 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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left pattern AST#expression#Right [ AST#expression#Left j AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right === AST#expression#Left AST#subscript_expression#Left AST#expression#Left text AST#expression#Right [ AST#expression#Left i 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#expression_statement#Left AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_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 j 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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left j AST#expression#Right === AST#expression#Left m 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#binary_expression#Left AST#expression#Left i AST#expression#Right - AST#expression#Left j AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#return_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#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#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left pattern AST#expression#Right [ AST#expression#Left j AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right !== AST#expression#Left AST#subscript_expression#Left AST#expression#Left text AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_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 j 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 j = AST#expression#Left AST#subscript_expression#Left AST#expression#Left lps AST#expression#Right [ AST#expression#Left AST#binary_expression#Left AST#expression#Left j 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 else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#update_expression#Left AST#expression#Left i 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#block_statement#Right AST#if_statement#Right AST#if_statement#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 AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static findFirstMatch(text: string, pattern: string): number { if (!text || !pattern || pattern.length === 0) { return -1; } const lps = KMP.computeLPS(pattern); const m = pattern.length; const n = text.length; let i = 0; let j = 0; while (i < n) { if (pattern[j] === text[i]) { i++; j++; } if (j === m) { return i - j; } else if (i < n && pattern[j] !== text[i]) { if (j !== 0) { j = lps[j - 1]; } else { i++; } } } return -1; }
https://github.com/salehelper/algorithm_arkts.git/blob/61af15272038646775a4745fca98a48ba89e1f4e/entry/src/main/ets/strings/KMP.ets#L190-L219
c9155671e3e5a7f34e31bb28f5b01221839f81d2
github
openharmony/xts_acts
5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686
validator/acts_validator/entry/src/main/ets/pages/Notification/CustomNotification/notificationUtil/NotificationContentUtil.ets
arkts
initNotificationMultiLineContent
init multiline notification content @param basicContent @param notificationBriefText @param notificationLongTitle @param notificationLines @return return the created NotificationContent
initNotificationMultiLineContent(basicContent: notificationManager.NotificationBasicContent, notificationBriefText: string, notificationLongTitle: string, notificationLines: Array<string>): notificationManager.NotificationContent { return { contentType: notification.ContentType.NOTIFICATION_CONTENT_MULTILINE, // 通知内容类型 multiLine: { title: basicContent.title, // 通知标题 text: basicContent.text, // 通知内容 additionalText: basicContent.additionalText ? basicContent.additionalText : '', // 通知次要内容,是对通知内容的补充 briefText: notificationBriefText, // 通知概要内容,是对通知内容的总结 longTitle: notificationLongTitle, // 通知展开时的标题 lines: notificationLines // 通知的多行文本 } }; }
AST#method_declaration#Left initNotificationMultiLineContent AST#parameter_list#Left ( AST#parameter#Left basicContent : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left notificationManager . NotificationBasicContent AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left notificationBriefText : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left notificationLongTitle : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left notificationLines : 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 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#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left notificationManager . NotificationContent 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#object_literal#Left { AST#property_assignment#Left AST#property_name#Left contentType 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 . ContentType AST#member_expression#Right AST#expression#Right . NOTIFICATION_CONTENT_MULTILINE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , // 通知内容类型 AST#property_assignment#Left AST#property_name#Left multiLine AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left title AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left basicContent AST#expression#Right . title AST#member_expression#Right 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 basicContent AST#expression#Right . text AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , // 通知内容 AST#property_assignment#Left AST#property_name#Left additionalText AST#property_name#Right : AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left basicContent AST#expression#Right . additionalText AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left basicContent AST#expression#Right . additionalText AST#member_expression#Right AST#expression#Right : AST#expression#Left '' AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#property_assignment#Right , // 通知次要内容,是对通知内容的补充 AST#property_assignment#Left AST#property_name#Left briefText AST#property_name#Right : AST#expression#Left notificationBriefText AST#expression#Right AST#property_assignment#Right , // 通知概要内容,是对通知内容的总结 AST#property_assignment#Left AST#property_name#Left longTitle AST#property_name#Right : AST#expression#Left notificationLongTitle AST#expression#Right AST#property_assignment#Right , // 通知展开时的标题 AST#property_assignment#Left AST#property_name#Left lines AST#property_name#Right : AST#expression#Left notificationLines AST#expression#Right AST#property_assignment#Right // 通知的多行文本 } AST#object_literal#Right 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
initNotificationMultiLineContent(basicContent: notificationManager.NotificationBasicContent, notificationBriefText: string, notificationLongTitle: string, notificationLines: Array<string>): notificationManager.NotificationContent { return { contentType: notification.ContentType.NOTIFICATION_CONTENT_MULTILINE, multiLine: { title: basicContent.title, text: basicContent.text, additionalText: basicContent.additionalText ? basicContent.additionalText : '', briefText: notificationBriefText, longTitle: notificationLongTitle, lines: notificationLines } }; }
https://github.com/openharmony/xts_acts/blob/5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686/validator/acts_validator/entry/src/main/ets/pages/Notification/CustomNotification/notificationUtil/NotificationContentUtil.ets#L67-L79
7b14ef9f558d8d0739b9591b8b23a6cdc758ffad
gitee
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
Card/MovieCard/entry/src/main/ets/viewmodel/FormBean.ets
arkts
Database form entity class.
export default class FormBean { /** * Form ID */ formId: string = ''; /** * Form name */ formName: string = ''; /** * Card dimension */ dimension: number = 0; /** * Get inserted form data. * * @return Return form data */ toValuesBucket(): relationalStore.ValuesBucket { return { 'formId': this.formId, 'formName': this.formName, 'dimension': this.dimension }; } }
AST#export_declaration#Left export default AST#class_declaration#Left class FormBean AST#class_body#Left { /** * Form ID */ AST#property_declaration#Left formId : 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 /** * Form name */ AST#property_declaration#Left formName : 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 /** * Card dimension */ AST#property_declaration#Left dimension : 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 /** * Get inserted form data. * * @return Return form data */ AST#method_declaration#Left toValuesBucket AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left relationalStore . ValuesBucket 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#object_literal#Left { AST#property_assignment#Left AST#property_name#Left 'formId' AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . formId AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'formName' AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . formName AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'dimension' AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dimension AST#member_expression#Right 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 } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export default class FormBean { formId: string = ''; formName: string = ''; dimension: number = 0; toValuesBucket(): relationalStore.ValuesBucket { return { 'formId': this.formId, 'formName': this.formName, 'dimension': this.dimension }; } }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Card/MovieCard/entry/src/main/ets/viewmodel/FormBean.ets#L21-L47
3968a7385dfcbd5508c13e7eaeca12e56b4c68f1
gitee
ThePivotPoint/ArkTS-LSP-Server-Plugin.git
6231773905435f000d00d94b26504433082ba40b
packages/declarations/ets/api/@ohos.atomicservice.AtomicServiceWeb.d.ets
arkts
Progress change event when the page loading progress changes. @typedef OnProgressChangeEvent @syscap SystemCapability.ArkUI.ArkUI.Full @atomicservice @since 12
export declare interface OnProgressChangeEvent { /** * The new progress of the page. * * @type { number } * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ newProgress: number; }
AST#export_declaration#Left export AST#ERROR#Left declare AST#ERROR#Right AST#interface_declaration#Left interface OnProgressChangeEvent AST#object_type#Left { /** * The new progress of the page. * * @type { number } * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#type_member#Left newProgress : 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 declare interface OnProgressChangeEvent { newProgress: number; }
https://github.com/ThePivotPoint/ArkTS-LSP-Server-Plugin.git/blob/6231773905435f000d00d94b26504433082ba40b/packages/declarations/ets/api/@ohos.atomicservice.AtomicServiceWeb.d.ets#L301-L311
bf558f0abb4d5bd92b496539dfaef63d86e53491
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/common/components/Speech/Recorder/SpeechRecordDbAccessor.ets
arkts
removeRecordSound
MARK: - 删除操作 根据文本删除录音 @param text - 要删除的录音文本
async removeRecordSound(text: string): Promise<void> { if (!this.db) return; const sql = `DELETE FROM ${Tables.Record.name} WHERE SUBSTR(${Tables.Record.Col.text}, ${DB.salt} + 1, LENGTH(${Tables.Record.Col.text}) - ${DB.salt}) = ?`; const textEncoded = StringEncoder.encodedToBase64(text.trim()); await this.db.updateDb(sql, [textEncoded]); }
AST#method_declaration#Left async removeRecordSound 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_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#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 . db AST#member_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left sql = AST#expression#Left AST#template_literal#Left ` DELETE FROM AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Tables AST#expression#Right . Record AST#member_expression#Right AST#expression#Right . name AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right WHERE SUBSTR( AST#template_substitution#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 Tables AST#expression#Right . Record AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . text 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 DB AST#expression#Right . salt AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right + 1, LENGTH( AST#template_substitution#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 Tables AST#expression#Right . Record AST#member_expression#Right AST#expression#Right . Col AST#member_expression#Right AST#expression#Right . text 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 DB AST#expression#Right . salt AST#member_expression#Right 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#variable_declaration#Left const AST#variable_declarator#Left textEncoded = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left StringEncoder AST#expression#Right . encodedToBase64 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 text 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#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 AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . db AST#member_expression#Right AST#expression#Right . updateDb AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sql AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left textEncoded 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#method_declaration#Right
async removeRecordSound(text: string): Promise<void> { if (!this.db) return; const sql = `DELETE FROM ${Tables.Record.name} WHERE SUBSTR(${Tables.Record.Col.text}, ${DB.salt} + 1, LENGTH(${Tables.Record.Col.text}) - ${DB.salt}) = ?`; const textEncoded = StringEncoder.encodedToBase64(text.trim()); await this.db.updateDb(sql, [textEncoded]); }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/components/Speech/Recorder/SpeechRecordDbAccessor.ets#L156-L166
be2d7edaf303b4cfe958e27c91a8020c858b29d5
github
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
core/util/src/main/ets/notification/NotificationUtil.ets
arkts
通知工具类(按功能场景拆分命名空间)
export namespace NotificationUtil { /** * 通知权限管理 */ export namespace Permission { /** * 查询当前应用通知使能状态 * @returns {boolean} 返回true,表示允许发布通知;返回false,表示禁止发布通知 */ export function isEnabled(): boolean { return notificationManager.isNotificationEnabledSync(); }
AST#export_declaration#Left export AST#ERROR#Left namespace Not if icationUtil { /** * 通知权限管理 */ export namespace Permission { /** * 查询当前应用通知使能状态 * @returns {boolean} 返回true,表示允许发布通知;返回false,表示禁止发布通知 */ export AST#ERROR#Right AST#function_declaration#Left function isEnabled 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left notificationManager AST#expression#Right . isNotificationEnabledSync 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#function_declaration#Right AST#export_declaration#Right
export namespace NotificationUtil { export namespace Permission { export function isEnabled(): boolean { return notificationManager.isNotificationEnabledSync(); }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/util/src/main/ets/notification/NotificationUtil.ets#L10-L21
185a66f453cbb0a8ebf2481a92b9f8913f5377dc
github
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
eventbus/src/main/ets/EventBusCore.ets
arkts
postApp
发布跨App消息 @param eventName 事件名 @param data 发送的数据
postApp(eventName: string, data: EventAllType) { let options: commonEventManager.CommonEventPublishData = { data: eventName, parameters: { data: data } }; commonEventManager.publish('event', options, (err) => { if (err) { console.error(`Failed to publish common event. Code is ${err.code}, message is ${err.message}`); } }); }
AST#method_declaration#Left postApp AST#parameter_list#Left ( AST#parameter#Left eventName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left EventAllType 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 options : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left commonEventManager . CommonEventPublishData 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 data AST#property_name#Right : AST#expression#Left eventName AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left parameters AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left data AST#property_name#Right : AST#expression#Left data AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left commonEventManager AST#expression#Right . publish AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'event' AST#expression#Right , AST#expression#Left options AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err 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 console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` Failed to publish common event. 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#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#method_declaration#Right
postApp(eventName: string, data: EventAllType) { let options: commonEventManager.CommonEventPublishData = { data: eventName, parameters: { data: data } }; commonEventManager.publish('event', options, (err) => { if (err) { console.error(`Failed to publish common event. Code is ${err.code}, message is ${err.message}`); } }); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/eventbus/src/main/ets/EventBusCore.ets#L117-L127
94f4455c615014e0545bff43b1a103fcf6cb43a7
gitee