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
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_ui/src/main/ets/ui/select/Cascade.ets
arkts
cityTxtColor
省市区list样式
@Extend(Text) function cityTxtColor() { .fontSize(UiConst.FONT_16) .textAlign(TextAlign.Start) .padding({ top: UiConst.NUMBER_3, bottom: UiConst.NUMBER_3 }) // .backgroundColor("#f7f8fa") }
AST#decorated_function_declaration#Left AST#decorator#Left @ Extend ( AST#expression#Left Text AST#expression#Right ) AST#decorator#Right function cityTxtColor AST#parameter_list#Left ( ) AST#parameter_list#Right AST#extend_function_body#Left { AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#member_expression#Left AST#expression#Left UiConst AST#expression#Right . FONT_16 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 . Start AST#member_expression#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 AST#member_expression#Left AST#expression#Left UiConst AST#expression#Right . NUMBER_3 AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left UiConst AST#expression#Right . NUMBER_3 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 // .backgroundColor("#f7f8fa") } AST#extend_function_body#Right AST#decorated_function_declaration#Right
@Extend(Text) function cityTxtColor() { .fontSize(UiConst.FONT_16) .textAlign(TextAlign.Start) .padding({ top: UiConst.NUMBER_3, bottom: UiConst.NUMBER_3 }) }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_ui/src/main/ets/ui/select/Cascade.ets#L48-L54
d89d3061750b57e78a748fc3f5b4c2f3cb29dc14
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/webpagesnapshot/src/main/ets/components/mainpage/ScrollableComponentPage.ets
arkts
ScrollableComponentPageBuilder
功能说明:本示例以List组件为例,实现可滚动组件截图、拼接生成长截图功能 推荐场景:可滚动组件需要长截图整个页面、截图至当前位置的场景 核心组件: 1. snapShot - 一键截图,无论滑动到任何为止,均将整个页面截图 2. snapShotToOffset - 滚动截图,实现方式与Web组件截图相同,截图至当前滑到的位置 实现步骤: 1. 滚动截图:实现方式与Web组件截图相同 2. 一键截图:创建截图函数,执行循环滚动截图并拼接 3. 截图后预览:截图后弹出预览窗口,可以滚动查看完整的截图,并保存图片到用户相册中
@Builder export function ScrollableComponentPageBuilder(name: string, param: Object) { ScrollableComponentSnapshotPage() }
AST#decorated_export_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right export function ScrollableComponentPageBuilder AST#parameter_list#Left ( AST#parameter#Left name : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left param : AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left ScrollableComponentSnapshotPage ( ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#decorated_export_declaration#Right
@Builder export function ScrollableComponentPageBuilder(name: string, param: Object) { ScrollableComponentSnapshotPage() }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/webpagesnapshot/src/main/ets/components/mainpage/ScrollableComponentPage.ets#L43-L46
d9e8b33cea1252a53ffbb9687871aa9b93e35f5a
gitee
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
AppDataSecurity/entry/src/main/ets/pages/Index.ets
arkts
getEl2Path
[Start get_el2_path]
getEl2Path(): void { let context = this.getUIContext().getHostContext() as common.UIAbilityContext; context.area = contextConstant.AreaMode.EL2; let filePath = context.filesDir + '/health_data.txt'; this.message = filePath; }
AST#method_declaration#Left getEl2Path AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left context = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#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 . getHostContext AST#member_expression#Right 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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left context AST#expression#Right . area AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left contextConstant AST#expression#Right . AreaMode AST#member_expression#Right AST#expression#Right . EL2 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 let AST#variable_declarator#Left filePath = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left context AST#expression#Right . filesDir AST#member_expression#Right AST#expression#Right + AST#expression#Left '/health_data.txt' 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 . message AST#member_expression#Right = AST#expression#Left filePath 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
getEl2Path(): void { let context = this.getUIContext().getHostContext() as common.UIAbilityContext; context.area = contextConstant.AreaMode.EL2; let filePath = context.filesDir + '/health_data.txt'; this.message = filePath; }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/AppDataSecurity/entry/src/main/ets/pages/Index.ets#L68-L73
74a4c016e4186663ae41085e3d15759f1c30eaa9
gitee
open9527/OpenHarmony
fdea69ed722d426bf04e817ec05bff4002e81a4e
entry/src/main/ets/common/component/TitleBar.ets
arkts
TitleBarView
@author open_9527 @date 2025/5/19 @desc 描述信息
@ComponentV2 export struct TitleBarView { @Builder private emptyBuilder() { } @Param config: TitleBarConfig = new TitleBarConfig() //自定义状态栏标部分 @BuilderParam public customStatusBarBuilder?: () => void = this.emptyBuilder //自定义整个标题栏部分 @BuilderParam public customContentBuilder?: () => void = this.emptyBuilder //自定义标题栏左边部分(注意:如果需要标题栏居中展示,需要左右部分宽度保持一致) @BuilderParam public customLeftBuilder?: () => void = this.emptyBuilder //自定义标题栏中间部分 @BuilderParam public customCenterBuilder?: () => void = this.emptyBuilder //自定义标题栏右边部分(注意:如果需要标题栏居中展示,需要左右部分宽度保持一致) @BuilderParam public customRightBuilder?: () => void = this.emptyBuilder //自定义标题栏底部下划线 @BuilderParam public customDividerBuilder?: () => void = this.emptyBuilder build() { Column() { if (this.customStatusBarBuilder && this.customStatusBarBuilder != this.emptyBuilder) { this.customStatusBarBuilder() } else { this.statusBarBuilder() } }.attributeModifier(this.config.TitleBarModifier) } @Builder statusBarBuilder() { Line().attributeModifier(this.config.statusBarModifier) } @Builder contentBuilder() { Row() { if (this.customLeftBuilder && this.customLeftBuilder != this.emptyBuilder) { this.customLeftBuilder() } else { this.leftBuilder() } if (this.customCenterBuilder && this.customCenterBuilder != this.emptyBuilder) { this.customCenterBuilder() } else { this.centerBuilder() } if (this.customRightBuilder && this.customRightBuilder != this.emptyBuilder) { this.customRightBuilder() } else { this.rightBuilder() } } .width(TitleBarConstants.FULL_PERCENT) .height(TitleBarConstants.TITLE_BAR_HEIGHT) .alignItems(VerticalAlign.Center) .justifyContent(FlexAlign.SpaceBetween) .padding(TitleBarConstants.PADDING) .backgroundColor(TitleBarConstants.WHITE_COLOR) } @Builder leftBuilder() { Row() { Image($r('app.media.bar_back_icon')) .attributeModifier(this.config.leftImageModifier) .onClick(() => { // if (this.config.leftImageClickListener) { // this.config.leftImageClickListener() // } }) Text('Back') .attributeModifier(this.config.leftTextModifier) .onClick(() => { // if (this.config.leftTextClickListener) { // this.config.leftTextClickListener() // } }) } .justifyContent(FlexAlign.Start) .height(TitleBarConstants.TITLE_BAR_HEIGHT) .constraintSize({ minWidth: TitleBarConstants.TITLE_BAR_HEIGHT }) } @Builder centerBuilder() { Column() { Text('这是标题') .attributeModifier(this.config.contentTextModifier) .onClick(() => { // if (this.config.centerTextClickListener) { // this.config.centerTextClickListener() // } }) } .justifyContent(FlexAlign.Center) .alignItems(HorizontalAlign.Center) .height(TitleBarConstants.TITLE_BAR_HEIGHT) .padding(TitleBarConstants.PADDING) .layoutWeight(1) } @Builder rightBuilder() { Row() { Text('按钮') .attributeModifier(this.config.leftTextModifier) .onClick(() => { // if (this.config.rightTextClickListener) { // this.config.rightTextClickListener() // } }) Image($r('app.media.bar_more_icon')) .attributeModifier(this.config.rightImageModifier) .onClick(() => { // if (this.config.rightImageClickListener) { // this.config.rightImageClickListener() // } }) } .justifyContent(FlexAlign.SpaceBetween) .height(TitleBarConstants.TITLE_BAR_HEIGHT) .constraintSize({ minWidth: TitleBarConstants.TITLE_BAR_HEIGHT }) .padding(TitleBarConstants.PADDING) } @Builder dividerBuilder() { Line() .attributeModifier(this.config.dividerLineModifier) } }
AST#decorated_export_declaration#Left AST#decorator#Left @ ComponentV2 AST#decorator#Right export struct TitleBarView AST#component_body#Left { AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right private emptyBuilder AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { } AST#builder_function_body#Right AST#method_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right config : AST#type_annotation#Left AST#primary_type#Left TitleBarConfig 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 TitleBarConfig 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 AST#decorator#Left @ BuilderParam AST#decorator#Right public customStatusBarBuilder ? : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . emptyBuilder AST#member_expression#Right AST#expression#Right //自定义整个标题栏部分 AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ BuilderParam AST#decorator#Right public customContentBuilder ? : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . emptyBuilder AST#member_expression#Right AST#expression#Right //自定义标题栏左边部分(注意:如果需要标题栏居中展示,需要左右部分宽度保持一致) AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ BuilderParam AST#decorator#Right public customLeftBuilder ? : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . emptyBuilder AST#member_expression#Right AST#expression#Right //自定义标题栏中间部分 AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ BuilderParam AST#decorator#Right public customCenterBuilder ? : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . emptyBuilder AST#member_expression#Right AST#expression#Right //自定义标题栏右边部分(注意:如果需要标题栏居中展示,需要左右部分宽度保持一致) AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ BuilderParam AST#decorator#Right public customRightBuilder ? : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . emptyBuilder AST#member_expression#Right AST#expression#Right //自定义标题栏底部下划线 AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ BuilderParam AST#decorator#Right public customDividerBuilder ? : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . emptyBuilder AST#member_expression#Right AST#expression#Right AST#property_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) 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#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 . customStatusBarBuilder AST#member_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . customStatusBarBuilder AST#member_expression#Right AST#expression#Right != AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . emptyBuilder 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 . customStatusBarBuilder 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 } else { 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 . statusBarBuilder 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#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . attributeModifier ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . config AST#member_expression#Right AST#expression#Right . TitleBarModifier AST#member_expression#Right 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 AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right statusBarBuilder 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 Line ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . attributeModifier ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . config AST#member_expression#Right AST#expression#Right . statusBarModifier AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right contentBuilder 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 Row ( ) 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#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 . customLeftBuilder AST#member_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . customLeftBuilder AST#member_expression#Right AST#expression#Right != AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . emptyBuilder 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 . customLeftBuilder 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 } else { 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 . leftBuilder 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#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#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . customCenterBuilder AST#member_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . customCenterBuilder AST#member_expression#Right AST#expression#Right != AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . emptyBuilder 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 . customCenterBuilder 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 } else { 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 . centerBuilder 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#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#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . customRightBuilder AST#member_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . customRightBuilder AST#member_expression#Right AST#expression#Right != AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . emptyBuilder 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 . customRightBuilder 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 } else { 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 . rightBuilder 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#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left TitleBarConstants AST#expression#Right . FULL_PERCENT AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left TitleBarConstants AST#expression#Right . TITLE_BAR_HEIGHT AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left VerticalAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#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#modifier_chain_expression#Left . padding ( AST#expression#Left AST#member_expression#Left AST#expression#Left TitleBarConstants AST#expression#Right . PADDING AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left TitleBarConstants AST#expression#Right . WHITE_COLOR AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right leftBuilder 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 Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.bar_back_icon' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . attributeModifier ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . config AST#member_expression#Right AST#expression#Right . leftImageModifier 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#expression#Left AST#object_literal#Left { // if (this.config.leftImageClickListener) { // this.config.leftImageClickListener() // } } 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#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 'Back' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . attributeModifier ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . config AST#member_expression#Right AST#expression#Right . leftTextModifier 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#expression#Left AST#object_literal#Left { // if (this.config.leftTextClickListener) { // this.config.leftTextClickListener() // } } 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#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 . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left TitleBarConstants AST#expression#Right . TITLE_BAR_HEIGHT AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . constraintSize ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left minWidth AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left TitleBarConstants AST#expression#Right . TITLE_BAR_HEIGHT 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#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right centerBuilder 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 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#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . attributeModifier ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . config AST#member_expression#Right AST#expression#Right . contentTextModifier 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#expression#Left AST#object_literal#Left { // if (this.config.centerTextClickListener) { // this.config.centerTextClickListener() // } } 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#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 . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left TitleBarConstants AST#expression#Right . TITLE_BAR_HEIGHT AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#member_expression#Left AST#expression#Left TitleBarConstants AST#expression#Right . PADDING AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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 AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right rightBuilder 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 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#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . attributeModifier ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . config AST#member_expression#Right AST#expression#Right . leftTextModifier 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#expression#Left AST#object_literal#Left { // if (this.config.rightTextClickListener) { // this.config.rightTextClickListener() // } } 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#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 Image ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.bar_more_icon' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . attributeModifier ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . config AST#member_expression#Right AST#expression#Right . rightImageModifier 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#expression#Left AST#object_literal#Left { // if (this.config.rightImageClickListener) { // this.config.rightImageClickListener() // } } 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#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 . SpaceBetween AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left TitleBarConstants AST#expression#Right . TITLE_BAR_HEIGHT AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . constraintSize ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left minWidth AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left TitleBarConstants AST#expression#Right . TITLE_BAR_HEIGHT AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#member_expression#Left AST#expression#Left TitleBarConstants AST#expression#Right . PADDING AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right dividerBuilder 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 Line ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . attributeModifier ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . config AST#member_expression#Right AST#expression#Right . dividerLineModifier AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@ComponentV2 export struct TitleBarView { @Builder private emptyBuilder() { } @Param config: TitleBarConfig = new TitleBarConfig() @BuilderParam public customStatusBarBuilder?: () => void = this.emptyBuilder @BuilderParam public customContentBuilder?: () => void = this.emptyBuilder @BuilderParam public customLeftBuilder?: () => void = this.emptyBuilder @BuilderParam public customCenterBuilder?: () => void = this.emptyBuilder @BuilderParam public customRightBuilder?: () => void = this.emptyBuilder @BuilderParam public customDividerBuilder?: () => void = this.emptyBuilder build() { Column() { if (this.customStatusBarBuilder && this.customStatusBarBuilder != this.emptyBuilder) { this.customStatusBarBuilder() } else { this.statusBarBuilder() } }.attributeModifier(this.config.TitleBarModifier) } @Builder statusBarBuilder() { Line().attributeModifier(this.config.statusBarModifier) } @Builder contentBuilder() { Row() { if (this.customLeftBuilder && this.customLeftBuilder != this.emptyBuilder) { this.customLeftBuilder() } else { this.leftBuilder() } if (this.customCenterBuilder && this.customCenterBuilder != this.emptyBuilder) { this.customCenterBuilder() } else { this.centerBuilder() } if (this.customRightBuilder && this.customRightBuilder != this.emptyBuilder) { this.customRightBuilder() } else { this.rightBuilder() } } .width(TitleBarConstants.FULL_PERCENT) .height(TitleBarConstants.TITLE_BAR_HEIGHT) .alignItems(VerticalAlign.Center) .justifyContent(FlexAlign.SpaceBetween) .padding(TitleBarConstants.PADDING) .backgroundColor(TitleBarConstants.WHITE_COLOR) } @Builder leftBuilder() { Row() { Image($r('app.media.bar_back_icon')) .attributeModifier(this.config.leftImageModifier) .onClick(() => { }) Text('Back') .attributeModifier(this.config.leftTextModifier) .onClick(() => { }) } .justifyContent(FlexAlign.Start) .height(TitleBarConstants.TITLE_BAR_HEIGHT) .constraintSize({ minWidth: TitleBarConstants.TITLE_BAR_HEIGHT }) } @Builder centerBuilder() { Column() { Text('这是标题') .attributeModifier(this.config.contentTextModifier) .onClick(() => { }) } .justifyContent(FlexAlign.Center) .alignItems(HorizontalAlign.Center) .height(TitleBarConstants.TITLE_BAR_HEIGHT) .padding(TitleBarConstants.PADDING) .layoutWeight(1) } @Builder rightBuilder() { Row() { Text('按钮') .attributeModifier(this.config.leftTextModifier) .onClick(() => { }) Image($r('app.media.bar_more_icon')) .attributeModifier(this.config.rightImageModifier) .onClick(() => { }) } .justifyContent(FlexAlign.SpaceBetween) .height(TitleBarConstants.TITLE_BAR_HEIGHT) .constraintSize({ minWidth: TitleBarConstants.TITLE_BAR_HEIGHT }) .padding(TitleBarConstants.PADDING) } @Builder dividerBuilder() { Line() .attributeModifier(this.config.dividerLineModifier) } }
https://github.com/open9527/OpenHarmony/blob/fdea69ed722d426bf04e817ec05bff4002e81a4e/entry/src/main/ets/common/component/TitleBar.ets#L13-L155
c922f58710effb0e0c7ce21318f386bcb85d11be
gitee
sithvothykiv/dialog_hub.git
b676c102ef2d05f8994d170abe48dcc40cd39005
custom_dialog/src/main/ets/model/base/IModalDialogOptions.ets
arkts
弹窗基础参数
export interface IModalDialogOptions extends IBaseDialogOptions { /** * 弹窗样式 */ style?: IModalDialogStyle /** * 弹窗标题 */ title?: ResourceStr; //弹框标题 // /** // * 操作回调˝ // */ // onAction?: ActionCallback | ActionStrCallback | ActionValueCallback | ActionDateCallback; //按钮的Callback事件。 /** * 【【【【仅系统弹窗支持】】】】 * Custom Theme. * * @type { ?(Theme | CustomTheme) } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ theme?: Theme | CustomTheme; /** * 【【【【仅系统弹窗支持】】】】 * Sets the TipsDialog dark or light Mode. * * @type { ?ThemeColorMode } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ themeColorMode?: ThemeColorMode; /** * 弹窗背板背景图片。 * @description 注意⚠️:(仅支持自定义内容弹窗CustomDialog、文本输入TextInput、多行文本输入TextArea) * */ backgroundImage?: ResourceStr /** * 弹窗背板背景图片铺展模式 * @default 默认ImageSize.FILL */ backgroundImageSize?: ImageSize }
AST#export_declaration#Left export AST#interface_declaration#Left interface IModalDialogOptions AST#extends_clause#Left extends IBaseDialogOptions AST#extends_clause#Right AST#object_type#Left { /** * 弹窗样式 */ AST#type_member#Left style ? : AST#type_annotation#Left AST#primary_type#Left IModalDialogStyle AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right /** * 弹窗标题 */ AST#type_member#Left title ? : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; //弹框标题 // /** // * 操作回调˝ // */ // onAction?: ActionCallback | ActionStrCallback | ActionValueCallback | ActionDateCallback; //按钮的Callback事件。 /** * 【【【【仅系统弹窗支持】】】】 * Custom Theme. * * @type { ?(Theme | CustomTheme) } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ AST#type_member#Left theme ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Theme AST#primary_type#Right | AST#primary_type#Left CustomTheme AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * 【【【【仅系统弹窗支持】】】】 * Sets the TipsDialog dark or light Mode. * * @type { ?ThemeColorMode } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ AST#type_member#Left themeColorMode ? : AST#type_annotation#Left AST#primary_type#Left ThemeColorMode AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * 弹窗背板背景图片。 * @description 注意⚠️:(仅支持自定义内容弹窗CustomDialog、文本输入TextInput、多行文本输入TextArea) * */ AST#type_member#Left backgroundImage ? : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right /** * 弹窗背板背景图片铺展模式 * @default 默认ImageSize.FILL */ AST#type_member#Left backgroundImageSize ? : AST#type_annotation#Left AST#primary_type#Left ImageSize 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 IModalDialogOptions extends IBaseDialogOptions { style?: IModalDialogStyle title?: ResourceStr; theme?: Theme | CustomTheme; themeColorMode?: ThemeColorMode; backgroundImage?: ResourceStr backgroundImageSize?: ImageSize }
https://github.com/sithvothykiv/dialog_hub.git/blob/b676c102ef2d05f8994d170abe48dcc40cd39005/custom_dialog/src/main/ets/model/base/IModalDialogOptions.ets#L8-L58
1549a0be33512c82fae64a05b7b21c81482b42c8
github
openharmony/developtools_profiler
73d26bb5acfcafb2b1f4f94ead5640241d1e5f73
host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/renderer/BarLineScatterCandleBubbleRenderer.ets
arkts
Created by Philipp Jahoda on 09/06/16.
export default abstract class BarLineScatterCandleBubbleRenderer extends DataRenderer { /** * buffer for storing the current minimum and maximum visible x */ protected mXBounds: XBounds; constructor(animator: ChartAnimator, viewPortHandler: ViewPortHandler) { super(animator, viewPortHandler); this.mXBounds = new XBounds(this.mAnimator); } /** * Returns true if the DataSet values should be drawn, false if not. * * @param set * @return */ protected shouldDrawValues(dataSet: IDataSet<any>): boolean { return dataSet.isVisible() && (dataSet.isDrawValuesEnabled() || dataSet.isDrawIconsEnabled()); } /** * Checks if the provided entry object is in bounds for drawing considering the current animation phase. * * @param e * @param set * @return */ protected isInBoundsX(e: EntryOhos, dataSet: IBarLineScatterCandleBubbleDataSet<EntryOhos>): boolean { if (e == null) { return false; } let entryIndex = dataSet.getEntryIndexByEntry(e); if (e == null || entryIndex >= dataSet.getEntryCount() * this.mAnimator.getPhaseX()) { return false; } else { return true; } } }
AST#export_declaration#Left export default AST#class_declaration#Left abstract class BarLineScatterCandleBubbleRenderer extends AST#type_annotation#Left AST#primary_type#Left DataRenderer AST#primary_type#Right AST#type_annotation#Right AST#class_body#Left { /** * buffer for storing the current minimum and maximum visible x */ AST#property_declaration#Left protected mXBounds : AST#type_annotation#Left AST#primary_type#Left XBounds AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left animator : AST#type_annotation#Left AST#primary_type#Left ChartAnimator AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left viewPortHandler : AST#type_annotation#Left AST#primary_type#Left ViewPortHandler 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 super AST#expression#Right AST#argument_list#Left ( AST#expression#Left animator AST#expression#Right , AST#expression#Left viewPortHandler 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 . mXBounds AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left XBounds AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mAnimator 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#block_statement#Right AST#constructor_declaration#Right /** * Returns true if the DataSet values should be drawn, false if not. * * @param set * @return */ AST#method_declaration#Left protected shouldDrawValues AST#parameter_list#Left ( AST#parameter#Left dataSet : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left IDataSet 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#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left dataSet AST#expression#Right . isVisible 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#parenthesized_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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left dataSet AST#expression#Right . isDrawValuesEnabled 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 dataSet AST#expression#Right AST#binary_expression#Right AST#expression#Right . isDrawIconsEnabled AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right 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 /** * Checks if the provided entry object is in bounds for drawing considering the current animation phase. * * @param e * @param set * @return */ AST#method_declaration#Left protected isInBoundsX AST#parameter_list#Left ( AST#parameter#Left e : AST#type_annotation#Left AST#primary_type#Left EntryOhos AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left dataSet : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left IBarLineScatterCandleBubbleDataSet AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left EntryOhos 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 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 e 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#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left entryIndex = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left dataSet AST#expression#Right . getEntryIndexByEntry AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left e AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#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 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#binary_expression#Left AST#expression#Left e 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 entryIndex AST#expression#Right >= AST#expression#Left dataSet AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . getEntryCount 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 . mAnimator AST#member_expression#Right AST#expression#Right . getPhaseX 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#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#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#block_statement#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export default abstract class BarLineScatterCandleBubbleRenderer extends DataRenderer { protected mXBounds: XBounds; constructor(animator: ChartAnimator, viewPortHandler: ViewPortHandler) { super(animator, viewPortHandler); this.mXBounds = new XBounds(this.mAnimator); } protected shouldDrawValues(dataSet: IDataSet<any>): boolean { return dataSet.isVisible() && (dataSet.isDrawValuesEnabled() || dataSet.isDrawIconsEnabled()); } protected isInBoundsX(e: EntryOhos, dataSet: IBarLineScatterCandleBubbleDataSet<EntryOhos>): boolean { if (e == null) { return false; } let entryIndex = dataSet.getEntryIndexByEntry(e); if (e == null || entryIndex >= dataSet.getEntryCount() * this.mAnimator.getPhaseX()) { return false; } else { return true; } } }
https://github.com/openharmony/developtools_profiler/blob/73d26bb5acfcafb2b1f4f94ead5640241d1e5f73/host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/renderer/BarLineScatterCandleBubbleRenderer.ets#L76-L117
2dc91ca858744d38245eca0aab40b27948f3d358
gitee
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
VideoPlayerSample/MediaService/src/main/ets/controller/AvSessionController.ets
arkts
setAvSessionPlayState
[End launch] [Start update_is_play]
public setAvSessionPlayState(playbackState: avSession.AVPlaybackState): void { if (this.avSession) { this.avSession.setAVPlaybackState(playbackState, (err: BusinessError) => { if (err) { Logger.error(TAG, `SetAVPlaybackState BusinessError: code: ${err.code}, message: ${err.message}`); } else { Logger.info(TAG, "SetAVPlaybackState successfully"); } }); } }
AST#method_declaration#Left public setAvSessionPlayState AST#parameter_list#Left ( AST#parameter#Left playbackState : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left avSession . AVPlaybackState 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#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . avSession AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . avSession AST#member_expression#Right AST#expression#Right . setAVPlaybackState AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left playbackState AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err : AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left err AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` SetAVPlaybackState BusinessError: code: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , message: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left "SetAVPlaybackState 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#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
public setAvSessionPlayState(playbackState: avSession.AVPlaybackState): void { if (this.avSession) { this.avSession.setAVPlaybackState(playbackState, (err: BusinessError) => { if (err) { Logger.error(TAG, `SetAVPlaybackState BusinessError: code: ${err.code}, message: ${err.message}`); } else { Logger.info(TAG, "SetAVPlaybackState successfully"); } }); } }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/VideoPlayerSample/MediaService/src/main/ets/controller/AvSessionController.ets#L147-L157
4af889972440d5b71f1344a2482b0b8d17645d1f
gitee
openharmony/developtools_profiler
73d26bb5acfcafb2b1f4f94ead5640241d1e5f73
host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/data/RadarDataSet.ets
arkts
getHighlightCircleStrokeAlpha
@Override
public getHighlightCircleStrokeAlpha(): number { return this.mHighlightCircleStrokeAlpha; }
AST#method_declaration#Left public getHighlightCircleStrokeAlpha 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 . mHighlightCircleStrokeAlpha AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
public getHighlightCircleStrokeAlpha(): number { return this.mHighlightCircleStrokeAlpha; }
https://github.com/openharmony/developtools_profiler/blob/73d26bb5acfcafb2b1f4f94ead5640241d1e5f73/host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/data/RadarDataSet.ets#L77-L79
ee2ba11f84e40e610fe1aa2004fbb16bc70416c3
gitee
awa_Liny/LinysBrowser_NEXT
a5cd96a9aa8114cae4972937f94a8967e55d4a10
home/src/main/ets/processes/extension_actions.ets
arkts
Uninstalls an extension. @param id The ID of extension. @returns True if success.
export function uninstall_extension(id: string) { console.log(`[uninstall_extension] Try to uninstall extension id=${id}`); let path = path_of_extension(id); if (path) { let exts = AppStorage.get('bunch_of_extensions') as bunch_of_extensions; for (let index = 0; index < exts.extensions.length; index++) { if (exts.extensions[index].id == id) { // The last bit of your life! Take it! terminate_extension(id); detach_show_extension(exts.extensions[index]); exts.extensions.splice(index, 1); let extensions_ids = AppStorage.get('extensions_ids') as string[]; extensions_ids.splice(index, 1); let node = exts.NodeControllers.splice(index, 1); node[0]?.detachWeb(); node[0]?.dispose(); exts.update_timestamp(); break; } } sandbox_rmdir_sync(`extensions/${id}`); return true; } return false; }
AST#export_declaration#Left export AST#function_declaration#Left function uninstall_extension 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_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` [uninstall_extension] Try to uninstall extension id= AST#template_substitution#Left $ { AST#expression#Left id AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left path = AST#expression#Left AST#call_expression#Left AST#expression#Left path_of_extension AST#expression#Right AST#argument_list#Left ( AST#expression#Left id 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 path AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left exts = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'bunch_of_extensions' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left bunch_of_extensions 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#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left index = 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#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right < AST#expression#Left exts AST#expression#Right AST#binary_expression#Right AST#expression#Right . extensions AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left index AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left exts AST#expression#Right . extensions AST#member_expression#Right AST#expression#Right [ AST#expression#Left index AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . id AST#member_expression#Right AST#expression#Right == AST#expression#Left id AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { // The last bit of your life! Take it! AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left terminate_extension AST#expression#Right AST#argument_list#Left ( AST#expression#Left id 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 detach_show_extension AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left exts AST#expression#Right . extensions AST#member_expression#Right AST#expression#Right [ AST#expression#Left index AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left exts AST#expression#Right . extensions 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#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left extensions_ids = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'extensions_ids' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as 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#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 extensions_ids 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#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left node = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left exts AST#expression#Right . NodeControllers 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#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#subscript_expression#Left AST#expression#Left node AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ?. detachWeb AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left node AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ?. dispose 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 exts AST#expression#Right . update_timestamp 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#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left sandbox_rmdir_sync AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` extensions/ AST#template_substitution#Left $ { AST#expression#Left id AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_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#function_declaration#Right AST#export_declaration#Right
export function uninstall_extension(id: string) { console.log(`[uninstall_extension] Try to uninstall extension id=${id}`); let path = path_of_extension(id); if (path) { let exts = AppStorage.get('bunch_of_extensions') as bunch_of_extensions; for (let index = 0; index < exts.extensions.length; index++) { if (exts.extensions[index].id == id) { terminate_extension(id); detach_show_extension(exts.extensions[index]); exts.extensions.splice(index, 1); let extensions_ids = AppStorage.get('extensions_ids') as string[]; extensions_ids.splice(index, 1); let node = exts.NodeControllers.splice(index, 1); node[0]?.detachWeb(); node[0]?.dispose(); exts.update_timestamp(); break; } } sandbox_rmdir_sync(`extensions/${id}`); return true; } return false; }
https://github.com/awa_Liny/LinysBrowser_NEXT/blob/a5cd96a9aa8114cae4972937f94a8967e55d4a10/home/src/main/ets/processes/extension_actions.ets#L157-L183
db469e543f5c4692397d1f98f29e25d8ce902392
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/collapsemenu/Index.ets
arkts
CollapseMenu
Copyright (c) 2024 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 { CollapseMenu } from './src/main/ets/view/CollapseMenu';
AST#export_declaration#Left export { CollapseMenu } from './src/main/ets/view/CollapseMenu' ; AST#export_declaration#Right
export { CollapseMenu } from './src/main/ets/view/CollapseMenu';
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/collapsemenu/Index.ets#L15-L15
64d2413ba3a1472528110e772edd4a9059944f91
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/styledtext/src/main/ets/components/StyledStringComponent.ets
arkts
handleExceedingSize
处理字符数超过指定字符长度的情况,末尾添加“...全文” @param {MyCustomSpan} span - 自定义文本片段,包含文本类型和内容 @param {number} charCount - 当前已拼接的字符长度 @param {MutableStyledString[]} styledStrings - 生成的属性字符串数组
handleExceedingSize(span: MyCustomSpan, charCount: number, styledStrings: MutableStyledString[]) { const ELLIPSIS: string = '...'; const FULL_TEXT: string = '全文'; // 检查文本片段的类型,决定如何处理超出部分 if (span.type === MyCustomSpanType.Normal) { // 如果是普通文本,则截断并拼接 ...全文 styledStrings.push(new MutableStyledString(`${span.content.substring(0, this.maxStringLength - charCount)}${ELLIPSIS}${FULL_TEXT}`, [ { start: this.maxStringLength - charCount + ELLIPSIS.length, length: FULL_TEXT.length, styledKey: StyledStringKey.FONT, styledValue: this.textAttribute }, { start: this.maxStringLength - charCount + ELLIPSIS.length, length: FULL_TEXT.length, styledKey: StyledStringKey.GESTURE, styledValue: this.generateClickStyle(span) }])); } else { // 对于链接类型,不截断直接拼接 ...全文,如果视频链接图标的pixelMap已存在,在对应类型的链接前添加图片类型的属性字符串 if (span.type === MyCustomSpanType.VideoLink && this.imagePixelMap !== undefined) { styledStrings.push(new MutableStyledString(new ImageAttachment({ value: this.imagePixelMap, size: { width: $r('app.integer.styled_text_video_link_icon_size'), height: $r('app.integer.styled_text_video_link_icon_size') }, verticalAlign: ImageSpanAlignment.CENTER, objectFit: ImageFit.Contain }))); } styledStrings.push(new MutableStyledString(`${span.content}${ELLIPSIS}${FULL_TEXT}`, [ { start: 0, length: span.content.length, styledKey: StyledStringKey.FONT, styledValue: this.textAttribute }, { start: 0, length: span.content.length, styledKey: StyledStringKey.GESTURE, styledValue: this.generateClickStyle(span) }, { start: span.content.length + ELLIPSIS.length, length: FULL_TEXT.length, styledKey: StyledStringKey.FONT, styledValue: this.textAttribute }, { start: span.content.length + ELLIPSIS.length, length: FULL_TEXT.length, styledKey: StyledStringKey.GESTURE, styledValue: this.generateClickStyle(span) }])); } }
AST#method_declaration#Left handleExceedingSize AST#parameter_list#Left ( AST#parameter#Left span : AST#type_annotation#Left AST#primary_type#Left MyCustomSpan AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left charCount : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left styledStrings : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left MutableStyledString [ ] AST#array_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 ELLIPSIS : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '...' 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 FULL_TEXT : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = 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#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left span AST#expression#Right . type AST#member_expression#Right AST#expression#Right === AST#expression#Left MyCustomSpanType AST#expression#Right AST#binary_expression#Right AST#expression#Right . Normal 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 styledStrings AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left MutableStyledString 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#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left span AST#expression#Right . content AST#member_expression#Right 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 AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . maxStringLength AST#member_expression#Right AST#expression#Right - AST#expression#Left charCount AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right AST#template_substitution#Left $ { AST#expression#Left ELLIPSIS AST#expression#Right } AST#template_substitution#Right AST#template_substitution#Left $ { AST#expression#Left FULL_TEXT AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left start AST#property_name#Right : 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 . maxStringLength AST#member_expression#Right AST#expression#Right - AST#expression#Left charCount AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left ELLIPSIS AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left length AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left FULL_TEXT AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left styledKey AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left StyledStringKey AST#expression#Right . FONT AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left styledValue AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . textAttribute AST#member_expression#Right 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 start AST#property_name#Right : 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 . maxStringLength AST#member_expression#Right AST#expression#Right - AST#expression#Left charCount AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left ELLIPSIS AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left length AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left FULL_TEXT AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left styledKey AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left StyledStringKey AST#expression#Right . GESTURE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left styledValue 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 . generateClickStyle AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left span 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#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#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { // 对于链接类型,不截断直接拼接 ...全文,如果视频链接图标的pixelMap已存在,在对应类型的链接前添加图片类型的属性字符串 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#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left span AST#expression#Right . type AST#member_expression#Right AST#expression#Right === AST#expression#Left MyCustomSpanType AST#expression#Right AST#binary_expression#Right AST#expression#Right . VideoLink AST#member_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . imagePixelMap AST#member_expression#Right AST#expression#Right !== AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left styledStrings AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left MutableStyledString AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ImageAttachment 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 value AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . imagePixelMap AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left size AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.styled_text_video_link_icon_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left height AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.styled_text_video_link_icon_size' AST#expression#Right ) AST#resource_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 verticalAlign AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left ImageSpanAlignment AST#expression#Right . CENTER AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left objectFit AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left ImageFit AST#expression#Right . Contain AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#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#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left styledStrings AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left MutableStyledString 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#member_expression#Left AST#expression#Left span AST#expression#Right . content AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right AST#template_substitution#Left $ { AST#expression#Left ELLIPSIS AST#expression#Right } AST#template_substitution#Right AST#template_substitution#Left $ { AST#expression#Left FULL_TEXT AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left start AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left length AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left span AST#expression#Right . content AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left styledKey AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left StyledStringKey AST#expression#Right . FONT AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left styledValue AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . textAttribute AST#member_expression#Right 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 start AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left length AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left span AST#expression#Right . content AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left styledKey AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left StyledStringKey AST#expression#Right . GESTURE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left styledValue 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 . generateClickStyle AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left span 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#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left start AST#property_name#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 span AST#expression#Right . content AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right + AST#expression#Left ELLIPSIS AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left length AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left FULL_TEXT AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left styledKey AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left StyledStringKey AST#expression#Right . FONT AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left styledValue AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . textAttribute AST#member_expression#Right 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 start AST#property_name#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 span AST#expression#Right . content AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right + AST#expression#Left ELLIPSIS AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left length AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left FULL_TEXT AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left styledKey AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left StyledStringKey AST#expression#Right . GESTURE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left styledValue 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 . generateClickStyle AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left span 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#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#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
handleExceedingSize(span: MyCustomSpan, charCount: number, styledStrings: MutableStyledString[]) { const ELLIPSIS: string = '...'; const FULL_TEXT: string = '全文'; if (span.type === MyCustomSpanType.Normal) { styledStrings.push(new MutableStyledString(`${span.content.substring(0, this.maxStringLength - charCount)}${ELLIPSIS}${FULL_TEXT}`, [ { start: this.maxStringLength - charCount + ELLIPSIS.length, length: FULL_TEXT.length, styledKey: StyledStringKey.FONT, styledValue: this.textAttribute }, { start: this.maxStringLength - charCount + ELLIPSIS.length, length: FULL_TEXT.length, styledKey: StyledStringKey.GESTURE, styledValue: this.generateClickStyle(span) }])); } else { if (span.type === MyCustomSpanType.VideoLink && this.imagePixelMap !== undefined) { styledStrings.push(new MutableStyledString(new ImageAttachment({ value: this.imagePixelMap, size: { width: $r('app.integer.styled_text_video_link_icon_size'), height: $r('app.integer.styled_text_video_link_icon_size') }, verticalAlign: ImageSpanAlignment.CENTER, objectFit: ImageFit.Contain }))); } styledStrings.push(new MutableStyledString(`${span.content}${ELLIPSIS}${FULL_TEXT}`, [ { start: 0, length: span.content.length, styledKey: StyledStringKey.FONT, styledValue: this.textAttribute }, { start: 0, length: span.content.length, styledKey: StyledStringKey.GESTURE, styledValue: this.generateClickStyle(span) }, { start: span.content.length + ELLIPSIS.length, length: FULL_TEXT.length, styledKey: StyledStringKey.FONT, styledValue: this.textAttribute }, { start: span.content.length + ELLIPSIS.length, length: FULL_TEXT.length, styledKey: StyledStringKey.GESTURE, styledValue: this.generateClickStyle(span) }])); } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/styledtext/src/main/ets/components/StyledStringComponent.ets#L110-L169
86d75035dab4f3efa8065d39525a972c0e109548
gitee
851432669/Smart-Home-ArkTs-Hi3861.git
0451f85f072ed3281cc23d9cdc2843d79f60f975
entry/src/main/ets/common/utils/ApiService.ets
arkts
API服务类 封装了与后端服务器通信的方法
export class ApiService { private static readonly apiBaseUrl: string = 'http://192.168.12.85:3001'//wifi /** * 用户登录 * @param username 用户名 * @param password 密码 * @returns Promise with API response */ static async login(username: string, password: string): Promise<ApiResponse> { let httpRequest = http.createHttp() try { // 构建请求数据 let requestData: LoginRequest = { username: username, password: password } // 创建请求参数 const requestParams = new HttpRequestParams(); requestParams.method = http.RequestMethod.POST; requestParams.addHeader('Content-Type', 'application/json'); requestParams.extraData = JSON.stringify(requestData); let response = await httpRequest.request( `${ApiService.apiBaseUrl}/api/login`, requestParams ) // 解析响应数据 let responseData = JSON.parse(response.result as string) as Record<string, string | number | boolean | null>; // 返回符合ApiResponse类型的结构 const successResponse: ApiResponse = { success: response.responseCode === 200 && (responseData.success as boolean), message: (responseData.message as string) || '登录成功', data: responseData } return successResponse; } catch (error) { const errorObj = new ErrorObject(); errorObj.message = error instanceof Error ? error.message : '网络请求失败'; const wrapper = new ResponseDataWrapper(); wrapper.setValue('message', errorObj.message); const errorResponse: ApiResponse = { success: false, message: '登录失败,请检查网络连接', error: wrapper.getAll() } return errorResponse; } finally { httpRequest.destroy(); } } /** * 重置密码 * @param username 用户名 * @param oldPassword 原密码 * @param newPassword 新密码 * @returns Promise with API response */ static async resetPassword(username: string, oldPassword: string, newPassword: string): Promise<ApiResponse> { // 创建HTTP请求客户端 let httpRequest = http.createHttp() try { // 构建请求数据 let requestData: ResetPasswordRequest = { username: username, oldPassword: oldPassword, newPassword: newPassword } // 创建请求参数 const requestParams = new HttpRequestParams(); requestParams.method = http.RequestMethod.POST; requestParams.addHeader('Content-Type', 'application/json'); requestParams.extraData = JSON.stringify(requestData); let response = await httpRequest.request( `${ApiService.apiBaseUrl}/api/reset-password`, requestParams ) // 解析响应数据 let responseData = JSON.parse(response.result as string) as Record<string, string | number | boolean | null>; // 返回符合ApiResponse类型的结构 const successResponse: ApiResponse = { success: response.responseCode === 200 && (responseData.success as boolean), message: (responseData.message as string) || '操作完成', data: responseData } return successResponse; } catch (error) { // 创建具体类型的错误对象 const errorObj = new ErrorObject(); errorObj.message = error instanceof Error ? error.message : '网络请求失败'; // 创建错误数据包装器 const wrapper = new ResponseDataWrapper(); wrapper.setValue('message', errorObj.message); const errorResponse: ApiResponse = { success: false, message: '网络请求失败', error: wrapper.getAll() } return errorResponse; } finally { // 释放HTTP客户端资源 httpRequest.destroy(); } } /** * 验证用户是否存在,并获取用户基本信息(如密保问题) * @param username 用户名 * @returns Promise with API response */ static async verifyUser(username: string): Promise<ApiResponse> { let httpRequest = http.createHttp() try { // 构建请求数据 let requestData: VerifyUserRequest = { username: username } // 创建请求参数 const requestParams = new HttpRequestParams(); requestParams.method = http.RequestMethod.POST; requestParams.addHeader('Content-Type', 'application/json'); requestParams.extraData = JSON.stringify(requestData); console.log('verifyUser 发送请求:', `${ApiService.apiBaseUrl}/api/verify-user`, JSON.stringify(requestData)); let response = await httpRequest.request( `${ApiService.apiBaseUrl}/api/verify-user`, requestParams ) console.log('verifyUser 原始响应:', response.responseCode, response.result); // 解析响应数据 interface UserData { username: string; question: string; hasEmail: boolean; hasPhone: boolean; } interface UserResponseData { success: boolean; message: string; data?: UserData; } let responseData = JSON.parse(response.result as string) as UserResponseData; console.log('verifyUser 解析后的响应数据:', JSON.stringify(responseData)); // 检查问题字段 if (responseData.data) { console.log('密保问题检查:', { hasQuestion: !!responseData.data.question, questionLength: responseData.data.question ? responseData.data.question.length : 0, questionValue: responseData.data.question || '未设置' }); } else { console.log('响应中没有data字段或data为空'); }
AST#export_declaration#Left export AST#class_declaration#Left class ApiService AST#ERROR#Left { AST#property_declaration#Left private static readonly apiBaseUrl : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'http://192.168.12.85:3001' AST#expression#Right //wifi /** * 用户登录 * @param username 用户名 * @param password 密码 * @returns Promise with API response */ AST#property_declaration#Right AST#method_declaration#Left static async login AST#parameter_list#Left ( AST#parameter#Left username : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left password : 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 ApiResponse 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 httpRequest = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left http AST#expression#Right . createHttp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { // 构建请求数据 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left requestData : AST#type_annotation#Left AST#primary_type#Left LoginRequest AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left username AST#property_name#Right : AST#expression#Left username AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left password AST#property_name#Right : AST#expression#Left password AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right // 创建请求参数 AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left requestParams = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left HttpRequestParams 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 AST#member_expression#Left AST#expression#Left requestParams AST#expression#Right . method AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left http AST#expression#Right . RequestMethod AST#member_expression#Right AST#expression#Right . POST 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left requestParams AST#expression#Right . addHeader AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Content-Type' AST#expression#Right , AST#expression#Left 'application/json' 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 requestParams AST#expression#Right . extraData AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left requestData 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 response = 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 httpRequest AST#expression#Right AST#await_expression#Right AST#expression#Right . request AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left ApiService AST#expression#Right . apiBaseUrl AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right /api/login ` AST#template_literal#Right AST#expression#Right , AST#expression#Left requestParams 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 responseData = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . parse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . result AST#member_expression#Right 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#argument_list#Right AST#call_expression#Right AST#expression#Right as 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#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left number AST#primary_type#Right | AST#primary_type#Left boolean AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_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 // 返回符合ApiResponse类型的结构 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left successResponse : AST#type_annotation#Left AST#primary_type#Left ApiResponse AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left success AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . responseCode AST#member_expression#Right AST#expression#Right === AST#expression#Left 200 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left responseData AST#expression#Right . success AST#member_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#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#binary_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 responseData AST#expression#Right . message AST#member_expression#Right 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#parenthesized_expression#Right AST#expression#Right || AST#expression#Left '登录成功' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left data AST#property_name#Right : AST#expression#Left responseData 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#return_statement#Left return AST#expression#Left successResponse 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#variable_declaration#Left const AST#variable_declarator#Left errorObj = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ErrorObject 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 AST#member_expression#Left AST#expression#Left errorObj AST#expression#Right . message AST#member_expression#Right = 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 '网络请求失败' AST#expression#Right AST#conditional_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 wrapper = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ResponseDataWrapper 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 wrapper AST#expression#Right . setValue AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'message' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left errorObj 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#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left errorResponse : AST#type_annotation#Left AST#primary_type#Left ApiResponse AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left success 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 message AST#property_name#Right : AST#expression#Left '登录失败,请检查网络连接' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left error AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left wrapper AST#expression#Right . getAll 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 AST#statement#Left AST#return_statement#Left return AST#expression#Left errorResponse AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#finally_clause#Left finally AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left httpRequest AST#expression#Right . destroy AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#finally_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 重置密码 * @param username 用户名 * @param oldPassword 原密码 * @param newPassword 新密码 * @returns Promise with API response */ AST#method_declaration#Left static async resetPassword AST#parameter_list#Left ( AST#parameter#Left username : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left oldPassword : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left newPassword : 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 ApiResponse 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 { // 创建HTTP请求客户端 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left httpRequest = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left http AST#expression#Right . createHttp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { // 构建请求数据 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left requestData : AST#type_annotation#Left AST#primary_type#Left ResetPasswordRequest AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left username AST#property_name#Right : AST#expression#Left username AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left oldPassword AST#property_name#Right : AST#expression#Left oldPassword AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left newPassword AST#property_name#Right : AST#expression#Left newPassword AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right // 创建请求参数 AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left requestParams = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left HttpRequestParams 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 AST#member_expression#Left AST#expression#Left requestParams AST#expression#Right . method AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left http AST#expression#Right . RequestMethod AST#member_expression#Right AST#expression#Right . POST 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left requestParams AST#expression#Right . addHeader AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Content-Type' AST#expression#Right , AST#expression#Left 'application/json' 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 requestParams AST#expression#Right . extraData AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left requestData 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 response = 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 httpRequest AST#expression#Right AST#await_expression#Right AST#expression#Right . request AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left ApiService AST#expression#Right . apiBaseUrl AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right /api/reset-password ` AST#template_literal#Right AST#expression#Right , AST#expression#Left requestParams 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 responseData = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . parse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . result AST#member_expression#Right 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#argument_list#Right AST#call_expression#Right AST#expression#Right as 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#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left number AST#primary_type#Right | AST#primary_type#Left boolean AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_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 // 返回符合ApiResponse类型的结构 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left successResponse : AST#type_annotation#Left AST#primary_type#Left ApiResponse AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left success AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . responseCode AST#member_expression#Right AST#expression#Right === AST#expression#Left 200 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left responseData AST#expression#Right . success AST#member_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#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#binary_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 responseData AST#expression#Right . message AST#member_expression#Right 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#parenthesized_expression#Right AST#expression#Right || AST#expression#Left '操作完成' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left data AST#property_name#Right : AST#expression#Left responseData 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#return_statement#Left return AST#expression#Left successResponse 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#variable_declaration#Left const AST#variable_declarator#Left errorObj = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ErrorObject 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 AST#member_expression#Left AST#expression#Left errorObj AST#expression#Right . message AST#member_expression#Right = 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 '网络请求失败' AST#expression#Right AST#conditional_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 wrapper = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ResponseDataWrapper 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 wrapper AST#expression#Right . setValue AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'message' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left errorObj 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#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left errorResponse : AST#type_annotation#Left AST#primary_type#Left ApiResponse AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left success 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 message AST#property_name#Right : AST#expression#Left '网络请求失败' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left error AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left wrapper AST#expression#Right . getAll 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 AST#statement#Left AST#return_statement#Left return AST#expression#Left errorResponse AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#finally_clause#Left finally AST#block_statement#Left { // 释放HTTP客户端资源 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left httpRequest AST#expression#Right . destroy AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#finally_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 验证用户是否存在,并获取用户基本信息(如密保问题) * @param username 用户名 * @returns Promise with API response */ AST#method_declaration#Left static async verifyUser AST#parameter_list#Left ( AST#parameter#Left username : 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 ApiResponse 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 httpRequest = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left http AST#expression#Right . createHttp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { // 构建请求数据 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left requestData : AST#type_annotation#Left AST#primary_type#Left VerifyUserRequest AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left username AST#property_name#Right : AST#expression#Left username AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right // 创建请求参数 AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left requestParams = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left HttpRequestParams 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 AST#member_expression#Left AST#expression#Left requestParams AST#expression#Right . method AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left http AST#expression#Right . RequestMethod AST#member_expression#Right AST#expression#Right . POST 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left requestParams AST#expression#Right . addHeader AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Content-Type' AST#expression#Right , AST#expression#Left 'application/json' 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 requestParams AST#expression#Right . extraData AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left requestData AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'verifyUser 发送请求:' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left ApiService AST#expression#Right . apiBaseUrl AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right /api/verify-user ` AST#template_literal#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left requestData AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left response = 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 httpRequest AST#expression#Right AST#await_expression#Right AST#expression#Right . request AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left ApiService AST#expression#Right . apiBaseUrl AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right /api/verify-user ` AST#template_literal#Right AST#expression#Right , AST#expression#Left requestParams AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left console AST#ERROR#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'verifyUser 原始响应:' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . responseCode AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . result 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 interface AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left UserData 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 username AST#property_name#Right : AST#expression#Left string AST#expression#Right AST#property_assignment#Right AST#object_literal#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left question AST#expression#Right AST#ERROR#Left : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left hasEmail AST#expression#Right AST#ERROR#Left : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left hasPhone AST#expression#Right AST#ERROR#Left : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#try_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left interface AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left UserResponseData 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 success AST#property_name#Right : AST#expression#Left boolean AST#expression#Right AST#property_assignment#Right AST#object_literal#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left message AST#expression#Right AST#ERROR#Left : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left data AST#expression#Right ? AST#expression#Left AST#expression#Right : AST#expression#Left UserData AST#expression#Right AST#conditional_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#property_declaration#Left let AST#ERROR#Left responseData AST#ERROR#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 JSON AST#expression#Right . parse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . result AST#member_expression#Right 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#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left UserResponseData AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#method_declaration#Left console AST#ERROR#Left . log ( 'verifyUser 解析后的响应数据:' , JSON . string if y AST#ERROR#Right AST#parameter_list#Left ( AST#parameter#Left responseData AST#parameter#Right ) AST#parameter_list#Right AST#ERROR#Left ) AST#ERROR#Right ; AST#method_declaration#Right // 检查问题字段 AST#method_declaration#Left if AST#parameter_list#Left ( AST#parameter#Left responseData AST#parameter#Right AST#ERROR#Left . data AST#ERROR#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 console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '密保问题检查:' AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left hasQuestion AST#property_name#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 AST#unary_expression#Left ! AST#expression#Left responseData AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#unary_expression#Right AST#expression#Right . data AST#member_expression#Right AST#expression#Right . question AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left questionLength 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 responseData AST#expression#Right . data AST#member_expression#Right AST#expression#Right . question AST#member_expression#Right AST#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 responseData AST#expression#Right . data AST#member_expression#Right AST#expression#Right . question AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right : AST#expression#Left 0 AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left questionValue AST#property_name#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 responseData AST#expression#Right . data AST#member_expression#Right AST#expression#Right . question AST#member_expression#Right AST#expression#Right || AST#expression#Left '未设置' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right else AST#ERROR#Right AST#class_body#Left { AST#method_declaration#Left console AST#ERROR#Left . log AST#ERROR#Right AST#parameter_list#Left ( AST#ERROR#Left '响应中没有data字段或data为空' AST#ERROR#Right ) AST#parameter_list#Right ; AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class ApiService { private static readonly apiBaseUrl: string = 'http://192.168.12.85:3001' static async login(username: string, password: string): Promise<ApiResponse> { let httpRequest = http.createHttp() try { let requestData: LoginRequest = { username: username, password: password } const requestParams = new HttpRequestParams(); requestParams.method = http.RequestMethod.POST; requestParams.addHeader('Content-Type', 'application/json'); requestParams.extraData = JSON.stringify(requestData); let response = await httpRequest.request( `${ApiService.apiBaseUrl}/api/login`, requestParams ) let responseData = JSON.parse(response.result as string) as Record<string, string | number | boolean | null>; const successResponse: ApiResponse = { success: response.responseCode === 200 && (responseData.success as boolean), message: (responseData.message as string) || '登录成功', data: responseData } return successResponse; } catch (error) { const errorObj = new ErrorObject(); errorObj.message = error instanceof Error ? error.message : '网络请求失败'; const wrapper = new ResponseDataWrapper(); wrapper.setValue('message', errorObj.message); const errorResponse: ApiResponse = { success: false, message: '登录失败,请检查网络连接', error: wrapper.getAll() } return errorResponse; } finally { httpRequest.destroy(); } } static async resetPassword(username: string, oldPassword: string, newPassword: string): Promise<ApiResponse> { let httpRequest = http.createHttp() try { let requestData: ResetPasswordRequest = { username: username, oldPassword: oldPassword, newPassword: newPassword } const requestParams = new HttpRequestParams(); requestParams.method = http.RequestMethod.POST; requestParams.addHeader('Content-Type', 'application/json'); requestParams.extraData = JSON.stringify(requestData); let response = await httpRequest.request( `${ApiService.apiBaseUrl}/api/reset-password`, requestParams ) let responseData = JSON.parse(response.result as string) as Record<string, string | number | boolean | null>; const successResponse: ApiResponse = { success: response.responseCode === 200 && (responseData.success as boolean), message: (responseData.message as string) || '操作完成', data: responseData } return successResponse; } catch (error) { const errorObj = new ErrorObject(); errorObj.message = error instanceof Error ? error.message : '网络请求失败'; const wrapper = new ResponseDataWrapper(); wrapper.setValue('message', errorObj.message); const errorResponse: ApiResponse = { success: false, message: '网络请求失败', error: wrapper.getAll() } return errorResponse; } finally { httpRequest.destroy(); } } static async verifyUser(username: string): Promise<ApiResponse> { let httpRequest = http.createHttp() try { let requestData: VerifyUserRequest = { username: username } const requestParams = new HttpRequestParams(); requestParams.method = http.RequestMethod.POST; requestParams.addHeader('Content-Type', 'application/json'); requestParams.extraData = JSON.stringify(requestData); console.log('verifyUser 发送请求:', `${ApiService.apiBaseUrl}/api/verify-user`, JSON.stringify(requestData)); let response = await httpRequest.request( `${ApiService.apiBaseUrl}/api/verify-user`, requestParams ) console.log('verifyUser 原始响应:', response.responseCode, response.result); interface UserData { username: string; question: string; hasEmail: boolean; hasPhone: boolean; } interface UserResponseData { success: boolean; message: string; data?: UserData; } let responseData = JSON.parse(response.result as string) as UserResponseData; console.log('verifyUser 解析后的响应数据:', JSON.stringify(responseData)); if (responseData.data) { console.log('密保问题检查:', { hasQuestion: !!responseData.data.question, questionLength: responseData.data.question ? responseData.data.question.length : 0, questionValue: responseData.data.question || '未设置' }); } else { console.log('响应中没有data字段或data为空'); }
https://github.com/851432669/Smart-Home-ArkTs-Hi3861.git/blob/0451f85f072ed3281cc23d9cdc2843d79f60f975/entry/src/main/ets/common/utils/ApiService.ets#L138-L316
cddc2e65e91ff5cf7199fd1774c3af8ede2d4f1b
github
Joker-x-dev/HarmonyKit.git
f97197ce157df7f303244fba42e34918306dfb08
core/designsystem/src/main/ets/attribute/ColumnAttribute.ets
arkts
获取纵向两端分布 + 水平起始的 Column 对齐修饰器 @returns {AttributeModifier<ColumnAttribute>} Column 对齐修饰器 @example Column() { Text("A"); Text("B"); }.attributeModifier(columnSpaceBetweenStart());
export function columnSpaceBetweenStart(): AttributeModifier<ColumnAttribute> { return { applyNormalAttribute: (instance: ColumnAttribute): void => { instance.justifyContent(FlexAlign.SpaceBetween); instance.alignItems(HorizontalAlign.Start); } }; }
AST#export_declaration#Left export AST#function_declaration#Left function columnSpaceBetweenStart AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left AttributeModifier AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left ColumnAttribute 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#object_literal#Left { AST#property_assignment#Left AST#property_name#Left applyNormalAttribute AST#property_name#Right : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left instance : AST#type_annotation#Left AST#primary_type#Left ColumnAttribute 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 AST#member_expression#Left AST#expression#Left instance AST#expression#Right . justifyContent AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . SpaceBetween AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; 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 instance AST#expression#Right . alignItems AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left HorizontalAlign AST#expression#Right . Start 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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export function columnSpaceBetweenStart(): AttributeModifier<ColumnAttribute> { return { applyNormalAttribute: (instance: ColumnAttribute): void => { instance.justifyContent(FlexAlign.SpaceBetween); instance.alignItems(HorizontalAlign.Start); } }; }
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/designsystem/src/main/ets/attribute/ColumnAttribute.ets#L132-L139
e91120e2c6fd152fc1ec005e6533cf3955137177
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/slidetohideanddisplace/src/main/ets/model/Util.ets
arkts
图标和文字描述
export class IconAndDescription { icon: Resource; description: string | Resource; constructor(icon: Resource, description: string | Resource) { this.icon = icon; this.description = description } }
AST#export_declaration#Left export AST#class_declaration#Left class IconAndDescription AST#class_body#Left { AST#property_declaration#Left icon : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left description : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left Resource AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left icon : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left description : 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#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 . icon AST#member_expression#Right = AST#expression#Left icon AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . description AST#member_expression#Right = AST#expression#Left description AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class IconAndDescription { icon: Resource; description: string | Resource; constructor(icon: Resource, description: string | Resource) { this.icon = icon; this.description = description } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/slidetohideanddisplace/src/main/ets/model/Util.ets#L17-L25
5cf105acbd13dd4c61118fc0c8e44858c8945c8e
gitee
jxdiaodeyi/YX_Sports.git
af5346bd3d5003c33c306ff77b4b5e9184219893
YX_Sports/entry/src/main/ets/pages/home/musicBank.ets
arkts
itemui
*************************************具体音乐**********************************//
@Builder itemui(item:musicBank){ Column({space:1}){ Image(item.img).width(180) .height(250) .borderRadius(12) .padding(5) Column(){ Row(){ Text(item.name).fontSize(15) .fontWeight(5) }.width('100%').justifyContent(FlexAlign.Start) Row(){ Text('已下载'+item.num+'首').padding(5).fontSize(15).fontColor('#ffaea2a2') }.width('100%').justifyContent(FlexAlign.Start) } .padding(15) }.onClick(()=>{ router.pushUrl({url:'pages/home/youyang'}) }) }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right itemui AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left musicBank AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 1 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . img AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 180 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 250 AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 12 AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left 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#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left 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#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 . fontSize ( AST#expression#Left 15 AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left 5 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 . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Start 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#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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left '已下载' AST#expression#Right + AST#expression#Left item AST#expression#Right AST#binary_expression#Right AST#expression#Right . num 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 . padding ( AST#expression#Left 5 AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 15 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#ffaea2a2' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Start 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 . padding ( AST#expression#Left 15 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 . 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 router AST#expression#Right . pushUrl AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left url AST#property_name#Right : AST#expression#Left 'pages/home/youyang' 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#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 itemui(item:musicBank){ Column({space:1}){ Image(item.img).width(180) .height(250) .borderRadius(12) .padding(5) Column(){ Row(){ Text(item.name).fontSize(15) .fontWeight(5) }.width('100%').justifyContent(FlexAlign.Start) Row(){ Text('已下载'+item.num+'首').padding(5).fontSize(15).fontColor('#ffaea2a2') }.width('100%').justifyContent(FlexAlign.Start) } .padding(15) }.onClick(()=>{ router.pushUrl({url:'pages/home/youyang'}) }) }
https://github.com/jxdiaodeyi/YX_Sports.git/blob/af5346bd3d5003c33c306ff77b4b5e9184219893/YX_Sports/entry/src/main/ets/pages/home/musicBank.ets#L41-L67
63d8fefb4e88d6e4ca9cdb638f395b8724f2cf27
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/BasicFeature/Notification/CustomNotification/notification/src/main/ets/notification/NotificationRequestUtil.ets
arkts
initWantAgentNotificationRequest
init wantAgent NotificationRequest @param notificationContent @param notificationWantAgent @return return the created NotificationRequest
initWantAgentNotificationRequest(notificationContent: notification.NotificationContent, notificationWantAgent: WantAgent): notification.NotificationRequest { return { slotType: notification.SlotType.CONTENT_INFORMATION, id: 1, // 通知id,默认为1 content: notificationContent, wantAgent: notificationWantAgent }; }
AST#method_declaration#Left initWantAgentNotificationRequest AST#parameter_list#Left ( AST#parameter#Left notificationContent : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left notification . NotificationContent AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left notificationWantAgent : AST#type_annotation#Left AST#primary_type#Left WantAgent 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 notification . NotificationRequest 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 slotType AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left notification AST#expression#Right . SlotType AST#member_expression#Right AST#expression#Right . CONTENT_INFORMATION AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left id AST#property_name#Right : AST#expression#Left 1 AST#expression#Right AST#property_assignment#Right , // 通知id,默认为1 AST#property_assignment#Left AST#property_name#Left content AST#property_name#Right : AST#expression#Left notificationContent AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left wantAgent AST#property_name#Right : AST#expression#Left notificationWantAgent 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
initWantAgentNotificationRequest(notificationContent: notification.NotificationContent, notificationWantAgent: WantAgent): notification.NotificationRequest { return { slotType: notification.SlotType.CONTENT_INFORMATION, id: 1, content: notificationContent, wantAgent: notificationWantAgent }; }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/BasicFeature/Notification/CustomNotification/notification/src/main/ets/notification/NotificationRequestUtil.ets#L41-L48
6e3c4873e59aeff9d252f48be3947d5231f40954
gitee
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
core/ui/src/main/ets/component/address/AddressActionButton.ets
arkts
构建地址操作按钮 @returns {void} 无返回值
build(): void { Row() { CommonIcon({ icon: this.iconResId, iconSize: this.iconSize, tintColor: this.iconColor }); } .width(this.buttonSize) .height(this.buttonSize) .backgroundColor(this.bgColor) .borderRadius(this.buttonSize / 2) .justifyContent(FlexAlign.Center) .alignItems(VerticalAlign.Center) .onClick((): void => this.onTap()); }
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#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#ui_custom_component_statement#Left CommonIcon ( AST#component_parameters#Left { AST#component_parameter#Left icon : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . iconResId AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left iconSize : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . iconSize AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left tintColor : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . iconColor AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) ; AST#ui_custom_component_statement#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . buttonSize AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . buttonSize AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . bgColor AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . buttonSize AST#member_expression#Right AST#expression#Right / AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right 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 . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left VerticalAlign 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#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 . onTap 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#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#ERROR#Left ; AST#ERROR#Right } AST#build_body#Right AST#build_method#Right
build(): void { Row() { CommonIcon({ icon: this.iconResId, iconSize: this.iconSize, tintColor: this.iconColor }); } .width(this.buttonSize) .height(this.buttonSize) .backgroundColor(this.bgColor) .borderRadius(this.buttonSize / 2) .justifyContent(FlexAlign.Center) .alignItems(VerticalAlign.Center) .onClick((): void => this.onTap()); }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/ui/src/main/ets/component/address/AddressActionButton.ets#L46-L61
b2ef72227674b2cf56fd7989a612cad3297a8bea
github
Leeson-Wong/ark-layer.git
9efa3553414a6b1eee890e3858c8cdcb308535d7
core/PhaseExample.ets
arkts
示例 3: 混合使用预定义和自定义阶段
export async function example3_MixedPhases() { console.log('========== Example 3: Mixed Predefined and Custom Phases ==========') // 定义多个自定义阶段 const CACHED_PHASE = createPhase({ name: 'CACHED', priority: 35, waitForComplete: false, description: '缓存服务阶段' }) const REPORT_PHASE = createPhase({ name: 'REPORT', priority: 45, waitForComplete: false, description: '报表服务阶段' }) // 加载各个阶段 serviceManager.load({ phase: GLOBAL_PHASE, sceneList: [new ConfigService()] }) serviceManager.load({ phase: BUSINESS_PHASE, sceneList: [new DatabaseService(), new UserService()] }) serviceManager.load({ phase: FEATURE_PHASE, sceneList: [new AuthService(), new NotificationService()] }) // 自定义阶段 serviceManager.load({ phase: CACHED_PHASE, sceneList: [new AnalyticsService()] }) serviceManager.load({ phase: REPORT_PHASE, sceneList: [new LogService()] }) await serviceManager.loginCallback() console.log('========== Example 3 Complete ==========\n') }
AST#export_declaration#Left export AST#function_declaration#Left async function example3_MixedPhases 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 . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '========== Example 3: Mixed Predefined and Custom Phases ==========' 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 CACHED_PHASE = AST#expression#Left AST#call_expression#Left AST#expression#Left createPhase AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left name AST#property_name#Right : AST#expression#Left 'CACHED' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left priority AST#property_name#Right : AST#expression#Left 35 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left waitForComplete 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 description AST#property_name#Right : AST#expression#Left '缓存服务阶段' 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 const AST#variable_declarator#Left REPORT_PHASE = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left createPhase AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left name AST#property_name#Right : AST#expression#Left 'REPORT' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left priority AST#property_name#Right : AST#expression#Left 45 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left waitForComplete 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 description AST#property_name#Right : AST#expression#Left '报表服务阶段' 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 serviceManager AST#ERROR#Right . load 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 phase AST#property_name#Right : AST#expression#Left GLOBAL_PHASE AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left sceneList AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ConfigService 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#array_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 serviceManager AST#ERROR#Right . load 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 phase AST#property_name#Right : AST#expression#Left BUSINESS_PHASE AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left sceneList AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left DatabaseService 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 AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left UserService 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#array_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 serviceManager AST#ERROR#Right . load 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 phase AST#property_name#Right : AST#expression#Left FEATURE_PHASE AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left sceneList AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left AuthService 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 AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left NotificationService 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#array_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 serviceManager AST#ERROR#Right . load 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 phase AST#property_name#Right : AST#expression#Left CACHED_PHASE AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left sceneList AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left AnalyticsService 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#array_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 serviceManager AST#ERROR#Right . load 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 phase AST#property_name#Right : AST#expression#Left REPORT_PHASE AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left sceneList AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left LogService 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#array_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left serviceManager AST#expression#Right AST#await_expression#Right AST#expression#Right . loginCallback 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 . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '========== Example 3 Complete ==========\n' 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 AST#export_declaration#Right
export async function example3_MixedPhases() { console.log('========== Example 3: Mixed Predefined and Custom Phases ==========') const CACHED_PHASE = createPhase({ name: 'CACHED', priority: 35, waitForComplete: false, description: '缓存服务阶段' }) const REPORT_PHASE = createPhase({ name: 'REPORT', priority: 45, waitForComplete: false, description: '报表服务阶段' }) serviceManager.load({ phase: GLOBAL_PHASE, sceneList: [new ConfigService()] }) serviceManager.load({ phase: BUSINESS_PHASE, sceneList: [new DatabaseService(), new UserService()] }) serviceManager.load({ phase: FEATURE_PHASE, sceneList: [new AuthService(), new NotificationService()] }) serviceManager.load({ phase: CACHED_PHASE, sceneList: [new AnalyticsService()] }) serviceManager.load({ phase: REPORT_PHASE, sceneList: [new LogService()] }) await serviceManager.loginCallback() console.log('========== Example 3 Complete ==========\n') }
https://github.com/Leeson-Wong/ark-layer.git/blob/9efa3553414a6b1eee890e3858c8cdcb308535d7/core/PhaseExample.ets#L258-L305
520ff8bbf0a9cce6e203eeb3920e3ceecf496e14
github
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
VideoPlayerSample/entry/src/main/ets/utils/WindowUtil.ets
arkts
setAvoidArea
[End set_stage1] Get status bar height and indicator height.
public static setAvoidArea(type: window.AvoidAreaType, area: window.AvoidArea): void { const uiContext: UIContext = AppStorage.get<UIContext>('uiContext')!; if (type === window.AvoidAreaType.TYPE_SYSTEM) { AppStorage.setOrCreate('statusBarHeight', uiContext?.px2vp(area.topRect.height)); } else { AppStorage.setOrCreate('navBarHeight', uiContext?.px2vp(area.bottomRect.height)); } }
AST#method_declaration#Left public static setAvoidArea AST#parameter_list#Left ( AST#parameter#Left type : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . AvoidAreaType AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left area : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . AvoidArea 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#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left uiContext : AST#type_annotation#Left AST#primary_type#Left UIContext 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 AppStorage AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left UIContext AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left 'uiContext' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left type 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . setOrCreate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'statusBarHeight' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left uiContext AST#expression#Right ?. px2vp 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 area AST#expression#Right . topRect AST#member_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right 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 AppStorage AST#expression#Right . setOrCreate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'navBarHeight' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left uiContext AST#expression#Right ?. px2vp 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 area AST#expression#Right . bottomRect AST#member_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
public static setAvoidArea(type: window.AvoidAreaType, area: window.AvoidArea): void { const uiContext: UIContext = AppStorage.get<UIContext>('uiContext')!; if (type === window.AvoidAreaType.TYPE_SYSTEM) { AppStorage.setOrCreate('statusBarHeight', uiContext?.px2vp(area.topRect.height)); } else { AppStorage.setOrCreate('navBarHeight', uiContext?.px2vp(area.bottomRect.height)); } }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/VideoPlayerSample/entry/src/main/ets/utils/WindowUtil.ets#L74-L81
0f4c19768ca560736cb9d9f207321f50bc6ef7f9
gitee
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/common/components/Vibrator/Vibrator.ets
arkts
vibrate
基础振动(时间模式) @param duration 振动时长(ms),默认25ms @param usage 使用场景,默认'touch'(触觉反馈)
vibrate(duration: number = 25, usage: vibrator.Usage = 'touch'): void { try { vibrator.startVibration( { type: 'time', duration }, { id: 0, usage }, (error: BusinessError) => { if (error) { console.error(`振动失败 code:${error.code}`); } } ); } catch (err) { console.error(`异常捕获 code:${(err as BusinessError).code}`); } }
AST#method_declaration#Left vibrate AST#parameter_list#Left ( AST#parameter#Left duration : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 25 AST#expression#Right AST#parameter#Right , AST#parameter#Left usage : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left vibrator . Usage AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'touch' AST#expression#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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left vibrator AST#expression#Right . startVibration 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 type AST#property_name#Right : AST#expression#Left 'time' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left duration 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 id AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left usage AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , 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#if_statement#Left if ( AST#expression#Left error 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 ` 振动失败 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 ` 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#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 AST#template_literal#Left ` 异常捕获 code: AST#template_substitution#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 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 . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
vibrate(duration: number = 25, usage: vibrator.Usage = 'touch'): void { try { vibrator.startVibration( { type: 'time', duration }, { id: 0, usage }, (error: BusinessError) => { if (error) { console.error(`振动失败 code:${error.code}`); } } ); } catch (err) { console.error(`异常捕获 code:${(err as BusinessError).code}`); } }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/components/Vibrator/Vibrator.ets#L29-L43
fc62e206e55c93ce2e461c65ebd9fd395ddfb578
github
harmonyos/samples
f5d967efaa7666550ee3252d118c3c73a77686f5
HarmonyOS_NEXT/AccountManager/AppAccountManager/entry/src/main/ets/model/AccountData.ets
arkts
getFromStorage
static instance: AccountData = null public static getInstance() { if (this.instance === null) { this.instance = new AccountData() } return this.instance }
async getFromStorage(context: common.Context, url: string) { let name = url Logger.info(TAG, `Name is ${name}`) try { storage = await preferences.getPreferences(context, `${name}`) } catch (err) { Logger.error(`getStorage failed, code is ${err?.code}, message is ${err?.message}`) } if (storage) { Logger.info(TAG, `Create stroage is fail.`) } }
AST#method_declaration#Left async getFromStorage AST#parameter_list#Left ( AST#parameter#Left context : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . Context AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , 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 name = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left url AST#expression#Right AST#ERROR#Left Logger AST#ERROR#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Name is AST#template_substitution#Left $ { AST#expression#Left name 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#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 storage = 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 AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left name 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#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 Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` getStorage failed, code is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right ?. code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , message is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right ?. message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left storage AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Create stroage is fail. ` 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
async getFromStorage(context: common.Context, url: string) { let name = url Logger.info(TAG, `Name is ${name}`) try { storage = await preferences.getPreferences(context, `${name}`) } catch (err) { Logger.error(`getStorage failed, code is ${err?.code}, message is ${err?.message}`) } if (storage) { Logger.info(TAG, `Create stroage is fail.`) } }
https://github.com/harmonyos/samples/blob/f5d967efaa7666550ee3252d118c3c73a77686f5/HarmonyOS_NEXT/AccountManager/AppAccountManager/entry/src/main/ets/model/AccountData.ets#L36-L47
fd18da2321791dd4ca7d7821b66448afa798cee2
gitee
Hyricane/Interview_Success.git
9783273fe05fc8951b99bf32d3887c605268db8f
entry/src/main/ets/commons/utils/Logger.ets
arkts
console.info() class 多写
export let logger = new Logger(0x0001, 'INTERVIEW', '%{public}s: %{public}s') // export let logger2 = new Logger(0x0002, 'ZHIBO', '%{public}s: %{public}s') // logger.info('姓名', '张三') // logger.error('年龄', '19') // 方法封装在实例上 而不是类上 // Logger.info() // Logger.error()
AST#export_declaration#Left export AST#variable_declaration#Left let AST#variable_declarator#Left logger = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Logger AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0001 AST#expression#Right , AST#expression#Left 'INTERVIEW' AST#expression#Right , AST#expression#Left '%{public}s: %{public}s' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right // export let logger2 = new Logger(0x0002, 'ZHIBO', '%{public}s: %{public}s') // logger.info('姓名', '张三') // logger.error('年龄', '19') // 方法封装在实例上 而不是类上 // Logger.info() // Logger.error() AST#variable_declaration#Right AST#export_declaration#Right
export let logger = new Logger(0x0001, 'INTERVIEW', '%{public}s: %{public}s')
https://github.com/Hyricane/Interview_Success.git/blob/9783273fe05fc8951b99bf32d3887c605268db8f/entry/src/main/ets/commons/utils/Logger.ets#L35-L45
56d1f5c793a38ade6a26f42e69637a8b78335de1
github
Piagari/arkts_example.git
a63b868eaa2a50dc480d487b84c4650cc6a40fc8
hmos_app-main/hmos_app-main/MusicHome-master/products/phone/src/main/ets/viewmodel/IndexItem.ets
arkts
Home page list information.
export default class IndexItem { /** * List item name. */ title: ResourceStr; /** * List item description. */ description: ResourceStr; /** * Button text information. */ button: ResourceStr; /** * Background image information. */ icon: Resource; /** * Jumping path information. */ url: string; constructor(title: ResourceStr, description: ResourceStr, button: ResourceStr, icon: Resource, url: string) { this.title = title; this.description = description; this.button = button; this.icon = icon; this.url = url; } }
AST#export_declaration#Left export default AST#class_declaration#Left class IndexItem AST#class_body#Left { /** * List item name. */ AST#property_declaration#Left title : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * List item description. */ AST#property_declaration#Left description : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Button text information. */ AST#property_declaration#Left button : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Background image information. */ AST#property_declaration#Left icon : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Jumping path information. */ AST#property_declaration#Left url : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#constructor_declaration#Left constructor 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 description : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left button : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left icon : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , 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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . title AST#member_expression#Right = AST#expression#Left title AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . description AST#member_expression#Right = AST#expression#Left description 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 . button AST#member_expression#Right = AST#expression#Left button AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . icon AST#member_expression#Right = AST#expression#Left icon AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . url AST#member_expression#Right = AST#expression#Left url AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export default class IndexItem { title: ResourceStr; description: ResourceStr; button: ResourceStr; icon: Resource; url: string; constructor(title: ResourceStr, description: ResourceStr, button: ResourceStr, icon: Resource, url: string) { this.title = title; this.description = description; this.button = button; this.icon = icon; this.url = url; } }
https://github.com/Piagari/arkts_example.git/blob/a63b868eaa2a50dc480d487b84c4650cc6a40fc8/hmos_app-main/hmos_app-main/MusicHome-master/products/phone/src/main/ets/viewmodel/IndexItem.ets#L19-L52
5956f78e24ef50d88fa29928c7b92e9ff59f4adc
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/models/datas/model/SearchManager.ets
arkts
getAliveUnits
获取活跃单元(包含未删除单词的单元)
getAliveUnits(): Unit[] { return this.units.filter(unit => unit.aliveWords.length > 0); }
AST#method_declaration#Left getAliveUnits AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Unit [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . units AST#member_expression#Right AST#expression#Right . filter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left unit => AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left unit AST#expression#Right . aliveWords 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#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
getAliveUnits(): Unit[] { return this.units.filter(unit => unit.aliveWords.length > 0); }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/datas/model/SearchManager.ets#L342-L344
ea26e4d74ac1f4411040673e541635d8c364c51d
github
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
ImageEditTaskPool/entry/src/main/ets/utils/EncodeUtil.ets
arkts
Pack the image. @param pixelMap.
export async function encode(component: Object, pixelMap: PixelMap) { hilog.info(0x0000, TAG, '%{public}s', `component is ${component}`); const newPixelMap = pixelMap; // Packing image. const imagePackerApi = image.createImagePacker(); const packOptions: image.PackingOption = { format: 'image/jpeg', quality: 100 } try { const imageData = await imagePackerApi.packToData(newPixelMap, packOptions); hilog.info(0x0000, TAG, '%{public}s', `imageData's length is ${imageData.byteLength}`); // Create image asset. let photoType: photoAccessHelper.PhotoType = photoAccessHelper.PhotoType.IMAGE; let extension: string = 'jpg'; phAccessHelper.createAsset(photoType, extension, (err, uri) => { if (err) { hilog.error(0x0000, TAG, 'createAsset ', JSON.stringify(err) ?? ''); } if (uri !== undefined) { let file = fileIo.openSync(uri, fileIo.OpenMode.READ_WRITE); fileIo.writeSync(file.fd, imageData); fileIo.close(file.fd).catch((err: BusinessError) => { hilog.error(0x0000, TAG, 'Failed to close: ', JSON.stringify(err) ?? ''); }); context.getPromptAction().showToast({ message: $r('app.string.image_save') }); } }); } catch (err) { hilog.error(0x0000, TAG, 'Failed to packToData: ', JSON.stringify(err) ?? ''); } }
AST#export_declaration#Left export AST#function_declaration#Left async function encode AST#parameter_list#Left ( AST#parameter#Left component : AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left pixelMap : AST#type_annotation#Left AST#primary_type#Left PixelMap 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 hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left TAG AST#expression#Right , AST#expression#Left '%{public}s' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` component is AST#template_substitution#Left $ { AST#expression#Left component AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left newPixelMap = AST#expression#Left pixelMap AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // Packing image. AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left imagePackerApi = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left image AST#expression#Right . createImagePacker 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 packOptions : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left image . PackingOption 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 format AST#property_name#Right : AST#expression#Left 'image/jpeg' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left quality AST#property_name#Right : AST#expression#Left 100 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#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left imageData = 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 imagePackerApi AST#expression#Right AST#await_expression#Right AST#expression#Right . packToData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left newPixelMap AST#expression#Right , AST#expression#Left packOptions 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 hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left TAG AST#expression#Right , AST#expression#Left '%{public}s' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` imageData's length is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left imageData AST#expression#Right . byteLength 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 // Create image asset. AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left photoType : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left photoAccessHelper . PhotoType AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left photoAccessHelper AST#expression#Right . PhotoType AST#member_expression#Right AST#expression#Right . IMAGE 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 extension : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'jpg' 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 phAccessHelper AST#expression#Right . createAsset AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left photoType AST#expression#Right , AST#expression#Left extension AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err AST#parameter#Right , AST#parameter#Left uri 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 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 TAG AST#expression#Right , AST#expression#Left 'createAsset ' AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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#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#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left uri 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 file = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fileIo AST#expression#Right . openSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left uri AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fileIo AST#expression#Right . OpenMode AST#member_expression#Right AST#expression#Right . READ_WRITE AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fileIo AST#expression#Right . writeSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left file AST#expression#Right . fd AST#member_expression#Right AST#expression#Right , AST#expression#Left imageData AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fileIo AST#expression#Right . close AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left file AST#expression#Right . fd AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . 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 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 TAG AST#expression#Right , AST#expression#Left 'Failed to close: ' AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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#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#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left context 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 . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.image_save' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#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#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 TAG AST#expression#Right , AST#expression#Left 'Failed to packToData: ' AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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#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#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export async function encode(component: Object, pixelMap: PixelMap) { hilog.info(0x0000, TAG, '%{public}s', `component is ${component}`); const newPixelMap = pixelMap; const imagePackerApi = image.createImagePacker(); const packOptions: image.PackingOption = { format: 'image/jpeg', quality: 100 } try { const imageData = await imagePackerApi.packToData(newPixelMap, packOptions); hilog.info(0x0000, TAG, '%{public}s', `imageData's length is ${imageData.byteLength}`); let photoType: photoAccessHelper.PhotoType = photoAccessHelper.PhotoType.IMAGE; let extension: string = 'jpg'; phAccessHelper.createAsset(photoType, extension, (err, uri) => { if (err) { hilog.error(0x0000, TAG, 'createAsset ', JSON.stringify(err) ?? ''); } if (uri !== undefined) { let file = fileIo.openSync(uri, fileIo.OpenMode.READ_WRITE); fileIo.writeSync(file.fd, imageData); fileIo.close(file.fd).catch((err: BusinessError) => { hilog.error(0x0000, TAG, 'Failed to close: ', JSON.stringify(err) ?? ''); }); context.getPromptAction().showToast({ message: $r('app.string.image_save') }); } }); } catch (err) { hilog.error(0x0000, TAG, 'Failed to packToData: ', JSON.stringify(err) ?? ''); } }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/ImageEditTaskPool/entry/src/main/ets/utils/EncodeUtil.ets#L31-L62
71378e7bf69445403ffc984ba1843af4eeaf1f07
gitee
queyun123/weatherApp-ArkTS.git
6beee6640db32ae70c342866b24fc643a9c512bf
entry/src/main/ets/pages/Index.ets
arkts
loadWeatherData
加载天气数据(使用新的HttpUtil)
async loadWeatherData() { this.isLoading = true; try { console.log('开始获取天气数据,城市ID:', this.cityId); // 使用新的HttpUtil获取天气数据 const weatherData = await HttpUtil.getWeatherByCityId(this.cityId); if (weatherData && weatherData.code === '200') { console.log('天气数据获取成功:', weatherData); // 更新UI状态 this.temperature = weatherData.now.temp; this.weatherText = weatherData.now.text; this.humidity = weatherData.now.humidity + '%'; this.wind = weatherData.now.windDir; this.windScale = weatherData.now.windScale; this.icon = getWeatherIcon(weatherData.now.text); // 格式化更新时间 if (weatherData.updateTime) { const timePart = weatherData.updateTime.split('T')[1]; if (timePart) { this.updateTime = timePart.substring(0, 5); } else { this.updateTime = new Date().toLocaleTimeString().substring(0, 5); } } else { this.updateTime = new Date().toLocaleTimeString().substring(0, 5); } // 保存当前城市到存储 await this.saveCurrentCity(); } else { console.error('天气数据格式错误'); this.setMockData(); } } catch (error) { console.error('获取天气数据异常:', JSON.stringify(error)); this.setMockData(); } this.isLoading = false; }
AST#method_declaration#Left async loadWeatherData 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 . isLoading AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#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 . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '开始获取天气数据,城市ID:' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cityId 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 // 使用新的HttpUtil获取天气数据 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left weatherData = 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 HttpUtil AST#expression#Right AST#await_expression#Right AST#expression#Right . getWeatherByCityId 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 . cityId 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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left weatherData AST#expression#Right && AST#expression#Left weatherData AST#expression#Right AST#binary_expression#Right AST#expression#Right . code AST#member_expression#Right AST#expression#Right === AST#expression#Left '200' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '天气数据获取成功:' AST#expression#Right , AST#expression#Left weatherData AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 更新UI状态 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . temperature AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left weatherData AST#expression#Right . now AST#member_expression#Right AST#expression#Right . temp 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 . weatherText AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left weatherData AST#expression#Right . now AST#member_expression#Right AST#expression#Right . text 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 . humidity 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 weatherData AST#expression#Right . now AST#member_expression#Right AST#expression#Right . humidity AST#member_expression#Right AST#expression#Right + AST#expression#Left '%' 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 . wind AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left weatherData AST#expression#Right . now AST#member_expression#Right AST#expression#Right . windDir 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 . windScale AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left weatherData AST#expression#Right . now AST#member_expression#Right AST#expression#Right . windScale 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 . icon AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left getWeatherIcon AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left weatherData AST#expression#Right . now AST#member_expression#Right AST#expression#Right . text 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#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left weatherData AST#expression#Right . updateTime AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left timePart = AST#expression#Left AST#subscript_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 weatherData AST#expression#Right . updateTime AST#member_expression#Right AST#expression#Right . split AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'T' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left timePart 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 . updateTime AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left timePart 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 5 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 else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . updateTime AST#member_expression#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#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 . toLocaleTimeString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right 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 5 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . updateTime AST#member_expression#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#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 . toLocaleTimeString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right 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 5 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 保存当前城市到存储 AST#statement#Left AST#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 . saveCurrentCity AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '天气数据格式错误' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . setMockData 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#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 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 error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . setMockData 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#try_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 . isLoading AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async loadWeatherData() { this.isLoading = true; try { console.log('开始获取天气数据,城市ID:', this.cityId); const weatherData = await HttpUtil.getWeatherByCityId(this.cityId); if (weatherData && weatherData.code === '200') { console.log('天气数据获取成功:', weatherData); this.temperature = weatherData.now.temp; this.weatherText = weatherData.now.text; this.humidity = weatherData.now.humidity + '%'; this.wind = weatherData.now.windDir; this.windScale = weatherData.now.windScale; this.icon = getWeatherIcon(weatherData.now.text); if (weatherData.updateTime) { const timePart = weatherData.updateTime.split('T')[1]; if (timePart) { this.updateTime = timePart.substring(0, 5); } else { this.updateTime = new Date().toLocaleTimeString().substring(0, 5); } } else { this.updateTime = new Date().toLocaleTimeString().substring(0, 5); } await this.saveCurrentCity(); } else { console.error('天气数据格式错误'); this.setMockData(); } } catch (error) { console.error('获取天气数据异常:', JSON.stringify(error)); this.setMockData(); } this.isLoading = false; }
https://github.com/queyun123/weatherApp-ArkTS.git/blob/6beee6640db32ae70c342866b24fc643a9c512bf/entry/src/main/ets/pages/Index.ets#L46-L91
eaac13813c9c4822a367158d8e4e5934c09c2f0c
github
JinnyWang-Space/guanlanwenjuan.git
601c4aa6c427e643d7bf42bc21945f658738e38c
common/src/main/ets/database/DistributedDB.ets
arkts
getAllSurveys
获取所有问卷数据(不包含问卷中的问题数据)
async getAllSurveys(): Promise<Survey[]> { if (!this.rdbStore) { Logger.info('[getAllSurveys]', 'getAllSurveys() has no callback!'); return []; } try { const predicates: relationalStore.RdbPredicates = new relationalStore.RdbPredicates('surveys'); const columns: string[] = ['id', 'title', 'description', 'created_time', 'status', 'published_time', 'closed_time', 'deleted', 'id_cloud']; const resultSet: relationalStore.ResultSet = await this.rdbStore.query(predicates, columns); const surveys: Survey[] = []; while (resultSet.goToNextRow()) { const survey: Survey = new Survey(); survey.id = resultSet.getLong(resultSet.getColumnIndex('id')); survey.title = resultSet.getString(resultSet.getColumnIndex('title')); survey.description = resultSet.getString(resultSet.getColumnIndex('description')); survey.createdTime = resultSet.getLong(resultSet.getColumnIndex('created_time')); survey.status = resultSet.getString(resultSet.getColumnIndex('status')) as SurveyStatus; survey.publishedTime = resultSet.getLong(resultSet.getColumnIndex('published_time')); survey.closedTime = resultSet.getLong(resultSet.getColumnIndex('closed_time')); survey.deleted = resultSet.getLong(resultSet.getColumnIndex('deleted')) === 1; survey.id_cloud = resultSet.getString(resultSet.getColumnIndex('id_cloud')); surveys.push(survey); } resultSet.close(); return surveys; } catch (error) { return []; } }
AST#method_declaration#Left async getAllSurveys AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Survey [ ] 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#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 . rdbStore 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 Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '[getAllSurveys]' AST#expression#Right , AST#expression#Left 'getAllSurveys() has no callback!' 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#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left predicates : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left relationalStore . RdbPredicates 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 relationalStore AST#expression#Right AST#new_expression#Right AST#expression#Right . RdbPredicates AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'surveys' 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 columns : 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#expression#Left 'id' AST#expression#Right , AST#expression#Left 'title' AST#expression#Right , AST#expression#Left 'description' AST#expression#Right , AST#expression#Left 'created_time' AST#expression#Right , AST#expression#Left 'status' AST#expression#Right , AST#expression#Left 'published_time' AST#expression#Right , AST#expression#Left 'closed_time' AST#expression#Right , AST#expression#Left 'deleted' AST#expression#Right , AST#expression#Left 'id_cloud' AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left resultSet : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left relationalStore . ResultSet AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . rdbStore AST#member_expression#Right AST#expression#Right . query AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left predicates AST#expression#Right , AST#expression#Left columns 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 surveys : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Survey [ ] 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#while_statement#Left while ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resultSet AST#expression#Right . goToNextRow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left survey : AST#type_annotation#Left AST#primary_type#Left Survey 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 Survey 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 AST#member_expression#Left AST#expression#Left survey AST#expression#Right . id AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resultSet AST#expression#Right . getLong 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 resultSet AST#expression#Right . getColumnIndex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'id' 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 AST#member_expression#Left AST#expression#Left survey AST#expression#Right . title AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resultSet AST#expression#Right . getString 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 resultSet AST#expression#Right . getColumnIndex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'title' 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 AST#member_expression#Left AST#expression#Left survey AST#expression#Right . description AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resultSet AST#expression#Right . getString 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 resultSet AST#expression#Right . getColumnIndex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'description' 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 AST#member_expression#Left AST#expression#Left survey AST#expression#Right . createdTime AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resultSet AST#expression#Right . getLong 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 resultSet AST#expression#Right . getColumnIndex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'created_time' 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 AST#member_expression#Left AST#expression#Left survey AST#expression#Right . status 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 resultSet AST#expression#Right . getString 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 resultSet AST#expression#Right . getColumnIndex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'status' 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 as AST#type_annotation#Left AST#primary_type#Left SurveyStatus 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#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left survey AST#expression#Right . publishedTime AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resultSet AST#expression#Right . getLong 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 resultSet AST#expression#Right . getColumnIndex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'published_time' 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 AST#member_expression#Left AST#expression#Left survey AST#expression#Right . closedTime AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resultSet AST#expression#Right . getLong 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 resultSet AST#expression#Right . getColumnIndex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'closed_time' 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 AST#member_expression#Left AST#expression#Left survey AST#expression#Right . deleted AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resultSet AST#expression#Right . getLong 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 resultSet AST#expression#Right . getColumnIndex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'deleted' 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 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left survey AST#expression#Right . id_cloud AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resultSet AST#expression#Right . getString 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 resultSet AST#expression#Right . getColumnIndex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'id_cloud' 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left surveys AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left survey 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#while_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 resultSet AST#expression#Right . close AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left surveys 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#return_statement#Left return AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async getAllSurveys(): Promise<Survey[]> { if (!this.rdbStore) { Logger.info('[getAllSurveys]', 'getAllSurveys() has no callback!'); return []; } try { const predicates: relationalStore.RdbPredicates = new relationalStore.RdbPredicates('surveys'); const columns: string[] = ['id', 'title', 'description', 'created_time', 'status', 'published_time', 'closed_time', 'deleted', 'id_cloud']; const resultSet: relationalStore.ResultSet = await this.rdbStore.query(predicates, columns); const surveys: Survey[] = []; while (resultSet.goToNextRow()) { const survey: Survey = new Survey(); survey.id = resultSet.getLong(resultSet.getColumnIndex('id')); survey.title = resultSet.getString(resultSet.getColumnIndex('title')); survey.description = resultSet.getString(resultSet.getColumnIndex('description')); survey.createdTime = resultSet.getLong(resultSet.getColumnIndex('created_time')); survey.status = resultSet.getString(resultSet.getColumnIndex('status')) as SurveyStatus; survey.publishedTime = resultSet.getLong(resultSet.getColumnIndex('published_time')); survey.closedTime = resultSet.getLong(resultSet.getColumnIndex('closed_time')); survey.deleted = resultSet.getLong(resultSet.getColumnIndex('deleted')) === 1; survey.id_cloud = resultSet.getString(resultSet.getColumnIndex('id_cloud')); surveys.push(survey); } resultSet.close(); return surveys; } catch (error) { return []; } }
https://github.com/JinnyWang-Space/guanlanwenjuan.git/blob/601c4aa6c427e643d7bf42bc21945f658738e38c/common/src/main/ets/database/DistributedDB.ets#L80-L114
428754e7aceff804b6aceaa4b8edc4956e496f7f
github
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
Distributed/OpenHarmonyPictureGame/entry/src/main/ets/MainAbility/pages/index.ets
arkts
onConnectRemoteService
连接远端Service
async function onConnectRemoteService(deviceId) { onDisconnectService() // 连接成功的回调 async function onConnectCallback(element, remote) { mRemote = remote; } // Service异常死亡的回调 function onDisconnectCallback(element) { } // 连接失败的回调 function onFailedCallback(code) { prompt.showToast({ message: "onConnectRemoteService onFailed: " + code }); } connectedAbility = await featureAbility.connectAbility( { deviceId: deviceId, bundleName: "com.pictureGame.pictureGame", abilityName: "com.example.openharmonypicturegame.ServiceAbility", }, { onConnect: onConnectCallback, onDisconnect: onDisconnectCallback, onFailed: onFailedCallback, }, ); }
AST#function_declaration#Left async function onConnectRemoteService AST#parameter_list#Left ( AST#parameter#Left deviceId 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 onDisconnectService 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#function_expression#Left async function onConnectCallback AST#parameter_list#Left ( AST#parameter#Left element AST#parameter#Right , AST#parameter#Left remote 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 mRemote = AST#expression#Left remote AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right // Service异常死亡的回调 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#function_expression#Left function onDisconnectCallback AST#parameter_list#Left ( AST#parameter#Left element AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { } AST#block_statement#Right AST#function_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right // 连接失败的回调 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#function_expression#Left function onFailedCallback AST#parameter_list#Left ( AST#parameter#Left code 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 prompt AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left "onConnectRemoteService onFailed: " AST#expression#Right + AST#expression#Left code AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_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 connectedAbility = 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 featureAbility AST#expression#Right AST#await_expression#Right AST#expression#Right . connectAbility 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 deviceId AST#property_name#Right : AST#expression#Left deviceId AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bundleName AST#property_name#Right : AST#expression#Left "com.pictureGame.pictureGame" AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left abilityName AST#property_name#Right : AST#expression#Left "com.example.openharmonypicturegame.ServiceAbility" 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 onConnect AST#property_name#Right : AST#expression#Left onConnectCallback AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left onDisconnect AST#property_name#Right : AST#expression#Left onDisconnectCallback AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left onFailed AST#property_name#Right : AST#expression#Left onFailedCallback AST#expression#Right AST#property_assignment#Right , } AST#object_literal#Right AST#expression#Right , AST#expression#Left 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#function_declaration#Right
async function onConnectRemoteService(deviceId) { onDisconnectService() async function onConnectCallback(element, remote) { mRemote = remote; } function onDisconnectCallback(element) { } function onFailedCallback(code) { prompt.showToast({ message: "onConnectRemoteService onFailed: " + code }); } connectedAbility = await featureAbility.connectAbility( { deviceId: deviceId, bundleName: "com.pictureGame.pictureGame", abilityName: "com.example.openharmonypicturegame.ServiceAbility", }, { onConnect: onConnectCallback, onDisconnect: onDisconnectCallback, onFailed: onFailedCallback, }, ); }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Distributed/OpenHarmonyPictureGame/entry/src/main/ets/MainAbility/pages/index.ets#L107-L136
611ac31610a170cb43e72717b09034e488f874e1
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/social/CommunityService.ets
arkts
通知类型枚举
export enum NotificationType { LIKE = 'like', COMMENT = 'comment', FOLLOW = 'follow', MENTION = 'mention', BIRTHDAY = 'birthday', EVENT = 'event', SYSTEM = 'system' }
AST#export_declaration#Left export AST#enum_declaration#Left enum NotificationType AST#enum_body#Left { AST#enum_member#Left LIKE = AST#expression#Left 'like' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left COMMENT = AST#expression#Left 'comment' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left FOLLOW = AST#expression#Left 'follow' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left MENTION = AST#expression#Left 'mention' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left BIRTHDAY = AST#expression#Left 'birthday' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left EVENT = AST#expression#Left 'event' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left SYSTEM = AST#expression#Left 'system' AST#expression#Right AST#enum_member#Right } AST#enum_body#Right AST#enum_declaration#Right AST#export_declaration#Right
export enum NotificationType { LIKE = 'like', COMMENT = 'comment', FOLLOW = 'follow', MENTION = 'mention', BIRTHDAY = 'birthday', EVENT = 'event', SYSTEM = 'system' }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/social/CommunityService.ets#L174-L182
13a9a5a66e0401768ff27a2929773dfe91d6eea8
github
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
feature/main/src/main/ets/view/CartPage.ets
arkts
CartContent
购物车页面内容视图 @returns {void} 无返回值
@Builder private CartContent() { if (this.vm.isEmpty) { EmptyCart(); } else { List({ space: 12 }) { // 空的 ListItem 用于分隔购物车商品和底部栏 ListItem() { } ForEach(this.vm.cartList, (cart: Cart) => { ListItem() { OrderGoodsCard({ data: cart, onGoodsClick: (goodsId: number): void => { GoodsNavigator.toDetail(goodsId); }, onQuantityChanged: (specId: number, count: number): void => { this.vm.updateSpecCount(cart.goodsId, specId, count); }, enableQuantityStepper: true, itemSelectSlotBuilder: (spec: CartGoodsSpec): void => { this.CheckboxSlot(cart.goodsId, spec); } }); } }, (cart: Cart): string => JSON.stringify(cart)); ListItem() { } } .width(P100) .padding({ left: $r("app.float.space_horizontal_medium"), right: $r("app.float.space_horizontal_medium"), }) .layoutWeight(1) .scrollBar(BarState.Off); } }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right private CartContent 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#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . vm AST#member_expression#Right AST#expression#Right . isEmpty AST#member_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left EmptyCart ( ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right } else { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left List ( 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 { // 空的 ListItem 用于分隔购物车商品和底部栏 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left ListItem ( ) AST#container_content_body#Left { } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#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 . vm AST#member_expression#Right AST#expression#Right . cartList AST#member_expression#Right AST#expression#Right , AST#ui_builder_arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left cart : AST#type_annotation#Left AST#primary_type#Left Cart 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 ListItem ( ) AST#container_content_body#Left { AST#ui_custom_component_statement#Left OrderGoodsCard ( AST#component_parameters#Left { AST#component_parameter#Left data : AST#expression#Left cart AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left onGoodsClick : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left goodsId : 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#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 GoodsNavigator AST#expression#Right . toDetail AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left goodsId 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#component_parameter#Right , AST#component_parameter#Left onQuantityChanged : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left specId : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left count : 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#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 . vm AST#member_expression#Right AST#expression#Right . updateSpecCount AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . goodsId AST#member_expression#Right AST#expression#Right , AST#expression#Left specId AST#expression#Right , AST#expression#Left count 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#component_parameter#Right , AST#component_parameter#Left enableQuantityStepper : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left itemSelectSlotBuilder : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left spec : AST#type_annotation#Left AST#primary_type#Left CartGoodsSpec 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . CheckboxSlot AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . goodsId AST#member_expression#Right AST#expression#Right , AST#expression#Left spec 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#component_parameter#Right } AST#component_parameters#Right ) ; AST#ui_custom_component_statement#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 AST#parameter_list#Left ( AST#parameter#Left cart : AST#type_annotation#Left AST#primary_type#Left Cart 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#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 cart AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#for_each_statement#Right AST#ui_control_flow#Right AST#ERROR#Left ; AST#ERROR#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left ListItem ( ) AST#container_content_body#Left { } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left P100 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 AST#resource_expression#Left $r ( AST#expression#Left "app.float.space_horizontal_medium" AST#expression#Right ) AST#resource_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#resource_expression#Left $r ( AST#expression#Left "app.float.space_horizontal_medium" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Left . scrollBar ( AST#expression#Left AST#member_expression#Left AST#expression#Left BarState AST#expression#Right . Off AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
@Builder private CartContent() { if (this.vm.isEmpty) { EmptyCart(); } else { List({ space: 12 }) { ListItem() { } ForEach(this.vm.cartList, (cart: Cart) => { ListItem() { OrderGoodsCard({ data: cart, onGoodsClick: (goodsId: number): void => { GoodsNavigator.toDetail(goodsId); }, onQuantityChanged: (specId: number, count: number): void => { this.vm.updateSpecCount(cart.goodsId, specId, count); }, enableQuantityStepper: true, itemSelectSlotBuilder: (spec: CartGoodsSpec): void => { this.CheckboxSlot(cart.goodsId, spec); } }); } }, (cart: Cart): string => JSON.stringify(cart)); ListItem() { } } .width(P100) .padding({ left: $r("app.float.space_horizontal_medium"), right: $r("app.float.space_horizontal_medium"), }) .layoutWeight(1) .scrollBar(BarState.Off); } }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/main/src/main/ets/view/CartPage.ets#L96-L135
1fcbbe7cc6f7b5c8e695545fd21a2dbdf8fbda8e
github
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
ETSUI/ArkTSComponents/entry/src/main/ets/view/Setting.ets
arkts
Setting
Setting tab content
@Component export default struct Setting { @Builder settingCell(item: ItemData) { Row() { Row({ space: CommonConstants.COMMON_SPACE }) { Image(item.img) .width($r('app.float.setting_size')) .height($r('app.float.setting_size')) Text(item.title) .fontSize($r('app.float.normal_text_size')) } if (item.others === null) { Image($r('app.media.right_grey')) .width($r('app.float.setting_jump_width')) .height($r('app.float.setting_jump_height')) } else { Toggle({ type: ToggleType.Switch, isOn: false }) } } .justifyContent(FlexAlign.SpaceBetween) .width(CommonConstants.FULL_PARENT) .padding({ left: $r('app.float.setting_settingCell_left'), right: $r('app.float.setting_settingCell_right') }) } build() { Scroll() { Column({ space: CommonConstants.COMMON_SPACE }) { Column(){ Text($r('app.string.mainPage_tabTitles_mine')) .fontWeight(FontWeight.Medium) .fontSize($r('app.float.page_title_text_size')) .margin({ top: $r('app.float.mainPage_tabTitles_margin') }) .padding({ left: $r('app.float.mainPage_tabTitles_padding') }) } .width(CommonConstants.FULL_PARENT) .alignItems(HorizontalAlign.Start) Row() { Image($r('app.media.account')) .width($r('app.float.setting_account_size')) .height($r('app.float.setting_account_size')) Column() { Text($r('app.string.setting_account_name')) .fontSize($r('app.float.setting_account_fontSize')) Text($r('app.string.setting_account_email')) .fontSize($r('app.float.little_text_size')) .margin({ top: $r('app.float.setting_name_margin') }) } .alignItems(HorizontalAlign.Start) .margin({ left: $r('app.float.setting_account_margin') }) } .margin({ top: $r('app.float.setting_account_margin') }) .alignItems(VerticalAlign.Center) .width(CommonConstants.FULL_PARENT) .height($r('app.float.setting_account_height')) .backgroundColor(Color.White) .padding({ left: $r('app.float.setting_account_padding') }) .borderRadius($r('app.float.setting_account_borderRadius')) List() { ForEach(mainViewModel.getSettingListData(), (item: ItemData) => { ListItem() { this.settingCell(item) } .height($r('app.float.setting_list_height')) }, (item: ItemData) => JSON.stringify(item)) } .backgroundColor(Color.White) .divider({ strokeWidth: $r('app.float.setting_list_strokeWidth'), color: Color.Grey, startMargin: $r('app.float.setting_list_startMargin'), endMargin: $r('app.float.setting_list_endMargin') }) .borderRadius($r('app.float.setting_list_borderRadius')) .padding({ top: $r('app.float.setting_list_padding'), bottom: $r('app.float.setting_list_padding') }) Blank() Button($r('app.string.setting_button'), { type: ButtonType.Capsule }) .width(CommonConstants.BUTTON_WIDTH) .height($r('app.float.login_button_height')) .fontSize($r('app.float.normal_text_size')) .fontColor($r('app.color.setting_button_fontColor')) .fontWeight(FontWeight.Medium) .backgroundColor($r('app.color.setting_button_backgroundColor')) .margin({ bottom: $r('app.float.setting_button_bottom')}) } .height(CommonConstants.FULL_PARENT) } } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export default struct Setting AST#component_body#Left { AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right settingCell AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left ItemData AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . COMMON_SPACE AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . img AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_size' 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 Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . title AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.normal_text_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#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 item AST#expression#Right . others 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#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.right_grey' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_jump_width' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_jump_height' 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 } else { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Toggle ( AST#component_parameters#Left { AST#component_parameter#Left type : AST#expression#Left AST#member_expression#Left AST#expression#Left ToggleType AST#expression#Right . Switch AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left isOn : 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#ui_if_statement#Right AST#ui_control_flow#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 . SpaceBetween AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FULL_PARENT AST#member_expression#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 left AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_settingCell_left' AST#expression#Right ) AST#resource_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#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_settingCell_right' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#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 Scroll ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . COMMON_SPACE 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 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#resource_expression#Left $r ( AST#expression#Left 'app.string.mainPage_tabTitles_mine' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#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 . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.page_title_text_size' 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 AST#resource_expression#Left $r ( AST#expression#Left 'app.float.mainPage_tabTitles_margin' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#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 AST#resource_expression#Left $r ( AST#expression#Left 'app.float.mainPage_tabTitles_padding' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FULL_PARENT 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 . Start 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#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.account' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_account_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_account_size' 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 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#resource_expression#Left $r ( AST#expression#Left 'app.string.setting_account_name' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_account_fontSize' AST#expression#Right ) AST#resource_expression#Right 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#resource_expression#Left $r ( AST#expression#Left 'app.string.setting_account_email' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.little_text_size' 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 AST#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_name_margin' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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 . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_account_margin' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#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 top AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_account_margin' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left VerticalAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FULL_PARENT AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_account_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . White AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_account_padding' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_account_borderRadius' 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#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left List ( ) AST#container_content_body#Left { AST#ui_control_flow#Left AST#for_each_statement#Left ForEach ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left mainViewModel AST#expression#Right . getSettingListData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_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 ItemData 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 ListItem ( ) 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 . settingCell AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left item AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_list_height' AST#expression#Right ) AST#resource_expression#Right AST#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 ItemData AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left item AST#expression#Right ) AST#argument_list#Right AST#call_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 . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . White AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . divider ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left strokeWidth AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_list_strokeWidth' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Grey AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left startMargin AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_list_startMargin' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left endMargin AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_list_endMargin' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_list_borderRadius' AST#expression#Right ) AST#resource_expression#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 AST#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_list_padding' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_list_padding' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right 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#ERROR#Left AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.setting_button' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#ERROR#Right AST#component_parameters#Left { AST#component_parameter#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#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . BUTTON_WIDTH AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.login_button_height' 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 'app.float.normal_text_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.setting_button_fontColor' 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 . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.setting_button_backgroundColor' 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 bottom AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_button_bottom' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FULL_PARENT AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Component export default struct Setting { @Builder settingCell(item: ItemData) { Row() { Row({ space: CommonConstants.COMMON_SPACE }) { Image(item.img) .width($r('app.float.setting_size')) .height($r('app.float.setting_size')) Text(item.title) .fontSize($r('app.float.normal_text_size')) } if (item.others === null) { Image($r('app.media.right_grey')) .width($r('app.float.setting_jump_width')) .height($r('app.float.setting_jump_height')) } else { Toggle({ type: ToggleType.Switch, isOn: false }) } } .justifyContent(FlexAlign.SpaceBetween) .width(CommonConstants.FULL_PARENT) .padding({ left: $r('app.float.setting_settingCell_left'), right: $r('app.float.setting_settingCell_right') }) } build() { Scroll() { Column({ space: CommonConstants.COMMON_SPACE }) { Column(){ Text($r('app.string.mainPage_tabTitles_mine')) .fontWeight(FontWeight.Medium) .fontSize($r('app.float.page_title_text_size')) .margin({ top: $r('app.float.mainPage_tabTitles_margin') }) .padding({ left: $r('app.float.mainPage_tabTitles_padding') }) } .width(CommonConstants.FULL_PARENT) .alignItems(HorizontalAlign.Start) Row() { Image($r('app.media.account')) .width($r('app.float.setting_account_size')) .height($r('app.float.setting_account_size')) Column() { Text($r('app.string.setting_account_name')) .fontSize($r('app.float.setting_account_fontSize')) Text($r('app.string.setting_account_email')) .fontSize($r('app.float.little_text_size')) .margin({ top: $r('app.float.setting_name_margin') }) } .alignItems(HorizontalAlign.Start) .margin({ left: $r('app.float.setting_account_margin') }) } .margin({ top: $r('app.float.setting_account_margin') }) .alignItems(VerticalAlign.Center) .width(CommonConstants.FULL_PARENT) .height($r('app.float.setting_account_height')) .backgroundColor(Color.White) .padding({ left: $r('app.float.setting_account_padding') }) .borderRadius($r('app.float.setting_account_borderRadius')) List() { ForEach(mainViewModel.getSettingListData(), (item: ItemData) => { ListItem() { this.settingCell(item) } .height($r('app.float.setting_list_height')) }, (item: ItemData) => JSON.stringify(item)) } .backgroundColor(Color.White) .divider({ strokeWidth: $r('app.float.setting_list_strokeWidth'), color: Color.Grey, startMargin: $r('app.float.setting_list_startMargin'), endMargin: $r('app.float.setting_list_endMargin') }) .borderRadius($r('app.float.setting_list_borderRadius')) .padding({ top: $r('app.float.setting_list_padding'), bottom: $r('app.float.setting_list_padding') }) Blank() Button($r('app.string.setting_button'), { type: ButtonType.Capsule }) .width(CommonConstants.BUTTON_WIDTH) .height($r('app.float.login_button_height')) .fontSize($r('app.float.normal_text_size')) .fontColor($r('app.color.setting_button_fontColor')) .fontWeight(FontWeight.Medium) .backgroundColor($r('app.color.setting_button_backgroundColor')) .margin({ bottom: $r('app.float.setting_button_bottom')}) } .height(CommonConstants.FULL_PARENT) } } }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/ETSUI/ArkTSComponents/entry/src/main/ets/view/Setting.ets#L23-L118
9b14d0c129950a140e07cc642a61001b471d09d4
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/LocationUtil.ets
arkts
getCurrentLocationEasy
获取当前位置,通过callback方式异步返回结果。 @param callBack @returns 失败返回错误码,成功返回0。
static async getCurrentLocationEasy(): Promise<geoLocationManager.Location> { return LocationUtil.getCurrentLocation(); }
AST#method_declaration#Left static async getCurrentLocationEasy AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left geoLocationManager . Location AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#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 LocationUtil AST#expression#Right . getCurrentLocation AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static async getCurrentLocationEasy(): Promise<geoLocationManager.Location> { return LocationUtil.getCurrentLocation(); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/LocationUtil.ets#L59-L61
9aa48d38e399685f724392b9c50c76369ccea953
gitee
2763981847/Clock-Alarm.git
8949bedddb7d011021848196735f30ffe2bd1daf
entry/src/main/ets/view/BackContainer.ets
arkts
定义组件的渲染函数
build() { Row() { // 创建返回按钮 Button() { // 设置按钮的图像,如果未设置 backImgRes,则使用默认图像 "app.media.ic_public_back" Image(this.backImgRes == null ? $r('app.media.ic_public_back') : this.backImgRes).objectFit(ImageFit.Fill) } // 设置按钮的背景颜色为透明 .backgroundColor($r('app.color.trans_parent')) // 设置按钮的宽度和高度,使用 DimensionUtil.getVp 获取尺寸 .width(DimensionUtil.getVp($r('app.float.title_button_size'))) .height(DimensionUtil.getVp($r('app.float.title_button_size'))) // 定义按钮的点击事件 .onClick(() => { // 如果设置了 backFunc,执行 backFunc;否则,执行默认的路由返回操作 this.backFunc ? this.backFunc() : router.back(); }) // 创建标题文本 Text(this.header) // 设置文本的字体大小、行高、左边距、字体颜色、字体粗细 .fontSize(DimensionUtil.getFp($r('app.float.detail_title_font_size'))) .lineHeight(DimensionUtil.getVp($r('app.float.title_line_height'))) .margin({ left: DimensionUtil.getVp($r('app.float.title_margin')) }) .fontColor($r('app.color.grey_divider')) .fontWeight(FontWeight.Bold) // 创建一个空白组件,用于添加关闭按钮 Blank() // 调用传入的组件闭包 this.closer(); } // 设置整个容器的内边距 .padding({ left: DimensionUtil.getVp($r('app.float.title_horizon_margin')), right: DimensionUtil.getVp($r('app.float.title_horizon_margin')) }) // 设置整个容器的高度和宽度 .height(DimensionUtil.getVp($r("app.float.page_header_height"))) .width(CommonConstants.FULL_LENGTH) }
AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { // 创建返回按钮 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( ) AST#container_content_body#Left { // 设置按钮的图像,如果未设置 backImgRes,则使用默认图像 "app.media.ic_public_back" 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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . backImgRes 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 AST#resource_expression#Left $r ( AST#expression#Left 'app.media.ic_public_back' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left this AST#expression#Right AST#conditional_expression#Right AST#expression#Right . backImgRes AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . objectFit ( AST#expression#Left AST#member_expression#Left AST#expression#Left ImageFit AST#expression#Right . Fill AST#member_expression#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 . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.trans_parent' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) // 设置按钮的宽度和高度,使用 DimensionUtil.getVp 获取尺寸 AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DimensionUtil AST#expression#Right . getVp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.title_button_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DimensionUtil AST#expression#Right . getVp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.title_button_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_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 { // 如果设置了 backFunc,执行 backFunc;否则,执行默认的路由返回操作 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#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . backFunc AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . backFunc 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 router AST#expression#Right AST#conditional_expression#Right AST#expression#Right . back AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 创建标题文本 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . header AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right // 设置文本的字体大小、行高、左边距、字体颜色、字体粗细 AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DimensionUtil AST#expression#Right . getFp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.detail_title_font_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . lineHeight ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DimensionUtil AST#expression#Right . getVp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.title_line_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DimensionUtil AST#expression#Right . getVp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.title_margin' AST#expression#Right ) AST#resource_expression#Right 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#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.grey_divider' 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#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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . closer 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#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 AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DimensionUtil AST#expression#Right . getVp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.title_horizon_margin' AST#expression#Right ) AST#resource_expression#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 right AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DimensionUtil AST#expression#Right . getVp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.title_horizon_margin' AST#expression#Right ) AST#resource_expression#Right 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#Left . height ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DimensionUtil AST#expression#Right . getVp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.float.page_header_height" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FULL_LENGTH 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() { Row() { Button() { Image(this.backImgRes == null ? $r('app.media.ic_public_back') : this.backImgRes).objectFit(ImageFit.Fill) } .backgroundColor($r('app.color.trans_parent')) .width(DimensionUtil.getVp($r('app.float.title_button_size'))) .height(DimensionUtil.getVp($r('app.float.title_button_size'))) .onClick(() => { this.backFunc ? this.backFunc() : router.back(); }) Text(this.header) .fontSize(DimensionUtil.getFp($r('app.float.detail_title_font_size'))) .lineHeight(DimensionUtil.getVp($r('app.float.title_line_height'))) .margin({ left: DimensionUtil.getVp($r('app.float.title_margin')) }) .fontColor($r('app.color.grey_divider')) .fontWeight(FontWeight.Bold) Blank() this.closer(); } .padding({ left: DimensionUtil.getVp($r('app.float.title_horizon_margin')), right: DimensionUtil.getVp($r('app.float.title_horizon_margin')) }) .height(DimensionUtil.getVp($r("app.float.page_header_height"))) .width(CommonConstants.FULL_LENGTH) }
https://github.com/2763981847/Clock-Alarm.git/blob/8949bedddb7d011021848196735f30ffe2bd1daf/entry/src/main/ets/view/BackContainer.ets#L22-L63
1f4c5a05174a0a5cb0020e361a8809f9ee56bbdb
github
zl3624/harmonyos_network_samples
b8664f8bf6ef5c5a60830fe616c6807e83c21f96
code/tls/TCPBaseTLSClient/entry/src/main/ets/pages/Index.ets
arkts
sendMsg2Server
发送消息到服务端
sendMsg2Server() { this.tlsSocket?.send(this.sendMsg + "\r\n") .then(async () => { this.msgHistory += "我:" + this.sendMsg + "\r\n" }) .catch((err: BusinessError) => { this.msgHistory += `发送失败:错误码 ${err.code}, 错误信息 ${JSON.stringify(err)}\r\n`; }) }
AST#method_declaration#Left sendMsg2Server 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#member_expression#Left AST#expression#Left this AST#expression#Right . tlsSocket AST#member_expression#Right AST#expression#Right ?. send 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 this AST#expression#Right . sendMsg AST#member_expression#Right AST#expression#Right + AST#expression#Left "\r\n" AST#expression#Right AST#binary_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 async 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 . msgHistory AST#member_expression#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#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . sendMsg AST#member_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#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#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 ` 发送失败:错误码 AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , 错误信息 AST#template_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#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
sendMsg2Server() { this.tlsSocket?.send(this.sendMsg + "\r\n") .then(async () => { this.msgHistory += "我:" + this.sendMsg + "\r\n" }) .catch((err: BusinessError) => { this.msgHistory += `发送失败:错误码 ${err.code}, 错误信息 ${JSON.stringify(err)}\r\n`; }) }
https://github.com/zl3624/harmonyos_network_samples/blob/b8664f8bf6ef5c5a60830fe616c6807e83c21f96/code/tls/TCPBaseTLSClient/entry/src/main/ets/pages/Index.ets#L135-L143
a6c204160de6258947dbb64cab5e5e7be31f9202
gitee
awa_Liny/LinysBrowser_NEXT
a5cd96a9aa8114cae4972937f94a8967e55d4a10
home/src/main/ets/hosts/bunch_of_tabs.ets
arkts
can_save_history
Checks if this url can be saved to history. meow:// pages are not allowed. @param url The url. @returns True if can.
private can_save_history(url: string) { if (url.substring(0, 7) == 'meow://') { return false; } return true; }
AST#method_declaration#Left private can_save_history 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#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 { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private can_save_history(url: string) { if (url.substring(0, 7) == 'meow://') { return false; } return true; }
https://github.com/awa_Liny/LinysBrowser_NEXT/blob/a5cd96a9aa8114cae4972937f94a8967e55d4a10/home/src/main/ets/hosts/bunch_of_tabs.ets#L1037-L1042
757d21b29d7b15ffce226c992c45eac1b5041d54
gitee
liuchao0739/arkTS_universal_starter.git
0ca845f5ae0e78db439dc09f712d100c0dd46ed3
entry/src/main/ets/pages/Login.ets
arkts
handleLogin
登录
async handleLogin(): Promise<void> { if (!this.username || !this.password) { this.errorMessage = '请输入用户名和密码'; return; } this.loading = true; this.errorMessage = ''; try { const success = await AuthService.login({ username: this.username, password: this.password }); if (success) { Logger.event('login_success'); Router.replace(Routes.MAIN_TAB); } else { this.errorMessage = '登录失败,请检查用户名和密码'; } } catch (error) { this.errorMessage = '登录失败,请稍后重试'; Logger.error('LoginPage', `Login error: ${error}`); } finally { this.loading = false; } }
AST#method_declaration#Left async handleLogin 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#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#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . username 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 . password 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 . errorMessage AST#member_expression#Right = AST#expression#Left '请输入用户名和密码' AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . errorMessage AST#member_expression#Right = AST#expression#Left '' AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left success = 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 AuthService AST#expression#Right AST#await_expression#Right AST#expression#Right . login 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 username AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . username AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left password AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . password AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left success AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . event AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'login_success' 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 Router AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left Routes AST#expression#Right . MAIN_TAB 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . errorMessage AST#member_expression#Right = AST#expression#Left '登录失败,请检查用户名和密码' AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . errorMessage AST#member_expression#Right = AST#expression#Left '登录失败,请稍后重试' AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'LoginPage' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Login error: 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#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
async handleLogin(): Promise<void> { if (!this.username || !this.password) { this.errorMessage = '请输入用户名和密码'; return; } this.loading = true; this.errorMessage = ''; try { const success = await AuthService.login({ username: this.username, password: this.password }); if (success) { Logger.event('login_success'); Router.replace(Routes.MAIN_TAB); } else { this.errorMessage = '登录失败,请检查用户名和密码'; } } catch (error) { this.errorMessage = '登录失败,请稍后重试'; Logger.error('LoginPage', `Login error: ${error}`); } finally { this.loading = false; } }
https://github.com/liuchao0739/arkTS_universal_starter.git/blob/0ca845f5ae0e78db439dc09f712d100c0dd46ed3/entry/src/main/ets/pages/Login.ets#L28-L55
204f84777140dc1b37c95b4ad2a580113d4c290c
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/lunar/LunarService.ets
arkts
calculateLunarBirthdayInfo
计算农历生日信息 @param birthYear 出生年份(农历) @param birthMonth 出生月份(农历) @param birthDay 出生日期(农历) @param isLeapMonth 是否闰月 @returns 农历生日信息
async calculateLunarBirthdayInfo( birthYear: number, birthMonth: number, birthDay: number, isLeapMonth: boolean ): Promise<LunarBirthdayInfo | null> { try { const currentYear = new Date().getFullYear(); const nextYear = currentYear + 1; // 获取今年的农历生日对应公历日期 const currentYearDate = LunarUtils.getLunarBirthdaySolarDate( birthYear, birthMonth, birthDay, isLeapMonth, currentYear ); // 获取明年的农历生日对应公历日期 const nextYearDate = LunarUtils.getLunarBirthdaySolarDate( birthYear, birthMonth, birthDay, isLeapMonth, nextYear ); // 计算距离生日的天数 let daysUntilBirthday = 365; // 默认值 let targetBirthdayDate = currentYearDate; if (currentYearDate) { const today = new Date(); const birthday = new Date(currentYearDate); if (birthday >= today) { // 今年生日还未过 daysUntilBirthday = DateUtils.getDaysBetween(today, birthday); } else if (nextYearDate) { // 今年生日已过,计算到明年生日的天数 const nextBirthday = new Date(nextYearDate); daysUntilBirthday = DateUtils.getDaysBetween(today, nextBirthday); targetBirthdayDate = nextYearDate; } } // 计算年龄(按农历计算) const currentLunar = await this.getCurrentLunarDate(); let age = 0; if (currentLunar) { age = currentLunar.year - birthYear; // 如果今年的农历生日还未到,年龄减1 if (currentLunar.month < birthMonth || (currentLunar.month === birthMonth && currentLunar.day < birthDay)) { age--; } } // 原始生日的公历日期 const originalSolarDate = LunarUtils.lunarToSolar(birthYear, birthMonth, birthDay, isLeapMonth); return { originalDate: originalSolarDate || '', currentYearDate, nextYearDate, daysUntilBirthday, age: Math.max(0, age) }; } catch (error) { hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to calculate lunar birthday info: ${error}`); return null; } }
AST#method_declaration#Left async calculateLunarBirthdayInfo AST#parameter_list#Left ( AST#parameter#Left birthYear : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left birthMonth : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left birthDay : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left isLeapMonth : 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 AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left LunarBirthdayInfo AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left currentYear = 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 . getFullYear 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 nextYear = AST#expression#Left AST#binary_expression#Left AST#expression#Left currentYear 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 currentYearDate = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LunarUtils AST#expression#Right . getLunarBirthdaySolarDate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left birthYear AST#expression#Right , AST#expression#Left birthMonth AST#expression#Right , AST#expression#Left birthDay AST#expression#Right , AST#expression#Left isLeapMonth AST#expression#Right , AST#expression#Left currentYear 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 nextYearDate = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LunarUtils AST#expression#Right . getLunarBirthdaySolarDate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left birthYear AST#expression#Right , AST#expression#Left birthMonth AST#expression#Right , AST#expression#Left birthDay AST#expression#Right , AST#expression#Left isLeapMonth AST#expression#Right , AST#expression#Left nextYear 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 daysUntilBirthday = AST#expression#Left 365 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 targetBirthdayDate = AST#expression#Left currentYearDate 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 currentYearDate AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left today = 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 AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left birthday = 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 currentYearDate 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 birthday AST#expression#Right >= AST#expression#Left today 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 daysUntilBirthday = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DateUtils AST#expression#Right . getDaysBetween AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left today AST#expression#Right , AST#expression#Left birthday 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 else AST#if_statement#Left if ( AST#expression#Left nextYearDate AST#expression#Right ) AST#block_statement#Left { // 今年生日已过,计算到明年生日的天数 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left nextBirthday = 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 nextYearDate 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 daysUntilBirthday = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DateUtils AST#expression#Right . getDaysBetween AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left today AST#expression#Right , AST#expression#Left nextBirthday 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 targetBirthdayDate = AST#expression#Left nextYearDate 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#if_statement#Right AST#statement#Right // 计算年龄(按农历计算) AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left currentLunar = 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 . getCurrentLunarDate 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 age = 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 currentLunar AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left age = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left currentLunar AST#expression#Right . year AST#member_expression#Right AST#expression#Right - AST#expression#Left birthYear AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_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#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left currentLunar AST#expression#Right . month AST#member_expression#Right AST#expression#Right < AST#expression#Left birthMonth AST#expression#Right AST#binary_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 currentLunar AST#expression#Right . month AST#member_expression#Right AST#expression#Right === AST#expression#Left birthMonth AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left currentLunar AST#expression#Right AST#binary_expression#Right AST#expression#Right . day AST#member_expression#Right AST#expression#Right < AST#expression#Left birthDay AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#update_expression#Left AST#expression#Left age 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#statement#Right // 原始生日的公历日期 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left originalSolarDate = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LunarUtils AST#expression#Right . lunarToSolar AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left birthYear AST#expression#Right , AST#expression#Left birthMonth AST#expression#Right , AST#expression#Left birthDay AST#expression#Right , AST#expression#Left isLeapMonth 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 originalDate AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left originalSolarDate AST#expression#Right || AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left currentYearDate AST#property_assignment#Right , AST#property_assignment#Left nextYearDate AST#property_assignment#Right , AST#property_assignment#Left daysUntilBirthday AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left age AST#property_name#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 0 AST#expression#Right , AST#expression#Left age 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#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 ` Failed to calculate lunar birthday info: 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#null_literal#Left null AST#null_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
async calculateLunarBirthdayInfo( birthYear: number, birthMonth: number, birthDay: number, isLeapMonth: boolean ): Promise<LunarBirthdayInfo | null> { try { const currentYear = new Date().getFullYear(); const nextYear = currentYear + 1; const currentYearDate = LunarUtils.getLunarBirthdaySolarDate( birthYear, birthMonth, birthDay, isLeapMonth, currentYear ); const nextYearDate = LunarUtils.getLunarBirthdaySolarDate( birthYear, birthMonth, birthDay, isLeapMonth, nextYear ); let daysUntilBirthday = 365; let targetBirthdayDate = currentYearDate; if (currentYearDate) { const today = new Date(); const birthday = new Date(currentYearDate); if (birthday >= today) { daysUntilBirthday = DateUtils.getDaysBetween(today, birthday); } else if (nextYearDate) { const nextBirthday = new Date(nextYearDate); daysUntilBirthday = DateUtils.getDaysBetween(today, nextBirthday); targetBirthdayDate = nextYearDate; } } const currentLunar = await this.getCurrentLunarDate(); let age = 0; if (currentLunar) { age = currentLunar.year - birthYear; if (currentLunar.month < birthMonth || (currentLunar.month === birthMonth && currentLunar.day < birthDay)) { age--; } } const originalSolarDate = LunarUtils.lunarToSolar(birthYear, birthMonth, birthDay, isLeapMonth); return { originalDate: originalSolarDate || '', currentYearDate, nextYearDate, daysUntilBirthday, age: Math.max(0, age) }; } catch (error) { hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to calculate lunar birthday info: ${error}`); return null; } }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/lunar/LunarService.ets#L215-L288
45f1b1a3de47c3cae288a7acf7921626feaf07ba
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
harmonyos/src/main/ets/common/types/SettingsTypes.ets
arkts
新增SettingsService需要的接口定义 通知设置接口
export interface NotificationSettings { enabled: boolean; methods: NotificationMethod[]; sound: boolean; vibration: boolean; showPreview: boolean; quietHours: QuietHoursConfig; }
AST#export_declaration#Left export AST#interface_declaration#Left interface NotificationSettings 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 methods : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left NotificationMethod [ ] AST#array_type#Right 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 showPreview : 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 quietHours : AST#type_annotation#Left AST#primary_type#Left QuietHoursConfig 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 NotificationSettings { enabled: boolean; methods: NotificationMethod[]; sound: boolean; vibration: boolean; showPreview: boolean; quietHours: QuietHoursConfig; }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/harmonyos/src/main/ets/common/types/SettingsTypes.ets#L512-L519
9dd870c25299d6b7c45aaf449572c164762171aa
github
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
AvoidTimeComsume/entry/src/main/ets/views/WaterFlowDataSource.ets
arkts
notifyDataReload
Notify the controller of the data reload
notifyDataReload(): void { this.listeners.forEach(listener => { listener.onDataReloaded(); }); }
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
notifyDataReload(): void { this.listeners.forEach(listener => { listener.onDataReloaded(); }); }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/AvoidTimeComsume/entry/src/main/ets/views/WaterFlowDataSource.ets#L32-L36
6734a99e447eeb272c7117e4eb68ff5ac3788b83
gitee
openharmony/developtools_profiler
73d26bb5acfcafb2b1f4f94ead5640241d1e5f73
host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/formatter/IValueFormatter.ets
arkts
Interface that allows custom formatting of all values inside the chart before they are being drawn to the screen. Simply create your own formatting class and let it implement IValueFormatter. Then override the getFormattedValue(...) method and return whatever you want. @author Philipp Jahoda
export default interface
AST#export_declaration#Left export default AST#expression#Left interface AST#expression#Right AST#export_declaration#Right
export default interface
https://github.com/openharmony/developtools_profiler/blob/73d26bb5acfcafb2b1f4f94ead5640241d1e5f73/host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/formatter/IValueFormatter.ets#L26-L26
deca09161d139a17b00fe0ed03bfe3f33b0e1bce
gitee
sithvothykiv/dialog_hub.git
b676c102ef2d05f8994d170abe48dcc40cd39005
custom_dialog/src/main/ets/core/proxy/BaseBuilderProxy.ets
arkts
autoCancel
是否自动取消 @description 默认为true @param autoCancel @returns
autoCancel(autoCancel: boolean) { this.builderOptions.autoCancel = autoCancel; return this; }
AST#method_declaration#Left autoCancel AST#parameter_list#Left ( AST#parameter#Left autoCancel : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . builderOptions AST#member_expression#Right AST#expression#Right . autoCancel AST#member_expression#Right = AST#expression#Left autoCancel 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 this AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
autoCancel(autoCancel: boolean) { this.builderOptions.autoCancel = autoCancel; return this; }
https://github.com/sithvothykiv/dialog_hub.git/blob/b676c102ef2d05f8994d170abe48dcc40cd39005/custom_dialog/src/main/ets/core/proxy/BaseBuilderProxy.ets#L110-L113
058b3a9c80d6ab2aa165b14adf560d8659e60d33
github
openharmony-tpc/ohos_mpchart
4fb43a7137320ef2fee2634598f53d93975dfb4a
library/src/main/ets/components/components/ComponentBase.ets
arkts
setYOffset
Sets the used y-axis offset for the labels on this axis. For the legend, higher offset means the legend as a whole will be placed further away from the top. @param yOffset
public setYOffset(yOffset: number): void { this.mYOffset = Utils.handleDataValues(yOffset); }
AST#method_declaration#Left public setYOffset AST#parameter_list#Left ( AST#parameter#Left yOffset : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mYOffset AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Utils AST#expression#Right . handleDataValues AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left yOffset AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
public setYOffset(yOffset: number): void { this.mYOffset = Utils.handleDataValues(yOffset); }
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/components/ComponentBase.ets#L90-L92
d57e75aae432299d8aa21189793a912d56bf5ea6
gitee
conrad_sheeran/TickAuth
8ef852e12999d15cf70394cdab82d08ac5843143
features/steam/src/main/ets/model/SteamTOTPModel.ets
arkts
Copyright (c) 2024 Yang He TickAuth is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
export class SecretClass { alias: string = ""; secret: string = ""; digit: number = 6; timeStep: number = 30; algorithm: string = "SHA1"; constructor(alias: string, secret: string, digit: number, timeStep: number, algorithm: string ) { this.alias = alias; this.secret = secret; this.digit = digit; this.timeStep = timeStep; this.algorithm = algorithm; } }
AST#export_declaration#Left export AST#class_declaration#Left class SecretClass AST#class_body#Left { AST#property_declaration#Left alias : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "" AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left secret : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "" AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left digit : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 6 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left timeStep : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 30 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left algorithm : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "SHA1" AST#expression#Right ; AST#property_declaration#Right AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left alias : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left secret : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left digit : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left timeStep : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left algorithm : 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 . alias AST#member_expression#Right = AST#expression#Left alias 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 . secret AST#member_expression#Right = AST#expression#Left secret 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 . digit AST#member_expression#Right = AST#expression#Left digit 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 . timeStep AST#member_expression#Right = AST#expression#Left timeStep 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 . algorithm AST#member_expression#Right = AST#expression#Left algorithm AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class SecretClass { alias: string = ""; secret: string = ""; digit: number = 6; timeStep: number = 30; algorithm: string = "SHA1"; constructor(alias: string, secret: string, digit: number, timeStep: number, algorithm: string ) { this.alias = alias; this.secret = secret; this.digit = digit; this.timeStep = timeStep; this.algorithm = algorithm; } }
https://github.com/conrad_sheeran/TickAuth/blob/8ef852e12999d15cf70394cdab82d08ac5843143/features/steam/src/main/ets/model/SteamTOTPModel.ets#L35-L49
513e1dcd43fabe05ce679622555ac20ca96e5d00
gitee
L1rics06/arkTS-.git
991fd131bfdb11e2933152133c97453d86092ac0
entry/src/main/ets/pages/NetworkUtil.ets
arkts
clearUnread
清空未读消息
static async clearUnread(myId: string, friendId: string): Promise<ResponseDao<null>> { try { const params: ClearUnreadParams = { myId, friendId }; const response: AxiosResponse<ResponseDao<null>> = await axios.post( `${BASE_URL}/ddchat/friend/clearUnread`, params, { headers: NetworkUtil.mergeHeaders("application/json") } ); return response.data; } catch (error) { console.error("Clear unread error:", JSON.stringify(error)); throw new Error(`Failed to clear unread messages: ${JSON.stringify(error)}`); } }
AST#method_declaration#Left static async clearUnread AST#parameter_list#Left ( AST#parameter#Left myId : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left friendId : 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 ResponseDao AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left null 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#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left params : AST#type_annotation#Left AST#primary_type#Left ClearUnreadParams AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left myId AST#property_assignment#Right , AST#property_assignment#Left friendId AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left response : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left AxiosResponse AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left ResponseDao AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left null AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left axios AST#expression#Right AST#await_expression#Right AST#expression#Right . post 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 BASE_URL AST#expression#Right } AST#template_substitution#Right /ddchat/friend/clearUnread ` AST#template_literal#Right AST#expression#Right , AST#expression#Left params AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left headers AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left NetworkUtil AST#expression#Right . mergeHeaders AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "application/json" 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#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#member_expression#Left AST#expression#Left response AST#expression#Right . data AST#member_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 "Clear unread error:" AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#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 ` Failed to clear unread messages: 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 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#method_declaration#Right
static async clearUnread(myId: string, friendId: string): Promise<ResponseDao<null>> { try { const params: ClearUnreadParams = { myId, friendId }; const response: AxiosResponse<ResponseDao<null>> = await axios.post( `${BASE_URL}/ddchat/friend/clearUnread`, params, { headers: NetworkUtil.mergeHeaders("application/json") } ); return response.data; } catch (error) { console.error("Clear unread error:", JSON.stringify(error)); throw new Error(`Failed to clear unread messages: ${JSON.stringify(error)}`); } }
https://github.com/L1rics06/arkTS-.git/blob/991fd131bfdb11e2933152133c97453d86092ac0/entry/src/main/ets/pages/NetworkUtil.ets#L494-L510
8ad95ed8e067b09584d4ae4099c5ba070b5c6b3c
github
xixi-cquer/BiJiDaiBan.git
206dc33a837acbe6fc837feff848427e83946534
entry/src/main/ets/viewmodel/DataModel.ets
arkts
getData
Get the data.
getData(): Array<Array<string>> { function ascend(x,y){ return x[1] - y[1]; //按照数组的第4个值升序排列 } this.tasks=this.tasks.sort(ascend); return this.tasks; }
AST#method_declaration#Left getData 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 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#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#function_expression#Left function ascend AST#parameter_list#Left ( AST#parameter#Left x AST#parameter#Right , AST#parameter#Left y AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left x AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right - AST#expression#Left AST#subscript_expression#Left AST#expression#Left y AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right //按照数组的第4个值升序排列 } AST#block_statement#Right AST#function_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 . tasks 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 . tasks AST#member_expression#Right AST#expression#Right . sort AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left ascend AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left 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 . tasks AST#member_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
getData(): Array<Array<string>> { function ascend(x,y){ return x[1] - y[1]; } this.tasks=this.tasks.sort(ascend); return this.tasks; }
https://github.com/xixi-cquer/BiJiDaiBan.git/blob/206dc33a837acbe6fc837feff848427e83946534/entry/src/main/ets/viewmodel/DataModel.ets#L30-L36
078ff818785d459a439cda3713c5b49e8b12b998
github
Joker-x-dev/HarmonyKit.git
f97197ce157df7f303244fba42e34918306dfb08
core/ui/src/main/ets/component/empty/EmptyNetwork.ets
arkts
构建网络缺省页视图 @returns {void} 无返回值
build(): void { Empty({ description: this.description, imageRes: $r("app.media.ic_empty_network"), actionText: this.actionText, onAction: this.onAction }); }
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 Empty ( AST#component_parameters#Left { AST#component_parameter#Left description : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . description AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left imageRes : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.media.ic_empty_network" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left actionText : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . actionText AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left onAction : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . onAction AST#member_expression#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
build(): void { Empty({ description: this.description, imageRes: $r("app.media.ic_empty_network"), actionText: this.actionText, onAction: this.onAction }); }
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/ui/src/main/ets/component/empty/EmptyNetwork.ets#L29-L36
308e5a9592a1deb440d33e1b1b8c23c5e4fdece5
github
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_crypto/src/main/ets/crypto/util/CryptoUtil.ets
arkts
generateSymKey
生成对称密钥 @param symAlgName 秘钥规格 @returns 指定秘钥规格的对称密钥
static async generateSymKey(symAlgName: string): Promise<string> { // 创建对称密钥生成器 let symKeyGenerator = crypto.createSymKeyGenerator(symAlgName); // 通过非对称密钥生成器,随机生成非对称密钥 let promiseSymKey = await symKeyGenerator.generateSymKey(); //转换成可以读懂的字符串 return StrAndUintUtil.unitArray2String(promiseSymKey.getEncoded().data); }
AST#method_declaration#Left static async generateSymKey AST#parameter_list#Left ( 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_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { // 创建对称密钥生成器 AST#statement#Left AST#variable_declaration#Left 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 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 promiseSymKey = 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 symKeyGenerator AST#expression#Right AST#await_expression#Right AST#expression#Right . generateSymKey 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 StrAndUintUtil AST#expression#Right . unitArray2String AST#member_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 promiseSymKey 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#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 generateSymKey(symAlgName: string): Promise<string> { let symKeyGenerator = crypto.createSymKeyGenerator(symAlgName); let promiseSymKey = await symKeyGenerator.generateSymKey(); return StrAndUintUtil.unitArray2String(promiseSymKey.getEncoded().data); }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto/src/main/ets/crypto/util/CryptoUtil.ets#L87-L94
74409b0a0333800308270a650260b6515be26073
gitee
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/entry/src/main/ets/pages/Index.ets
arkts
aboutToAppear
[EndExclude appear_router]
aboutToAppear(): void { // [StartExclude appear_router] let intervalId = setInterval(() => { if (this.timer === 1) { let uiContext = this.getUIContext(); let router = uiContext.getRouter(); router.pushUrl({ url: 'pages/OnIdlePage' }); router.clear(); clearInterval(intervalId) } else { this.timer--; } }, 1000) // [EndExclude appear_router] // Obtain analog data let viewItems: ViewItem[] = []; viewItems.push(...furnitureData()); viewItems.push(...natureData()); let context = this.getUIContext(); // Open frame callback context.postFrameCallback(new IdleCallback(context, viewItems)); }
AST#method_declaration#Left aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { // [StartExclude appear_router] AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left intervalId = 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#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 . timer 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#variable_declaration#Left let AST#variable_declarator#Left uiContext = 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 AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left router = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left uiContext AST#expression#Right . getRouter 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 router AST#expression#Right . pushUrl AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left url AST#property_name#Right : AST#expression#Left 'pages/OnIdlePage' 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 router 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left clearInterval AST#expression#Right AST#argument_list#Left ( AST#expression#Left intervalId 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#update_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . timer AST#member_expression#Right AST#expression#Right -- AST#update_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right , AST#expression#Left 1000 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right // [EndExclude appear_router] // Obtain analog data AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left viewItems : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left ViewItem [ ] 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 viewItems 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 furnitureData 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left viewItems 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 natureData 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#variable_declaration#Left let AST#variable_declarator#Left context = 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 AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // Open frame callback AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left context AST#expression#Right . postFrameCallback AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left IdleCallback AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right , AST#expression#Left viewItems AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
aboutToAppear(): void { let intervalId = setInterval(() => { if (this.timer === 1) { let uiContext = this.getUIContext(); let router = uiContext.getRouter(); router.pushUrl({ url: 'pages/OnIdlePage' }); router.clear(); clearInterval(intervalId) } else { this.timer--; } }, 1000) let viewItems: ViewItem[] = []; viewItems.push(...furnitureData()); viewItems.push(...natureData()); let context = this.getUIContext(); context.postFrameCallback(new IdleCallback(context, viewItems)); }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/GlobalCustomComponentReuse/ComponentPrebuildByOnIdle/entry/src/main/ets/pages/Index.ets#L28-L49
f32cad69afd9d9249c8d0b61ecdec533e0cf73c5
gitee
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
NativeAPI/XComponent/entry/src/main/ets/common/CommonConstants.ets
arkts
Copyright (c) 2023 Huawei Device Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
export default class CommonConstants { /** * Height and width is 100%. * */ static readonly FULL_PARENT: string = '100%'; /** * Font weight. */ static readonly FONT_WEIGHT: number = 500; /** * TextInput layout weight. */ static readonly LAYOUT_WEIGHT: number = 1; /** * XComponent id. */ static readonly XCOMPONENT_ID: string = 'xcomponentId'; /** * XComponent type. */ static readonly XCOMPONENT_TYPE: string = 'surface'; /** * XComponent library name. */ static readonly XCOMPONENT_LIBRARY_NAME: string = 'nativerender'; /** * XComponent height. */ static readonly XCOMPONENT_HEIGHT: string = '32.3%'; /** * Button width. */ static readonly BUTTON_WIDTH: string = '53.6%'; }
AST#export_declaration#Left export default AST#class_declaration#Left class CommonConstants AST#class_body#Left { /** * Height and width is 100%. * */ AST#property_declaration#Left static readonly FULL_PARENT : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '100%' AST#expression#Right ; AST#property_declaration#Right /** * Font weight. */ AST#property_declaration#Left static readonly FONT_WEIGHT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 500 AST#expression#Right ; AST#property_declaration#Right /** * TextInput layout weight. */ AST#property_declaration#Left static readonly LAYOUT_WEIGHT : 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 /** * XComponent id. */ AST#property_declaration#Left static readonly XCOMPONENT_ID : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'xcomponentId' AST#expression#Right ; AST#property_declaration#Right /** * XComponent type. */ AST#property_declaration#Left static readonly XCOMPONENT_TYPE : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'surface' AST#expression#Right ; AST#property_declaration#Right /** * XComponent library name. */ AST#property_declaration#Left static readonly XCOMPONENT_LIBRARY_NAME : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'nativerender' AST#expression#Right ; AST#property_declaration#Right /** * XComponent height. */ AST#property_declaration#Left static readonly XCOMPONENT_HEIGHT : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '32.3%' AST#expression#Right ; AST#property_declaration#Right /** * Button width. */ AST#property_declaration#Left static readonly BUTTON_WIDTH : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '53.6%' AST#expression#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export default class CommonConstants { static readonly FULL_PARENT: string = '100%'; static readonly FONT_WEIGHT: number = 500; static readonly LAYOUT_WEIGHT: number = 1; static readonly XCOMPONENT_ID: string = 'xcomponentId'; static readonly XCOMPONENT_TYPE: string = 'surface'; static readonly XCOMPONENT_LIBRARY_NAME: string = 'nativerender'; static readonly XCOMPONENT_HEIGHT: string = '32.3%'; static readonly BUTTON_WIDTH: string = '53.6%'; }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/NativeAPI/XComponent/entry/src/main/ets/common/CommonConstants.ets#L16-L56
192dbe4743b850c023f2bf0b726882f50f6a60d6
gitee
jxdiaodeyi/YX_Sports.git
af5346bd3d5003c33c306ff77b4b5e9184219893
YX_Sports/oh_modules/.ohpm/@pura+harmony-utils@1.3.6/oh_modules/@pura/harmony-utils/src/main/ets/crypto/DES.ets
arkts
decryptCBCSync
解密(CBC模式),同步 @param data 加密或者解密的数据。data不能为null。 @param symKey 指定加密或解密的密钥。 @param params 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 @param transformation 待生成Cipher的算法名称(含密钥长度)、加密模式以及填充方法的组合(AES256|CBC|PKCS7、AES192|CBC|PKCS7、AES128|CBC|PKCS7)。 @returns
static decryptCBCSync(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, params: cryptoFramework.ParamsSpec): cryptoFramework.DataBlob { return DES.decryptSync(data, symKey, params, '3DES192|CBC|PKCS7'); }
AST#method_declaration#Left static decryptCBCSync AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . DataBlob AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left symKey : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . SymKey AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left params : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . ParamsSpec 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 cryptoFramework . DataBlob AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DES AST#expression#Right . decryptSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left data AST#expression#Right , AST#expression#Left symKey AST#expression#Right , AST#expression#Left params AST#expression#Right , AST#expression#Left '3DES192|CBC|PKCS7' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static decryptCBCSync(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, params: cryptoFramework.ParamsSpec): cryptoFramework.DataBlob { return DES.decryptSync(data, symKey, params, '3DES192|CBC|PKCS7'); }
https://github.com/jxdiaodeyi/YX_Sports.git/blob/af5346bd3d5003c33c306ff77b4b5e9184219893/YX_Sports/oh_modules/.ohpm/@pura+harmony-utils@1.3.6/oh_modules/@pura/harmony-utils/src/main/ets/crypto/DES.ets#L110-L113
08df4e6559752d41ab0475fc09a5a7ee5b23df8c
github
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
feature/main/src/main/ets/component/HomeTopBar.ets
arkts
titleBuilder
标题区域构建 @returns {void} 无返回值
@Builder private titleBuilder() { Row() { Image($r("app.media.ic_search")) .fillColor($r("app.color.text_tertiary")) .attributeModifier(size(18)); SpaceHorizontalSmall(); Text($r("app.string.search_goods")) .fontSize($r("app.float.body_medium")) .fontColor($r("app.color.text_tertiary")); } .attributeModifier(rowCenter()) .width(P100) .height(38) .padding({ left: $r("app.float.space_horizontal_medium"), right: $r("app.float.space_horizontal_medium") }) .backgroundColor($r("app.color.bg_white")) .borderRadius($r("app.float.radius_medium")) .onClick((): void => this.onSearchTap()); }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right private titleBuilder 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 Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.media.ic_search" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fillColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.color.text_tertiary" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . attributeModifier ( AST#expression#Left AST#call_expression#Left AST#expression#Left size AST#expression#Right AST#argument_list#Left ( AST#expression#Left 18 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#expression_statement#Left AST#expression#Left AST#expression#Right ; AST#expression_statement#Right AST#ui_custom_component_statement#Left SpaceHorizontalSmall ( ) ; AST#ui_custom_component_statement#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.search_goods" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.float.body_medium" AST#expression#Right ) AST#resource_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_tertiary" 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#ERROR#Left ; AST#ERROR#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . attributeModifier ( AST#expression#Left AST#call_expression#Left AST#expression#Left rowCenter AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left P100 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 38 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 AST#resource_expression#Left $r ( AST#expression#Left "app.float.space_horizontal_medium" AST#expression#Right ) AST#resource_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#resource_expression#Left $r ( AST#expression#Left "app.float.space_horizontal_medium" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.color.bg_white" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.float.radius_medium" AST#expression#Right ) AST#resource_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#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 . onSearchTap 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#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#ERROR#Left ; AST#ERROR#Right } AST#builder_function_body#Right AST#method_declaration#Right
@Builder private titleBuilder() { Row() { Image($r("app.media.ic_search")) .fillColor($r("app.color.text_tertiary")) .attributeModifier(size(18)); SpaceHorizontalSmall(); Text($r("app.string.search_goods")) .fontSize($r("app.float.body_medium")) .fontColor($r("app.color.text_tertiary")); } .attributeModifier(rowCenter()) .width(P100) .height(38) .padding({ left: $r("app.float.space_horizontal_medium"), right: $r("app.float.space_horizontal_medium") }) .backgroundColor($r("app.color.bg_white")) .borderRadius($r("app.float.radius_medium")) .onClick((): void => this.onSearchTap()); }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/main/src/main/ets/component/HomeTopBar.ets#L49-L72
56510d0bc87af495d2a07d63628a6a5c908144a9
github
openharmony/interface_sdk-js
c349adc73e2ec1f61f6fca489b5af059e3ed6999
api/arkui/component/gesture.d.ets
arkts
Defines Gesture interface. @syscap SystemCapability.ArkUI.ArkUI.Full @crossplatform @atomicservice @since 20
export declare class Gesture { /** * Set gesture's tag. * * @param { string } tag * @returns { this } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 20 * */ tag(tag: string): this; /** * Input source type for gesture response. * * @param { Array<SourceTool> } types - indicate the allowed input source for gesture to response * @returns { this } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 20 * */ allowedTypes(types: Array<SourceTool>): this; }
AST#export_declaration#Left export AST#ERROR#Left declare AST#ERROR#Right AST#class_declaration#Left class Gesture AST#class_body#Left { /** * Set gesture's tag. * * @param { string } tag * @returns { this } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 20 * */ AST#method_declaration#Left tag AST#parameter_list#Left ( AST#parameter#Left tag : 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 this AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right /** * Input source type for gesture response. * * @param { Array<SourceTool> } types - indicate the allowed input source for gesture to response * @returns { this } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 20 * */ AST#method_declaration#Left allowedTypes AST#parameter_list#Left ( AST#parameter#Left types : 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 SourceTool 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 this 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 Gesture { tag(tag: string): this; allowedTypes(types: Array<SourceTool>): this; }
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/arkui/component/gesture.d.ets#L327-L352
a99434318091a37c9fa3b38993f54a19a61a409a
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/PasteboardUtil.ets
arkts
setDataWant
将Want数据写入系统剪贴板,使用Promise异步回调。 @param want Want内容 @returns
static async setDataWant(want: Want): Promise<void> { PasteboardUtil.setData(pasteboard.MIMETYPE_TEXT_WANT, want); }
AST#method_declaration#Left static async setDataWant AST#parameter_list#Left ( AST#parameter#Left want : AST#type_annotation#Left AST#primary_type#Left Want AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left PasteboardUtil AST#expression#Right . setData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left pasteboard AST#expression#Right . MIMETYPE_TEXT_WANT AST#member_expression#Right AST#expression#Right , AST#expression#Left want AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
static async setDataWant(want: Want): Promise<void> { PasteboardUtil.setData(pasteboard.MIMETYPE_TEXT_WANT, want); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/PasteboardUtil.ets#L221-L223
2779ed60dfac346fa79538eb30fd2ebf3dce516f
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/ArkTS1.2/ComponentSample/entry/src/main/ets/pages/Example4/MonthDataSource.ets
arkts
unregisterDataChangeListener
为对应的LazyForEach组件在数据源处去除listener监听。 @param {DataChangeListener} listener - 监听对象。
unregisterDataChangeListener(listener: DataChangeListener): void { const pos = this.listeners.indexOf(listener); if (pos >= 0) { this.listeners.splice(pos, 1); } }
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 const AST#variable_declarator#Left pos = 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 pos AST#expression#Right >= AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 pos 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
unregisterDataChangeListener(listener: DataChangeListener): void { const pos = this.listeners.indexOf(listener); if (pos >= 0) { this.listeners.splice(pos, 1); } }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/ArkTS1.2/ComponentSample/entry/src/main/ets/pages/Example4/MonthDataSource.ets#L106-L111
90585e777a5a9317829277b1ce97b4163e571dc6
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/UI/TabContentTouchHotZone/casesfeature/tabcontentoverflow/src/main/ets/mainpage/TabContentOverFlow.ets
arkts
aboutToDisappear
退出案例时设置状态栏颜色,避免影响其他案例。
aboutToDisappear(): void { setStatusBar(ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT); }
AST#method_declaration#Left aboutToDisappear AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#ui_custom_component_statement#Left setStatusBar ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ConfigurationConstant AST#expression#Right . ColorMode AST#member_expression#Right AST#expression#Right . COLOR_MODE_LIGHT AST#member_expression#Right AST#expression#Right ) ; AST#ui_custom_component_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
aboutToDisappear(): void { setStatusBar(ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT); }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/UI/TabContentTouchHotZone/casesfeature/tabcontentoverflow/src/main/ets/mainpage/TabContentOverFlow.ets#L65-L67
f3545330cbfa2742af6664d8a615d22000e15a71
gitee
openharmony/developtools_profiler
73d26bb5acfcafb2b1f4f94ead5640241d1e5f73
host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/components/YAxis.ets
arkts
getSpaceBottom
Returns the bottom axis space in percent of the full range. Default 10f @return
public getSpaceBottom(): number { return this.mSpacePercentBottom; }
AST#method_declaration#Left public getSpaceBottom AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mSpacePercentBottom AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
public getSpaceBottom(): number { return this.mSpacePercentBottom; }
https://github.com/openharmony/developtools_profiler/blob/73d26bb5acfcafb2b1f4f94ead5640241d1e5f73/host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/components/YAxis.ets#L299-L301
87186ebf0f5d7959f083f5eaa55f0c83ffbcb1f8
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/calendar/LunarSolarMappingService.ets
arkts
缓存统计信息
export interface CacheStats { years: number; totalMappings: number; memoryUsage: string; }
AST#export_declaration#Left export AST#interface_declaration#Left interface CacheStats AST#object_type#Left { AST#type_member#Left years : 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 totalMappings : 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 memoryUsage : 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 CacheStats { years: number; totalMappings: number; memoryUsage: string; }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/calendar/LunarSolarMappingService.ets#L39-L43
6d94213136579e9edaceed707541628a3c49c494
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/game/VirtualEconomyService.ets
arkts
商店接口
export interface VirtualShop { categories: ShopCategory[]; featuredItems: VirtualItem[]; dailyDeals: VirtualItem[]; specialOffers: SpecialOffer[]; lastRefresh: string; nextRefresh: string; }
AST#export_declaration#Left export AST#interface_declaration#Left interface VirtualShop AST#object_type#Left { AST#type_member#Left categories : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left ShopCategory [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left featuredItems : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left VirtualItem [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left dailyDeals : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left VirtualItem [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left specialOffers : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left SpecialOffer [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left lastRefresh : 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 nextRefresh : 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 VirtualShop { categories: ShopCategory[]; featuredItems: VirtualItem[]; dailyDeals: VirtualItem[]; specialOffers: SpecialOffer[]; lastRefresh: string; nextRefresh: string; }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/game/VirtualEconomyService.ets#L189-L196
0d52f2d9c367488165386f95a0ab4f2a7ca92d77
github
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/LocationUtil.ets
arkts
offLocationEnabledChange
取消订阅位置服务状态变化 @param callback 需要取消订阅的回调函数。该回调函数需要与on接口传入的回调函数保持一致。若无此参数,则取消当前类型的所有订阅。
static offLocationEnabledChange(callback?: Callback<boolean>) { if (callback) { geoLocationManager.off('locationEnabledChange', callback); } else { geoLocationManager.off('locationEnabledChange'); } }
AST#method_declaration#Left static offLocationEnabledChange AST#parameter_list#Left ( AST#parameter#Left callback ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Callback AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left 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#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 callback AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left geoLocationManager AST#expression#Right . off AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'locationEnabledChange' AST#expression#Right , AST#expression#Left callback AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } else { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left geoLocationManager AST#expression#Right . off AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'locationEnabledChange' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
static offLocationEnabledChange(callback?: Callback<boolean>) { if (callback) { geoLocationManager.off('locationEnabledChange', callback); } else { geoLocationManager.off('locationEnabledChange'); } }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/LocationUtil.ets#L183-L189
4629298ebc4d93dd8ab0f1b5ee035e1a99be5b14
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/SystemFeature/DataManagement/CrossAppDataShare/common/index.ets
arkts
TABLE_NAME
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 { TABLE_NAME, STORE_CONFIG, SQL_CREATE_TABLE, BASE_URI, COLUMNS, OPERATE_STATUS, SYNC_STATE } from './src/main/ets/utils/Consts'
AST#export_declaration#Left export { TABLE_NAME , STORE_CONFIG , SQL_CREATE_TABLE , BASE_URI , COLUMNS , OPERATE_STATUS , SYNC_STATE } from './src/main/ets/utils/Consts' AST#export_declaration#Right
export { TABLE_NAME, STORE_CONFIG, SQL_CREATE_TABLE, BASE_URI, COLUMNS, OPERATE_STATUS, SYNC_STATE } from './src/main/ets/utils/Consts'
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/SystemFeature/DataManagement/CrossAppDataShare/common/index.ets#L16-L24
862b5ad070f8cb0a037ad4aa9536995724fbc27f
gitee
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
core/ui/src/main/ets/component/modal/BottomModal.ets
arkts
BottomModal
@file 底部弹出层 Modal 组件 基于鸿蒙官方 bindSheet API 实现的半模态弹窗组件。 提供统一的样式和行为,支持自定义背景色、圆角、内边距等。 @param visible 是否显示弹窗 @param title 标题文本(可选) @param onDismiss 关闭回调 @param detents 高度档位,默认 [SheetSize.FIT_CONTENT, SheetSize.FIT_CONTENT] @param dragBar 是否显示拖动条,默认 true @param showClose 是否显示关闭按钮,默认 true @param containerColor 容器背景色,默认白色 @param sheetBorderRadius 容器圆角,默认顶部 16vp 圆角 @param horizontalPadding 水平内边距,默认 16vp @param content 内容构建器 @author Joker.X
@ComponentV2 export struct BottomModal { /** * 是否显示弹窗 */ @Param @Require visible: boolean = false; /** * 标题 */ @Param title?: string | Resource = undefined; /** * 关闭回调 */ @Param onDismiss: () => void = () => { }; /** * 高度档位 */ @Param detents: [SheetSize | Length, (SheetSize | Length)?, (SheetSize | Length)?] = [SheetSize.FIT_CONTENT, SheetSize.FIT_CONTENT]; /** * 是否显示拖动条 */ @Param dragBar: boolean = true; /** * 是否显示关闭按钮 */ @Param showClose: boolean = true; /** * 容器背景色 */ @Param containerColor: ResourceColor = $r("app.color.bg_white"); /** * 容器圆角 */ @Param sheetBorderRadius: BorderRadiuses = { topLeft: $r("app.float.radius_large"), topRight: $r("app.float.radius_large") }; /** * 水平内边距 */ @Param horizontalPadding: number | Resource = $r("app.float.space_padding_large"); /** * 当前窗口安全区状态(可外部传入,默认内部获取) */ @Param windowSafeAreaState: WindowSafeAreaState = getWindowSafeAreaState(); /** * 内容构建器 */ @BuilderParam @Require content: () => void; /** * 构建底部弹窗 * @returns {void} 无返回值 */ build() { Column() .width(0) .height(0) .bindSheet($$this.visible, this.sheetBuilder, { detents: this.detents, dragBar: this.dragBar, showClose: this.showClose, backgroundColor: this.containerColor, radius: this.sheetBorderRadius, title: this.title ? { title: this.title } : undefined, onDisappear: () => { this.onDismiss(); } }) } /** * Sheet 内容构建器 * @returns {void} 无返回值 */ @Builder sheetBuilder() { Column() { this.content(); } .padding({ left: this.horizontalPadding, right: this.horizontalPadding, bottom: this.windowSafeAreaState.bottomInset }) } }
AST#decorated_export_declaration#Left AST#decorator#Left @ ComponentV2 AST#decorator#Right export struct BottomModal AST#component_body#Left { /** * 是否显示弹窗 */ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right AST#decorator#Left @ Require AST#decorator#Right visible : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#property_declaration#Right /** * 标题 */ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right 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#expression#Left undefined AST#expression#Right ; AST#property_declaration#Right /** * 关闭回调 */ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right onDismiss : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right = AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#expression#Left AST#object_literal#Left { } AST#object_literal#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ; AST#property_declaration#Right /** * 高度档位 */ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right detents : AST#type_annotation#Left AST#primary_type#Left AST#tuple_type#Left [ AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left SheetSize AST#primary_type#Right | AST#primary_type#Left Length AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left AST#parenthesized_type#Left ( AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left SheetSize AST#primary_type#Right | AST#primary_type#Left Length AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right ) AST#parenthesized_type#Right AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left ? AST#ERROR#Right , AST#type_annotation#Left AST#primary_type#Left AST#parenthesized_type#Left ( AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left SheetSize AST#primary_type#Right | AST#primary_type#Left Length AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right ) AST#parenthesized_type#Right AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left ? AST#ERROR#Right ] AST#tuple_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left SheetSize AST#expression#Right . FIT_CONTENT AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left SheetSize AST#expression#Right . FIT_CONTENT AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right ; AST#property_declaration#Right /** * 是否显示拖动条 */ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right dragBar : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#property_declaration#Right /** * 是否显示关闭按钮 */ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right showClose : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#property_declaration#Right /** * 容器背景色 */ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right containerColor : AST#type_annotation#Left AST#primary_type#Left ResourceColor AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.color.bg_white" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * 容器圆角 */ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right sheetBorderRadius : AST#type_annotation#Left AST#primary_type#Left BorderRadiuses AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left topLeft AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.float.radius_large" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left topRight AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.float.radius_large" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#property_declaration#Right /** * 水平内边距 */ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right horizontalPadding : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left number AST#primary_type#Right | AST#primary_type#Left Resource AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.float.space_padding_large" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * 当前窗口安全区状态(可外部传入,默认内部获取) */ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right windowSafeAreaState : AST#type_annotation#Left AST#primary_type#Left WindowSafeAreaState AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left getWindowSafeAreaState 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 AST#decorator#Left @ BuilderParam AST#decorator#Right AST#decorator#Left @ Require AST#decorator#Right content : 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 /** * 构建底部弹窗 * @returns {void} 无返回值 */ 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#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 0 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 0 AST#expression#Right ) AST#modifier_chain_expression#Left . bindSheet ( AST#expression#Left AST#member_expression#Left AST#expression#Left $$this AST#expression#Right . visible AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . sheetBuilder AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left detents AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . detents AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left dragBar AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dragBar AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left showClose AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showClose AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left backgroundColor AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . containerColor AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left radius AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . sheetBorderRadius AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left title AST#property_name#Right : AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . title AST#member_expression#Right AST#expression#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 this AST#expression#Right . title AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right : AST#expression#Left undefined AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left onDisappear AST#property_name#Right : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . onDismiss AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#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 /** * Sheet 内容构建器 * @returns {void} 无返回值 */ AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right sheetBuilder 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 Column ( ) 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 . content 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#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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . horizontalPadding 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 this AST#expression#Right . horizontalPadding AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . windowSafeAreaState AST#member_expression#Right AST#expression#Right . bottomInset AST#member_expression#Right 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#builder_function_body#Right AST#method_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@ComponentV2 export struct BottomModal { @Param @Require visible: boolean = false; @Param title?: string | Resource = undefined; @Param onDismiss: () => void = () => { }; @Param detents: [SheetSize | Length, (SheetSize | Length)?, (SheetSize | Length)?] = [SheetSize.FIT_CONTENT, SheetSize.FIT_CONTENT]; @Param dragBar: boolean = true; @Param showClose: boolean = true; @Param containerColor: ResourceColor = $r("app.color.bg_white"); @Param sheetBorderRadius: BorderRadiuses = { topLeft: $r("app.float.radius_large"), topRight: $r("app.float.radius_large") }; @Param horizontalPadding: number | Resource = $r("app.float.space_padding_large"); @Param windowSafeAreaState: WindowSafeAreaState = getWindowSafeAreaState(); @BuilderParam @Require content: () => void; build() { Column() .width(0) .height(0) .bindSheet($$this.visible, this.sheetBuilder, { detents: this.detents, dragBar: this.dragBar, showClose: this.showClose, backgroundColor: this.containerColor, radius: this.sheetBorderRadius, title: this.title ? { title: this.title } : undefined, onDisappear: () => { this.onDismiss(); } }) } @Builder sheetBuilder() { Column() { this.content(); } .padding({ left: this.horizontalPadding, right: this.horizontalPadding, bottom: this.windowSafeAreaState.bottomInset }) } }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/ui/src/main/ets/component/modal/BottomModal.ets#L21-L122
94b03fb51cc6ce15b43b06853688ab58c56cf670
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/ArkTS1.2/ComponentSample/entry/src/main/ets/pages/Example1/SecondaryLinkExample.ets
arkts
contentListItemBuilder
右侧内容视图
@Builder contentListItemBuilder(item: CustomDataType, index: number) { ListItem() { Row() { Text() .aspectRatio(1) .height('100%') .backgroundColor('#ffe5e5e5') .borderRadius(15) Column() { Text(item.desc + index) Text(item.tag) .fontSize(20) .fontColor('#ff1dee06') Text() .height(ComponentStyle.SUB_ITEM_TEXT_HEIGHT) .width(ComponentStyle.SUB_ITEM_TEXT_WIDTH_TITLE) .backgroundColor('#ffb8b8b8') Text() .height(ComponentStyle.SUB_ITEM_TEXT_HEIGHT) .width(ComponentStyle.SUB_ITEM_TEXT_WIDTH_BODY) .backgroundColor('#ff8f8f8f') } .width('100%') .alignItems(HorizontalAlign.Start) .justifyContent(FlexAlign.SpaceEvenly) .height('100%') } .backgroundColor('#ffffffff') .height(ComponentStyle.SUB_ITEM_HEIGHT) } .id('content_' + index) }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right contentListItemBuilder AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left CustomDataType 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#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left ListItem ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . aspectRatio ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#ffe5e5e5' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 15 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 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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . desc AST#member_expression#Right AST#expression#Right + AST#expression#Left index AST#expression#Right AST#binary_expression#Right AST#expression#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 Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . tag AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 20 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#ff1dee06' 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#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left ComponentStyle AST#expression#Right . SUB_ITEM_TEXT_HEIGHT AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left ComponentStyle AST#expression#Right . SUB_ITEM_TEXT_WIDTH_TITLE AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#ffb8b8b8' 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#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left ComponentStyle AST#expression#Right . SUB_ITEM_TEXT_HEIGHT AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left ComponentStyle AST#expression#Right . SUB_ITEM_TEXT_WIDTH_BODY AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#ff8f8f8f' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . 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 . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . SpaceEvenly AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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 '#ffffffff' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left ComponentStyle AST#expression#Right . SUB_ITEM_HEIGHT 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 . id ( AST#expression#Left AST#binary_expression#Left AST#expression#Left 'content_' AST#expression#Right + AST#expression#Left index AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
@Builder contentListItemBuilder(item: CustomDataType, index: number) { ListItem() { Row() { Text() .aspectRatio(1) .height('100%') .backgroundColor('#ffe5e5e5') .borderRadius(15) Column() { Text(item.desc + index) Text(item.tag) .fontSize(20) .fontColor('#ff1dee06') Text() .height(ComponentStyle.SUB_ITEM_TEXT_HEIGHT) .width(ComponentStyle.SUB_ITEM_TEXT_WIDTH_TITLE) .backgroundColor('#ffb8b8b8') Text() .height(ComponentStyle.SUB_ITEM_TEXT_HEIGHT) .width(ComponentStyle.SUB_ITEM_TEXT_WIDTH_BODY) .backgroundColor('#ff8f8f8f') } .width('100%') .alignItems(HorizontalAlign.Start) .justifyContent(FlexAlign.SpaceEvenly) .height('100%') } .backgroundColor('#ffffffff') .height(ComponentStyle.SUB_ITEM_HEIGHT) } .id('content_' + index) }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/ArkTS1.2/ComponentSample/entry/src/main/ets/pages/Example1/SecondaryLinkExample.ets#L203-L235
d92067195af355b5c577570f78c02cab67c5ce61
gitee
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
ArkUI/Component_Redundancy_Refresh_Optimization/entry/src/main/ets/segment/segment1.ets
arkts
isRenderSpecialImage
Default transparency
private isRenderSpecialImage(): number { // Image transparency increases by 0.1 each time it is rendered, cycling between 0 and 1. this.opacityNum = (this.opacityNum + opacityChangeValue) % opacityChangeRange; return this.opacityNum; }
AST#method_declaration#Left private isRenderSpecialImage 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 { // Image transparency increases by 0.1 each time it is rendered, cycling between 0 and 1. AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . opacityNum AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . opacityNum AST#member_expression#Right AST#expression#Right + AST#expression#Left opacityChangeValue AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right % AST#expression#Left opacityChangeRange 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . opacityNum AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private isRenderSpecialImage(): number { this.opacityNum = (this.opacityNum + opacityChangeValue) % opacityChangeRange; return this.opacityNum; }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/ArkUI/Component_Redundancy_Refresh_Optimization/entry/src/main/ets/segment/segment1.ets#L84-L88
bcc419f90cf4ae84a99cbcdf4c877826ea1d92fe
gitee
iamhyc/Aigis.git
585de9128882d868484438d32832ca9b9b50442d
entry/src/main/ets/common/conts.ets
arkts
5s
export const ATL1_AUTH_TIMEOUT = 90*1000;
AST#export_declaration#Left export AST#variable_declaration#Left const AST#variable_declarator#Left ATL1_AUTH_TIMEOUT = AST#expression#Left AST#binary_expression#Left AST#expression#Left 90 AST#expression#Right * AST#expression#Left 1000 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#export_declaration#Right
export const ATL1_AUTH_TIMEOUT = 90*1000;
https://github.com/iamhyc/Aigis.git/blob/585de9128882d868484438d32832ca9b9b50442d/entry/src/main/ets/common/conts.ets#L22-L22
b04bf6f20e9b96ade711b4e127db2d7676a3e537
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/DocsSample/CoreFile/NDKAppFileSample/entry/src/main/ets/entryability/EntryAbility.ets
arkts
应用的编码
export default class EntryAbility extends UIAbility { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { hilog.info(DOMAIN, 'testTag', `%{public}s`, 'Ability onCreate'); } onDestroy(): void { hilog.info(DOMAIN, 'testTag', `%{public}s`, 'Ability onDestroy'); } onWindowStageCreate(windowStage: window.WindowStage): void { // Main window is created, set main page for this ability hilog.info(DOMAIN, 'testTag', `%{public}s`, 'Ability onWindowStageCreate'); windowStage.loadContent('pages/Index', (err) => { if (err.code) { hilog.error(DOMAIN, 'testTag', `Failed to load the content. Cause: %{public}s`, JSON.stringify(err) ?? ''); return; } hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); }); } onWindowStageDestroy(): void { // Main window is destroyed, release UI related resources hilog.info(DOMAIN, 'testTag', `%{public}s`, 'Ability onWindowStageDestroy'); } onForeground(): void { // Ability has brought to foreground hilog.info(DOMAIN, 'testTag', `%{public}s`, 'Ability onForeground'); } onBackground(): void { // Ability has back to background hilog.info(DOMAIN, 'testTag', `%{public}s`, 'Ability onBackground'); } };
AST#export_declaration#Left export default AST#class_declaration#Left class EntryAbility extends AST#type_annotation#Left AST#primary_type#Left UIAbility AST#primary_type#Right AST#type_annotation#Right AST#class_body#Left { AST#method_declaration#Left onCreate AST#parameter_list#Left ( AST#parameter#Left want : AST#type_annotation#Left AST#primary_type#Left Want AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left launchParam : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left AbilityConstant . LaunchParam AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left DOMAIN AST#expression#Right , AST#expression#Left 'testTag' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` %{public}s ` AST#template_literal#Right AST#expression#Right , AST#expression#Left 'Ability onCreate' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left onDestroy 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 hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left DOMAIN AST#expression#Right , AST#expression#Left 'testTag' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` %{public}s ` AST#template_literal#Right AST#expression#Right , AST#expression#Left 'Ability onDestroy' 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 onWindowStageCreate 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 { // Main window is created, set main page for this ability AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left DOMAIN AST#expression#Right , AST#expression#Left 'testTag' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` %{public}s ` AST#template_literal#Right AST#expression#Right , AST#expression#Left 'Ability onWindowStageCreate' 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 windowStage AST#expression#Right . loadContent AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'pages/Index' 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 AST#member_expression#Left AST#expression#Left err AST#expression#Right . code 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 hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left DOMAIN AST#expression#Right , AST#expression#Left 'testTag' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Failed to load the content. Cause: %{public}s ` AST#template_literal#Right AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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#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#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left DOMAIN AST#expression#Right , AST#expression#Left 'testTag' AST#expression#Right , AST#expression#Left 'Succeeded in loading the 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#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 onWindowStageDestroy 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 { // Main window is destroyed, release UI related resources AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left DOMAIN AST#expression#Right , AST#expression#Left 'testTag' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` %{public}s ` AST#template_literal#Right AST#expression#Right , AST#expression#Left 'Ability onWindowStageDestroy' 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 onForeground AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { // Ability has brought to foreground AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left DOMAIN AST#expression#Right , AST#expression#Left 'testTag' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` %{public}s ` AST#template_literal#Right AST#expression#Right , AST#expression#Left 'Ability onForeground' 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 onBackground AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { // Ability has back to background AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left DOMAIN AST#expression#Right , AST#expression#Left 'testTag' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` %{public}s ` AST#template_literal#Right AST#expression#Right , AST#expression#Left 'Ability onBackground' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right ; AST#export_declaration#Right
export default class EntryAbility extends UIAbility { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { hilog.info(DOMAIN, 'testTag', `%{public}s`, 'Ability onCreate'); } onDestroy(): void { hilog.info(DOMAIN, 'testTag', `%{public}s`, 'Ability onDestroy'); } onWindowStageCreate(windowStage: window.WindowStage): void { hilog.info(DOMAIN, 'testTag', `%{public}s`, 'Ability onWindowStageCreate'); windowStage.loadContent('pages/Index', (err) => { if (err.code) { hilog.error(DOMAIN, 'testTag', `Failed to load the content. Cause: %{public}s`, JSON.stringify(err) ?? ''); return; } hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); }); } onWindowStageDestroy(): void { hilog.info(DOMAIN, 'testTag', `%{public}s`, 'Ability onWindowStageDestroy'); } onForeground(): void { hilog.info(DOMAIN, 'testTag', `%{public}s`, 'Ability onForeground'); } onBackground(): void { hilog.info(DOMAIN, 'testTag', `%{public}s`, 'Ability onBackground'); } };
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/CoreFile/NDKAppFileSample/entry/src/main/ets/entryability/EntryAbility.ets#L22-L58
374ff452b2f16a77402be779abede266071f8b05
gitee
WinWang/HarmoneyOpenEye.git
57f0542795336009aa0d46fd9fa5b07facc2ae87
entry/src/main/ets/utils/StorageUtils.ets
arkts
delete
删除值 @param key @param preferenceName @returns
static async delete(key: string, preferenceName: string = defaultPreferenceName) { let preferences = await this.getPreferences(preferenceName) return await preferences.delete(key) }
AST#method_declaration#Left static async delete 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 preferenceName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left defaultPreferenceName AST#expression#Right AST#parameter#Right ) AST#parameter_list#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 this 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#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left preferences AST#expression#Right AST#await_expression#Right AST#expression#Right . delete AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key 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 delete(key: string, preferenceName: string = defaultPreferenceName) { let preferences = await this.getPreferences(preferenceName) return await preferences.delete(key) }
https://github.com/WinWang/HarmoneyOpenEye.git/blob/57f0542795336009aa0d46fd9fa5b07facc2ae87/entry/src/main/ets/utils/StorageUtils.ets#L51-L54
6786ea1ac115708d49e733c5d3f5e358d264b7e4
github
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
Security/AccessPermission/entry/src/main/ets/common/util/PermissionUtil.ets
arkts
applyPermission
Applying for Permissions. @returns Permission application result.
async applyPermission() { let atManager = abilityAccessCtrl.createAtManager(); let data = await atManager.requestPermissionsFromUser(getContext(this), [CommonConstants.PERMISSION]); let grantStatus: Array<number> = data.authResults; let length: number = grantStatus.length; if (length === 0) { return 1; } return grantStatus[0]; }
AST#method_declaration#Left async applyPermission AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left atManager = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left abilityAccessCtrl AST#expression#Right . createAtManager AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left data = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left atManager AST#expression#Right AST#await_expression#Right AST#expression#Right . requestPermissionsFromUser AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left getContext AST#expression#Right AST#argument_list#Left ( AST#expression#Left this AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . PERMISSION AST#member_expression#Right AST#expression#Right ] AST#array_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 grantStatus : 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 number AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . authResults 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 length : 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 grantStatus AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left length 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 1 AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#subscript_expression#Left AST#expression#Left grantStatus AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async applyPermission() { let atManager = abilityAccessCtrl.createAtManager(); let data = await atManager.requestPermissionsFromUser(getContext(this), [CommonConstants.PERMISSION]); let grantStatus: Array<number> = data.authResults; let length: number = grantStatus.length; if (length === 0) { return 1; } return grantStatus[0]; }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Security/AccessPermission/entry/src/main/ets/common/util/PermissionUtil.ets#L32-L41
2f6fe031bc3725c0516b1a919878e5008e677583
gitee
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/models/networks/Http.ets
arkts
_isSucceed
判断请求是否成功(根据业务状态码)
private static _isSucceed(code?: number): boolean { //return code >= 200 && code < 300; return HttpUtils.Functions.succeed(code) }
AST#method_declaration#Left private static _isSucceed 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_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { //return code >= 200 && code < 300; 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 HttpUtils AST#expression#Right . Functions AST#member_expression#Right AST#expression#Right . succeed AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left code 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
private static _isSucceed(code?: number): boolean { return HttpUtils.Functions.succeed(code) }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/networks/Http.ets#L239-L242
9d0accf8b0954ba76e29562a2c233c8e28a0a51c
github
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
core/network/src/main/ets/datasource/order/OrderNetworkDataSourceImpl.ets
arkts
createOrder
创建订单 @param {CreateOrderRequest} params - 创建订单参数 @returns {Promise<NetworkResponse<Order>>} 创建成功的订单信息
async createOrder(params: CreateOrderRequest): Promise<NetworkResponse<Order>> { const resp: AxiosResponse<NetworkResponse<Order>> = await NetworkClient.http.post("order/info/create", params); return resp.data; }
AST#method_declaration#Left async createOrder AST#parameter_list#Left ( AST#parameter#Left params : AST#type_annotation#Left AST#primary_type#Left CreateOrderRequest 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 NetworkResponse AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left Order 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#variable_declaration#Left const AST#variable_declarator#Left resp : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left AxiosResponse AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left NetworkResponse AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left Order AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#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 NetworkClient AST#expression#Right AST#await_expression#Right AST#expression#Right . http AST#member_expression#Right AST#expression#Right . post AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "order/info/create" AST#expression#Right , AST#expression#Left params 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#member_expression#Left AST#expression#Left resp AST#expression#Right . data AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async createOrder(params: CreateOrderRequest): Promise<NetworkResponse<Order>> { const resp: AxiosResponse<NetworkResponse<Order>> = await NetworkClient.http.post("order/info/create", params); return resp.data; }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/network/src/main/ets/datasource/order/OrderNetworkDataSourceImpl.ets#L71-L75
5991eacf80cfccd7443e5cbbcaffc7403b84b7d5
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/storage/DatabaseService.ets
arkts
checkInitialized
检查是否已初始化
private checkInitialized(): void { if (!this.initialized || !this.store) { throw new Error('DatabaseService not initialized. Call initialize() first.'); } }
AST#method_declaration#Left private checkInitialized 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#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 . initialized 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 . store AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#throw_statement#Left throw AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Error AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'DatabaseService not initialized. Call initialize() first.' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#throw_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private checkInitialized(): void { if (!this.initialized || !this.store) { throw new Error('DatabaseService not initialized. Call initialize() first.'); } }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/storage/DatabaseService.ets#L198-L202
672d1a52087396d4e2f5aa05bb89d854bc28d288
github
openharmony/interface_sdk-js
c349adc73e2ec1f61f6fca489b5af059e3ed6999
api/@ohos.arkui.advanced.DialogV2.d.ets
arkts
Defines PopoverDialogV2 Options @interface PopoverDialogV2Options @extends CustomPopupOptions @syscap SystemCapability.ArkUI.ArkUI.Full @crossplatform @atomicservice @since 18
export declare interface PopoverDialogV2Options extends CustomPopupOptions { }
AST#export_declaration#Left export AST#ERROR#Left declare AST#ERROR#Right AST#interface_declaration#Left interface PopoverDialogV2Options AST#extends_clause#Left extends CustomPopupOptions AST#extends_clause#Right AST#object_type#Left { } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
export declare interface PopoverDialogV2Options extends CustomPopupOptions { }
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.arkui.advanced.DialogV2.d.ets#L790-L791
c7200a105a5b471fc9b8bc33023386ecc99e3dc7
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/listslidetohistory/src/main/ets/model/BasicDataSource.ets
arkts
IDataSource处理数据监听的基本实现
export abstract class BasicDataSource<T> implements IDataSource { private listeners: DataChangeListener[] = []; public abstract totalCount(): number; public abstract getData(index: number): T | void; registerDataChangeListener(listener: DataChangeListener): void { if (this.listeners.indexOf(listener) < 0) { this.listeners.push(listener); } } unregisterDataChangeListener(listener: DataChangeListener): void { const pos = this.listeners.indexOf(listener) if (pos >= 0) { this.listeners.splice(pos, 1); } } notifyDataReload(): void { this.listeners.forEach((listener: DataChangeListener) => { listener.onDataReloaded(); }); } notifyDataAdd(index: number): void { this.listeners.forEach((listener: DataChangeListener) => { listener.onDataAdd(index); }) } notifyDataChange(index: number): void { this.listeners.forEach((listener: DataChangeListener) => { listener.onDataChange(index); }) } notifyDataDelete(index: number): void { this.listeners.forEach((listener: DataChangeListener) => { listener.onDataDelete(index); }) } notifyDataMove(from: number, to: number): void { this.listeners.forEach((listener: DataChangeListener) => { listener.onDataMove(from, to); }) } }
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#array_type#Left DataChangeListener [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#method_declaration#Left public abstract 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#method_declaration#Right AST#method_declaration#Left public abstract 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#union_type#Left AST#primary_type#Left T AST#primary_type#Right | AST#primary_type#Left void AST#primary_type#Right AST#union_type#Right AST#type_annotation#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 ) { 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 const AST#variable_declarator#Left pos = 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 pos AST#expression#Right >= AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 pos 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 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 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#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 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#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 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#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 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#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 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#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 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#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 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#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 notifyDataMove AST#parameter_list#Left ( AST#parameter#Left from : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left to : 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 . 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 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#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 . onDataMove AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left from AST#expression#Right , AST#expression#Left to 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#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export abstract class BasicDataSource<T> implements IDataSource { private listeners: DataChangeListener[] = []; public abstract totalCount(): number; public abstract getData(index: number): T | void; registerDataChangeListener(listener: DataChangeListener): void { if (this.listeners.indexOf(listener) < 0) { this.listeners.push(listener); } } unregisterDataChangeListener(listener: DataChangeListener): void { const pos = this.listeners.indexOf(listener) if (pos >= 0) { this.listeners.splice(pos, 1); } } notifyDataReload(): void { this.listeners.forEach((listener: DataChangeListener) => { listener.onDataReloaded(); }); } notifyDataAdd(index: number): void { this.listeners.forEach((listener: DataChangeListener) => { listener.onDataAdd(index); }) } notifyDataChange(index: number): void { this.listeners.forEach((listener: DataChangeListener) => { listener.onDataChange(index); }) } notifyDataDelete(index: number): void { this.listeners.forEach((listener: DataChangeListener) => { listener.onDataDelete(index); }) } notifyDataMove(from: number, to: number): void { this.listeners.forEach((listener: DataChangeListener) => { listener.onDataMove(from, to); }) } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/listslidetohistory/src/main/ets/model/BasicDataSource.ets#L20-L69
d9369c02492d6edfec932712f9dba40ad9e6b613
gitee
zhongte/TaoYao
80850f3800dd6037216d3f7c58a2bf34a881c93f
taoyao/src/main/ets/shijing/taoyao/picker/media/MediaBuilder.ets
arkts
setMediaMineType
可选择的媒体文件类型,图片类型、视频类型、图片和视频类型、动态照片类型 @param mediaMineType @returns
public setMediaMineType(mediaMineType: MediaMimeType): MediaBuilder { this._mediaMineType = mediaMineType return this }
AST#method_declaration#Left public setMediaMineType AST#parameter_list#Left ( AST#parameter#Left mediaMineType : AST#type_annotation#Left AST#primary_type#Left MediaMimeType AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left MediaBuilder AST#primary_type#Right AST#type_annotation#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 . _mediaMineType AST#member_expression#Right = AST#expression#Left mediaMineType 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 this AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
public setMediaMineType(mediaMineType: MediaMimeType): MediaBuilder { this._mediaMineType = mediaMineType return this }
https://github.com/zhongte/TaoYao/blob/80850f3800dd6037216d3f7c58a2bf34a881c93f/taoyao/src/main/ets/shijing/taoyao/picker/media/MediaBuilder.ets#L29-L32
8288b08010b5b9b783c68829bdc07f577e3c876e
gitee
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
ArkUI/Component_Reuse_Scenarios/entry/src/main/ets/segment/segment5.ets
arkts
[StartExclude Case5]
build() { Column() { } }
AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right
build() { Column() { } }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/ArkUI/Component_Reuse_Scenarios/entry/src/main/ets/segment/segment5.ets#L68-L71
fe625be53f65fb3c4a019776d217fd16d638a261
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/accessibility/AccessibilityService.ets
arkts
getSettings
获取当前设置
getSettings(): AccessibilitySettings { return this.deepCopySettings(this.settings); }
AST#method_declaration#Left getSettings AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AccessibilitySettings 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 this AST#expression#Right . deepCopySettings 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 . settings 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
getSettings(): AccessibilitySettings { return this.deepCopySettings(this.settings); }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/accessibility/AccessibilityService.ets#L216-L218
5154ecbc8a292b65eeca486ff03f2ac26a461c5f
github
tomorrowKreswell/Ledger.git
1f2783ae70b8540d677af8a27f29db1b4089ea69
ledger/entry/src/main/ets/common/utils/DateUtils.ets
arkts
获取本月的第一天的日期
export function getFirstDateOfThisMonth(date: Date | number): Date { // 如果输入的日期是数字,将其转换为日期对象 if (typeof date === 'number') { date = new Date(date) } // 返回本月的第一天的日期 return new Date(date.getFullYear(), date.getMonth()) }
AST#export_declaration#Left export AST#function_declaration#Left function getFirstDateOfThisMonth 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#type_annotation#Left AST#primary_type#Left Date 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#unary_expression#Left typeof AST#expression#Left date AST#expression#Right AST#unary_expression#Right AST#expression#Right === AST#expression#Left 'number' 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 date = 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 date AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 返回本月的第一天的日期 AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#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 date 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 AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date AST#expression#Right . getMonth 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#function_declaration#Right AST#export_declaration#Right
export function getFirstDateOfThisMonth(date: Date | number): Date { if (typeof date === 'number') { date = new Date(date) } return new Date(date.getFullYear(), date.getMonth()) }
https://github.com/tomorrowKreswell/Ledger.git/blob/1f2783ae70b8540d677af8a27f29db1b4089ea69/ledger/entry/src/main/ets/common/utils/DateUtils.ets#L96-L103
445a552dc0e4b26653b5bdcd5fae750e676d282c
github
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_core/src/main/ets/core/util/Logger.ets
arkts
warn
warn级别日志【入参为两个字符串,第一个为提示消息,第二个为错误原因】 @param args 错误信息
static warn(...args: string[]): void { hilog.warn(Logger.domain, Logger.prefix, Logger.format, args); }
AST#method_declaration#Left static 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 Logger AST#expression#Right . domain AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . prefix AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left Logger 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
static warn(...args: string[]): void { hilog.warn(Logger.domain, Logger.prefix, Logger.format, args); }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_core/src/main/ets/core/util/Logger.ets#L139-L141
44c6e700c8cf9478f428f718b633ef95b3c61f5a
gitee
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/views/setting/AdviceView.ets
arkts
uploadImage
上传图片到服务器
private async uploadImage(adviceStr: string) { if (this.pickedUri) { let ext = PathUtility.getExtension(this.pickedUri) let fileName = `${UserManager.shared.userId}_${this.getDateNowString()}.${ext}` CosDownloaderAdviceData.shared.uploadUserData(this.pickedUri, fileName, (progress: number) => {}, async (success: boolean, filePath?: string, error?: string)=>{ let str = adviceStr str += "\n\n\n图片: \n" + filePath if (success) { await this.sendToServer(str) }else{ Toast.showMessage('上传图片失败: ' + error) } }) } }
AST#method_declaration#Left private async uploadImage AST#parameter_list#Left ( AST#parameter#Left adviceStr : 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#member_expression#Left AST#expression#Left this AST#expression#Right . pickedUri AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left ext = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left PathUtility AST#expression#Right . getExtension 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 . pickedUri 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 fileName = 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#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left UserManager AST#expression#Right . shared AST#member_expression#Right AST#expression#Right . userId AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right _ AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getDateNowString 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 ext AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#ERROR#Left CosDownloaderAdviceData AST#ERROR#Right . shared AST#member_expression#Right AST#expression#Right . uploadUserData 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 . pickedUri AST#member_expression#Right AST#expression#Right , AST#expression#Left fileName AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left progress : AST#type_annotation#Left AST#primary_type#Left 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#expression#Left AST#arrow_function#Left async AST#parameter_list#Left ( AST#parameter#Left success : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left filePath ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left error ? : 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 str = AST#expression#Left AST#assignment_expression#Left adviceStr AST#ERROR#Left str AST#ERROR#Right += AST#expression#Left AST#binary_expression#Left AST#expression#Left "\n\n\n图片: \n" AST#expression#Right + AST#expression#Left filePath 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#statement#Left AST#if_statement#Left if ( AST#expression#Left success 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 . sendToServer 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 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 Toast AST#expression#Right . showMessage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left '上传图片失败: ' AST#expression#Right + AST#expression#Left error AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#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#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#method_declaration#Right
private async uploadImage(adviceStr: string) { if (this.pickedUri) { let ext = PathUtility.getExtension(this.pickedUri) let fileName = `${UserManager.shared.userId}_${this.getDateNowString()}.${ext}` CosDownloaderAdviceData.shared.uploadUserData(this.pickedUri, fileName, (progress: number) => {}, async (success: boolean, filePath?: string, error?: string)=>{ let str = adviceStr str += "\n\n\n图片: \n" + filePath if (success) { await this.sendToServer(str) }else{ Toast.showMessage('上传图片失败: ' + error) } }) } }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/views/setting/AdviceView.ets#L214-L233
790a94e026f04c1a77f346024885b84a6c9c03e1
github
dcm23333/FishManager.git
952dde4475268ac16f3480f3d55f82033aa6b467
FishManager/entry/src/main/ets/common/contants/commonContants.ets
arkts
100ms list space
export const LIST_ITEM_SPACE: number = 2;
AST#export_declaration#Left export AST#variable_declaration#Left const AST#variable_declarator#Left LIST_ITEM_SPACE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 2 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#export_declaration#Right
export const LIST_ITEM_SPACE: number = 2;
https://github.com/dcm23333/FishManager.git/blob/952dde4475268ac16f3480f3d55f82033aa6b467/FishManager/entry/src/main/ets/common/contants/commonContants.ets#L105-L105
2a6665d13b2986235bd2188b247d2f2e160975f0
github
2763981847/Clock-Alarm.git
8949bedddb7d011021848196735f30ffe2bd1daf
entry/src/main/ets/common/constant/StopWatchConstants.ets
arkts
秒表常量类。
export class StopWatchConstants { /** * 秒表格式。 */ static readonly TIMER_FORMAT: string = 'mm:ss.SS'; /** * 秒表字符串。 */ static readonly STOP_WATCH: string = '秒表'; /** * 标记项高度。 */ static readonly FLAG_ITEM_HEIGHT = 35; }
AST#export_declaration#Left export AST#class_declaration#Left class StopWatchConstants AST#class_body#Left { /** * 秒表格式。 */ AST#property_declaration#Left static readonly TIMER_FORMAT : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'mm:ss.SS' AST#expression#Right ; AST#property_declaration#Right /** * 秒表字符串。 */ AST#property_declaration#Left static readonly STOP_WATCH : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '秒表' AST#expression#Right ; AST#property_declaration#Right /** * 标记项高度。 */ AST#property_declaration#Left static readonly FLAG_ITEM_HEIGHT = AST#expression#Left 35 AST#expression#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class StopWatchConstants { static readonly TIMER_FORMAT: string = 'mm:ss.SS'; static readonly STOP_WATCH: string = '秒表'; static readonly FLAG_ITEM_HEIGHT = 35; }
https://github.com/2763981847/Clock-Alarm.git/blob/8949bedddb7d011021848196735f30ffe2bd1daf/entry/src/main/ets/common/constant/StopWatchConstants.ets#L4-L17
61dd44ee54b9765264cc14ef23473a0cedd4ac86
github
sithvothykiv/dialog_hub.git
b676c102ef2d05f8994d170abe48dcc40cd39005
custom_dialog/src/main/ets/core/dialog/SelectDialog.ets
arkts
initBase
------------------------- 保护、私有方法 protected | private methods -------------------------
private initBase(options: ISelectDialogOptions): ISelectDialogOptions { if (options.confirm) { options.confirm = this.initButton(options, options.confirm, false, 0) as ButtonOptions } if (options.radioContent?.length && options.actionCancel) { options.radioContent = options.radioContent.map(item => { return this.initButton(options, item, false, 0) as SheetInfo }) } return options }
AST#method_declaration#Left private initBase AST#parameter_list#Left ( AST#parameter#Left options : AST#type_annotation#Left AST#primary_type#Left ISelectDialogOptions AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left ISelectDialogOptions 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 options AST#expression#Right . confirm 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 options AST#expression#Right . confirm 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 this AST#expression#Right . initButton AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left options AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . confirm AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right , AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left ButtonOptions 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#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#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . radioContent AST#member_expression#Right AST#expression#Right ?. length AST#member_expression#Right AST#expression#Right && AST#expression#Left options AST#expression#Right AST#binary_expression#Right AST#expression#Right . actionCancel 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 options AST#expression#Right . radioContent 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 options AST#expression#Right . radioContent 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 item => 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 this AST#expression#Right . initButton AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left options AST#expression#Right , AST#expression#Left item AST#expression#Right , AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right , AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left SheetInfo 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#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#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 options AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
private initBase(options: ISelectDialogOptions): ISelectDialogOptions { if (options.confirm) { options.confirm = this.initButton(options, options.confirm, false, 0) as ButtonOptions } if (options.radioContent?.length && options.actionCancel) { options.radioContent = options.radioContent.map(item => { return this.initButton(options, item, false, 0) as SheetInfo }) } return options }
https://github.com/sithvothykiv/dialog_hub.git/blob/b676c102ef2d05f8994d170abe48dcc40cd39005/custom_dialog/src/main/ets/core/dialog/SelectDialog.ets#L22-L32
0a527165fe86fa30db9c9670f41d6c3cecfb70b4
github
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
Ability/StageAbility/entry/src/main/ets/model/ButtonClickMethod.ets
arkts
toSecondAbilityIndex
Navigate to the Index Page of SecondAbility. @param context Context of EntryAbility.
toSecondAbilityIndex(context: common.UIAbilityContext) { let want: Want = { 'deviceId': '', 'bundleName': CommonConstants.BUNDLE_NAME, 'abilityName': CommonConstants.SECOND_ABILITY_NAME, 'moduleName': CommonConstants.DEVICE_MODULE_NAME, 'parameters': { src: textMessage, count: CommonConstants.NUM_VALUES[1] } }; context.startAbility(want).then(() => { Logger.info(CommonConstants.TAG, `start second ability index page succeed with ${JSON.stringify(want)}`); }).catch((error: Error) => { Logger.error(CommonConstants.TAG, `start second ability index page failedwith ${error}`); }); }
AST#method_declaration#Left toSecondAbilityIndex AST#parameter_list#Left ( AST#parameter#Left context : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . UIAbilityContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#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 'deviceId' AST#property_name#Right : AST#expression#Left '' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'bundleName' AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . BUNDLE_NAME AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'abilityName' AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . SECOND_ABILITY_NAME AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'moduleName' AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . DEVICE_MODULE_NAME AST#member_expression#Right 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 src AST#property_name#Right : AST#expression#Left textMessage AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left count AST#property_name#Right : AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . NUM_VALUES AST#member_expression#Right AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 . 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 Logger 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 CommonConstants AST#expression#Right . TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` start second ability index page succeed with 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 want 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#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 Error AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger 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 CommonConstants AST#expression#Right . TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` start second ability index page failedwith 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#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
toSecondAbilityIndex(context: common.UIAbilityContext) { let want: Want = { 'deviceId': '', 'bundleName': CommonConstants.BUNDLE_NAME, 'abilityName': CommonConstants.SECOND_ABILITY_NAME, 'moduleName': CommonConstants.DEVICE_MODULE_NAME, 'parameters': { src: textMessage, count: CommonConstants.NUM_VALUES[1] } }; context.startAbility(want).then(() => { Logger.info(CommonConstants.TAG, `start second ability index page succeed with ${JSON.stringify(want)}`); }).catch((error: Error) => { Logger.error(CommonConstants.TAG, `start second ability index page failedwith ${error}`); }); }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Ability/StageAbility/entry/src/main/ets/model/ButtonClickMethod.ets#L51-L67
d09d1766b7eed579da14214be64cfc6938d830f5
gitee
L1rics06/arkTS-.git
991fd131bfdb11e2933152133c97453d86092ac0
entry/src/main/ets/pages/NetworkUtil.ets
arkts
注册信息接口
export interface RegisterInfo { email: string; nickname: string; gender: string; password1: string; password2: string; avatar:string }
AST#export_declaration#Left export AST#interface_declaration#Left interface RegisterInfo AST#object_type#Left { AST#type_member#Left email : 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 nickname : 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 gender : 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 password1 : 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 password2 : 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 avatar : 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 RegisterInfo { email: string; nickname: string; gender: string; password1: string; password2: string; avatar:string }
https://github.com/L1rics06/arkTS-.git/blob/991fd131bfdb11e2933152133c97453d86092ac0/entry/src/main/ets/pages/NetworkUtil.ets#L63-L70
dcedcf4152dfbac4a7fb04a910030df549b4db06
github
hqj201013136012/HarmonyMiliUiPro.git
0625e681e07b771998a0ac4430824627d0eb60ed
entry/src/main/ets/common/helper/kvManagerHelper.ets
arkts
键值数据库管理类
export type kvValueType = boolean | string | number | Uint8Array;
AST#export_declaration#Left export AST#type_declaration#Left type kvValueType = AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left boolean AST#primary_type#Right | AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left number AST#primary_type#Right | AST#primary_type#Left Uint8Array AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right ; AST#type_declaration#Right AST#export_declaration#Right
export type kvValueType = boolean | string | number | Uint8Array;
https://github.com/hqj201013136012/HarmonyMiliUiPro.git/blob/0625e681e07b771998a0ac4430824627d0eb60ed/entry/src/main/ets/common/helper/kvManagerHelper.ets#L7-L7
8a44e93c58660dad7d9bb1cc57329d7132a2ac3a
github
sithvothykiv/dialog_hub.git
b676c102ef2d05f8994d170abe48dcc40cd39005
custom_dialog/src/main/ets/component/TextAreaDialogView.ets
arkts
TextAreaDialogView
TextArea文本输入
@ComponentV2 export struct TextAreaDialogView { private controller: TextInputController = new TextInputController() @Require @Param options: ITextAreaOptions; @Local customOptions: IBaseContentOptions | undefined = undefined; @Local modifier: TextAreaInputFilterModifier = new TextAreaInputFilterModifier(); @Local text: ResourceStr = ''; @Local textAlignment: Alignment = Alignment.Top; // @Local themeColorMode: ThemeColorMode = DialogHub.getThemeColorMode(); aboutToAppear(): void { this.text = this.options.text ?? ""; this.modifier.inputFilter = this.options.inputFilter; if (this.options.align == TextAlignment.Bottom) { this.textAlignment = Alignment.Bottom; } else if (this.options.align == TextAlignment.Center) { this.textAlignment = Alignment.Center; } else { this.textAlignment = Alignment.Top; } this.customOptions = (this.options as IBaseContentOptions); this.customOptions.contentBuilder = () => { this.InputBuilder() } // LRUCacheHelper.put(`${LRUCacheHelper.PRE_KEY}${this.options.dialogId ?? ""}`, this.text); if(this.options.observedData){ this.options.observedData.text = this.text as string; } } @Builder buildContent() { CustomContentDialog(this.customOptions as ESObject) .height(this.options.style?.height) .width(this.options.style?.width) .constraintSize({ maxWidth: this.options.style?.maxWidth, maxHeight: this.options.style?.maxHeight }) .backgroundColor(this.options.style?.backgroundColor) .backgroundBlurStyle(this.options.style?.backgroundBlurStyle) .border(this.options.style?.border) .borderRadius(this.options.style?.borderRadius) .backgroundImage(this.options.backgroundImage) .backgroundImageSize(this.options.backgroundImage ? (this.options.backgroundImageSize ?? ImageSize.FILL) : undefined) .padding(this.options?.style?.padding) .clip(true) .onClick(() => { //用于阻止点击冒泡,让点击mask遮罩事件能正常 focusControl.requestFocus('closeKeyboard'); //TODO:待确认点击没有关闭弹窗 }) } build() { this.buildContent() } @Builder InputBuilder() { // WithTheme({ colorMode: this.themeColorMode }) {//@ComponentV2不支持WithTheme TextArea({ controller: this.controller, text: $$this.text, placeholder: this.options.placeholder ?? '请输入' }) .type(this.options.inputType ?? TextAreaType.NORMAL) .defaultFocus(this.options.defaultFocus) .fontSize(this.options.style?.fontSize) .fontColor(this.options.style?.fontColor) .fontSize(this.options.style?.fontSize) .placeholderColor(this.options.style?.placeholderColor) .textAlign(this.options.textAlign) .align(this.textAlignment) .lineHeight(this.options.inputLineHeight) .backgroundColor(this.options.style?.inputBackgroundColor) .border(this.options.style?.inputBorder ?? { radius: 8 }) .maxLength(this.options.maxLength == 0 ? Infinity : this.options.maxLength) .attributeModifier(this.modifier) .width('100%') .height(this.options.style?.inputHeight ?? 155)//默认155 .padding({ top: 12, bottom: 12 }) .onChange((value: string, previewText?: PreviewText) => { // LRUCacheHelper.put(`${LRUCacheHelper.PRE_KEY}${this.options.dialogId ?? ""}`, value ?? ""); if(this.options.observedData){ this.options.observedData.text = value; } if (this.options.onChange) { this.options.onChange(value, this.options.dialogId ?? ''); } }) } }
AST#decorated_export_declaration#Left AST#decorator#Left @ ComponentV2 AST#decorator#Right export struct TextAreaDialogView AST#component_body#Left { AST#property_declaration#Left private controller : AST#type_annotation#Left AST#primary_type#Left TextInputController 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 TextInputController 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 AST#decorator#Left @ Require AST#decorator#Right AST#decorator#Left @ Param AST#decorator#Right options : AST#type_annotation#Left AST#primary_type#Left ITextAreaOptions AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Local AST#decorator#Right customOptions : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left IBaseContentOptions AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left undefined AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Local AST#decorator#Right modifier : AST#type_annotation#Left AST#primary_type#Left TextAreaInputFilterModifier 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 TextAreaInputFilterModifier 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 AST#decorator#Left @ Local AST#decorator#Right text : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Local AST#decorator#Right textAlignment : AST#type_annotation#Left AST#primary_type#Left Alignment AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left Alignment AST#expression#Right . Top AST#member_expression#Right AST#expression#Right ; AST#property_declaration#Right // @Local themeColorMode: ThemeColorMode = DialogHub.getThemeColorMode(); AST#method_declaration#Left aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . text 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 . text AST#member_expression#Right AST#expression#Right ?? AST#expression#Left "" 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 . modifier AST#member_expression#Right AST#expression#Right . inputFilter AST#member_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 . inputFilter AST#member_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#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 . align AST#member_expression#Right AST#expression#Right == AST#expression#Left TextAlignment AST#expression#Right AST#binary_expression#Right AST#expression#Right . Bottom 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 . textAlignment AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left Alignment AST#expression#Right . Bottom AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } else AST#ui_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 . options AST#member_expression#Right AST#expression#Right . align AST#member_expression#Right AST#expression#Right == AST#expression#Left TextAlignment AST#expression#Right AST#binary_expression#Right AST#expression#Right . Center 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 . textAlignment AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left Alignment AST#expression#Right . Center AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } else { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . textAlignment AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left Alignment AST#expression#Right . Top AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_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 . customOptions AST#member_expression#Right = AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left IBaseContentOptions AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_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 . customOptions AST#member_expression#Right AST#expression#Right . contentBuilder AST#member_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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . InputBuilder 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#assignment_expression#Right AST#expression#Right AST#expression_statement#Right // LRUCacheHelper.put(`${LRUCacheHelper.PRE_KEY}${this.options.dialogId ?? ""}`, this.text); 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 . options AST#member_expression#Right AST#expression#Right . observedData 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 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 . observedData AST#member_expression#Right AST#expression#Right . text AST#member_expression#Right = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . text AST#member_expression#Right 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#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 AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildContent 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 CustomContentDialog ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . customOptions AST#member_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left ESObject AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . style AST#member_expression#Right AST#expression#Right ?. height AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . style AST#member_expression#Right AST#expression#Right ?. width AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . constraintSize ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left maxWidth AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . style AST#member_expression#Right AST#expression#Right ?. maxWidth AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left maxHeight AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . style AST#member_expression#Right AST#expression#Right ?. maxHeight AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . style AST#member_expression#Right AST#expression#Right ?. backgroundColor AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundBlurStyle ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . style AST#member_expression#Right AST#expression#Right ?. backgroundBlurStyle AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . border ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . style AST#member_expression#Right AST#expression#Right ?. border AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . style AST#member_expression#Right AST#expression#Right ?. borderRadius AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundImage ( 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 . backgroundImage AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundImageSize ( 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 . backgroundImage AST#member_expression#Right 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . backgroundImageSize AST#member_expression#Right AST#expression#Right ?? AST#expression#Left ImageSize AST#expression#Right AST#binary_expression#Right AST#expression#Right . FILL AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right : AST#expression#Left undefined AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right ?. style AST#member_expression#Right AST#expression#Right ?. padding AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . clip ( AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { //用于阻止点击冒泡,让点击mask遮罩事件能正常 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left focusControl AST#expression#Right . requestFocus AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'closeKeyboard' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right //TODO:待确认点击没有关闭弹窗 } 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#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 AST#build_method#Left build ( ) AST#build_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 . buildContent 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#build_body#Right AST#build_method#Right AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right InputBuilder AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { // WithTheme({ colorMode: this.themeColorMode }) {//@ComponentV2不支持WithTheme AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left TextArea ( AST#component_parameters#Left { 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_parameter#Left text : AST#expression#Left AST#member_expression#Left AST#expression#Left $$this AST#expression#Right . text AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left placeholder : 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 . placeholder AST#member_expression#Right AST#expression#Right ?? AST#expression#Left '请输入' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . type ( 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 . inputType AST#member_expression#Right AST#expression#Right ?? AST#expression#Left TextAreaType AST#expression#Right AST#binary_expression#Right AST#expression#Right . NORMAL AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . defaultFocus ( 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 . defaultFocus AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . style AST#member_expression#Right AST#expression#Right ?. fontSize AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . style AST#member_expression#Right AST#expression#Right ?. fontColor AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . style AST#member_expression#Right AST#expression#Right ?. fontSize AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . placeholderColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . style AST#member_expression#Right AST#expression#Right ?. placeholderColor AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . textAlign ( 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 . textAlign AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . align ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . textAlignment AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . lineHeight ( 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 . inputLineHeight AST#member_expression#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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . style AST#member_expression#Right AST#expression#Right ?. inputBackgroundColor AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . border ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . style AST#member_expression#Right AST#expression#Right ?. inputBorder AST#member_expression#Right AST#expression#Right ?? AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left radius AST#property_name#Right : AST#expression#Left 8 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . maxLength AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#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 . maxLength 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Infinity AST#expression#Right AST#ERROR#Left : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left this . options . maxLength AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right ) AST#ERROR#Right . attributeModifier 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 . modifier AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . width AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '100%' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right . style AST#member_expression#Right AST#expression#Right ?. inputHeight AST#member_expression#Right AST#expression#Right ?? AST#expression#Left 155 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right //默认155 . padding AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 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#argument_list#Right AST#call_expression#Right AST#expression#Right . onChange AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left previewText ? : AST#type_annotation#Left AST#primary_type#Left PreviewText AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { // LRUCacheHelper.put(`${LRUCacheHelper.PRE_KEY}${this.options.dialogId ?? ""}`, value ?? ""); 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 . observedData 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 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 . observedData AST#member_expression#Right AST#expression#Right . text AST#member_expression#Right = AST#expression#Left value AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#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 . options AST#member_expression#Right AST#expression#Right . onChange 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 . onChange AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left value 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#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Right } AST#builder_function_body#Right AST#method_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@ComponentV2 export struct TextAreaDialogView { private controller: TextInputController = new TextInputController() @Require @Param options: ITextAreaOptions; @Local customOptions: IBaseContentOptions | undefined = undefined; @Local modifier: TextAreaInputFilterModifier = new TextAreaInputFilterModifier(); @Local text: ResourceStr = ''; @Local textAlignment: Alignment = Alignment.Top; aboutToAppear(): void { this.text = this.options.text ?? ""; this.modifier.inputFilter = this.options.inputFilter; if (this.options.align == TextAlignment.Bottom) { this.textAlignment = Alignment.Bottom; } else if (this.options.align == TextAlignment.Center) { this.textAlignment = Alignment.Center; } else { this.textAlignment = Alignment.Top; } this.customOptions = (this.options as IBaseContentOptions); this.customOptions.contentBuilder = () => { this.InputBuilder() } if(this.options.observedData){ this.options.observedData.text = this.text as string; } } @Builder buildContent() { CustomContentDialog(this.customOptions as ESObject) .height(this.options.style?.height) .width(this.options.style?.width) .constraintSize({ maxWidth: this.options.style?.maxWidth, maxHeight: this.options.style?.maxHeight }) .backgroundColor(this.options.style?.backgroundColor) .backgroundBlurStyle(this.options.style?.backgroundBlurStyle) .border(this.options.style?.border) .borderRadius(this.options.style?.borderRadius) .backgroundImage(this.options.backgroundImage) .backgroundImageSize(this.options.backgroundImage ? (this.options.backgroundImageSize ?? ImageSize.FILL) : undefined) .padding(this.options?.style?.padding) .clip(true) .onClick(() => { focusControl.requestFocus('closeKeyboard'); }) } build() { this.buildContent() } @Builder InputBuilder() { TextArea({ controller: this.controller, text: $$this.text, placeholder: this.options.placeholder ?? '请输入' }) .type(this.options.inputType ?? TextAreaType.NORMAL) .defaultFocus(this.options.defaultFocus) .fontSize(this.options.style?.fontSize) .fontColor(this.options.style?.fontColor) .fontSize(this.options.style?.fontSize) .placeholderColor(this.options.style?.placeholderColor) .textAlign(this.options.textAlign) .align(this.textAlignment) .lineHeight(this.options.inputLineHeight) .backgroundColor(this.options.style?.inputBackgroundColor) .border(this.options.style?.inputBorder ?? { radius: 8 }) .maxLength(this.options.maxLength == 0 ? Infinity : this.options.maxLength) .attributeModifier(this.modifier) .width('100%') .height(this.options.style?.inputHeight ?? 155) .padding({ top: 12, bottom: 12 }) .onChange((value: string, previewText?: PreviewText) => { if(this.options.observedData){ this.options.observedData.text = value; } if (this.options.onChange) { this.options.onChange(value, this.options.dialogId ?? ''); } }) } }
https://github.com/sithvothykiv/dialog_hub.git/blob/b676c102ef2d05f8994d170abe48dcc40cd39005/custom_dialog/src/main/ets/component/TextAreaDialogView.ets#L10-L101
a9fd4dbe33b0463366f3977bbded0ed878939bc9
github
harmonyos/samples
f5d967efaa7666550ee3252d118c3c73a77686f5
ETSUI/LoginSample/entry/src/main/ets/common/bean/ListItemData.ets
arkts
Basic list item data bean.
export class ListItemData { /** * Indicates list item title. */ title: Resource; /** * Indicates list item summary. */ summary: Resource; }
AST#export_declaration#Left export AST#class_declaration#Left class ListItemData AST#class_body#Left { /** * Indicates list item title. */ AST#property_declaration#Left title : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Indicates list item summary. */ AST#property_declaration#Left summary : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class ListItemData { title: Resource; summary: Resource; }
https://github.com/harmonyos/samples/blob/f5d967efaa7666550ee3252d118c3c73a77686f5/ETSUI/LoginSample/entry/src/main/ets/common/bean/ListItemData.ets#L4-L14
8b4d6773548deb936ca84818466f00846bd33dae
gitee
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/app/constants/AppTheme.ets
arkts
主题接口
export interface Theme { color: ColorPalette }
AST#export_declaration#Left export AST#interface_declaration#Left interface Theme AST#object_type#Left { AST#type_member#Left color : AST#type_annotation#Left AST#primary_type#Left ColorPalette 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 Theme { color: ColorPalette }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/app/constants/AppTheme.ets#L3-L5
1511237731ff2d23a94dd4ef0a3b199d9b1a0484
github
fmtjava/Ohs_ArkTs_Eyepetizer.git
79578f394ccb926da1455e63b7fe0722df9b9a22
entry/src/main/ets/common/PreferencesUtil.ets
arkts
getBoolean
读取布尔值数据 @param context 应用上下文 @param key 键 @param defaultValue 默认值 @returns 布尔值
static async getBoolean(context: common.UIAbilityContext, key: string, defaultValue: boolean = false): Promise<boolean> { try { const dataPreferences = await PreferencesUtil.getPreferences(context); return await dataPreferences.get(key, defaultValue) as boolean; } catch (error) { console.error('PreferencesUtil getBoolean error: ' + JSON.stringify(error)); return defaultValue; } }
AST#method_declaration#Left static async getBoolean AST#parameter_list#Left ( AST#parameter#Left context : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . UIAbilityContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#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 defaultValue : 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#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 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#variable_declaration#Left const AST#variable_declarator#Left dataPreferences = 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 context AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#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 AST#await_expression#Left await AST#expression#Left dataPreferences 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 defaultValue 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#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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'PreferencesUtil getBoolean error: ' AST#expression#Right + AST#expression#Left JSON AST#expression#Right AST#binary_expression#Right AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left defaultValue AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static async getBoolean(context: common.UIAbilityContext, key: string, defaultValue: boolean = false): Promise<boolean> { try { const dataPreferences = await PreferencesUtil.getPreferences(context); return await dataPreferences.get(key, defaultValue) as boolean; } catch (error) { console.error('PreferencesUtil getBoolean error: ' + JSON.stringify(error)); return defaultValue; } }
https://github.com/fmtjava/Ohs_ArkTs_Eyepetizer.git/blob/79578f394ccb926da1455e63b7fe0722df9b9a22/entry/src/main/ets/common/PreferencesUtil.ets#L121-L130
451af6ed87defe70f52fe82b1be6c63b9dfdf5fc
github
openharmony/interface_sdk-js
c349adc73e2ec1f61f6fca489b5af059e3ed6999
api/@ohos.arkui.advanced.ToolBarV2.d.ets
arkts
ToolBarV2ItemText
Declare type ToolBarV2ItemText @class ToolBarV2ItemText @syscap SystemCapability.ArkUI.ArkUI.Full @crossplatform @atomicservice @since 18
@ObservedV2 export declare class ToolBarV2ItemText { /** * Define text content. * * @type { ResourceStr }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 18 */ @Trace text: ResourceStr; /** * Define text fontColor. * * @type { ?ColorMetrics }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 18 */ @Trace color?: ColorMetrics; /** * Text fontColor when the item is activated. * * @type { ?ColorMetrics }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 18 */ @Trace activatedColor?: ColorMetrics; /** * The constructor used to create a ToolBarV2ItemText object. * * @param { ToolBarV2ItemTextOptions } options - text info. * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 18 */ constructor(options: ToolBarV2ItemTextOptions); }
AST#decorated_export_declaration#Left AST#decorator#Left @ ObservedV2 AST#decorator#Right export AST#ERROR#Left declare AST#ERROR#Right class ToolBarV2ItemText AST#class_body#Left { /** * Define text content. * * @type { ResourceStr }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 18 */ AST#property_declaration#Left AST#decorator#Left @ Trace AST#decorator#Right text : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Define text fontColor. * * @type { ?ColorMetrics }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 18 */ AST#property_declaration#Left AST#decorator#Left @ Trace AST#decorator#Right color ? : AST#type_annotation#Left AST#primary_type#Left ColorMetrics AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Text fontColor when the item is activated. * * @type { ?ColorMetrics }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 18 */ AST#property_declaration#Left AST#decorator#Left @ Trace AST#decorator#Right activatedColor ? : AST#type_annotation#Left AST#primary_type#Left ColorMetrics AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * The constructor used to create a ToolBarV2ItemText object. * * @param { ToolBarV2ItemTextOptions } options - text info. * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 18 */ AST#ERROR#Left constructor AST#parameter_list#Left ( AST#parameter#Left options : AST#type_annotation#Left AST#primary_type#Left ToolBarV2ItemTextOptions AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right ; AST#ERROR#Right } AST#class_body#Right AST#decorated_export_declaration#Right
@ObservedV2 export declare class ToolBarV2ItemText { @Trace text: ResourceStr; @Trace color?: ColorMetrics; @Trace activatedColor?: ColorMetrics; constructor(options: ToolBarV2ItemTextOptions); }
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.arkui.advanced.ToolBarV2.d.ets#L147-L192
ea243703199f1f2b64291fe49da7509842bc4be2
gitee
bigbear20240612/planner_build-.git
89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1
entry/src/main/ets/viewmodel/AcademyManager.ets
arkts
practiceMethod
实践方法论
practiceMethod(methodId: string): void { const progress = this.learningProgress.get(methodId); if (!progress) return; const updatedProgress: LearningProgress = { methodId: progress.methodId, methodName: progress.methodName, status: progress.status, progress: progress.progress, startDate: progress.startDate, completedDate: progress.completedDate, studyTimeMinutes: progress.studyTimeMinutes, practiceCount: progress.practiceCount + 1, lastStudyDate: new Date() }; this.learningProgress.set(methodId, updatedProgress); this.updateLearningProgress(methodId, 10); // 实践获得10%进度 }
AST#method_declaration#Left practiceMethod AST#parameter_list#Left ( AST#parameter#Left methodId : 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 progress = 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 . learningProgress AST#member_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left methodId AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left progress AST#expression#Right AST#unary_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 updatedProgress : AST#type_annotation#Left AST#primary_type#Left LearningProgress AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left methodId AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left progress AST#expression#Right . methodId AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left methodName AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left progress AST#expression#Right . methodName AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left status AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left progress AST#expression#Right . status AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left progress AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left progress AST#expression#Right . progress AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left startDate AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left progress AST#expression#Right . startDate AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left completedDate AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left progress AST#expression#Right . completedDate AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left studyTimeMinutes AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left progress AST#expression#Right . studyTimeMinutes AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left practiceCount AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left progress AST#expression#Right . practiceCount AST#member_expression#Right AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left lastStudyDate AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#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 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 . learningProgress AST#member_expression#Right AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left methodId AST#expression#Right , AST#expression#Left updatedProgress 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 . updateLearningProgress AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left methodId AST#expression#Right , AST#expression#Left 10 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 实践获得10%进度 } AST#block_statement#Right AST#method_declaration#Right
practiceMethod(methodId: string): void { const progress = this.learningProgress.get(methodId); if (!progress) return; const updatedProgress: LearningProgress = { methodId: progress.methodId, methodName: progress.methodName, status: progress.status, progress: progress.progress, startDate: progress.startDate, completedDate: progress.completedDate, studyTimeMinutes: progress.studyTimeMinutes, practiceCount: progress.practiceCount + 1, lastStudyDate: new Date() }; this.learningProgress.set(methodId, updatedProgress); this.updateLearningProgress(methodId, 10); }
https://github.com/bigbear20240612/planner_build-.git/blob/89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1/entry/src/main/ets/viewmodel/AcademyManager.ets#L233-L251
b60b401d0e843a1fd40a8815f76aaa41191c3975
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
完整农历系统设计.ets
arkts
getDayOffset
计算日期偏移
private static getDayOffset(date: Date): number { const base = new Date(1900, 0, 1); return Math.floor((date.getTime() - base.getTime()) / (1000 * 60 * 60 * 24)); }
AST#method_declaration#Left private static getDayOffset AST#parameter_list#Left ( AST#parameter#Left date : AST#type_annotation#Left AST#primary_type#Left Date AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left base = 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 1900 AST#expression#Right , AST#expression#Left 0 AST#expression#Right , AST#expression#Left 1 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 Math AST#expression#Right . floor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date 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 base AST#expression#Right AST#binary_expression#Right AST#expression#Right . getTime AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right / AST#expression#Left AST#parenthesized_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 1000 AST#expression#Right * AST#expression#Left 60 AST#expression#Right AST#binary_expression#Right AST#expression#Right * AST#expression#Left 60 AST#expression#Right AST#binary_expression#Right AST#expression#Right * AST#expression#Left 24 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private static getDayOffset(date: Date): number { const base = new Date(1900, 0, 1); return Math.floor((date.getTime() - base.getTime()) / (1000 * 60 * 60 * 24)); }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/完整农历系统设计.ets#L439-L442
3ebc754783dfaaad23110a259280e71d4e19da51
github
gracienewd/openharmony-App-YunmoAi.git
181952ab00aab5025a81b7b3a6b88d2a5258c76a
entry/src/main/ets/common/utils/AssetUtils.ets
arkts
基于 @ohos.security.asset 的封装。可以保证『重装/删除应用而不丢失数据』。 @author Tanranran @date 2024/5/14 22:14 @description 关键资产存储服务提供了用户短敏感数据的安全存储及管理能力。 其中,短敏感数据可以是密码类(账号/密码)、Token类(应用凭据)、其他关键明文(如银行卡号)等长度较短的用户敏感数据。 可在应用卸载时保留数据。需要权限: ohos.permission.STORE_PERSISTENT_DATA。 更多API可参考https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-asset-0000001815758836-V5 使用例子: // 增。 const result = await AssetStore.set('key', 'value'); if (result.isSuccess) { console.log('asset add succeeded') } 删。 AssetStore.remove('key'); if (result.isSuccess) { console.log('asset remove succeeded') } 改 const result = await AssetStore.update('key', 'value'); if (result.isSuccess) { console.log('asset update succeeded') } 读取。 const result = (await AssetStore.get('key')); if (result.isSuccess) { console.log('asset get succeeded, value == ', result.data) }
export class AssetStore { /** * 新增数据 * 添加成功,会通过 AppStorage 传值值变更,外部可通过 @StorageProp(key) value: string 观察值变化。 * @param key 要添加的索引 * @param value 要添加的值 * @param isPersistent 在应用卸载时是否需要保留关键资产,默认为 true * @returns Promise<AssetStoreResult> 表示添加操作的异步结果 */ public static async set(key: string, value: string, isPersistent: boolean = true): Promise<AssetStoreResult> { let attr: asset.AssetMap = new Map(); if (canIUse("SystemCapability.Security.Asset")) { // 关键资产别名,每条关键资产的唯一索引。 // 类型为Uint8Array,长度为1-256字节。 attr.set(asset.Tag.ALIAS, AssetStore.stringToArray(key)); // 关键资产明文。 // 类型为Uint8Array,长度为1-1024字节 attr.set(asset.Tag.SECRET, AssetStore.stringToArray(value)); // 关键资产同步类型>THIS_DEVICE只在本设备进行同步,如仅在本设备还原的备份场景。 attr.set(asset.Tag.SYNC_TYPE, asset.SyncType.THIS_DEVICE); //枚举,新增关键资产时的冲突(如:别名相同)处理策略。OVERWRITE》抛出异常,由业务进行后续处理。 attr.set(asset.Tag.CONFLICT_RESOLUTION,asset.ConflictResolution.THROW_ERROR) // 在应用卸载时是否需要保留关键资产。 // 需要权限: ohos.permission.STORE_PERSISTENT_DATA。 // 类型为bool。 if (isPersistent) { attr.set(asset.Tag.IS_PERSISTENT, isPersistent); } } let result: AssetStoreResult if ((await AssetStore.has(key)).isSuccess) { result = await AssetStore.updateAssetMap(attr, attr); } else { result = await AssetStore.setAssetMap(attr); } if (result.isSuccess) { hilog.debug(0x1111,'AssetStore', `AssetStore: Asset add succeeded. Key is ${key}, value is ${value}, isPersistent is ${isPersistent}`); // 添加成功,会通过 AppStorage 传值值变更,外部可通过 @StorageProp(key) value: string 观察值变化。 AppStorage.setOrCreate(key, value); } return result; } /** * 新增数据 * @param attr 要添加的属性集 * @returns Promise<AssetStoreResult> 表示添加操作的异步结果 */ public static async setAssetMap(attr: asset.AssetMap): Promise<AssetStoreResult> { try { if (canIUse("SystemCapability.Security.Asset")) { await asset.add(attr); return { isSuccess: true }; } return { isSuccess: false, error: AssetStore.getUnSupportedPlatforms() }; } catch (error) { const err = error as BusinessError; hilog.debug(0x1111,'AssetStore', `AssetStore: Failed to add Asset. Code is ${err.code}, message is ${err.message}`); return { isSuccess: false, error: err }; } } /** * 删除数据 * 删除成功,会通过 AppStorage 传值值变更,外部可通过 @StorageProp(key) value: string 观察值变化。 * AppStorage API12 及以上支持 undefined 和 null类型。 * @param key 要删除的索引 * @returns Promise<AssetStoreResult> 表示添加操作的异步结果 */ public static async remove(key: string) { let query: asset.AssetMap = new Map(); if (canIUse("SystemCapability.Security.Asset")) { // 关键资产别名,每条关键资产的唯一索引。 // 类型为Uint8Array,长度为1-256字节。 query.set(asset.Tag.ALIAS, AssetStore.stringToArray(key)); } const result = await AssetStore.removeAssetMap(query); if (result.isSuccess) { hilog.debug(0x1111,'AssetStore', `AssetStore: Asset remove succeeded. Key is ${key}`); // 删除成功,会通过 AppStorage 传值值变更,外部可通过 @StorageProp(key) value: string 观察值变化。 // AppStorage API12 及以上支持 undefined 和 null类型。 AppStorage.setOrCreate(key, ''); } return result; } /** * 删除数据 * @param attr 要删除的属性集 * @returns Promise<AssetStoreResult> 表示添加操作的异步结果 */ public static async removeAssetMap(attr: asset.AssetMap): Promise<AssetStoreResult> { try { if (canIUse("SystemCapability.Security.Asset")) { await asset.remove(attr); return { isSuccess: true }; } return { isSuccess: false }; } catch (error) { const err = error as BusinessError; hilog.debug(0x1111,'AssetStore', `AssetStore: Failed to remove Asset. Code is ${err.code}, message is ${err.message}`); return { isSuccess: false, error: err }; } } /** * 判断是否存在 数据 * @param key 要查找的索引 * @returns Promise<AssetStoreResult> 表示添加操作的异步结果 */ public static async has(key: string): Promise<AssetStoreResult> { if (canIUse("SystemCapability.Security.Asset")) { let query: asset.AssetMap = new Map(); // 关键资产别名,每条关键资产的唯一索引。 // 类型为Uint8Array,长度为1-256字节。 query.set(asset.Tag.ALIAS, AssetStore.stringToArray(key)); // 关键资产查询返回的结果类型。 query.set(asset.Tag.RETURN_TYPE, asset.ReturnType.ALL); const result = await AssetStore.getAssetMap(query); const res = result.res; if (!res) { return { isSuccess: false, error: result.error }; } if (res.length < 1) { return { isSuccess: false }; } } return { isSuccess: false }; } /** * 查找数据 * @param key 要查找的索引 * @returns Promise<AssetStoreResult> 表示添加操作的异步结果 */ public static async get(key: string): Promise<AssetStoreResult> { if (canIUse("SystemCapability.Security.Asset")) { let query: asset.AssetMap = new Map(); // 关键资产别名,每条关键资产的唯一索引。 // 类型为Uint8Array,长度为1-256字节。 query.set(asset.Tag.ALIAS, AssetStore.stringToArray(key)); // 关键资产查询返回的结果类型。 query.set(asset.Tag.RETURN_TYPE, asset.ReturnType.ALL); const result = await AssetStore.getAssetMap(query); const res = result.res; if (!res) { return { isSuccess: false, error: result.error }; } if (res.length < 1) { return { isSuccess: false }; } // parse the secret. let secret: Uint8Array = res[0].get(asset.Tag.SECRET) as Uint8Array; // parse uint8array to string let secretStr: string = AssetStore.arrayToString(secret); return { isSuccess: true, data: secretStr }; } return { isSuccess: false, data: "" }; } /** * 查找数据 * @param key 要查找的索引 * @returns Promise<AssetStoreQueryResult> 表示添加操作的异步结果 */ public static async getAssetMap(query: asset.AssetMap): Promise<AssetStoreQueryResult> { try { if (canIUse("SystemCapability.Security.Asset")) { const res: asset.AssetMap[] = await asset.query(query); return { res: res }; } return { error: AssetStore.getUnSupportedPlatforms() }; } catch (error) { const err = error as BusinessError; hilog.debug(0x1111,'AssetStore', `AssetStore>getAssetMap: Failed to query Asset. Code is ${err.code}, message is ${err.message}`); return { error: err }; } } /** * 更新数据 * @param query 要更新的索引数据集 * @param attrsToUpdate 要更新的数据集 * @returns Promise<AssetStoreResult> 表示添加操作的异步结果 */ public static async updateAssetMap(query: asset.AssetMap, attrsToUpdate: asset.AssetMap): Promise<AssetStoreResult> { try { if (canIUse("SystemCapability.Security.Asset")) { await asset.update(query, attrsToUpdate); return { isSuccess: true }; } return { isSuccess: false, error: AssetStore.getUnSupportedPlatforms() }; } catch (error) { const err = error as BusinessError; hilog.debug(0x1111, 'AssetStore', `AssetStore: Failed to update Asset. Code is ${err.code}, message is ${err.message}`); return { isSuccess: false, error: err }; } } private static stringToArray(str: string): Uint8Array { let textEncoder = new util.TextEncoder(); return textEncoder.encodeInto(str); } private static arrayToString(arr: Uint8Array): string { let textDecoder = util.TextDecoder.create('utf-8', { ignoreBOM: true }); let str = textDecoder.decodeWithStream(arr, { stream: false }); return str; } private static getUnSupportedPlatforms() { return { name: "AssetStore", message: "不支持该平台" } as BusinessError } }
AST#export_declaration#Left export AST#class_declaration#Left class AssetStore AST#class_body#Left { /** * 新增数据 * 添加成功,会通过 AppStorage 传值值变更,外部可通过 @StorageProp(key) value: string 观察值变化。 * @param key 要添加的索引 * @param value 要添加的值 * @param isPersistent 在应用卸载时是否需要保留关键资产,默认为 true * @returns Promise<AssetStoreResult> 表示添加操作的异步结果 */ AST#method_declaration#Left public static async set 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 string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left isPersistent : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AssetStoreResult 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 attr : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left asset . AssetMap AST#qualified_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 Map 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#call_expression#Left AST#expression#Left canIUse AST#expression#Right AST#argument_list#Left ( AST#expression#Left "SystemCapability.Security.Asset" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { // 关键资产别名,每条关键资产的唯一索引。 // 类型为Uint8Array,长度为1-256字节。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left attr AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left asset AST#expression#Right . Tag AST#member_expression#Right AST#expression#Right . ALIAS AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AssetStore AST#expression#Right . stringToArray AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 关键资产明文。 // 类型为Uint8Array,长度为1-1024字节 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left attr AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left asset AST#expression#Right . Tag AST#member_expression#Right AST#expression#Right . SECRET AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AssetStore AST#expression#Right . stringToArray 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#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 关键资产同步类型>THIS_DEVICE只在本设备进行同步,如仅在本设备还原的备份场景。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left attr AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left asset AST#expression#Right . Tag AST#member_expression#Right AST#expression#Right . SYNC_TYPE AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left asset AST#expression#Right . SyncType AST#member_expression#Right AST#expression#Right . THIS_DEVICE 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 //枚举,新增关键资产时的冲突(如:别名相同)处理策略。OVERWRITE》抛出异常,由业务进行后续处理。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left attr AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left asset AST#expression#Right . Tag AST#member_expression#Right AST#expression#Right . CONFLICT_RESOLUTION AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left asset AST#expression#Right . ConflictResolution AST#member_expression#Right AST#expression#Right . THROW_ERROR 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 // 在应用卸载时是否需要保留关键资产。 // 需要权限: ohos.permission.STORE_PERSISTENT_DATA。 // 类型为bool。 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left isPersistent 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 attr AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left asset AST#expression#Right . Tag AST#member_expression#Right AST#expression#Right . IS_PERSISTENT AST#member_expression#Right AST#expression#Right , AST#expression#Left isPersistent 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#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left result : AST#type_annotation#Left AST#primary_type#Left AssetStoreResult AST#primary_type#Right AST#type_annotation#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_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 AssetStore AST#expression#Right AST#await_expression#Right AST#expression#Right . has AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . isSuccess 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 result = 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 AssetStore AST#expression#Right AST#await_expression#Right AST#expression#Right . updateAssetMap AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left attr AST#expression#Right , AST#expression#Left attr 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 else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left result = 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 AssetStore AST#expression#Right AST#await_expression#Right AST#expression#Right . setAssetMap AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left attr AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . isSuccess 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 hilog AST#expression#Right . debug AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x1111 AST#expression#Right , AST#expression#Left 'AssetStore' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` AssetStore: Asset add succeeded. Key is AST#template_substitution#Left $ { AST#expression#Left key AST#expression#Right } AST#template_substitution#Right , value is AST#template_substitution#Left $ { AST#expression#Left value AST#expression#Right } AST#template_substitution#Right , isPersistent is AST#template_substitution#Left $ { AST#expression#Left isPersistent 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 // 添加成功,会通过 AppStorage 传值值变更,外部可通过 @StorageProp(key) value: string 观察值变化。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . setOrCreate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 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#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left result AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 新增数据 * @param attr 要添加的属性集 * @returns Promise<AssetStoreResult> 表示添加操作的异步结果 */ AST#method_declaration#Left public static async setAssetMap AST#parameter_list#Left ( AST#parameter#Left attr : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left asset . AssetMap AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AssetStoreResult 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#call_expression#Left AST#expression#Left canIUse AST#expression#Right AST#argument_list#Left ( AST#expression#Left "SystemCapability.Security.Asset" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left asset AST#expression#Right AST#await_expression#Right AST#expression#Right . add AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left attr 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#object_literal#Left { AST#property_assignment#Left AST#property_name#Left isSuccess 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#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#object_literal#Left { AST#property_assignment#Left AST#property_name#Left isSuccess 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 error AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AssetStore AST#expression#Right . getUnSupportedPlatforms 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#return_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 BusinessError 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 . debug AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x1111 AST#expression#Right , AST#expression#Left 'AssetStore' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` AssetStore: Failed to add Asset. Code is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , message is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left isSuccess 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 error AST#property_name#Right : AST#expression#Left err 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#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 删除数据 * 删除成功,会通过 AppStorage 传值值变更,外部可通过 @StorageProp(key) value: string 观察值变化。 * AppStorage API12 及以上支持 undefined 和 null类型。 * @param key 要删除的索引 * @returns Promise<AssetStoreResult> 表示添加操作的异步结果 */ AST#method_declaration#Left public static async remove 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 query : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left asset . AssetMap AST#qualified_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 Map 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#call_expression#Left AST#expression#Left canIUse AST#expression#Right AST#argument_list#Left ( AST#expression#Left "SystemCapability.Security.Asset" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { // 关键资产别名,每条关键资产的唯一索引。 // 类型为Uint8Array,长度为1-256字节。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left query AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left asset AST#expression#Right . Tag AST#member_expression#Right AST#expression#Right . ALIAS AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AssetStore AST#expression#Right . stringToArray AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left result = 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 AssetStore AST#expression#Right AST#await_expression#Right AST#expression#Right . removeAssetMap AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left query 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 result AST#expression#Right . isSuccess 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 hilog AST#expression#Right . debug AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x1111 AST#expression#Right , AST#expression#Left 'AssetStore' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` AssetStore: Asset remove succeeded. Key is AST#template_substitution#Left $ { AST#expression#Left key 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 // 删除成功,会通过 AppStorage 传值值变更,外部可通过 @StorageProp(key) value: string 观察值变化。 // AppStorage API12 及以上支持 undefined 和 null类型。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . setOrCreate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right , 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#statement#Left AST#return_statement#Left return AST#expression#Left result AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 删除数据 * @param attr 要删除的属性集 * @returns Promise<AssetStoreResult> 表示添加操作的异步结果 */ AST#method_declaration#Left public static async removeAssetMap AST#parameter_list#Left ( AST#parameter#Left attr : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left asset . AssetMap AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AssetStoreResult 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#call_expression#Left AST#expression#Left canIUse AST#expression#Right AST#argument_list#Left ( AST#expression#Left "SystemCapability.Security.Asset" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left asset AST#expression#Right AST#await_expression#Right AST#expression#Right . remove AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left attr 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#object_literal#Left { AST#property_assignment#Left AST#property_name#Left isSuccess 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#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#object_literal#Left { AST#property_assignment#Left AST#property_name#Left isSuccess AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_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#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 BusinessError 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 . debug AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x1111 AST#expression#Right , AST#expression#Left 'AssetStore' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` AssetStore: Failed to remove Asset. Code is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , message is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left isSuccess 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 error AST#property_name#Right : AST#expression#Left err 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#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 判断是否存在 数据 * @param key 要查找的索引 * @returns Promise<AssetStoreResult> 表示添加操作的异步结果 */ AST#method_declaration#Left public static async has 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#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AssetStoreResult 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#call_expression#Left AST#expression#Left canIUse AST#expression#Right AST#argument_list#Left ( AST#expression#Left "SystemCapability.Security.Asset" 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 let AST#variable_declarator#Left query : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left asset . AssetMap AST#qualified_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 Map 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 // 关键资产别名,每条关键资产的唯一索引。 // 类型为Uint8Array,长度为1-256字节。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left query AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left asset AST#expression#Right . Tag AST#member_expression#Right AST#expression#Right . ALIAS AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AssetStore AST#expression#Right . stringToArray AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 关键资产查询返回的结果类型。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left query AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left asset AST#expression#Right . Tag AST#member_expression#Right AST#expression#Right . RETURN_TYPE AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left asset AST#expression#Right . ReturnType AST#member_expression#Right AST#expression#Right . ALL 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 result = 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 AssetStore AST#expression#Right AST#await_expression#Right AST#expression#Right . getAssetMap AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left query 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 res = AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . res AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left res 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 AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left isSuccess 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 error AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . error 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#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 res 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 AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left isSuccess AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_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#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 AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left isSuccess AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_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 /** * 查找数据 * @param key 要查找的索引 * @returns Promise<AssetStoreResult> 表示添加操作的异步结果 */ AST#method_declaration#Left public static async get 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#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AssetStoreResult 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#call_expression#Left AST#expression#Left canIUse AST#expression#Right AST#argument_list#Left ( AST#expression#Left "SystemCapability.Security.Asset" 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 let AST#variable_declarator#Left query : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left asset . AssetMap AST#qualified_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 Map 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 // 关键资产别名,每条关键资产的唯一索引。 // 类型为Uint8Array,长度为1-256字节。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left query AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left asset AST#expression#Right . Tag AST#member_expression#Right AST#expression#Right . ALIAS AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AssetStore AST#expression#Right . stringToArray AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 关键资产查询返回的结果类型。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left query AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left asset AST#expression#Right . Tag AST#member_expression#Right AST#expression#Right . RETURN_TYPE AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left asset AST#expression#Right . ReturnType AST#member_expression#Right AST#expression#Right . ALL 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 result = 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 AssetStore AST#expression#Right AST#await_expression#Right AST#expression#Right . getAssetMap AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left query 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 res = AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . res AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left res 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 AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left isSuccess 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 error AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . error 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#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 res 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 AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left isSuccess AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_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#if_statement#Right AST#statement#Right // parse the secret. AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left secret : AST#type_annotation#Left AST#primary_type#Left Uint8Array AST#primary_type#Right AST#type_annotation#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 AST#subscript_expression#Left AST#expression#Left res AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . get 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 asset AST#expression#Right . Tag AST#member_expression#Right AST#expression#Right . SECRET AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left Uint8Array 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 // parse uint8array to string AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left secretStr : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AssetStore AST#expression#Right . arrayToString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left secret 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 isSuccess 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 data AST#property_name#Right : AST#expression#Left secretStr 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#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left isSuccess 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 data AST#property_name#Right : AST#expression#Left "" 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 /** * 查找数据 * @param key 要查找的索引 * @returns Promise<AssetStoreQueryResult> 表示添加操作的异步结果 */ AST#method_declaration#Left public static async getAssetMap AST#parameter_list#Left ( AST#parameter#Left query : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left asset . AssetMap AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AssetStoreQueryResult 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#call_expression#Left AST#expression#Left canIUse AST#expression#Right AST#argument_list#Left ( AST#expression#Left "SystemCapability.Security.Asset" 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 res : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left asset AST#ERROR#Left . AssetMap AST#ERROR#Right [ ] 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#await_expression#Left await AST#expression#Left asset AST#expression#Right AST#await_expression#Right AST#expression#Right . query AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left query 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 res AST#property_name#Right : AST#expression#Left res 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#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left error AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AssetStore AST#expression#Right . getUnSupportedPlatforms 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#return_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 BusinessError 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 . debug AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x1111 AST#expression#Right , AST#expression#Left 'AssetStore' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` AssetStore>getAssetMap: Failed to query Asset. Code is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , message is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left error AST#property_name#Right : AST#expression#Left err 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#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 更新数据 * @param query 要更新的索引数据集 * @param attrsToUpdate 要更新的数据集 * @returns Promise<AssetStoreResult> 表示添加操作的异步结果 */ AST#method_declaration#Left public static async updateAssetMap AST#parameter_list#Left ( AST#parameter#Left query : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left asset . AssetMap AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left attrsToUpdate : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left asset . AssetMap AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AssetStoreResult 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#call_expression#Left AST#expression#Left canIUse AST#expression#Right AST#argument_list#Left ( AST#expression#Left "SystemCapability.Security.Asset" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left asset AST#expression#Right AST#await_expression#Right AST#expression#Right . update AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left query AST#expression#Right , AST#expression#Left attrsToUpdate 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#object_literal#Left { AST#property_assignment#Left AST#property_name#Left isSuccess 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#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#object_literal#Left { AST#property_assignment#Left AST#property_name#Left isSuccess 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 error AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AssetStore AST#expression#Right . getUnSupportedPlatforms 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#return_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 BusinessError 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 . debug AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x1111 AST#expression#Right , AST#expression#Left 'AssetStore' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` AssetStore: Failed to update Asset. Code is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , message is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left isSuccess 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 error AST#property_name#Right : AST#expression#Left err 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#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left private static stringToArray 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 Uint8Array AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left textEncoder = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left util AST#expression#Right AST#new_expression#Right AST#expression#Right . TextEncoder 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 textEncoder AST#expression#Right . encodeInto 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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left private static arrayToString AST#parameter_list#Left ( AST#parameter#Left arr : AST#type_annotation#Left AST#primary_type#Left Uint8Array AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left textDecoder = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left util AST#expression#Right . TextDecoder AST#member_expression#Right AST#expression#Right . create AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'utf-8' AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left ignoreBOM 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left str = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left textDecoder AST#expression#Right . decodeWithStream AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left arr AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left stream AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left str AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left private static getUnSupportedPlatforms AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#as_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left name AST#property_name#Right : AST#expression#Left "AssetStore" AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left "不支持该平台" AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right 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#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 AssetStore { public static async set(key: string, value: string, isPersistent: boolean = true): Promise<AssetStoreResult> { let attr: asset.AssetMap = new Map(); if (canIUse("SystemCapability.Security.Asset")) { attr.set(asset.Tag.ALIAS, AssetStore.stringToArray(key)); attr.set(asset.Tag.SECRET, AssetStore.stringToArray(value)); attr.set(asset.Tag.SYNC_TYPE, asset.SyncType.THIS_DEVICE); attr.set(asset.Tag.CONFLICT_RESOLUTION,asset.ConflictResolution.THROW_ERROR) if (isPersistent) { attr.set(asset.Tag.IS_PERSISTENT, isPersistent); } } let result: AssetStoreResult if ((await AssetStore.has(key)).isSuccess) { result = await AssetStore.updateAssetMap(attr, attr); } else { result = await AssetStore.setAssetMap(attr); } if (result.isSuccess) { hilog.debug(0x1111,'AssetStore', `AssetStore: Asset add succeeded. Key is ${key}, value is ${value}, isPersistent is ${isPersistent}`); AppStorage.setOrCreate(key, value); } return result; } public static async setAssetMap(attr: asset.AssetMap): Promise<AssetStoreResult> { try { if (canIUse("SystemCapability.Security.Asset")) { await asset.add(attr); return { isSuccess: true }; } return { isSuccess: false, error: AssetStore.getUnSupportedPlatforms() }; } catch (error) { const err = error as BusinessError; hilog.debug(0x1111,'AssetStore', `AssetStore: Failed to add Asset. Code is ${err.code}, message is ${err.message}`); return { isSuccess: false, error: err }; } } public static async remove(key: string) { let query: asset.AssetMap = new Map(); if (canIUse("SystemCapability.Security.Asset")) { query.set(asset.Tag.ALIAS, AssetStore.stringToArray(key)); } const result = await AssetStore.removeAssetMap(query); if (result.isSuccess) { hilog.debug(0x1111,'AssetStore', `AssetStore: Asset remove succeeded. Key is ${key}`); AppStorage.setOrCreate(key, ''); } return result; } public static async removeAssetMap(attr: asset.AssetMap): Promise<AssetStoreResult> { try { if (canIUse("SystemCapability.Security.Asset")) { await asset.remove(attr); return { isSuccess: true }; } return { isSuccess: false }; } catch (error) { const err = error as BusinessError; hilog.debug(0x1111,'AssetStore', `AssetStore: Failed to remove Asset. Code is ${err.code}, message is ${err.message}`); return { isSuccess: false, error: err }; } } public static async has(key: string): Promise<AssetStoreResult> { if (canIUse("SystemCapability.Security.Asset")) { let query: asset.AssetMap = new Map(); query.set(asset.Tag.ALIAS, AssetStore.stringToArray(key)); query.set(asset.Tag.RETURN_TYPE, asset.ReturnType.ALL); const result = await AssetStore.getAssetMap(query); const res = result.res; if (!res) { return { isSuccess: false, error: result.error }; } if (res.length < 1) { return { isSuccess: false }; } } return { isSuccess: false }; } public static async get(key: string): Promise<AssetStoreResult> { if (canIUse("SystemCapability.Security.Asset")) { let query: asset.AssetMap = new Map(); query.set(asset.Tag.ALIAS, AssetStore.stringToArray(key)); query.set(asset.Tag.RETURN_TYPE, asset.ReturnType.ALL); const result = await AssetStore.getAssetMap(query); const res = result.res; if (!res) { return { isSuccess: false, error: result.error }; } if (res.length < 1) { return { isSuccess: false }; } let secret: Uint8Array = res[0].get(asset.Tag.SECRET) as Uint8Array; let secretStr: string = AssetStore.arrayToString(secret); return { isSuccess: true, data: secretStr }; } return { isSuccess: false, data: "" }; } public static async getAssetMap(query: asset.AssetMap): Promise<AssetStoreQueryResult> { try { if (canIUse("SystemCapability.Security.Asset")) { const res: asset.AssetMap[] = await asset.query(query); return { res: res }; } return { error: AssetStore.getUnSupportedPlatforms() }; } catch (error) { const err = error as BusinessError; hilog.debug(0x1111,'AssetStore', `AssetStore>getAssetMap: Failed to query Asset. Code is ${err.code}, message is ${err.message}`); return { error: err }; } } public static async updateAssetMap(query: asset.AssetMap, attrsToUpdate: asset.AssetMap): Promise<AssetStoreResult> { try { if (canIUse("SystemCapability.Security.Asset")) { await asset.update(query, attrsToUpdate); return { isSuccess: true }; } return { isSuccess: false, error: AssetStore.getUnSupportedPlatforms() }; } catch (error) { const err = error as BusinessError; hilog.debug(0x1111, 'AssetStore', `AssetStore: Failed to update Asset. Code is ${err.code}, message is ${err.message}`); return { isSuccess: false, error: err }; } } private static stringToArray(str: string): Uint8Array { let textEncoder = new util.TextEncoder(); return textEncoder.encodeInto(str); } private static arrayToString(arr: Uint8Array): string { let textDecoder = util.TextDecoder.create('utf-8', { ignoreBOM: true }); let str = textDecoder.decodeWithStream(arr, { stream: false }); return str; } private static getUnSupportedPlatforms() { return { name: "AssetStore", message: "不支持该平台" } as BusinessError } }
https://github.com/gracienewd/openharmony-App-YunmoAi.git/blob/181952ab00aab5025a81b7b3a6b88d2a5258c76a/entry/src/main/ets/common/utils/AssetUtils.ets#L53-L278
223e2cced080ce476f3c7df2c09192844754fb21
github
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_core/src/main/ets/core/util/ArrayUtil.ets
arkts
isEmpty
集合是否为空集合,空为true否则false @param array @returns
static isEmpty<T>(array: T[]): boolean { return array == null || array.length == 0; }
AST#method_declaration#Left static isEmpty AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right > AST#type_parameters#Right AST#parameter_list#Left ( AST#parameter#Left array : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left T [ ] 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 boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left array 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 array 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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static isEmpty<T>(array: T[]): boolean { return array == null || array.length == 0; }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_core/src/main/ets/core/util/ArrayUtil.ets#L50-L52
98c11c5074a9496fbb6554411479c45d42607442
gitee
wangjinyuan/JS-TS-ArkTS-database.git
a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26
npm/alprazolamdiv/11.5.1/package/src/structures/VoiceChannel.ets
arkts
应用约束1: 显式参数类型
constructor(guild: Guild, data: VoiceChannelData) { super(guild, data); this.setup(data); }
AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left guild : AST#type_annotation#Left AST#primary_type#Left Guild AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left VoiceChannelData 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 super AST#expression#Right AST#argument_list#Left ( AST#expression#Left guild 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#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 . setup 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#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right
constructor(guild: Guild, data: VoiceChannelData) { super(guild, data); this.setup(data); }
https://github.com/wangjinyuan/JS-TS-ArkTS-database.git/blob/a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26/npm/alprazolamdiv/11.5.1/package/src/structures/VoiceChannel.ets#L26-L29
0d4ebc1004d61cfc4953fa5a12d35d4a230f2c78
github
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
OptimizationAppMemoryUsage/entry/src/main/ets/utils/LRUCacheUtil.ets
arkts
remove
Delete the cache corresponding to the key
public remove(key: string): void { this.lruCache.remove(key); }
AST#method_declaration#Left public remove 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#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 . lruCache AST#member_expression#Right AST#expression#Right . remove AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key 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 remove(key: string): void { this.lruCache.remove(key); }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/OptimizationAppMemoryUsage/entry/src/main/ets/utils/LRUCacheUtil.ets#L41-L43
2d0d3f1e366b22b5cc2bb6876c752a965f32ef09
gitee
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
ArkWebrenderingframework/entry/src/main/ets/pages/proxy.ets
arkts
call
[Start listener] Execute channel call
call(channelType: string, objectJson: string): any { let fun = this.channelListeners.get(channelType); if (!fun) { return undefined; } let result :string= fun(JSON.parse(objectJson)); return JSON.stringify(result); }
AST#method_declaration#Left call AST#parameter_list#Left ( AST#parameter#Left channelType : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left objectJson : 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 any AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left fun = 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 . channelListeners AST#member_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left channelType AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left fun 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 undefined AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left result : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left fun AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . parse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left objectJson AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return 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 result 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
call(channelType: string, objectJson: string): any { let fun = this.channelListeners.get(channelType); if (!fun) { return undefined; } let result :string= fun(JSON.parse(objectJson)); return JSON.stringify(result); }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/ArkWebrenderingframework/entry/src/main/ets/pages/proxy.ets#L83-L90
7297f8d28e4871f2ff376181d7bc1bab325fea4d
gitee
openharmony/arkui_ace_engine
30c7d1ee12fbedf0fabece54291d75897e2ad44f
examples/Overlay/entry/src/main/ets/pages/components/menu/customMenu.ets
arkts
subMenuOne
Copyright (c) 2025 Huawei Device Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
@Builder export function subMenuOne() { Menu() { MenuItem({ content: '菜单选项1', labelInfo: 'Ctrl+C' }) MenuItem({ content: '菜单选项2', labelInfo: 'Ctrl+C' }) MenuItem({ content: '菜单选项3', labelInfo: 'Ctrl+C' }) MenuItem({ content: '菜单选项4', labelInfo: 'Ctrl+V' }) } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right export function subMenuOne 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 Menu ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left MenuItem ( AST#component_parameters#Left { AST#component_parameter#Left content : AST#expression#Left '菜单选项1' AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left labelInfo : AST#expression#Left 'Ctrl+C' 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 MenuItem ( AST#component_parameters#Left { AST#component_parameter#Left content : AST#expression#Left '菜单选项2' AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left labelInfo : AST#expression#Left 'Ctrl+C' 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 MenuItem ( AST#component_parameters#Left { AST#component_parameter#Left content : AST#expression#Left '菜单选项3' AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left labelInfo : AST#expression#Left 'Ctrl+C' 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 MenuItem ( AST#component_parameters#Left { AST#component_parameter#Left content : AST#expression#Left '菜单选项4' AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left labelInfo : AST#expression#Left 'Ctrl+V' 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#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#decorated_export_declaration#Right
@Builder export function subMenuOne() { Menu() { MenuItem({ content: '菜单选项1', labelInfo: 'Ctrl+C' }) MenuItem({ content: '菜单选项2', labelInfo: 'Ctrl+C' }) MenuItem({ content: '菜单选项3', labelInfo: 'Ctrl+C' }) MenuItem({ content: '菜单选项4', labelInfo: 'Ctrl+V' }) } }
https://github.com/openharmony/arkui_ace_engine/blob/30c7d1ee12fbedf0fabece54291d75897e2ad44f/examples/Overlay/entry/src/main/ets/pages/components/menu/customMenu.ets#L16-L24
d1f953cd1ef4ccfe11fdd700ae6f9fceec283c09
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/social/CommunityService.ets
arkts
saveCurrentUser
保存当前用户
private async saveCurrentUser(): Promise<void> { try { if (this.currentUser) { await this.preferences?.put(StorageKeys.CURRENT_USER, JSON.stringify(this.currentUser)); await this.preferences?.flush(); } } catch (error) { hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to save current user: ${error}`); } }
AST#method_declaration#Left private async saveCurrentUser 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#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentUser 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 AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . preferences AST#member_expression#Right AST#expression#Right ?. put AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left StorageKeys AST#expression#Right . CURRENT_USER AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentUser AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#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 . preferences 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#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 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 save current user: AST#template_substitution#Left $ { AST#expression#Left error AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private async saveCurrentUser(): Promise<void> { try { if (this.currentUser) { await this.preferences?.put(StorageKeys.CURRENT_USER, JSON.stringify(this.currentUser)); await this.preferences?.flush(); } } catch (error) { hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to save current user: ${error}`); } }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/social/CommunityService.ets#L664-L674
128ed7b956a1ad419115fd446823c6fc941c4e0b
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/nativeembed/src/main/ets/model/GoodsModel.ets
arkts
设置项的数据类
export class ProductDataModel { id: number; uri: ResourceStr; title: ResourceStr; price: ResourceStr; constructor(id: number, uri: ResourceStr, title: ResourceStr, price: ResourceStr) { this.id = id; this.uri = uri; this.title = title; this.price = price; } }
AST#export_declaration#Left export AST#class_declaration#Left class ProductDataModel AST#class_body#Left { AST#property_declaration#Left id : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left uri : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left title : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left price : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left id : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left uri : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left title : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left price : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . id AST#member_expression#Right = AST#expression#Left id AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . uri AST#member_expression#Right = AST#expression#Left uri AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . title AST#member_expression#Right = AST#expression#Left title AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . price AST#member_expression#Right = AST#expression#Left price AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class ProductDataModel { id: number; uri: ResourceStr; title: ResourceStr; price: ResourceStr; constructor(id: number, uri: ResourceStr, title: ResourceStr, price: ResourceStr) { this.id = id; this.uri = uri; this.title = title; this.price = price; } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/nativeembed/src/main/ets/model/GoodsModel.ets#L17-L29
1c3643c516730cdd492a5cb181fb4726c6cf7af3
gitee
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
eftool/src/main/ets/core/media/ImageUtil.ets
arkts
base64ToPixelMap
图片base64字符串转PixelMap @param base64 图片base64字符串 @returns 转换后的结果
static async base64ToPixelMap(base64: string): Promise<OutDTO<image.PixelMap>> { //将原始图片base64字符串转变为通过base64字符串 const base64Str = StrUtil.replace(base64, new RegExp('data:image/\\w+;base64,'), ''); //将通用base64字符串转变为arrayBuffer let arrayBuffer = Base64Util.decodeSync(base64Str).buffer; //将arrayBuffer转变为pixelMap let imageSource = image.createImageSource(arrayBuffer); let opts: image.DecodingOptions = { editable: false } //创建PixelMap let res = await imageSource.createPixelMap(opts); //返回结果 return OutDTO.OKByDataRow<image.PixelMap>('图片base64字符串转PixelMap成功~', res); }
AST#method_declaration#Left static async base64ToPixelMap AST#parameter_list#Left ( AST#parameter#Left base64 : 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 AST#qualified_type#Left image . PixelMap AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { //将原始图片base64字符串转变为通过base64字符串 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left base64Str = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left StrUtil AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left base64 AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left RegExp AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'data:image/\\w+;base64,' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left '' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right //将通用base64字符串转变为arrayBuffer AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left arrayBuffer = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Base64Util AST#expression#Right . decodeSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left base64Str AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . buffer AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right //将arrayBuffer转变为pixelMap AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left imageSource = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left image AST#expression#Right . createImageSource AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left arrayBuffer 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 opts : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left image . DecodingOptions 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 editable AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right //创建PixelMap AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left res = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left imageSource AST#expression#Right AST#await_expression#Right AST#expression#Right . createPixelMap AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left opts 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 OutDTO AST#expression#Right . OKByDataRow AST#member_expression#Right AST#expression#Right AST#type_arguments#Left < 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#type_arguments#Right AST#argument_list#Left ( AST#expression#Left '图片base64字符串转PixelMap成功~' AST#expression#Right , AST#expression#Left res 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 base64ToPixelMap(base64: string): Promise<OutDTO<image.PixelMap>> { const base64Str = StrUtil.replace(base64, new RegExp('data:image/\\w+;base64,'), ''); let arrayBuffer = Base64Util.decodeSync(base64Str).buffer; let imageSource = image.createImageSource(arrayBuffer); let opts: image.DecodingOptions = { editable: false } let res = await imageSource.createPixelMap(opts); return OutDTO.OKByDataRow<image.PixelMap>('图片base64字符串转PixelMap成功~', res); }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/eftool/src/main/ets/core/media/ImageUtil.ets#L96-L108
6dbf09266ced892cad07b841d146860cfe71ac66
gitee