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
fengmingdev/protobuf-arkts-generator.git
75888d404fd6ce52a046cba2a94807ecf1350147
runtime/arkpb/MessageRegistry.ets
arkts
has
检查类型是否已注册 @param typeName 消息类型名称 @returns true 如果已注册 使用示例: ```typescript if (MessageRegistry.has('test.Person')) { console.log('Person type is registered') } ```
static has(typeName: string): boolean { return MessageRegistry.types.has(typeName) }
AST#method_declaration#Left static has AST#parameter_list#Left ( AST#parameter#Left typeName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left MessageRegistry AST#expression#Right . types AST#member_expression#Right AST#expression#Right . has AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left typeName 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 has(typeName: string): boolean { return MessageRegistry.types.has(typeName) }
https://github.com/fengmingdev/protobuf-arkts-generator.git/blob/75888d404fd6ce52a046cba2a94807ecf1350147/runtime/arkpb/MessageRegistry.ets#L136-L138
f884f15d7da323d91bb1448b0d63654aea2c47b3
github
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
ScreenFlickerSolution/entry/src/main/ets/pages/TabsRight.ets
arkts
getCurrentIndicatorInfo
[End tabs_right_build] [Start get_current_indicator_info]
private getCurrentIndicatorInfo(index: number, event: TabsAnimationEvent): Record<string, number> { let nextIndex = index; if (index > 0 && event.currentOffset > 0) { nextIndex--; } else if (index < 3 && event.currentOffset < 0) { nextIndex++; } let indexInfo: [number, number] = this.textInfos[index]; let nextIndexInfo: [number, number] = this.textInfos[nextIndex]; let swipeRatio: number = Math.abs(event.currentOffset / this.tabsWidth); let currentIndex: number = swipeRatio > 0.5 ? nextIndex : index; // The page slides more than halfway and the tabBar switches to the next page. let currentLeft: number = indexInfo[0] + (nextIndexInfo[0] - indexInfo[0]) * swipeRatio; let currentWidth: number = indexInfo[1] + (nextIndexInfo[1] - indexInfo[1]) * swipeRatio; return { 'index': currentIndex, 'left': currentLeft, 'width': currentWidth }; }
AST#method_declaration#Left private getCurrentIndicatorInfo AST#parameter_list#Left ( AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left event : AST#type_annotation#Left AST#primary_type#Left TabsAnimationEvent 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 Record AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left nextIndex = AST#expression#Left index AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left event AST#expression#Right AST#binary_expression#Right AST#expression#Right . currentOffset AST#member_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#update_expression#Left AST#expression#Left nextIndex AST#expression#Right -- AST#update_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#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 index AST#expression#Right < AST#expression#Left 3 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left event AST#expression#Right AST#binary_expression#Right AST#expression#Right . currentOffset AST#member_expression#Right AST#expression#Right < AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#update_expression#Left AST#expression#Left nextIndex 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#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left indexInfo : AST#type_annotation#Left AST#primary_type#Left AST#tuple_type#Left [ AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ] AST#tuple_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . textInfos AST#member_expression#Right AST#expression#Right [ AST#expression#Left index AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left nextIndexInfo : AST#type_annotation#Left AST#primary_type#Left AST#tuple_type#Left [ AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ] AST#tuple_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . textInfos AST#member_expression#Right AST#expression#Right [ AST#expression#Left nextIndex AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left swipeRatio : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . abs AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left event AST#expression#Right . currentOffset AST#member_expression#Right AST#expression#Right / AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . tabsWidth 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#ERROR#Left let currentIndex : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left swipeRatio AST#expression#Right > AST#expression#Left 0.5 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? nextIndex : AST#type_annotation#Left AST#primary_type#Left index AST#primary_type#Right AST#type_annotation#Right ; AST#ERROR#Right // The page slides more than halfway and the tabBar switches to the next page. AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left currentLeft : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left indexInfo AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#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#subscript_expression#Left AST#expression#Left nextIndexInfo AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right - AST#expression#Left AST#subscript_expression#Left AST#expression#Left indexInfo AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right * AST#expression#Left swipeRatio AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left currentWidth : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left indexInfo AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#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#subscript_expression#Left AST#expression#Left nextIndexInfo 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 indexInfo 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#parenthesized_expression#Right AST#expression#Right * AST#expression#Left swipeRatio AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left 'index' AST#property_name#Right : AST#expression#Left currentIndex AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'left' AST#property_name#Right : AST#expression#Left currentLeft AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'width' AST#property_name#Right : AST#expression#Left currentWidth AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private getCurrentIndicatorInfo(index: number, event: TabsAnimationEvent): Record<string, number> { let nextIndex = index; if (index > 0 && event.currentOffset > 0) { nextIndex--; } else if (index < 3 && event.currentOffset < 0) { nextIndex++; } let indexInfo: [number, number] = this.textInfos[index]; let nextIndexInfo: [number, number] = this.textInfos[nextIndex]; let swipeRatio: number = Math.abs(event.currentOffset / this.tabsWidth); let currentIndex: number = swipeRatio > 0.5 ? nextIndex : index; let currentLeft: number = indexInfo[0] + (nextIndexInfo[0] - indexInfo[0]) * swipeRatio; let currentWidth: number = indexInfo[1] + (nextIndexInfo[1] - indexInfo[1]) * swipeRatio; return { 'index': currentIndex, 'left': currentLeft, 'width': currentWidth }; }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/ScreenFlickerSolution/entry/src/main/ets/pages/TabsRight.ets#L130-L146
53116df22c6793cb8697542b2ea22ab13ec7498f
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
entry/src/main/ets/component/CustomImageView.ets
arkts
CustomImageView
showCustomContentDialog - 自定义的图片文本组件
@ComponentV2 export struct CustomImageView { @Require @Param content: ResourceStr; @Require @Param src: Resource; build() { Scroll() { Column() { Text(this.content) .fontSize(13) .fontStyle(FontStyle.Normal) .fontFamily('MyFont') .padding(5) .textShadow({ color: Color.Red, radius: 2, type: ShadowType.COLOR, fill: true }) .alignSelf(ItemAlign.Center) .width('100%') Image(this.src) .width("100%") .objectFit(ImageFit.Fill) .margin({ top: 10 }) .borderRadius(2) } .width("100%") .padding(10) } .backgroundColor($r('app.color.color_line')) .borderRadius(5) } }
AST#decorated_export_declaration#Left AST#decorator#Left @ ComponentV2 AST#decorator#Right export struct CustomImageView AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ Require AST#decorator#Right AST#decorator#Left @ Param AST#decorator#Right content : 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 AST#decorator#Left @ Require AST#decorator#Right AST#decorator#Left @ Param AST#decorator#Right src : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Scroll ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . content AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 13 AST#expression#Right ) AST#modifier_chain_expression#Left . fontStyle ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontStyle AST#expression#Right . Normal AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontFamily ( AST#expression#Left 'MyFont' AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left 5 AST#expression#Right ) AST#modifier_chain_expression#Left . textShadow ( AST#expression#Left AST#object_literal#Left { 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 . Red 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 2 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left type AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left ShadowType AST#expression#Right . COLOR AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left fill 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#modifier_chain_expression#Left . alignSelf ( AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( 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#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 Image ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . src AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left "100%" AST#expression#Right ) AST#modifier_chain_expression#Left . 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#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 10 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 2 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left "100%" AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left 10 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.color_line' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( 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#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@ComponentV2 export struct CustomImageView { @Require @Param content: ResourceStr; @Require @Param src: Resource; build() { Scroll() { Column() { Text(this.content) .fontSize(13) .fontStyle(FontStyle.Normal) .fontFamily('MyFont') .padding(5) .textShadow({ color: Color.Red, radius: 2, type: ShadowType.COLOR, fill: true }) .alignSelf(ItemAlign.Center) .width('100%') Image(this.src) .width("100%") .objectFit(ImageFit.Fill) .margin({ top: 10 }) .borderRadius(2) } .width("100%") .padding(10) } .backgroundColor($r('app.color.color_line')) .borderRadius(5) } }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/entry/src/main/ets/component/CustomImageView.ets#L3-L37
4af556b62cb39a075204d111b292636d4f625531
gitee
sithvothykiv/dialog_hub.git
b676c102ef2d05f8994d170abe48dcc40cd39005
custom_dialog/src/main/ets/model/observe/InputObserved.ets
arkts
InputObserved
输入框Observed数据 @author pll @create 2025-06-06 09:05
@ObservedV2 export class InputObserved extends CommonObservedData implements IObservedData { @Trace text: string = '' }
AST#decorated_export_declaration#Left AST#decorator#Left @ ObservedV2 AST#decorator#Right export class InputObserved extends AST#type_annotation#Left AST#primary_type#Left CommonObservedData AST#primary_type#Right AST#type_annotation#Right AST#implements_clause#Left implements IObservedData AST#implements_clause#Right AST#class_body#Left { AST#property_declaration#Left AST#decorator#Left @ Trace AST#decorator#Right 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#property_declaration#Right } AST#class_body#Right AST#decorated_export_declaration#Right
@ObservedV2 export class InputObserved extends CommonObservedData implements IObservedData { @Trace text: string = '' }
https://github.com/sithvothykiv/dialog_hub.git/blob/b676c102ef2d05f8994d170abe48dcc40cd39005/custom_dialog/src/main/ets/model/observe/InputObserved.ets#L9-L13
701919f0299d7bf7d2ee5f20e94ac34449461447
github
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
feature/user/src/main/ets/view/AddressDetailPage.ets
arkts
buildFormCard
构建基础信息表单 @returns {void} 无返回值
@Builder private buildFormCard(): void { IBestForm({ formId: this.formId, controller: this.vm.formController, rules: this.vm.formRules }) { IBestCellGroup({ inset: true, radius: $r("app.float.radius_medium"), outerMargin: 0 }) { IBestField({ formId: this.formId, prop: "contact", value: this.vm.contactName, label: $r("app.string.contact_person"), placeholder: $r("app.string.please_input_contact"), fieldPadding: $r("app.float.space_padding_large"), onChange: (value: IBestFieldValueType): void => { this.vm.updateContactName(`${value ?? ""}`); } }); IBestField({ formId: this.formId, prop: "phone", value: this.vm.phone, label: $r("app.string.phone_number"), placeholder: $r("app.string.please_input_phone"), type: "phone", fieldPadding: $r("app.float.space_padding_large"), onChange: (value: IBestFieldValueType): void => { this.vm.updatePhone(`${value ?? ""}`); } }); IBestField({ formId: this.formId, prop: "region", value: this.vm.regionValue, showValue: this.vm.regionDisplay, label: $r("app.string.region"), placeholder: $r("app.string.please_select_region"), isLink: true, fieldPadding: $r("app.float.space_padding_large"), onFieldClick: (): void => { this.vm.onRegionFieldClick(); } }); IBestField({ formId: this.formId, prop: "detailAddress", value: this.vm.detailAddress, label: $r("app.string.detail_address"), placeholder: $r("app.string.street_number_etc"), hasBorder: false, autosize: true, rows: 4, fieldPadding: $r("app.float.space_padding_large"), onChange: (value: IBestFieldValueType): void => { this.vm.updateDetailAddress(`${value ?? ""}`); } }); } } IBestCascader({ visible: this.vm.isRegionPickerVisible, options: this.vm.regionOptions, value: this.vm.regionValue, $visible: (visible: boolean): void => { this.vm.updateRegionPickerVisible(visible); }, onConfirm: (value: IBestCascaderOption[]): void => { this.vm.handleRegionConfirm(value); } }); }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right private buildFormCard 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#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left IBestForm ( AST#component_parameters#Left { AST#component_parameter#Left formId : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . formId AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left controller : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . vm AST#member_expression#Right AST#expression#Right . formController AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left rules : 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 . formRules 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 IBestCellGroup ( AST#component_parameters#Left { AST#component_parameter#Left inset : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left radius : 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#component_parameter#Right , AST#component_parameter#Left outerMargin : AST#expression#Left 0 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#ui_custom_component_statement#Left IBestField ( AST#component_parameters#Left { AST#component_parameter#Left formId : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . formId AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left prop : AST#expression#Left "contact" AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left value : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . vm AST#member_expression#Right AST#expression#Right . contactName AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left label : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.contact_person" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left placeholder : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.please_input_contact" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left fieldPadding : 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#component_parameter#Right , AST#component_parameter#Left onChange : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left IBestFieldValueType 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 . updateContactName AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#binary_expression#Left AST#expression#Left value AST#expression#Right ?? AST#expression#Left "" AST#expression#Right AST#binary_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#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#ui_custom_component_statement#Left IBestField ( AST#component_parameters#Left { AST#component_parameter#Left formId : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . formId AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left prop : AST#expression#Left "phone" AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left value : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . vm AST#member_expression#Right AST#expression#Right . phone AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left label : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.phone_number" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left placeholder : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.please_input_phone" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left type : AST#expression#Left "phone" AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left fieldPadding : 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#component_parameter#Right , AST#component_parameter#Left onChange : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left IBestFieldValueType 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 . updatePhone AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#binary_expression#Left AST#expression#Left value AST#expression#Right ?? AST#expression#Left "" AST#expression#Right AST#binary_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#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#ui_custom_component_statement#Left IBestField ( AST#component_parameters#Left { AST#component_parameter#Left formId : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . formId AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left prop : AST#expression#Left "region" AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left value : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . vm AST#member_expression#Right AST#expression#Right . regionValue AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left showValue : 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 . regionDisplay AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left label : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.region" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left placeholder : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.please_select_region" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left isLink : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left fieldPadding : 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#component_parameter#Right , AST#component_parameter#Left onFieldClick : 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#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 . onRegionFieldClick 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#component_parameter#Right } AST#component_parameters#Right ) ; AST#ui_custom_component_statement#Right AST#ui_custom_component_statement#Left IBestField ( AST#component_parameters#Left { AST#component_parameter#Left formId : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . formId AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left prop : AST#expression#Left "detailAddress" AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left value : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . vm AST#member_expression#Right AST#expression#Right . detailAddress AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left label : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.detail_address" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left placeholder : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.street_number_etc" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left hasBorder : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left autosize : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left rows : AST#expression#Left 4 AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left fieldPadding : 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#component_parameter#Right , AST#component_parameter#Left onChange : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left IBestFieldValueType 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 . updateDetailAddress AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#binary_expression#Left AST#expression#Left value AST#expression#Right ?? AST#expression#Left "" AST#expression#Right AST#binary_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#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#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ui_custom_component_statement#Left IBestCascader ( AST#component_parameters#Left { AST#component_parameter#Left visible : 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 . isRegionPickerVisible AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left options : 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 . regionOptions AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left value : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . vm AST#member_expression#Right AST#expression#Right . regionValue AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left $visible : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left visible : 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 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 . updateRegionPickerVisible AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left visible 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 onConfirm : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left IBestCascaderOption [ ] 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#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 . handleRegionConfirm AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left value AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) ; AST#ui_custom_component_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
@Builder private buildFormCard(): void { IBestForm({ formId: this.formId, controller: this.vm.formController, rules: this.vm.formRules }) { IBestCellGroup({ inset: true, radius: $r("app.float.radius_medium"), outerMargin: 0 }) { IBestField({ formId: this.formId, prop: "contact", value: this.vm.contactName, label: $r("app.string.contact_person"), placeholder: $r("app.string.please_input_contact"), fieldPadding: $r("app.float.space_padding_large"), onChange: (value: IBestFieldValueType): void => { this.vm.updateContactName(`${value ?? ""}`); } }); IBestField({ formId: this.formId, prop: "phone", value: this.vm.phone, label: $r("app.string.phone_number"), placeholder: $r("app.string.please_input_phone"), type: "phone", fieldPadding: $r("app.float.space_padding_large"), onChange: (value: IBestFieldValueType): void => { this.vm.updatePhone(`${value ?? ""}`); } }); IBestField({ formId: this.formId, prop: "region", value: this.vm.regionValue, showValue: this.vm.regionDisplay, label: $r("app.string.region"), placeholder: $r("app.string.please_select_region"), isLink: true, fieldPadding: $r("app.float.space_padding_large"), onFieldClick: (): void => { this.vm.onRegionFieldClick(); } }); IBestField({ formId: this.formId, prop: "detailAddress", value: this.vm.detailAddress, label: $r("app.string.detail_address"), placeholder: $r("app.string.street_number_etc"), hasBorder: false, autosize: true, rows: 4, fieldPadding: $r("app.float.space_padding_large"), onChange: (value: IBestFieldValueType): void => { this.vm.updateDetailAddress(`${value ?? ""}`); } }); } } IBestCascader({ visible: this.vm.isRegionPickerVisible, options: this.vm.regionOptions, value: this.vm.regionValue, $visible: (visible: boolean): void => { this.vm.updateRegionPickerVisible(visible); }, onConfirm: (value: IBestCascaderOption[]): void => { this.vm.handleRegionConfirm(value); } }); }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/user/src/main/ets/view/AddressDetailPage.ets#L95-L174
a3fadb7e7555644a594d5d1c98dc18572b181acc
github
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/WindowUtil.ets
arkts
setWindowPrivacyMode
设置窗口是否为隐私模式。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。 @param isPrivacyMode 窗口是否为隐私模式。true表示模式开启;false表示模式关闭。 @param windowClass 不传该值,默认主窗口。 @returns
static async setWindowPrivacyMode(isPrivacyMode: boolean, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.setWindowPrivacyMode(isPrivacyMode); }
AST#method_declaration#Left static async setWindowPrivacyMode AST#parameter_list#Left ( AST#parameter#Left isPrivacyMode : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . setWindowPrivacyMode AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left isPrivacyMode 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 setWindowPrivacyMode(isPrivacyMode: boolean, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.setWindowPrivacyMode(isPrivacyMode); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/WindowUtil.ets#L69-L72
1ac5d44c63b2eeaddcf287088a456708790e8482
gitee
Application-Security-Automation/Arktan.git
3ad9cb05235e38b00cd5828476aa59a345afa1c0
dataset/completeness/control_flow/loop_stmt/while_body_001_T.ets
arkts
Introduction 循环结构-body语句
export function while_body_001_T(taint_src : string) { let i = 0 let t = '' while (i < 2) { t = t + taint_src i++ } taint.Sink(t); }
AST#export_declaration#Left export AST#function_declaration#Left function while_body_001_T AST#parameter_list#Left ( AST#parameter#Left taint_src : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left t = AST#expression#Left '' AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#while_statement#Left while ( AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left t = AST#expression#Left AST#binary_expression#Left AST#expression#Left t AST#expression#Right + AST#expression#Left taint_src 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#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#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 taint AST#expression#Right . Sink 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_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export function while_body_001_T(taint_src : string) { let i = 0 let t = '' while (i < 2) { t = t + taint_src i++ } taint.Sink(t); }
https://github.com/Application-Security-Automation/Arktan.git/blob/3ad9cb05235e38b00cd5828476aa59a345afa1c0/dataset/completeness/control_flow/loop_stmt/while_body_001_T.ets#L6-L14
3c176d8e42b8adbf597347388e18d3a7a7ebfd27
github
open9527/OpenHarmony
fdea69ed722d426bf04e817ec05bff4002e81a4e
libs/dialog/src/main/ets/tips/TipsDialogManager.ets
arkts
showSuccess
成功提示 弹窗 @param params
static showSuccess(msg: string = '') { TipsDialogManager.showInfo(msg, $r('app.media.dialog_tips_success_icon')) }
AST#method_declaration#Left static showSuccess AST#parameter_list#Left ( AST#parameter#Left msg : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '' AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left TipsDialogManager AST#expression#Right . showInfo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left msg AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.dialog_tips_success_icon' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
static showSuccess(msg: string = '') { TipsDialogManager.showInfo(msg, $r('app.media.dialog_tips_success_icon')) }
https://github.com/open9527/OpenHarmony/blob/fdea69ed722d426bf04e817ec05bff4002e81a4e/libs/dialog/src/main/ets/tips/TipsDialogManager.ets#L22-L24
44bda7fd72786f9089201bdea798b30d35020524
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/pages/Calc.ets
arkts
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.
export function add(a: number, b: number): number { let c = a + b; console.info('DynamicImport I am a HAP, %d + %d = %d', a, b, c); return c; }
AST#export_declaration#Left export AST#function_declaration#Left function add AST#parameter_list#Left ( AST#parameter#Left a : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left b : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left c = AST#expression#Left AST#binary_expression#Left AST#expression#Left a AST#expression#Right + AST#expression#Left b 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'DynamicImport I am a HAP, %d + %d = %d' AST#expression#Right , AST#expression#Left a AST#expression#Right , AST#expression#Left b AST#expression#Right , AST#expression#Left c 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 c AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export function add(a: number, b: number): number { let c = a + b; console.info('DynamicImport I am a HAP, %d + %d = %d', a, b, c); return c; }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/entry/src/main/ets/pages/Calc.ets#L16-L20
fb692c07461d49378c107e9eab1a6205e8f37178
gitee
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
VideoPlayerSample/entry/src/main/ets/pages/IndexPage.ets
arkts
onWindowSizeChange
[Start device_width1] Because the width and height of the floating window are the system default, the value of isFloatWindow (whether to display the floating window or not) is only processed according to the height of the window, which is used to control the display and concealment of the interface components. [EndExclude index_page1]
onWindowSizeChange(): void { // [StartExclude index_page1] let deviceWidth: number = AppStorage.get<number>('deviceWidth') || 0; // Judge whether it is a horizontal screen or a vertical screen suspension window. if (this.isFullLandscapeScreen && Math.round((this.deviceHeight / deviceWidth) * 1000) / 1000 === 0.563) { this.isFloatWindow = true; } else if (this.isFullScreen && (Math.round((deviceWidth / this.deviceHeight) * 1000) / 1000 === 0.563 || Math.round((deviceWidth / this.deviceHeight) * 10) / 10 === 0.6)) { this.isFloatWindow = true; } else { this.isFloatWindow = false; } // [EndExclude index_page1] }
AST#method_declaration#Left onWindowSizeChange 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 index_page1] AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left deviceWidth : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#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 number AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left 'deviceWidth' 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // Judge whether it is a horizontal screen or a vertical screen suspension window. 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isFullLandscapeScreen AST#member_expression#Right AST#expression#Right && AST#expression#Left Math AST#expression#Right AST#binary_expression#Right AST#expression#Right . round AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . deviceHeight AST#member_expression#Right AST#expression#Right / AST#expression#Left deviceWidth AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right * AST#expression#Left 1000 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right / AST#expression#Left 1000 AST#expression#Right AST#binary_expression#Right AST#expression#Right === AST#expression#Left 0.563 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isFloatWindow AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isFullScreen AST#member_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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . round AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left deviceWidth AST#expression#Right / AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . deviceHeight AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right * AST#expression#Left 1000 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right / AST#expression#Left 1000 AST#expression#Right AST#binary_expression#Right AST#expression#Right === AST#expression#Left 0.563 AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left Math AST#expression#Right AST#binary_expression#Right AST#expression#Right . round AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left deviceWidth AST#expression#Right / AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . deviceHeight AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right * AST#expression#Left 10 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right / AST#expression#Left 10 AST#expression#Right AST#binary_expression#Right AST#expression#Right === AST#expression#Left 0.6 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#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 . isFloatWindow AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right 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 . isFloatWindow AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#if_statement#Right AST#statement#Right // [EndExclude index_page1] } AST#block_statement#Right AST#method_declaration#Right
onWindowSizeChange(): void { let deviceWidth: number = AppStorage.get<number>('deviceWidth') || 0; if (this.isFullLandscapeScreen && Math.round((this.deviceHeight / deviceWidth) * 1000) / 1000 === 0.563) { this.isFloatWindow = true; } else if (this.isFullScreen && (Math.round((deviceWidth / this.deviceHeight) * 1000) / 1000 === 0.563 || Math.round((deviceWidth / this.deviceHeight) * 10) / 10 === 0.6)) { this.isFloatWindow = true; } else { this.isFloatWindow = false; } }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/VideoPlayerSample/entry/src/main/ets/pages/IndexPage.ets#L234-L248
5d9be6b10962f0bf6e98401ced1511d35a670c53
gitee
chongzi/Lucky-ArkTs.git
84fc104d4a68def780a483e2543ebf9f53e793fd
entry/src/main/ets/common/StudyTimeManager.ets
arkts
updateStudyTime
更新学习时长到数据库
private async updateStudyTime(): Promise<void> { if (!this.isTracking || this.startTime === 0) { return } try { const currentTime = Date.now() const sessionTime = Math.floor((currentTime - this.startTime) / 1000 / 60) // 转换为分钟 if (sessionTime > this.totalSessionTime) { const newMinutes = sessionTime - this.totalSessionTime this.totalSessionTime = sessionTime console.info(`[StudyTimeManager] 本次会话学习时长: ${sessionTime}分钟, 新增: ${newMinutes}分钟`) // 更新数据库中的学习时长 const dbManager = DatabaseManager.getInstance() await this.addStudyTime(newMinutes) } } catch (error) { console.error('[StudyTimeManager] 更新学习时长失败:', error) } }
AST#method_declaration#Left private async updateStudyTime 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#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#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . isTracking AST#member_expression#Right AST#expression#Right || AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . startTime AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#object_literal#Left { AST#ERROR#Left return AST#ERROR#Right } AST#object_literal#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left currentTime = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Date AST#expression#Right . now AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left sessionTime = 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#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left currentTime AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . startTime AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right / AST#expression#Left 1000 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#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right // 转换为分钟 AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left sessionTime AST#expression#Right > AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . totalSessionTime AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left newMinutes = AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left sessionTime AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . totalSessionTime AST#member_expression#Right AST#expression#Right AST#ERROR#Left this AST#ERROR#Right . totalSessionTime AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left sessionTime AST#expression#Right AST#ERROR#Left console AST#ERROR#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` [StudyTimeManager] 本次会话学习时长: AST#template_substitution#Left $ { AST#expression#Left sessionTime AST#expression#Right } AST#template_substitution#Right 分钟, 新增: AST#template_substitution#Left $ { AST#expression#Left newMinutes 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#variable_declarator#Right // 更新数据库中的学习时长 AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left dbManager = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DatabaseManager AST#expression#Right . getInstance AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#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 . addStudyTime AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left newMinutes AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '[StudyTimeManager] 更新学习时长失败:' AST#expression#Right , AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private async updateStudyTime(): Promise<void> { if (!this.isTracking || this.startTime === 0) { return } try { const currentTime = Date.now() const sessionTime = Math.floor((currentTime - this.startTime) / 1000 / 60) if (sessionTime > this.totalSessionTime) { const newMinutes = sessionTime - this.totalSessionTime this.totalSessionTime = sessionTime console.info(`[StudyTimeManager] 本次会话学习时长: ${sessionTime}分钟, 新增: ${newMinutes}分钟`) const dbManager = DatabaseManager.getInstance() await this.addStudyTime(newMinutes) } } catch (error) { console.error('[StudyTimeManager] 更新学习时长失败:', error) } }
https://github.com/chongzi/Lucky-ArkTs.git/blob/84fc104d4a68def780a483e2543ebf9f53e793fd/entry/src/main/ets/common/StudyTimeManager.ets#L57-L79
1998369078cd1b9b58fccdaf83137054555f89a4
github
Joker-x-dev/HarmonyKit.git
f97197ce157df7f303244fba42e34918306dfb08
core/network/src/main/ets/NetworkClient.ets
arkts
网络客户端 管理 Axios 实例和拦截器配置。 @author Joker.X
export class NetworkClient { // 单例实例 private static instance: NetworkClient; // Axios 实例 private axiosInstance: AxiosInstance; // 基础 URL private readonly BASE_URL = 'https://mall.dusksnow.top/app/'; private constructor() { this.axiosInstance = axios.create({ baseURL: this.BASE_URL, timeout: 10000, headers: { 'Content-Type': 'application/json' } }); // 初始化拦截器 setupInterceptors(this.axiosInstance); } /** * 获取 NetworkClient 单例 */ public static getInstance(): NetworkClient { if (!NetworkClient.instance) { NetworkClient.instance = new NetworkClient(); } return NetworkClient.instance; } /** * 获取 Axios 实例 */ public getAxios(): AxiosInstance { return this.axiosInstance; } /** * 静态访问属性,方便直接通过 NetworkClient.http 调用 */ public static get http(): AxiosInstance { return NetworkClient.getInstance().getAxios(); } }
AST#export_declaration#Left export AST#class_declaration#Left class NetworkClient AST#class_body#Left { // 单例实例 AST#property_declaration#Left private static instance : AST#type_annotation#Left AST#primary_type#Left NetworkClient AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right // Axios 实例 AST#property_declaration#Left private axiosInstance : AST#type_annotation#Left AST#primary_type#Left AxiosInstance AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right // 基础 URL AST#property_declaration#Left private readonly BASE_URL = AST#expression#Left 'https://mall.dusksnow.top/app/' AST#expression#Right ; AST#property_declaration#Right AST#constructor_declaration#Left private constructor AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { 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 . axiosInstance AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left axios AST#expression#Right . create 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 baseURL AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . BASE_URL AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left timeout AST#property_name#Right : AST#expression#Left 10000 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left headers AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left 'Content-Type' AST#property_name#Right : AST#expression#Left 'application/json' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#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 setupInterceptors AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . axiosInstance 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#constructor_declaration#Right /** * 获取 NetworkClient 单例 */ AST#method_declaration#Left public static getInstance AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left NetworkClient AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left NetworkClient AST#expression#Right AST#unary_expression#Right AST#expression#Right . instance AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left NetworkClient AST#expression#Right . instance AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left NetworkClient AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#expression_statement#Left AST#expression#Left return AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left NetworkClient AST#expression#Right . instance AST#member_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right /** * 获取 Axios 实例 */ AST#method_declaration#Left public getAxios AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AxiosInstance 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 . axiosInstance AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 静态访问属性,方便直接通过 NetworkClient.http 调用 */ AST#method_declaration#Left public static get AST#ERROR#Left http AST#ERROR#Right AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AxiosInstance AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left NetworkClient AST#expression#Right . getInstance AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . getAxios AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class NetworkClient { private static instance: NetworkClient; private axiosInstance: AxiosInstance; private readonly BASE_URL = 'https://mall.dusksnow.top/app/'; private constructor() { this.axiosInstance = axios.create({ baseURL: this.BASE_URL, timeout: 10000, headers: { 'Content-Type': 'application/json' } }); setupInterceptors(this.axiosInstance); } public static getInstance(): NetworkClient { if (!NetworkClient.instance) { NetworkClient.instance = new NetworkClient(); } return NetworkClient.instance; } public getAxios(): AxiosInstance { return this.axiosInstance; } public static get http(): AxiosInstance { return NetworkClient.getInstance().getAxios(); } }
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/network/src/main/ets/NetworkClient.ets#L10-L53
279d1a526158963aa824c252c3b1aa74a4496346
github
Vinson0709/arkdemo.git
793491fe04b387f55dadfef86b30e28d0535d994
entry/src/main/ets/pages/Linear.ets
arkts
bodyBuilder
内容展示(自定义builder渲染)
@Builder bodyBuilder() { Column(){ // Row 行组件 Text('Row 行组件') .fontSize(14) .margin({ top:20, bottom: 12}) // 横向居中 alignItems(Center),间距为10 Text('横向居中 alignItems(Center),间距为10').fontSize(14).width('100%') Row({ space: 10}) { Row().width('25%').height(30).backgroundColor(0xAFEEEE) Row().width('25%').height(30).backgroundColor(0x00FFFF) } .rowStyle() // 横向顶部对齐 alignItems(Top) Text('横向顶部对齐 alignItems(Top)').fontSize(14).width('100%') Row() { Row().width('25%').height(30).backgroundColor(0xAFEEEE) Row().width('25%').height(30).backgroundColor(0x00FFFF) } .rowStyle() .alignItems(VerticalAlign.Top) // 横向底部对齐,alignItems(Bottom) Text('横向底部对齐 alignItems(Bottom)').fontSize(14).width('100%') Row() { Row().width('25%').height(30).backgroundColor(0xAFEEEE) Row().width('25%').height(30).backgroundColor(0x00FFFF) } .rowStyle() .alignItems(VerticalAlign.Bottom) // 纵向居中 justifyContent(Center) Text('纵向居中 justifyContent(Center)').fontSize(14).width('100%') Row() { Row().width('25%').height(30).backgroundColor(0xAFEEEE) Row().width('25%').height(30).backgroundColor(0x00FFFF) } .rowStyle() .height(50) .justifyContent(FlexAlign.Center) // 纵向居左 justifyContent(Start) Text('纵向居左 justifyContent(Start)').fontSize(14).width('100%') Row() { Row().width('25%').height(30).backgroundColor(0xAFEEEE) Row().width('25%').height(30).backgroundColor(0x00FFFF) } .rowStyle() .height(30) .justifyContent(FlexAlign.Start) // 纵向居右 justifyContent(End) Text('纵向居右 justifyContent(End)').fontSize(14).width('100%') Row() { Row().width('25%').height(30).backgroundColor(0xAFEEEE) Row().width('25%').height(30).backgroundColor(0x00FFFF) } .rowStyle() .height(30) .justifyContent(FlexAlign.End) // 纵向两侧对齐 justifyContent(SpaceBetween) Text('纵向两侧对齐 justifyContent(SpaceBetween)').fontSize(14).width('100%') Row() { Row().width('25%').height(30).backgroundColor(0xAFEEEE) Row().width('25%').height(30).backgroundColor(0x00FFFF) Row().width('25%').height(30).backgroundColor(0xAFEEEE) } .rowStyle() .height(30) .justifyContent(FlexAlign.SpaceBetween) // 纵向两侧对齐 justifyContent(SpaceAround) Text('纵向两侧对齐 justifyContent(SpaceAround)').fontSize(14).width('100%') Row() { Row().width('25%').height(30).backgroundColor(0xAFEEEE) Row().width('25%').height(30).backgroundColor(0x00FFFF) Row().width('25%').height(30).backgroundColor(0xAFEEEE) } .rowStyle() .height(30) .justifyContent(FlexAlign.SpaceAround) // 纵向两侧对齐 justifyContent(SpaceEvenly) Text('纵向两侧对齐 justifyContent(SpaceEvenly)').fontSize(14).width('100%') Row() { Row().width('25%').height(30).backgroundColor(0xAFEEEE) Row().width('25%').height(30).backgroundColor(0x00FFFF) Row().width('25%').height(30).backgroundColor(0xAFEEEE) } .rowStyle() .height(30) .justifyContent(FlexAlign.SpaceEvenly) .margin({ bottom: 0 }) // 分割线 Divider() .color('#CCCCCC') .dividerStyle() // Column 行组件 Text('Column 列组件') .fontSize(14) .margin({ bottom: 12}) // 纵向居中 HorizontalAlign(Center),间距为10 Text('纵向居中 HorizontalAlign(Center),间距为10').fontSize(14).width('100%') Column({ space: 10 }) { Column().width(60).height(25).backgroundColor(0xF5DEB3) Column().width(60).height(25).backgroundColor(0xD2B48C) } .columnStyle() // 纵向居左 HorizontalAlign(Start) Text('纵向居左 HorizontalAlign(Start)').fontSize(14).width('100%') Column() { Column().width(60).height(25).backgroundColor(0xF5DEB3) Column().width(60).height(25).backgroundColor(0xD2B48C) } .columnStyle() .alignItems(HorizontalAlign.Start) // 纵向居右 HorizontalAlign(End) Text('纵向居右 HorizontalAlign(End)').fontSize(14).width('100%') Column() { Column().width(60).height('25%').backgroundColor(0xF5DEB3) Column().width(60).height('25%').backgroundColor(0xD2B48C) } .columnStyle() .alignItems(HorizontalAlign.End) // 横向居中 justifyContent(Center) Text('横向居中 justifyContent(Center)').fontSize(14).width('100%') Column() { Column().width(60).height(25).backgroundColor(0xF5DEB3) Column().width(60).height(25).backgroundColor(0xD2B48C) } .columnStyle() .width(60) .justifyContent(FlexAlign.Center) // 横向居左 justifyContent(Start) Text('横向居左 justifyContent(Start)').fontSize(14).width('100%') Column() { Column().width(60).height(25).backgroundColor(0xF5DEB3) Column().width(60).height(25).backgroundColor(0xD2B48C) } .columnStyle() .width(60) .justifyContent(FlexAlign.Start) // 横向居右 justifyContent(End) Text('横向居右 justifyContent(End)').fontSize(14).width('100%') Column() { Column().width(60).height(25).backgroundColor(0xF5DEB3) Column().width(60).height(25).backgroundColor(0xD2B48C) } .columnStyle() .width(60) .justifyContent(FlexAlign.End) // 横向两侧对齐 justifyContent(SpaceBetween) Text('横向两侧对齐 justifyContent(SpaceBetween)').fontSize(14).width('100%') Column() { Column().width(60).height(25).backgroundColor(0xF5DEB3) Column().width(60).height(25).backgroundColor(0xD2B48C) Column().width(60).height(25).backgroundColor(0xF5DEB3) } .columnStyle() .width(60) .justifyContent(FlexAlign.SpaceBetween) // 横向两侧对齐 justifyContent(SpaceAround) Text('横向两侧对齐 justifyContent(SpaceAround)').fontSize(14).width('100%') Column() { Column().width(60).height(25).backgroundColor(0xF5DEB3) Column().width(60).height(25).backgroundColor(0xD2B48C) Column().width(60).height(25).backgroundColor(0xF5DEB3) } .columnStyle() .width(60) .justifyContent(FlexAlign.SpaceAround) // 横向两侧对齐 justifyContent(SpaceEvenly) Text('横向两侧对齐 justifyContent(SpaceEvenly)').fontSize(14).width('100%') Column() { Column().width(60).height(25).backgroundColor(0xF5DEB3) Column().width(60).height(25).backgroundColor(0xD2B48C) Column().width(60).height(25).backgroundColor(0xF5DEB3) } .columnStyle() .width(60) .justifyContent(FlexAlign.SpaceEvenly) } .pageStyle() //自定义样式:page }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right bodyBuilder 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 { // Row 行组件 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left 'Row 行组件' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 20 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 横向居中 alignItems(Center),间距为10 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '横向居中 alignItems(Center),间距为10' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 10 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '25%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xAFEEEE 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 Row ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '25%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0x00FFFF 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 . rowStyle ( ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 横向顶部对齐 alignItems(Top) AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '横向顶部对齐 alignItems(Top)' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#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#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '25%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xAFEEEE 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 Row ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '25%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0x00FFFF 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 . rowStyle ( ) AST#modifier_chain_expression#Left . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left VerticalAlign AST#expression#Right . Top AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 横向底部对齐,alignItems(Bottom) AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '横向底部对齐 alignItems(Bottom)' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#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#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '25%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xAFEEEE 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 Row ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '25%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0x00FFFF 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 . rowStyle ( ) AST#modifier_chain_expression#Left . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left VerticalAlign AST#expression#Right . Bottom 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 // 纵向居中 justifyContent(Center) AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '纵向居中 justifyContent(Center)' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#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#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '25%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xAFEEEE 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 Row ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '25%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0x00FFFF 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 . rowStyle ( ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 50 AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 纵向居左 justifyContent(Start) AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '纵向居左 justifyContent(Start)' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#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#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '25%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xAFEEEE 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 Row ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '25%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0x00FFFF 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 . rowStyle ( ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 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#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 纵向居右 justifyContent(End) AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '纵向居右 justifyContent(End)' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#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#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '25%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xAFEEEE 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 Row ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '25%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0x00FFFF 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 . rowStyle ( ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . End AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 纵向两侧对齐 justifyContent(SpaceBetween) AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '纵向两侧对齐 justifyContent(SpaceBetween)' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#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#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '25%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xAFEEEE 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 Row ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '25%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0x00FFFF 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 Row ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '25%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xAFEEEE 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 . rowStyle ( ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 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#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 纵向两侧对齐 justifyContent(SpaceAround) AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '纵向两侧对齐 justifyContent(SpaceAround)' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#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#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '25%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xAFEEEE 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 Row ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '25%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0x00FFFF 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 Row ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '25%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xAFEEEE 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 . rowStyle ( ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . SpaceAround 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 // 纵向两侧对齐 justifyContent(SpaceEvenly) AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '纵向两侧对齐 justifyContent(SpaceEvenly)' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#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#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '25%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xAFEEEE 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 Row ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '25%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0x00FFFF 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 Row ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '25%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xAFEEEE 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 . rowStyle ( ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 30 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 . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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 Divider ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . color ( AST#expression#Left '#CCCCCC' AST#expression#Right ) AST#modifier_chain_expression#Left . dividerStyle ( ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // Column 行组件 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left 'Column 列组件' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 纵向居中 HorizontalAlign(Center),间距为10 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '纵向居中 HorizontalAlign(Center),间距为10' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#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 10 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#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 25 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xF5DEB3 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 Column ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 25 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xD2B48C 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 . columnStyle ( ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 纵向居左 HorizontalAlign(Start) AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '纵向居左 HorizontalAlign(Start)' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 25 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xF5DEB3 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 Column ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 25 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xD2B48C 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 . columnStyle ( ) 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 // 纵向居右 HorizontalAlign(End) AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '纵向居右 HorizontalAlign(End)' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '25%' AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xF5DEB3 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 Column ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '25%' AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xD2B48C 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 . columnStyle ( ) AST#modifier_chain_expression#Left . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left HorizontalAlign AST#expression#Right . End AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 横向居中 justifyContent(Center) AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '横向居中 justifyContent(Center)' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 25 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xF5DEB3 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 Column ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 25 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xD2B48C 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 . columnStyle ( ) AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 横向居左 justifyContent(Start) AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '横向居左 justifyContent(Start)' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 25 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xF5DEB3 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 Column ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 25 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xD2B48C 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 . columnStyle ( ) AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 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#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 横向居右 justifyContent(End) AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '横向居右 justifyContent(End)' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 25 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xF5DEB3 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 Column ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 25 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xD2B48C 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 . columnStyle ( ) AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . End AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 横向两侧对齐 justifyContent(SpaceBetween) AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '横向两侧对齐 justifyContent(SpaceBetween)' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 25 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xF5DEB3 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 Column ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 25 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xD2B48C 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 Column ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 25 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xF5DEB3 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 . columnStyle ( ) AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 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#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 横向两侧对齐 justifyContent(SpaceAround) AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '横向两侧对齐 justifyContent(SpaceAround)' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 25 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xF5DEB3 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 Column ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 25 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xD2B48C 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 Column ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 25 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xF5DEB3 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 . columnStyle ( ) AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . SpaceAround 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 // 横向两侧对齐 justifyContent(SpaceEvenly) AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '横向两侧对齐 justifyContent(SpaceEvenly)' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 25 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xF5DEB3 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 Column ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 25 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xD2B48C 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 Column ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 25 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 0xF5DEB3 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 . columnStyle ( ) AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 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#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 . pageStyle ( ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right //自定义样式:page } AST#builder_function_body#Right AST#method_declaration#Right
@Builder bodyBuilder() { Column(){ Text('Row 行组件') .fontSize(14) .margin({ top:20, bottom: 12}) Text('横向居中 alignItems(Center),间距为10').fontSize(14).width('100%') Row({ space: 10}) { Row().width('25%').height(30).backgroundColor(0xAFEEEE) Row().width('25%').height(30).backgroundColor(0x00FFFF) } .rowStyle() Text('横向顶部对齐 alignItems(Top)').fontSize(14).width('100%') Row() { Row().width('25%').height(30).backgroundColor(0xAFEEEE) Row().width('25%').height(30).backgroundColor(0x00FFFF) } .rowStyle() .alignItems(VerticalAlign.Top) Text('横向底部对齐 alignItems(Bottom)').fontSize(14).width('100%') Row() { Row().width('25%').height(30).backgroundColor(0xAFEEEE) Row().width('25%').height(30).backgroundColor(0x00FFFF) } .rowStyle() .alignItems(VerticalAlign.Bottom) Text('纵向居中 justifyContent(Center)').fontSize(14).width('100%') Row() { Row().width('25%').height(30).backgroundColor(0xAFEEEE) Row().width('25%').height(30).backgroundColor(0x00FFFF) } .rowStyle() .height(50) .justifyContent(FlexAlign.Center) Text('纵向居左 justifyContent(Start)').fontSize(14).width('100%') Row() { Row().width('25%').height(30).backgroundColor(0xAFEEEE) Row().width('25%').height(30).backgroundColor(0x00FFFF) } .rowStyle() .height(30) .justifyContent(FlexAlign.Start) Text('纵向居右 justifyContent(End)').fontSize(14).width('100%') Row() { Row().width('25%').height(30).backgroundColor(0xAFEEEE) Row().width('25%').height(30).backgroundColor(0x00FFFF) } .rowStyle() .height(30) .justifyContent(FlexAlign.End) Text('纵向两侧对齐 justifyContent(SpaceBetween)').fontSize(14).width('100%') Row() { Row().width('25%').height(30).backgroundColor(0xAFEEEE) Row().width('25%').height(30).backgroundColor(0x00FFFF) Row().width('25%').height(30).backgroundColor(0xAFEEEE) } .rowStyle() .height(30) .justifyContent(FlexAlign.SpaceBetween) Text('纵向两侧对齐 justifyContent(SpaceAround)').fontSize(14).width('100%') Row() { Row().width('25%').height(30).backgroundColor(0xAFEEEE) Row().width('25%').height(30).backgroundColor(0x00FFFF) Row().width('25%').height(30).backgroundColor(0xAFEEEE) } .rowStyle() .height(30) .justifyContent(FlexAlign.SpaceAround) Text('纵向两侧对齐 justifyContent(SpaceEvenly)').fontSize(14).width('100%') Row() { Row().width('25%').height(30).backgroundColor(0xAFEEEE) Row().width('25%').height(30).backgroundColor(0x00FFFF) Row().width('25%').height(30).backgroundColor(0xAFEEEE) } .rowStyle() .height(30) .justifyContent(FlexAlign.SpaceEvenly) .margin({ bottom: 0 }) Divider() .color('#CCCCCC') .dividerStyle() Text('Column 列组件') .fontSize(14) .margin({ bottom: 12}) Text('纵向居中 HorizontalAlign(Center),间距为10').fontSize(14).width('100%') Column({ space: 10 }) { Column().width(60).height(25).backgroundColor(0xF5DEB3) Column().width(60).height(25).backgroundColor(0xD2B48C) } .columnStyle() Text('纵向居左 HorizontalAlign(Start)').fontSize(14).width('100%') Column() { Column().width(60).height(25).backgroundColor(0xF5DEB3) Column().width(60).height(25).backgroundColor(0xD2B48C) } .columnStyle() .alignItems(HorizontalAlign.Start) Text('纵向居右 HorizontalAlign(End)').fontSize(14).width('100%') Column() { Column().width(60).height('25%').backgroundColor(0xF5DEB3) Column().width(60).height('25%').backgroundColor(0xD2B48C) } .columnStyle() .alignItems(HorizontalAlign.End) Text('横向居中 justifyContent(Center)').fontSize(14).width('100%') Column() { Column().width(60).height(25).backgroundColor(0xF5DEB3) Column().width(60).height(25).backgroundColor(0xD2B48C) } .columnStyle() .width(60) .justifyContent(FlexAlign.Center) Text('横向居左 justifyContent(Start)').fontSize(14).width('100%') Column() { Column().width(60).height(25).backgroundColor(0xF5DEB3) Column().width(60).height(25).backgroundColor(0xD2B48C) } .columnStyle() .width(60) .justifyContent(FlexAlign.Start) Text('横向居右 justifyContent(End)').fontSize(14).width('100%') Column() { Column().width(60).height(25).backgroundColor(0xF5DEB3) Column().width(60).height(25).backgroundColor(0xD2B48C) } .columnStyle() .width(60) .justifyContent(FlexAlign.End) Text('横向两侧对齐 justifyContent(SpaceBetween)').fontSize(14).width('100%') Column() { Column().width(60).height(25).backgroundColor(0xF5DEB3) Column().width(60).height(25).backgroundColor(0xD2B48C) Column().width(60).height(25).backgroundColor(0xF5DEB3) } .columnStyle() .width(60) .justifyContent(FlexAlign.SpaceBetween) Text('横向两侧对齐 justifyContent(SpaceAround)').fontSize(14).width('100%') Column() { Column().width(60).height(25).backgroundColor(0xF5DEB3) Column().width(60).height(25).backgroundColor(0xD2B48C) Column().width(60).height(25).backgroundColor(0xF5DEB3) } .columnStyle() .width(60) .justifyContent(FlexAlign.SpaceAround) Text('横向两侧对齐 justifyContent(SpaceEvenly)').fontSize(14).width('100%') Column() { Column().width(60).height(25).backgroundColor(0xF5DEB3) Column().width(60).height(25).backgroundColor(0xD2B48C) Column().width(60).height(25).backgroundColor(0xF5DEB3) } .columnStyle() .width(60) .justifyContent(FlexAlign.SpaceEvenly) } .pageStyle() }
https://github.com/Vinson0709/arkdemo.git/blob/793491fe04b387f55dadfef86b30e28d0535d994/entry/src/main/ets/pages/Linear.ets#L61-L258
3c821464b502758c0668a729013b38313b49b334
github
vhall/VHLive_SDK_Harmony
29c820e5301e17ae01bc6bdcc393a4437b518e7c
watchKit/src/main/ets/builder/LotteryDialog.ets
arkts
LotteryDetails
中奖页面
@Component export struct LotteryDetails { //关闭弹窗 @State closeDialog: boolean = true @Prop user_id: number @Prop room_id: string @Prop nickname: string @State receive_award_way: number = 0; @State bol: boolean = true @Consume lotteryResultNotice: VHLotteryResultNoticeModel | null @Consume lotteryPush: VHLotteryResultNoticeModel | null @State WinnerList: VHWinnerInformationItem[] = [] @Prop LotteryList: VHLotteryList[] = [] @Link LotteryStatusEnd: boolean @Consume closeLotteryListDialog: boolean aboutToAppear(): void { this.lotteryPush = null this.WinnerInformation() this.boll() this.closeLotteryListDialog = true; }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct LotteryDetails AST#ERROR#Left { //关闭弹窗 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right closeDialog : 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 @ Prop AST#decorator#Right user_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 AST#decorator#Left @ Prop AST#decorator#Right room_id : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right nickname : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right receive_award_way : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right bol : 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 @ Consume AST#decorator#Right lotteryResultNotice : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left VHLotteryResultNoticeModel AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Consume AST#decorator#Right lotteryPush : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left VHLotteryResultNoticeModel AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right WinnerList : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left VHWinnerInformationItem [ ] 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#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right LotteryList : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left VHLotteryList [ ] 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#property_declaration#Left AST#decorator#Left @ Link AST#decorator#Right LotteryStatusEnd : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#property_declaration#Right AST#decorator#Left @ Consume AST#decorator#Right closeLotteryListDialog : AST#ERROR#Left boolean aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#ERROR#Right AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Right AST#component_body#Left { AST#property_declaration#Left this AST#ERROR#Left . lotteryPush AST#ERROR#Right = AST#expression#Left AST#assignment_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#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#ERROR#Left this AST#ERROR#Right . WinnerInformation AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left this AST#ERROR#Right . boll AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left this AST#ERROR#Right . closeLotteryListDialog 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#property_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Component export struct LotteryDetails { @State closeDialog: boolean = true @Prop user_id: number @Prop room_id: string @Prop nickname: string @State receive_award_way: number = 0; @State bol: boolean = true @Consume lotteryResultNotice: VHLotteryResultNoticeModel | null @Consume lotteryPush: VHLotteryResultNoticeModel | null @State WinnerList: VHWinnerInformationItem[] = [] @Prop LotteryList: VHLotteryList[] = [] @Link LotteryStatusEnd: boolean @Consume closeLotteryListDialog: boolean aboutToAppear(): void { this.lotteryPush = null this.WinnerInformation() this.boll() this.closeLotteryListDialog = true; }
https://github.com/vhall/VHLive_SDK_Harmony/blob/29c820e5301e17ae01bc6bdcc393a4437b518e7c/watchKit/src/main/ets/builder/LotteryDialog.ets#L139-L160
a0829e9574892ce4fb25b5adb3e0a2f150a81ae3
gitee
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
AvoidTimeComsume/entry/src/main/ets/views/NegativeOfGrid.ets
arkts
[StartExclude negative_of_grid] [EndExclude negative_of_grid] [End negative_of_grid]
build() { Column() { Image($r('app.media.app_icon')) .width(48) .height(48) .margin({ bottom: 12 }) Text(`image${this.item}`) .fontSize(12) .textAlign(TextAlign.Center) } .width('100%') .height(82) }
AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.app_icon' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 48 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 48 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 12 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#template_literal#Left ` image AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . item AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 12 AST#expression#Right ) AST#modifier_chain_expression#Left . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 82 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right
build() { Column() { Image($r('app.media.app_icon')) .width(48) .height(48) .margin({ bottom: 12 }) Text(`image${this.item}`) .fontSize(12) .textAlign(TextAlign.Center) } .width('100%') .height(82) }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/AvoidTimeComsume/entry/src/main/ets/views/NegativeOfGrid.ets#L133-L145
9ca51e005b84739f50c79f0a6306e8d5ee4e1ebc
gitee
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_crypto_dto/src/main/ets/crypto/encryption/sm2/SM2Convert.ets
arkts
readC2
读取C2部分 @param sm2_sequence sm2序列工具 @param data 待读取的数据 @returns C2部分
private readC2(sm2_sequence: SM2Sequence, data: string): string { if (data.startsWith(ASN1Util.OCTEN_STRING)) { data = data.slice(ASN1Util.OCTEN_STRING.length, data.length); let C2_lenHex = this.getLenHex(data); data = data.slice(C2_lenHex.length, data.length); if (this.lenHex2number(C2_lenHex) != data.length / 2) { Logger.debug('SM2字符串中的C2长度不正确~'); } sm2_sequence.C2 = data; } else { Logger.debug('读取SM2字符串中的C2出错~'); } return data; }
AST#method_declaration#Left private readC2 AST#parameter_list#Left ( AST#parameter#Left sm2_sequence : AST#type_annotation#Left AST#primary_type#Left SM2Sequence AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . startsWith AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left ASN1Util AST#expression#Right . OCTEN_STRING AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left data = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . slice 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 ASN1Util AST#expression#Right . OCTEN_STRING AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . length AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left C2_lenHex = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getLenHex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left data AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left data = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . slice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left C2_lenHex AST#expression#Right . length AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . length 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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . lenHex2number AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left C2_lenHex AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right != AST#expression#Left data AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right / AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#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 . debug AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'SM2字符串中的C2长度不正确~' 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left sm2_sequence AST#expression#Right . C2 AST#member_expression#Right = AST#expression#Left data AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#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 . debug AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '读取SM2字符串中的C2出错~' 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 data AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private readC2(sm2_sequence: SM2Sequence, data: string): string { if (data.startsWith(ASN1Util.OCTEN_STRING)) { data = data.slice(ASN1Util.OCTEN_STRING.length, data.length); let C2_lenHex = this.getLenHex(data); data = data.slice(C2_lenHex.length, data.length); if (this.lenHex2number(C2_lenHex) != data.length / 2) { Logger.debug('SM2字符串中的C2长度不正确~'); } sm2_sequence.C2 = data; } else { Logger.debug('读取SM2字符串中的C2出错~'); } return data; }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto_dto/src/main/ets/crypto/encryption/sm2/SM2Convert.ets#L232-L245
adbf9e3989662bdf5d6df63149304eac414b69de
gitee
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
ETSUI/MultipleDialog/entry/src/main/ets/viewmodel/HobbyModel.ets
arkts
Hobby info model.
export default class HobbyModel { /** * Hobby title */ label: string = ''; /** * Hobby check status */ isChecked: boolean = false; }
AST#export_declaration#Left export default AST#class_declaration#Left class HobbyModel AST#class_body#Left { /** * Hobby title */ AST#property_declaration#Left label : 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 /** * Hobby check status */ AST#property_declaration#Left isChecked : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export default class HobbyModel { label: string = ''; isChecked: boolean = false; }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/ETSUI/MultipleDialog/entry/src/main/ets/viewmodel/HobbyModel.ets#L19-L29
4d06389c8f8c17298e8dd8459d99d3d89686f821
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/DocsSample/NetWork_Kit/NetWorkKit_Datatransmission/WebSocket_case/entry/src/main/ets/pages/Index.ets
arkts
connectWebSocket
[Start websocket_development_steps] 连接WebSocket
connectWebSocket() { this.connectionStatus = 'Connecting...'; this.sendMessageResult = ''; this.closeConnectionResult = ''; if (this.isConnect) { this.connectionStatus = 'WebSocket is already connected'; return; } this.ws = webSocket.createWebSocket(); this.ws.on('open', (err: BusinessError, value: Object) => { if (!err) { this.connectionStatus = 'Connected'; this.isConnect = true; Logger.info(`${LOG_TAG} WebSocket connected: ` + JSON.stringify(value)); } else { this.connectionStatus = 'Connection failed'; Logger.error(`${LOG_TAG} WebSocket connection failed: ` + JSON.stringify(err)); } }); this.ws.on('message', (err: BusinessError, value: string | ArrayBuffer) => { if (err) { Logger.error(`${LOG_TAG} Error receiving message: ` + JSON.stringify(err)); return; } Logger.info('Received message: ' + value); if (value === 'bye') { this.ws!.close((err: BusinessError) => { if (!err) { this.closeConnectionResult = 'Connection closed successfully'; this.connectionStatus = 'Not connected'; Logger.info(`${LOG_TAG} WebSocket closed successfully`); } else { this.closeConnectionResult = 'Connection closing failed'; Logger.error(`${LOG_TAG} WebSocket closing failed: ` + JSON.stringify(err)); } }); } }) this.ws.on('close', (err: BusinessError, value: webSocket.CloseResult) => { if (!err) { this.connectionStatus = 'Disconnected'; Logger.info('Connection closed: code = ' + value.code + ', reason =' + value.reason); this.ws = null; } else { Logger.error('Error while closing connection: ' + JSON.stringify(err)); } }); this.ws.on('error', (err: BusinessError) => { this.connectionStatus = 'Error'; Logger.error('WebSocket error: ' + JSON.stringify(err)); }); this.ws.connect(DEFAULT_IP_ADDRESS, (err: BusinessError) => { if (!err) { } else { this.connectionStatus = 'Connection failed'; Logger.error(`${LOG_TAG} WebSocket connection failed: ` + JSON.stringify(err)); } }); }
AST#method_declaration#Left connectWebSocket AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . connectionStatus AST#member_expression#Right = AST#expression#Left 'Connecting...' AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . sendMessageResult AST#member_expression#Right = AST#expression#Left '' AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . closeConnectionResult AST#member_expression#Right = AST#expression#Left '' 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 this AST#expression#Right . isConnect 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 . connectionStatus AST#member_expression#Right = AST#expression#Left 'WebSocket is already connected' 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#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 . ws AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left webSocket AST#expression#Right . createWebSocket AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#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 . ws AST#member_expression#Right AST#expression#Right . on AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'open' AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err : AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left err AST#expression#Right AST#unary_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 . connectionStatus AST#member_expression#Right = AST#expression#Left 'Connected' 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 . isConnect AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left LOG_TAG AST#expression#Right } AST#template_substitution#Right WebSocket connected: ` AST#template_literal#Right 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 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 } 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 . connectionStatus AST#member_expression#Right = AST#expression#Left 'Connection failed' 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 AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left LOG_TAG AST#expression#Right } AST#template_substitution#Right WebSocket connection failed: ` AST#template_literal#Right AST#expression#Right + AST#expression#Left JSON AST#expression#Right AST#binary_expression#Right AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left 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 . ws AST#member_expression#Right AST#expression#Right . on AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'message' AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err : AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left value : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left ArrayBuffer AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left 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 AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left LOG_TAG AST#expression#Right } AST#template_substitution#Right Error receiving message: ` AST#template_literal#Right AST#expression#Right + AST#expression#Left JSON AST#expression#Right AST#binary_expression#Right AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#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 Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left 'Received message: ' AST#expression#Right + AST#expression#Left value 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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left value AST#expression#Right === AST#expression#Left 'bye' 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#non_null_assertion_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . ws AST#member_expression#Right AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right . close 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#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left err AST#expression#Right AST#unary_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 . closeConnectionResult AST#member_expression#Right = AST#expression#Left 'Connection closed successfully' 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 . connectionStatus AST#member_expression#Right = AST#expression#Left 'Not connected' 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 . info 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 LOG_TAG AST#expression#Right } AST#template_substitution#Right WebSocket closed successfully ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . closeConnectionResult AST#member_expression#Right = AST#expression#Left 'Connection closing failed' 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 AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left LOG_TAG AST#expression#Right } AST#template_substitution#Right WebSocket closing failed: ` AST#template_literal#Right AST#expression#Right + AST#expression#Left JSON AST#expression#Right AST#binary_expression#Right AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . ws AST#member_expression#Right AST#expression#Right . on AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'close' AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err : AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left webSocket . CloseResult AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left err AST#expression#Right AST#unary_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 . connectionStatus AST#member_expression#Right = AST#expression#Left 'Disconnected' 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 . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'Connection closed: code = ' AST#expression#Right + AST#expression#Left value AST#expression#Right AST#binary_expression#Right AST#expression#Right . code AST#member_expression#Right AST#expression#Right + AST#expression#Left ', reason =' AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left value AST#expression#Right AST#binary_expression#Right AST#expression#Right . reason AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . ws AST#member_expression#Right = AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'Error while closing connection: ' AST#expression#Right + AST#expression#Left JSON AST#expression#Right AST#binary_expression#Right AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left 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 . ws AST#member_expression#Right AST#expression#Right . on AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'error' AST#expression#Right , AST#expression#Left AST#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 . connectionStatus AST#member_expression#Right = AST#expression#Left 'Error' 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 AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'WebSocket 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 err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . ws AST#member_expression#Right AST#expression#Right . connect AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left DEFAULT_IP_ADDRESS 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 AST#unary_expression#Left ! AST#expression#Left err AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#block_statement#Left { } 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 . connectionStatus AST#member_expression#Right = AST#expression#Left 'Connection failed' 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 AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left LOG_TAG AST#expression#Right } AST#template_substitution#Right WebSocket connection failed: ` AST#template_literal#Right AST#expression#Right + AST#expression#Left JSON AST#expression#Right AST#binary_expression#Right AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
connectWebSocket() { this.connectionStatus = 'Connecting...'; this.sendMessageResult = ''; this.closeConnectionResult = ''; if (this.isConnect) { this.connectionStatus = 'WebSocket is already connected'; return; } this.ws = webSocket.createWebSocket(); this.ws.on('open', (err: BusinessError, value: Object) => { if (!err) { this.connectionStatus = 'Connected'; this.isConnect = true; Logger.info(`${LOG_TAG} WebSocket connected: ` + JSON.stringify(value)); } else { this.connectionStatus = 'Connection failed'; Logger.error(`${LOG_TAG} WebSocket connection failed: ` + JSON.stringify(err)); } }); this.ws.on('message', (err: BusinessError, value: string | ArrayBuffer) => { if (err) { Logger.error(`${LOG_TAG} Error receiving message: ` + JSON.stringify(err)); return; } Logger.info('Received message: ' + value); if (value === 'bye') { this.ws!.close((err: BusinessError) => { if (!err) { this.closeConnectionResult = 'Connection closed successfully'; this.connectionStatus = 'Not connected'; Logger.info(`${LOG_TAG} WebSocket closed successfully`); } else { this.closeConnectionResult = 'Connection closing failed'; Logger.error(`${LOG_TAG} WebSocket closing failed: ` + JSON.stringify(err)); } }); } }) this.ws.on('close', (err: BusinessError, value: webSocket.CloseResult) => { if (!err) { this.connectionStatus = 'Disconnected'; Logger.info('Connection closed: code = ' + value.code + ', reason =' + value.reason); this.ws = null; } else { Logger.error('Error while closing connection: ' + JSON.stringify(err)); } }); this.ws.on('error', (err: BusinessError) => { this.connectionStatus = 'Error'; Logger.error('WebSocket error: ' + JSON.stringify(err)); }); this.ws.connect(DEFAULT_IP_ADDRESS, (err: BusinessError) => { if (!err) { } else { this.connectionStatus = 'Connection failed'; Logger.error(`${LOG_TAG} WebSocket connection failed: ` + JSON.stringify(err)); } }); }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/NetWork_Kit/NetWorkKit_Datatransmission/WebSocket_case/entry/src/main/ets/pages/Index.ets#L108-L173
d5dc5d3ccfa8a1313d8e46f0e01c053afc41b751
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/SM4.ets
arkts
TODO SM4加解密 author: 桃花镇童长老ᥫ᭡ since: 2024/07/01
export class SM4 { /** * 加密(GCM模式),异步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @param gcmParams 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 * @returns */ static async encryptGCM(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, gcmParams: cryptoFramework.GcmParamsSpec): Promise<cryptoFramework.DataBlob> { let cipher = cryptoFramework.createCipher('SM4_128|GCM|PKCS7'); await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, gcmParams); let encryptUpdate = await cipher.update(data); //GCM模式加密doFinal时传入空,获得tag数据,并更新至gcmParams对象中。 gcmParams.authTag = await cipher.doFinal(null); return encryptUpdate; } /** * 加密(GCM模式),同步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @param gcmParams 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 * @returns */ static encryptGCMSync(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, gcmParams: cryptoFramework.GcmParamsSpec): cryptoFramework.DataBlob { let cipher = cryptoFramework.createCipher('SM4_128|GCM|PKCS7'); cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, gcmParams); let encryptUpdate = cipher.updateSync(data); //GCM模式加密doFinal时传入空,获得tag数据,并更新至gcmParams对象中。 gcmParams.authTag = cipher.doFinalSync(null); return encryptUpdate; } /** * 解密(GCM模式),异步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @param gcmParams 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。。 * @returns */ static async decryptGCM(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, gcmParams: cryptoFramework.GcmParamsSpec): Promise<cryptoFramework.DataBlob> { let decoder = cryptoFramework.createCipher('SM4_128|GCM|PKCS7'); await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, gcmParams); let decryptUpdate = await decoder.update(data); //GCM模式解密doFinal时传入空,验证init时传入的tag数据,如果验证失败会抛出异常。 await decoder.doFinal(null) return decryptUpdate; } /** * 解密(GCM模式),同步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @param gcmParams 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 * @returns */ static decryptGCMSync(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, gcmParams: cryptoFramework.GcmParamsSpec): cryptoFramework.DataBlob { let decoder = cryptoFramework.createCipher('SM4_128|GCM|PKCS7'); decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, gcmParams); let decryptUpdate = decoder.updateSync(data); //GCM模式解密doFinal时传入空,验证init时传入的tag数据,如果验证失败会抛出异常。 decoder.doFinalSync(null) return decryptUpdate; } /** * 加密(CBC模式),异步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @param ivParams 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 * @returns */ static async encryptCBC(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, ivParams: cryptoFramework.IvParamsSpec): Promise<cryptoFramework.DataBlob> { return SM4.encrypt(data, symKey, ivParams, 'SM4_128|CBC|PKCS7'); } /** * 加密(CBC模式),同步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @param ivParams 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 * @returns */ static encryptCBCSync(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, ivParams: cryptoFramework.IvParamsSpec): cryptoFramework.DataBlob { return SM4.encryptSync(data, symKey, ivParams, 'SM4_128|CBC|PKCS7'); } /** * 解密(CBC模式),异步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @param ivParams 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 * @returns */ static async decryptCBC(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, ivParams: cryptoFramework.IvParamsSpec): Promise<cryptoFramework.DataBlob> { return SM4.decrypt(data, symKey, ivParams, 'SM4_128|CBC|PKCS7'); } /** * 解密(CBC模式),同步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @param ivParams 指定加密或解密的参数,对于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, ivParams: cryptoFramework.IvParamsSpec): cryptoFramework.DataBlob { return SM4.decryptSync(data, symKey, ivParams, 'SM4_128|CBC|PKCS7'); } /** * 加密(ECB模式),异步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @returns */ static async encryptECB(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey): Promise<cryptoFramework.DataBlob> { return SM4.encrypt(data, symKey, null, 'SM4_128|ECB|PKCS7'); } /** * 加密(ECB模式),异步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @returns */ static encryptECBSync(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey): cryptoFramework.DataBlob { return SM4.encryptSync(data, symKey, null, 'SM4_128|ECB|PKCS7'); } /** * 解密(ECB模式),异步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @returns */ static async decryptECB(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey): Promise<cryptoFramework.DataBlob> { return SM4.decrypt(data, symKey, null, 'SM4_128|ECB|PKCS7'); } /** * 解密(ECB模式),异步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @returns */ static decryptECBSync(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey): cryptoFramework.DataBlob { return SM4.decryptSync(data, symKey, null, 'SM4_128|ECB|PKCS7'); } /** * 加密,异步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @param params 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 * @param transformation 待生成Cipher的算法名称(含密钥长度)、加密模式以及填充方法的组合(SM4_128|GCM|PKCS7、SM4_128|CBC|PKCS7、SM4_128|ECB|PKCS7、等)。 * @returns */ static async encrypt(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, params: cryptoFramework.ParamsSpec | null, transformation: string): Promise<cryptoFramework.DataBlob> { return CryptoUtil.encrypt(data, symKey, params, transformation); } /** * 加密,同步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @param params 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 * @param transformation 待生成Cipher的算法名称(含密钥长度)、加密模式以及填充方法的组合(SM4_128|GCM|PKCS7、SM4_128|CBC|PKCS7、SM4_128|ECB|PKCS7、等)。 * @returns */ static encryptSync(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, params: cryptoFramework.ParamsSpec | null, transformation: string): cryptoFramework.DataBlob { return CryptoUtil.encryptSync(data, symKey, params, transformation); } /** * 解密,异步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @param params 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 * @param transformation 待生成Cipher的算法名称(含密钥长度)、加密模式以及填充方法的组合(SM4_128|GCM|PKCS7、SM4_128|CBC|PKCS7、SM4_128|ECB|PKCS7、等)。 * @returns */ static async decrypt(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, params: cryptoFramework.ParamsSpec | null, transformation: string): Promise<cryptoFramework.DataBlob> { return CryptoUtil.decrypt(data, symKey, params, transformation); } /** * 解密,同步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @param params 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 * @param transformation 待生成Cipher的算法名称(含密钥长度)、加密模式以及填充方法的组合(SM4_128|GCM|PKCS7、SM4_128|CBC|PKCS7、SM4_128|ECB|PKCS7、等)。 * @returns */ static decryptSync(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, params: cryptoFramework.ParamsSpec | null, transformation: string): cryptoFramework.DataBlob { return CryptoUtil.decryptSync(data, symKey, params, transformation); } /** * 加密(GCM模式)分段,异步 * @param dataBlob 加密或者解密的数据。dataBlob不能为null。 * @param key 指定加密或解密的密钥。 * @param gcmParams 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 * @param len 自定义的数据拆分长度。 * @returns */ static async encryptGCMSegment(dataBlob: cryptoFramework.DataBlob, key: cryptoFramework.Key, gcmParams: cryptoFramework.GcmParamsSpec, len: number = 128): Promise<cryptoFramework.DataBlob> { let cipher = cryptoFramework.createCipher('SM4_128|GCM|PKCS7'); await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, key, gcmParams); let encryptData = new Uint8Array(); for (let i = 0; i < dataBlob.data.length; i += len) { let updateData = dataBlob.data.subarray(i, i + len); let updateDataBlob: cryptoFramework.DataBlob = { data: updateData }; let updateOutput = await cipher.update(updateDataBlob); //分段update let mergeTData = new Uint8Array(encryptData.length + updateOutput.data.length); mergeTData.set(encryptData); mergeTData.set(updateOutput.data, encryptData.length); encryptData = mergeTData; } gcmParams.authTag = await cipher.doFinal(null); let encryptBlob: cryptoFramework.DataBlob = { data: encryptData }; return encryptBlob; } /** * 加密(GCM模式)分段,同步 * @param dataBlob 加密或者解密的数据。dataBlob不能为null。 * @param key 指定加密或解密的密钥。 * @param gcmParams 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 * @param len 自定义的数据拆分长度。 * @returns */ static encryptGCMSegmentSync(dataBlob: cryptoFramework.DataBlob, key: cryptoFramework.Key, gcmParams: cryptoFramework.GcmParamsSpec, len: number = 128): cryptoFramework.DataBlob { let cipher = cryptoFramework.createCipher('SM4_128|GCM|PKCS7'); cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, key, gcmParams); let encryptData = new Uint8Array(); for (let i = 0; i < dataBlob.data.length; i += len) { let updateData = dataBlob.data.subarray(i, i + len); let updateDataBlob: cryptoFramework.DataBlob = { data: updateData }; let updateOutput = cipher.updateSync(updateDataBlob); //分段update let mergeTData = new Uint8Array(encryptData.length + updateOutput.data.length); mergeTData.set(encryptData); mergeTData.set(updateOutput.data, encryptData.length); encryptData = mergeTData; } gcmParams.authTag = cipher.doFinalSync(null); let encryptBlob: cryptoFramework.DataBlob = { data: encryptData }; return encryptBlob; } /** * 解密(GCM模式)分段,异步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @param gcmParams 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 * @param len 自定义的数据拆分长度。 * @returns */ static async decryptGCMSegment(dataBlob: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, gcmParams: cryptoFramework.GcmParamsSpec, len: number = 128): Promise<cryptoFramework.DataBlob> { let decoder = cryptoFramework.createCipher('SM4_128|GCM|PKCS7'); await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, gcmParams); let decryptData = new Uint8Array(); for (let i = 0; i < dataBlob.data.length; i += len) { let updateData = dataBlob.data.subarray(i, i + len); let updateDataBlob: cryptoFramework.DataBlob = { data: updateData }; let updateOutput = await decoder.update(updateDataBlob); //分段update //把update的结果拼接起来,得到明文 let mergeTData = new Uint8Array(decryptData.length + updateOutput.data.length); mergeTData.set(decryptData); mergeTData.set(updateOutput.data, decryptData.length); decryptData = mergeTData; } await decoder.doFinal(null); let decryptBlob: cryptoFramework.DataBlob = { data: decryptData }; return decryptBlob; } /** * 解密(GCM模式)分段,异步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @param gcmParams 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 * @param len 自定义的数据拆分长度。 * @returns */ static decryptGCMSegmentSync(dataBlob: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, gcmParams: cryptoFramework.GcmParamsSpec, len: number = 128): cryptoFramework.DataBlob { let decoder = cryptoFramework.createCipher('SM4_128|GCM|PKCS7'); decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, gcmParams); let decryptData = new Uint8Array(); for (let i = 0; i < dataBlob.data.length; i += len) { let updateData = dataBlob.data.subarray(i, i + len); let updateDataBlob: cryptoFramework.DataBlob = { data: updateData }; let updateOutput = decoder.updateSync(updateDataBlob); //分段update //把update的结果拼接起来,得到明文 let mergeTData = new Uint8Array(decryptData.length + updateOutput.data.length); mergeTData.set(decryptData); mergeTData.set(updateOutput.data, decryptData.length); decryptData = mergeTData; } decoder.doFinalSync(null); let decryptBlob: cryptoFramework.DataBlob = { data: decryptData }; return decryptBlob; } /** * 生成对称密钥SymKey,异步 * @param symAlgName 待生成对称密钥生成器的算法名称(SM4_128) * @returns */ static async generateSymKey(): Promise<cryptoFramework.SymKey> { return CryptoUtil.generateSymKey('SM4_128'); } /** * 生成对称密钥SymKey,同步 * @param symAlgName 待生成对称密钥生成器的算法名称(SM4_128) * @returns */ static generateSymKeySync(): cryptoFramework.SymKey { return CryptoUtil.generateSymKeySync('SM4_128'); } }
AST#export_declaration#Left export AST#class_declaration#Left class SM4 AST#class_body#Left { /** * 加密(GCM模式),异步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @param gcmParams 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 * @returns */ AST#method_declaration#Left static async encryptGCM AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . DataBlob AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left symKey : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . SymKey AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left gcmParams : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . GcmParamsSpec AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_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 cryptoFramework . DataBlob 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#variable_declaration#Left let AST#variable_declarator#Left cipher = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . createCipher AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'SM4_128|GCM|PKCS7' 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 cipher AST#expression#Right AST#await_expression#Right AST#expression#Right . init AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . CryptoMode AST#member_expression#Right AST#expression#Right . ENCRYPT_MODE AST#member_expression#Right AST#expression#Right , AST#expression#Left symKey AST#expression#Right , AST#expression#Left gcmParams AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left encryptUpdate = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left cipher 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 data AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right //GCM模式加密doFinal时传入空,获得tag数据,并更新至gcmParams对象中。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left gcmParams AST#expression#Right . authTag AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left cipher AST#expression#Right AST#await_expression#Right AST#expression#Right . doFinal AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left encryptUpdate AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 加密(GCM模式),同步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @param gcmParams 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 * @returns */ AST#method_declaration#Left static encryptGCMSync AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . DataBlob AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left symKey : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . SymKey AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left gcmParams : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . GcmParamsSpec AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . DataBlob AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left cipher = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . createCipher AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'SM4_128|GCM|PKCS7' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cipher AST#expression#Right . initSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . CryptoMode AST#member_expression#Right AST#expression#Right . ENCRYPT_MODE AST#member_expression#Right AST#expression#Right , AST#expression#Left symKey AST#expression#Right , AST#expression#Left gcmParams AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left encryptUpdate = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cipher AST#expression#Right . updateSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left data AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right //GCM模式加密doFinal时传入空,获得tag数据,并更新至gcmParams对象中。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left gcmParams AST#expression#Right . authTag AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cipher AST#expression#Right . doFinalSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left encryptUpdate AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 解密(GCM模式),异步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @param gcmParams 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。。 * @returns */ AST#method_declaration#Left static async decryptGCM AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . DataBlob AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left symKey : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . SymKey AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left gcmParams : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . GcmParamsSpec AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_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 cryptoFramework . DataBlob 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#variable_declaration#Left let AST#variable_declarator#Left decoder = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . createCipher AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'SM4_128|GCM|PKCS7' 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 decoder AST#expression#Right AST#await_expression#Right AST#expression#Right . init AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . CryptoMode AST#member_expression#Right AST#expression#Right . DECRYPT_MODE AST#member_expression#Right AST#expression#Right , AST#expression#Left symKey AST#expression#Right , AST#expression#Left gcmParams AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left decryptUpdate = 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 decoder 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 data AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right //GCM模式解密doFinal时传入空,验证init时传入的tag数据,如果验证失败会抛出异常。 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 decoder AST#expression#Right AST#await_expression#Right AST#expression#Right . doFinal AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left decryptUpdate AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 解密(GCM模式),同步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @param gcmParams 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 * @returns */ AST#method_declaration#Left static decryptGCMSync AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . DataBlob AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left symKey : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . SymKey AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left gcmParams : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . GcmParamsSpec AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . DataBlob AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left decoder = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . createCipher AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'SM4_128|GCM|PKCS7' 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 decoder AST#expression#Right . initSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . CryptoMode AST#member_expression#Right AST#expression#Right . DECRYPT_MODE AST#member_expression#Right AST#expression#Right , AST#expression#Left symKey AST#expression#Right , AST#expression#Left gcmParams AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left decryptUpdate = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left decoder AST#expression#Right . updateSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left data AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right //GCM模式解密doFinal时传入空,验证init时传入的tag数据,如果验证失败会抛出异常。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left decoder AST#expression#Right . doFinalSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left decryptUpdate AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 加密(CBC模式),异步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @param ivParams 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 * @returns */ AST#method_declaration#Left static async encryptCBC 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 ivParams : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . IvParamsSpec 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 AST#qualified_type#Left cryptoFramework . DataBlob 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 SM4 AST#expression#Right . encrypt 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 ivParams AST#expression#Right , AST#expression#Left 'SM4_128|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 /** * 加密(CBC模式),同步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @param ivParams 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 * @returns */ AST#method_declaration#Left static encryptCBCSync 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 ivParams : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . IvParamsSpec 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 SM4 AST#expression#Right . encryptSync 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 ivParams AST#expression#Right , AST#expression#Left 'SM4_128|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 /** * 解密(CBC模式),异步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @param ivParams 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 * @returns */ AST#method_declaration#Left static async decryptCBC 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 ivParams : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . IvParamsSpec 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 AST#qualified_type#Left cryptoFramework . DataBlob 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 SM4 AST#expression#Right . decrypt 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 ivParams AST#expression#Right , AST#expression#Left 'SM4_128|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 /** * 解密(CBC模式),同步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @param ivParams 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 * @param transformation 待生成Cipher的算法名称(含密钥长度)、加密模式以及填充方法的组合(AES256|CBC|PKCS7、AES192|CBC|PKCS7、AES128|CBC|PKCS7)。 * @returns */ 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 ivParams : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . IvParamsSpec 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 SM4 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 ivParams AST#expression#Right , AST#expression#Left 'SM4_128|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 /** * 加密(ECB模式),异步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @returns */ AST#method_declaration#Left static async encryptECB 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_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 cryptoFramework . DataBlob 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 SM4 AST#expression#Right . encrypt 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 AST#null_literal#Left null AST#null_literal#Right AST#expression#Right , AST#expression#Left 'SM4_128|ECB|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 /** * 加密(ECB模式),异步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @returns */ AST#method_declaration#Left static encryptECBSync 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_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 SM4 AST#expression#Right . encryptSync 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 AST#null_literal#Left null AST#null_literal#Right AST#expression#Right , AST#expression#Left 'SM4_128|ECB|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 /** * 解密(ECB模式),异步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @returns */ AST#method_declaration#Left static async decryptECB 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_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 cryptoFramework . DataBlob 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 SM4 AST#expression#Right . decrypt 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 AST#null_literal#Left null AST#null_literal#Right AST#expression#Right , AST#expression#Left 'SM4_128|ECB|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 /** * 解密(ECB模式),异步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @returns */ AST#method_declaration#Left static decryptECBSync 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_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 SM4 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 AST#null_literal#Left null AST#null_literal#Right AST#expression#Right , AST#expression#Left 'SM4_128|ECB|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 /** * 加密,异步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @param params 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 * @param transformation 待生成Cipher的算法名称(含密钥长度)、加密模式以及填充方法的组合(SM4_128|GCM|PKCS7、SM4_128|CBC|PKCS7、SM4_128|ECB|PKCS7、等)。 * @returns */ AST#method_declaration#Left static async encrypt AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . DataBlob AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left symKey : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . SymKey AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left params : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . ParamsSpec AST#qualified_type#Right AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left transformation : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#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#qualified_type#Left cryptoFramework . DataBlob 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 CryptoUtil AST#expression#Right . encrypt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left data AST#expression#Right , AST#expression#Left symKey AST#expression#Right , AST#expression#Left params AST#expression#Right , AST#expression#Left transformation AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 加密,同步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @param params 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 * @param transformation 待生成Cipher的算法名称(含密钥长度)、加密模式以及填充方法的组合(SM4_128|GCM|PKCS7、SM4_128|CBC|PKCS7、SM4_128|ECB|PKCS7、等)。 * @returns */ AST#method_declaration#Left static encryptSync AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . DataBlob AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left symKey : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . SymKey AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left params : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . ParamsSpec AST#qualified_type#Right AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left transformation : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#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 CryptoUtil AST#expression#Right . encryptSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left data AST#expression#Right , AST#expression#Left symKey AST#expression#Right , AST#expression#Left params AST#expression#Right , AST#expression#Left transformation AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 解密,异步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @param params 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 * @param transformation 待生成Cipher的算法名称(含密钥长度)、加密模式以及填充方法的组合(SM4_128|GCM|PKCS7、SM4_128|CBC|PKCS7、SM4_128|ECB|PKCS7、等)。 * @returns */ AST#method_declaration#Left static async decrypt AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . DataBlob AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left symKey : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . SymKey AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left params : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . ParamsSpec AST#qualified_type#Right AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left transformation : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#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#qualified_type#Left cryptoFramework . DataBlob 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 CryptoUtil AST#expression#Right . decrypt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left data AST#expression#Right , AST#expression#Left symKey AST#expression#Right , AST#expression#Left params AST#expression#Right , AST#expression#Left transformation AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 解密,同步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @param params 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 * @param transformation 待生成Cipher的算法名称(含密钥长度)、加密模式以及填充方法的组合(SM4_128|GCM|PKCS7、SM4_128|CBC|PKCS7、SM4_128|ECB|PKCS7、等)。 * @returns */ AST#method_declaration#Left static decryptSync AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . DataBlob AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left symKey : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . SymKey AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left params : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . ParamsSpec AST#qualified_type#Right AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left transformation : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#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 CryptoUtil AST#expression#Right . decryptSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left data AST#expression#Right , AST#expression#Left symKey AST#expression#Right , AST#expression#Left params AST#expression#Right , AST#expression#Left transformation AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 加密(GCM模式)分段,异步 * @param dataBlob 加密或者解密的数据。dataBlob不能为null。 * @param key 指定加密或解密的密钥。 * @param gcmParams 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 * @param len 自定义的数据拆分长度。 * @returns */ AST#method_declaration#Left static async encryptGCMSegment AST#parameter_list#Left ( AST#parameter#Left dataBlob : 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 key : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . Key AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left gcmParams : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . GcmParamsSpec AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left len : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 128 AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . DataBlob 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#variable_declaration#Left let AST#variable_declarator#Left cipher = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . createCipher AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'SM4_128|GCM|PKCS7' 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 cipher AST#expression#Right AST#await_expression#Right AST#expression#Right . init AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . CryptoMode AST#member_expression#Right AST#expression#Right . ENCRYPT_MODE AST#member_expression#Right AST#expression#Right , AST#expression#Left key AST#expression#Right , AST#expression#Left gcmParams AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left encryptData = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Uint8Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left dataBlob AST#expression#Right AST#binary_expression#Right AST#expression#Right . data AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ; AST#expression#Left AST#assignment_expression#Left i += AST#expression#Left len AST#expression#Right AST#assignment_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left updateData = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left dataBlob AST#expression#Right . data AST#member_expression#Right AST#expression#Right . subarray AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left i AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right + AST#expression#Left len AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left updateDataBlob : 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#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left data AST#property_name#Right : AST#expression#Left updateData AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left updateOutput = 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 cipher 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 updateDataBlob 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 //分段update AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left mergeTData = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Uint8Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left encryptData AST#expression#Right . length AST#member_expression#Right AST#expression#Right + AST#expression#Left updateOutput AST#expression#Right AST#binary_expression#Right AST#expression#Right . data AST#member_expression#Right AST#expression#Right . length 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 mergeTData AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left encryptData 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 mergeTData 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 updateOutput AST#expression#Right . data AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left encryptData AST#expression#Right . length AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left encryptData = AST#expression#Left mergeTData AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left gcmParams AST#expression#Right . authTag AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left cipher AST#expression#Right AST#await_expression#Right AST#expression#Right . doFinal AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left encryptBlob : 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#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left data AST#property_name#Right : AST#expression#Left encryptData 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 encryptBlob AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 加密(GCM模式)分段,同步 * @param dataBlob 加密或者解密的数据。dataBlob不能为null。 * @param key 指定加密或解密的密钥。 * @param gcmParams 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 * @param len 自定义的数据拆分长度。 * @returns */ AST#method_declaration#Left static encryptGCMSegmentSync AST#parameter_list#Left ( AST#parameter#Left dataBlob : 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 key : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . Key AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left gcmParams : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . GcmParamsSpec AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left len : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 128 AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . DataBlob AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left cipher = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . createCipher AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'SM4_128|GCM|PKCS7' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cipher AST#expression#Right . initSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . CryptoMode AST#member_expression#Right AST#expression#Right . ENCRYPT_MODE AST#member_expression#Right AST#expression#Right , AST#expression#Left key AST#expression#Right , AST#expression#Left gcmParams AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left encryptData = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Uint8Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left dataBlob AST#expression#Right AST#binary_expression#Right AST#expression#Right . data AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ; AST#expression#Left AST#assignment_expression#Left i += AST#expression#Left len AST#expression#Right AST#assignment_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left updateData = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left dataBlob AST#expression#Right . data AST#member_expression#Right AST#expression#Right . subarray AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left i AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right + AST#expression#Left len AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left updateDataBlob : 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#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left data AST#property_name#Right : AST#expression#Left updateData AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left updateOutput = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cipher AST#expression#Right . updateSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left updateDataBlob 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 //分段update AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left mergeTData = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Uint8Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left encryptData AST#expression#Right . length AST#member_expression#Right AST#expression#Right + AST#expression#Left updateOutput AST#expression#Right AST#binary_expression#Right AST#expression#Right . data AST#member_expression#Right AST#expression#Right . length 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 mergeTData AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left encryptData 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 mergeTData 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 updateOutput AST#expression#Right . data AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left encryptData AST#expression#Right . length AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left encryptData = AST#expression#Left mergeTData AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left gcmParams AST#expression#Right . authTag AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cipher AST#expression#Right . doFinalSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left encryptBlob : 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#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left data AST#property_name#Right : AST#expression#Left encryptData 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 encryptBlob AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 解密(GCM模式)分段,异步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @param gcmParams 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 * @param len 自定义的数据拆分长度。 * @returns */ AST#method_declaration#Left static async decryptGCMSegment AST#parameter_list#Left ( AST#parameter#Left dataBlob : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . DataBlob AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left symKey : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . SymKey AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left gcmParams : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . GcmParamsSpec AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left len : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 128 AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . DataBlob 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#variable_declaration#Left let AST#variable_declarator#Left decoder = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . createCipher AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'SM4_128|GCM|PKCS7' 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 decoder AST#expression#Right AST#await_expression#Right AST#expression#Right . init AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . CryptoMode AST#member_expression#Right AST#expression#Right . DECRYPT_MODE AST#member_expression#Right AST#expression#Right , AST#expression#Left symKey AST#expression#Right , AST#expression#Left gcmParams AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left decryptData = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Uint8Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left dataBlob AST#expression#Right AST#binary_expression#Right AST#expression#Right . data AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ; AST#expression#Left AST#assignment_expression#Left i += AST#expression#Left len AST#expression#Right AST#assignment_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left updateData = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left dataBlob AST#expression#Right . data AST#member_expression#Right AST#expression#Right . subarray AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left i AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right + AST#expression#Left len AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left updateDataBlob : 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#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left data AST#property_name#Right : AST#expression#Left updateData AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left updateOutput = 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 decoder 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 updateDataBlob 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 //分段update //把update的结果拼接起来,得到明文 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left mergeTData = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Uint8Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left decryptData AST#expression#Right . length AST#member_expression#Right AST#expression#Right + AST#expression#Left updateOutput AST#expression#Right AST#binary_expression#Right AST#expression#Right . data AST#member_expression#Right AST#expression#Right . length 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 mergeTData AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left decryptData 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 mergeTData 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 updateOutput AST#expression#Right . data AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left decryptData AST#expression#Right . length AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left decryptData = AST#expression#Left mergeTData AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#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 decoder AST#expression#Right AST#await_expression#Right AST#expression#Right . doFinal AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left decryptBlob : 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#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left data AST#property_name#Right : AST#expression#Left decryptData 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 decryptBlob AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 解密(GCM模式)分段,异步 * @param data 加密或者解密的数据。data不能为null。 * @param symKey 指定加密或解密的密钥。 * @param gcmParams 指定加密或解密的参数,对于ECB等没有参数的算法模式,可以传入null。API 10之前只支持ParamsSpec, API 10之后增加支持null。 * @param len 自定义的数据拆分长度。 * @returns */ AST#method_declaration#Left static decryptGCMSegmentSync AST#parameter_list#Left ( AST#parameter#Left dataBlob : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . DataBlob AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left symKey : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . SymKey AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left gcmParams : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . GcmParamsSpec AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left len : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 128 AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . DataBlob AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left decoder = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . createCipher AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'SM4_128|GCM|PKCS7' 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 decoder AST#expression#Right . initSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . CryptoMode AST#member_expression#Right AST#expression#Right . DECRYPT_MODE AST#member_expression#Right AST#expression#Right , AST#expression#Left symKey AST#expression#Right , AST#expression#Left gcmParams AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left decryptData = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Uint8Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left dataBlob AST#expression#Right AST#binary_expression#Right AST#expression#Right . data AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ; AST#expression#Left AST#assignment_expression#Left i += AST#expression#Left len AST#expression#Right AST#assignment_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left updateData = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left dataBlob AST#expression#Right . data AST#member_expression#Right AST#expression#Right . subarray AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left i AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right + AST#expression#Left len AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left updateDataBlob : 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#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left data AST#property_name#Right : AST#expression#Left updateData AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left updateOutput = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left decoder AST#expression#Right . updateSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left updateDataBlob 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 //分段update //把update的结果拼接起来,得到明文 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left mergeTData = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Uint8Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left decryptData AST#expression#Right . length AST#member_expression#Right AST#expression#Right + AST#expression#Left updateOutput AST#expression#Right AST#binary_expression#Right AST#expression#Right . data AST#member_expression#Right AST#expression#Right . length 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 mergeTData AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left decryptData 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 mergeTData 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 updateOutput AST#expression#Right . data AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left decryptData AST#expression#Right . length AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left decryptData = AST#expression#Left mergeTData AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left decoder AST#expression#Right . doFinalSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left decryptBlob : 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#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left data AST#property_name#Right : AST#expression#Left decryptData 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 decryptBlob AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 生成对称密钥SymKey,异步 * @param symAlgName 待生成对称密钥生成器的算法名称(SM4_128) * @returns */ AST#method_declaration#Left static async generateSymKey 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 cryptoFramework . SymKey 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 CryptoUtil AST#expression#Right . generateSymKey AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'SM4_128' 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 /** * 生成对称密钥SymKey,同步 * @param symAlgName 待生成对称密钥生成器的算法名称(SM4_128) * @returns */ AST#method_declaration#Left static generateSymKeySync AST#parameter_list#Left ( ) AST#parameter_list#Right : 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#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CryptoUtil AST#expression#Right . generateSymKeySync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'SM4_128' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class SM4 { static async encryptGCM(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, gcmParams: cryptoFramework.GcmParamsSpec): Promise<cryptoFramework.DataBlob> { let cipher = cryptoFramework.createCipher('SM4_128|GCM|PKCS7'); await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, gcmParams); let encryptUpdate = await cipher.update(data); gcmParams.authTag = await cipher.doFinal(null); return encryptUpdate; } static encryptGCMSync(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, gcmParams: cryptoFramework.GcmParamsSpec): cryptoFramework.DataBlob { let cipher = cryptoFramework.createCipher('SM4_128|GCM|PKCS7'); cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, gcmParams); let encryptUpdate = cipher.updateSync(data); gcmParams.authTag = cipher.doFinalSync(null); return encryptUpdate; } static async decryptGCM(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, gcmParams: cryptoFramework.GcmParamsSpec): Promise<cryptoFramework.DataBlob> { let decoder = cryptoFramework.createCipher('SM4_128|GCM|PKCS7'); await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, gcmParams); let decryptUpdate = await decoder.update(data); await decoder.doFinal(null) return decryptUpdate; } static decryptGCMSync(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, gcmParams: cryptoFramework.GcmParamsSpec): cryptoFramework.DataBlob { let decoder = cryptoFramework.createCipher('SM4_128|GCM|PKCS7'); decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, gcmParams); let decryptUpdate = decoder.updateSync(data); decoder.doFinalSync(null) return decryptUpdate; } static async encryptCBC(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, ivParams: cryptoFramework.IvParamsSpec): Promise<cryptoFramework.DataBlob> { return SM4.encrypt(data, symKey, ivParams, 'SM4_128|CBC|PKCS7'); } static encryptCBCSync(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, ivParams: cryptoFramework.IvParamsSpec): cryptoFramework.DataBlob { return SM4.encryptSync(data, symKey, ivParams, 'SM4_128|CBC|PKCS7'); } static async decryptCBC(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, ivParams: cryptoFramework.IvParamsSpec): Promise<cryptoFramework.DataBlob> { return SM4.decrypt(data, symKey, ivParams, 'SM4_128|CBC|PKCS7'); } static decryptCBCSync(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, ivParams: cryptoFramework.IvParamsSpec): cryptoFramework.DataBlob { return SM4.decryptSync(data, symKey, ivParams, 'SM4_128|CBC|PKCS7'); } static async encryptECB(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey): Promise<cryptoFramework.DataBlob> { return SM4.encrypt(data, symKey, null, 'SM4_128|ECB|PKCS7'); } static encryptECBSync(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey): cryptoFramework.DataBlob { return SM4.encryptSync(data, symKey, null, 'SM4_128|ECB|PKCS7'); } static async decryptECB(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey): Promise<cryptoFramework.DataBlob> { return SM4.decrypt(data, symKey, null, 'SM4_128|ECB|PKCS7'); } static decryptECBSync(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey): cryptoFramework.DataBlob { return SM4.decryptSync(data, symKey, null, 'SM4_128|ECB|PKCS7'); } static async encrypt(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, params: cryptoFramework.ParamsSpec | null, transformation: string): Promise<cryptoFramework.DataBlob> { return CryptoUtil.encrypt(data, symKey, params, transformation); } static encryptSync(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, params: cryptoFramework.ParamsSpec | null, transformation: string): cryptoFramework.DataBlob { return CryptoUtil.encryptSync(data, symKey, params, transformation); } static async decrypt(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, params: cryptoFramework.ParamsSpec | null, transformation: string): Promise<cryptoFramework.DataBlob> { return CryptoUtil.decrypt(data, symKey, params, transformation); } static decryptSync(data: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, params: cryptoFramework.ParamsSpec | null, transformation: string): cryptoFramework.DataBlob { return CryptoUtil.decryptSync(data, symKey, params, transformation); } static async encryptGCMSegment(dataBlob: cryptoFramework.DataBlob, key: cryptoFramework.Key, gcmParams: cryptoFramework.GcmParamsSpec, len: number = 128): Promise<cryptoFramework.DataBlob> { let cipher = cryptoFramework.createCipher('SM4_128|GCM|PKCS7'); await cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, key, gcmParams); let encryptData = new Uint8Array(); for (let i = 0; i < dataBlob.data.length; i += len) { let updateData = dataBlob.data.subarray(i, i + len); let updateDataBlob: cryptoFramework.DataBlob = { data: updateData }; let updateOutput = await cipher.update(updateDataBlob); let mergeTData = new Uint8Array(encryptData.length + updateOutput.data.length); mergeTData.set(encryptData); mergeTData.set(updateOutput.data, encryptData.length); encryptData = mergeTData; } gcmParams.authTag = await cipher.doFinal(null); let encryptBlob: cryptoFramework.DataBlob = { data: encryptData }; return encryptBlob; } static encryptGCMSegmentSync(dataBlob: cryptoFramework.DataBlob, key: cryptoFramework.Key, gcmParams: cryptoFramework.GcmParamsSpec, len: number = 128): cryptoFramework.DataBlob { let cipher = cryptoFramework.createCipher('SM4_128|GCM|PKCS7'); cipher.initSync(cryptoFramework.CryptoMode.ENCRYPT_MODE, key, gcmParams); let encryptData = new Uint8Array(); for (let i = 0; i < dataBlob.data.length; i += len) { let updateData = dataBlob.data.subarray(i, i + len); let updateDataBlob: cryptoFramework.DataBlob = { data: updateData }; let updateOutput = cipher.updateSync(updateDataBlob); let mergeTData = new Uint8Array(encryptData.length + updateOutput.data.length); mergeTData.set(encryptData); mergeTData.set(updateOutput.data, encryptData.length); encryptData = mergeTData; } gcmParams.authTag = cipher.doFinalSync(null); let encryptBlob: cryptoFramework.DataBlob = { data: encryptData }; return encryptBlob; } static async decryptGCMSegment(dataBlob: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, gcmParams: cryptoFramework.GcmParamsSpec, len: number = 128): Promise<cryptoFramework.DataBlob> { let decoder = cryptoFramework.createCipher('SM4_128|GCM|PKCS7'); await decoder.init(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, gcmParams); let decryptData = new Uint8Array(); for (let i = 0; i < dataBlob.data.length; i += len) { let updateData = dataBlob.data.subarray(i, i + len); let updateDataBlob: cryptoFramework.DataBlob = { data: updateData }; let updateOutput = await decoder.update(updateDataBlob); let mergeTData = new Uint8Array(decryptData.length + updateOutput.data.length); mergeTData.set(decryptData); mergeTData.set(updateOutput.data, decryptData.length); decryptData = mergeTData; } await decoder.doFinal(null); let decryptBlob: cryptoFramework.DataBlob = { data: decryptData }; return decryptBlob; } static decryptGCMSegmentSync(dataBlob: cryptoFramework.DataBlob, symKey: cryptoFramework.SymKey, gcmParams: cryptoFramework.GcmParamsSpec, len: number = 128): cryptoFramework.DataBlob { let decoder = cryptoFramework.createCipher('SM4_128|GCM|PKCS7'); decoder.initSync(cryptoFramework.CryptoMode.DECRYPT_MODE, symKey, gcmParams); let decryptData = new Uint8Array(); for (let i = 0; i < dataBlob.data.length; i += len) { let updateData = dataBlob.data.subarray(i, i + len); let updateDataBlob: cryptoFramework.DataBlob = { data: updateData }; let updateOutput = decoder.updateSync(updateDataBlob); let mergeTData = new Uint8Array(decryptData.length + updateOutput.data.length); mergeTData.set(decryptData); mergeTData.set(updateOutput.data, decryptData.length); decryptData = mergeTData; } decoder.doFinalSync(null); let decryptBlob: cryptoFramework.DataBlob = { data: decryptData }; return decryptBlob; } static async generateSymKey(): Promise<cryptoFramework.SymKey> { return CryptoUtil.generateSymKey('SM4_128'); } static generateSymKeySync(): cryptoFramework.SymKey { return CryptoUtil.generateSymKeySync('SM4_128'); } }
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/SM4.ets#L25-L376
4c0dc248ed54fdb7ac635830ecf3e07a1c85d6de
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/cuberotateanimation/src/main/ets/model/DataModel.ets
arkts
定义3D立方体旋转动画轮播项的数据类型。 每个轮播项包含一个主标题 (title)、一个副标题 (subTitle) 和一个图像资源 (image)。
export class MySwiperItem { title: string; subTitle: string; image: Resource; constructor(title: string, subTitle: string, image: Resource) { this.title = title; this.subTitle = subTitle; this.image = image; } }
AST#export_declaration#Left export AST#class_declaration#Left class MySwiperItem AST#class_body#Left { AST#property_declaration#Left title : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left subTitle : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left image : AST#type_annotation#Left AST#primary_type#Left Resource 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 string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left subTitle : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left image : AST#type_annotation#Left AST#primary_type#Left Resource 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 . subTitle AST#member_expression#Right = AST#expression#Left subTitle 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 . image AST#member_expression#Right = AST#expression#Left image 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 MySwiperItem { title: string; subTitle: string; image: Resource; constructor(title: string, subTitle: string, image: Resource) { this.title = title; this.subTitle = subTitle; this.image = image; } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/cuberotateanimation/src/main/ets/model/DataModel.ets#L79-L89
1a449705b77809ffd30b42c10956b44901558410
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/ai/SimpleAIService.ets
arkts
GenerationParams
导出接口供Index使用
export { GenerationParams, GiftRequestParams };
AST#export_declaration#Left export { GenerationParams , GiftRequestParams } ; AST#export_declaration#Right
export { GenerationParams, GiftRequestParams };
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/ai/SimpleAIService.ets#L56-L56
485b178807eb618946b9d9cfc2388abd3a74a05f
github
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
AppColdStart/entry/src/main/ets/utils/NetRequest.ets
arkts
Download picture resources from the Internet through the http request method
export function httpRequest(): void { hiTraceMeter.startTrace('Http Request', 1); http.createHttp() // The actual development needs to "https://www.example1.com/POST?e=f&g=h"replaced with the real website address to visit .request('https://www.example1.com/POST?e=f&g=h', (error: BusinessError, data: http.HttpResponse) => { if (error) { // The follow-up logic is not executed when the download fails. return; } // Processing the data returned by network requests transcodePixelMap(data); } ) }
AST#export_declaration#Left export AST#function_declaration#Left function httpRequest 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hiTraceMeter AST#expression#Right . startTrace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Http Request' 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#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 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 // The actual development needs to "https://www.example1.com/POST?e=f&g=h"replaced with the real website address to visit . request AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'https://www.example1.com/POST?e=f&g=h' 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#Left data : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left http . HttpResponse AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left error AST#expression#Right ) AST#block_statement#Left { // The follow-up logic is not executed when the download fails. 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 // Processing the data returned by network requests AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left transcodePixelMap 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#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export function httpRequest(): void { hiTraceMeter.startTrace('Http Request', 1); http.createHttp() .request('https://www.example1.com/POST?e=f&g=h', (error: BusinessError, data: http.HttpResponse) => { if (error) { return; } transcodePixelMap(data); } ) }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/AppColdStart/entry/src/main/ets/utils/NetRequest.ets#L9-L23
66be954473a4e0147df06bcc13ad6d06c66c00de
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/keyboardavoid/src/main/ets/components/KeyboardAvoidIndex.ets
arkts
KeyboardAvoid
功能描述: 本示例介绍使用TextInput组件和LazyForEach实现组件随软键盘弹出避让场景 推荐场景: 需要用户手动输入文字的场景 核心组件: 1. KeyboardAvoid.liftUpComponents 2. KeyboardAvoid.scalingComponents 实现步骤: 1. 在输入按钮的点击事件中调用focusControl.requestFocus API,即可实现给TextInput组件申请焦点功能 2. 通过监听键盘高度,可以感知到键盘的拉起收起状态,实现缩放组件尺寸的调整,配合KeyboardAvoidMode.RESIZE避让模式,实现组件上抬压缩效果
@Component export struct KeyboardAvoid { @State keyboardHeight: number = 0; // 软键盘高度 @State contentData: string[] = ['第一条数据', '第二条数据', '第三条数据', '第四条数据', '第五条数据', '第六条数据', '第七条数据', '第八条数据', '第九条数据', '第十条数据', '第十一条数据', '第十二条数据']; @State isLiftUpShow: boolean = true; @State isScalingShow: boolean = false; @StorageLink('avoidAreaBottomToModule') avoidAreaBottomToModule: number = 0; private scrollerForLiftUp: Scroller = new Scroller(); private scrollerForScaling: Scroller = new Scroller(); private dataSource: KeyboardDataSource = new KeyboardDataSource(this.contentData); aboutToAppear(): void { // TODO:知识点:虚拟键盘抬起时,页面的避让模式设置为RESIZE模式 let context = getContext(this) as common.UIAbilityContext; context.windowStage.getMainWindowSync().getUIContext().setKeyboardAvoidMode(KeyboardAvoidMode.RESIZE); window.getLastWindow(getContext(this)).then(currentWindow => { currentWindow.on('keyboardHeightChange', (data: number) => { this.keyboardHeight = px2vp(data); }) }) } // 上抬组件 @Builder liftUpComponents() { Scroll(this.scrollerForLiftUp) { Column() { LazyForEach(this.dataSource, (item: string) => { this.liftUpContentComponent(item) }, (item: string) => item) } .id('KeyboardAvoidLiftUpComponents') .width($r('app.string.key_board_components_weight')) .alignItems(HorizontalAlign.Center) .justifyContent(FlexAlign.End) .backgroundColor($r('app.color.key_board_page_background_color')) } .height($r('app.string.key_board_lift_up_components_height')) .layoutWeight(1) .visibility(this.isLiftUpShow ? Visibility.Visible : Visibility.None) .borderRadius($r('app.string.key_board_scenes_main_page_list_borderRadius')) } // 上抬组件成员 @Builder liftUpContentComponent(item: string) { Row() { Image('') .borderRadius($r('app.string.key_board_scenes_item_image_border_radius')) .objectFit(ImageFit.Contain) .width($r('app.string.key_board_scenes_item_image_height')) .height($r('app.string.key_board_scenes_item_image_height')) .backgroundColor($r('app.color.key_board_item_image_background_color')) .margin($r('app.string.key_board_scenes_item_image_border_radius')) Text(item) .padding({ left: $r('app.string.key_board_scenes_main_page_padding6'), right: $r('app.string.key_board_scenes_main_page_padding6') }) .width($r('app.string.key_board_components_weight')) .textAlign(TextAlign.Start) .maxLines(2) .fontSize($r('app.string.key_board_scenes_item_text_font_size')) .fontColor($r('app.color.key_board_item_font_color')) .margin({ top: $r('app.string.key_board_scenes_main_page_margin_top'), bottom: $r('app.string.key_board_scenes_main_page_margin_top') }) .textOverflow({ overflow: TextOverflow.Ellipsis }) } .linearGradient({ angle: 180, colors: [[$r('app.color.key_board_item_background_color1'), 0], [$r('app.color.key_board_item_background_color2'), 1]] }) .width($r('app.string.key_board_components_weight')) .borderRadius($r('app.string.key_board_scenes_main_page_list_borderRadius')) .margin($r('app.string.key_board_scenes_item_gap_half')) } // 缩放组件 @Builder scalingComponents() { Scroll(this.scrollerForScaling) { Column() { Grid() { LazyForEach(this.dataSource, (item: string) => { GridItem() { this.scalingContentComponent(item) } }, (item: string) => item) } .backgroundColor($r('app.color.key_board_page_background_color')) .cachedCount(Number($r('app.integer.key_board_grid_cache_count'))) } .id('KeyboardAvoidScalingComponents') .width($r('app.string.key_board_components_weight')) .alignItems(HorizontalAlign.Center) .justifyContent(FlexAlign.End) } .height($r('app.string.key_board_lift_up_components_height')) .layoutWeight(1) .visibility(this.isScalingShow ? Visibility.Visible : Visibility.None) .borderRadius($r('app.string.key_board_scenes_main_page_list_borderRadius')) } // 缩放组件成员 @Builder scalingContentComponent(item: string) { Column() { Image('') .borderRadius(8) .objectFit(ImageFit.Contain) .width(this.keyboardHeight > 0 ? $r('app.string.key_board_scenes_item_small_image_height') : $r('app.string.key_board_scenes_item_big_image_height')) .height(this.keyboardHeight > 0 ? $r('app.string.key_board_scenes_item_small_image_height') : $r('app.string.key_board_scenes_item_big_image_height')) .backgroundColor($r('app.color.key_board_item_image_background_color')) .margin($r('app.string.key_board_scenes_item_gap_half')) Text(item) .fontColor(Color.Black) .textAlign(TextAlign.Center) .fontSize($r('app.string.key_board_scenes_item_text_font_size')) .fontColor($r('app.color.key_board_item_font_color')) .margin({ top: $r('app.string.key_board_scenes_main_page_margin_top'), bottom: $r('app.string.key_board_scenes_main_page_margin_top') }) .textOverflow({ overflow: TextOverflow.Ellipsis }) } .linearGradient({ angle: 180, colors: [[$r('app.color.key_board_item_background_color1'), 0], [$r('app.color.key_board_item_background_color2'), 1]] }) .alignItems(HorizontalAlign.Center) .justifyContent(FlexAlign.Center) .width(this.keyboardHeight > 0 ? $r('app.string.key_board_scenes_item_small_height') : $r('app.string.key_board_scenes_item_big_height')) .height(this.keyboardHeight > 0 ? $r('app.string.key_board_scenes_item_small_height') : $r('app.string.key_board_scenes_item_big_height')) .borderRadius($r('app.string.key_board_scenes_main_page_list_borderRadius')) .margin($r('app.string.key_board_scenes_item_gap_half')) } build() { Column() { this.liftUpComponents() this.scalingComponents() TextInput()// TODO:知识点:输入框自动获焦 .id('keyboardAvoidTextInput') .defaultFocus(true) .key($r('app.string.key_board_text_input_key_string').toString()) .border({ width: $r('app.integer.key_board_text_input_border_width'), color: $r('app.color.key_board_input_border_color') }) .opacity($r('app.string.key_board_scenes_item_image_opacity')) .margin($r('app.integer.key_board_scenes_tab_bar_image_more_row_margin')) Row() { Button($r('app.string.key_board_button_input_string')) .id('KeyboardAvoidButtonPopUpKeyboard') .opacity(this.keyboardHeight > 0 ? 0.5 : 1) .onClick(() => { // TODO:知识点:使用focusControl.requestFocus API实现textInput获焦拉起键盘 focusControl.requestFocus($r('app.string.key_board_text_input_key_string').toString()); }) Button($r('app.string.key_board_button_lift_up_string')) .id('KeyboardAvoidButtonLiftUp') .fontColor(this.isLiftUpShow ? Color.White : Color.Black) .backgroundColor(this.isLiftUpShow ? $r('app.color.key_board_button_selected_color') : $r('app.color.key_board_button_unselected_color')) .opacity(this.isLiftUpShow ? 1 : 0.8) .onClick(() => { // 点击按钮实现上抬组件显示,缩放组件隐藏 this.isLiftUpShow = true; this.isScalingShow = false; }) Button($r('app.string.key_board_button_scaling_string')) .id('KeyboardAvoidButtonScaling') .fontColor(this.isScalingShow ? Color.White : Color.Black) .backgroundColor(this.isScalingShow ? $r('app.color.key_board_button_selected_color') : $r('app.color.key_board_button_unselected_color')) .opacity(this.isScalingShow ? 1 : 0.8) .onClick(() => { // 点击按钮实现缩放组件显示,上抬组件隐藏 this.isScalingShow = true; this.isLiftUpShow = false; }) } .justifyContent(FlexAlign.SpaceAround) .width($r('app.string.key_board_components_weight')) .margin({ bottom: $r('app.integer.key_board_scenes_tab_bar_image_more_row_margin') }) } .id('KeyboardAvoidBlank') .padding({ bottom: px2vp(this.avoidAreaBottomToModule) }) .width($r('app.string.key_board_components_weight')) .height($r('app.string.key_board_components_height')) .onClick(() => { // 点击收起键盘 inputMethod.getController().stopInputSession(); }) } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct KeyboardAvoid AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right keyboardHeight : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right // 软键盘高度 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right contentData : 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 '第一条数据' AST#expression#Right , AST#expression#Left '第二条数据' AST#expression#Right , AST#expression#Left '第三条数据' AST#expression#Right , AST#expression#Left '第四条数据' AST#expression#Right , AST#expression#Left '第五条数据' AST#expression#Right , AST#expression#Left '第六条数据' AST#expression#Right , AST#expression#Left '第七条数据' AST#expression#Right , AST#expression#Left '第八条数据' AST#expression#Right , AST#expression#Left '第九条数据' AST#expression#Right , AST#expression#Left '第十条数据' AST#expression#Right , AST#expression#Left '第十一条数据' AST#expression#Right , AST#expression#Left '第十二条数据' AST#expression#Right ] AST#array_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right isLiftUpShow : 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 @ State AST#decorator#Right isScalingShow : 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 @ StorageLink ( AST#expression#Left 'avoidAreaBottomToModule' AST#expression#Right ) AST#decorator#Right avoidAreaBottomToModule : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private scrollerForLiftUp : AST#type_annotation#Left AST#primary_type#Left Scroller 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 Scroller AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private scrollerForScaling : AST#type_annotation#Left AST#primary_type#Left Scroller 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 Scroller AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private dataSource : AST#type_annotation#Left AST#primary_type#Left KeyboardDataSource 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 KeyboardDataSource 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 . contentData AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#method_declaration#Left aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { // TODO:知识点:虚拟键盘抬起时,页面的避让模式设置为RESIZE模式 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left context = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left getContext AST#expression#Right AST#argument_list#Left ( AST#expression#Left this AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . UIAbilityContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left context AST#expression#Right . windowStage AST#member_expression#Right AST#expression#Right . getMainWindowSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . getUIContext AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . setKeyboardAvoidMode AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left KeyboardAvoidMode AST#expression#Right . RESIZE 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 AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . getLastWindow 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#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 currentWindow => 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 currentWindow AST#expression#Right . on AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'keyboardHeightChange' AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . keyboardHeight AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left px2vp 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#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right // 上抬组件 AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right liftUpComponents 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 Scroll ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scrollerForLiftUp AST#member_expression#Right AST#expression#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#ui_control_flow#Left AST#lazy_for_each_statement#Left LazyForEach ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataSource AST#member_expression#Right AST#expression#Right , AST#ui_builder_arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#ui_arrow_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . liftUpContentComponent 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#ui_arrow_function_body#Right AST#ui_builder_arrow_function#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left item AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#lazy_for_each_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . id ( AST#expression#Left 'KeyboardAvoidLiftUpComponents' AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_components_weight' AST#expression#Right ) AST#resource_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 . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . End AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.key_board_page_background_color' 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#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#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_lift_up_components_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Left . visibility ( 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 . isLiftUpShow AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left Visibility AST#expression#Right . Visible AST#member_expression#Right AST#expression#Right : AST#expression#Left Visibility AST#expression#Right AST#conditional_expression#Right AST#expression#Right . None AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_scenes_main_page_list_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#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 liftUpContentComponent AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_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#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_scenes_item_image_border_radius' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . objectFit ( AST#expression#Left AST#member_expression#Left AST#expression#Left ImageFit AST#expression#Right . Contain AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_scenes_item_image_height' 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.string.key_board_scenes_item_image_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.key_board_item_image_background_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_scenes_item_image_border_radius' 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#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 item AST#expression#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#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_scenes_main_page_padding6' 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.string.key_board_scenes_main_page_padding6' 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 . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_components_weight' AST#expression#Right ) AST#resource_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 . maxLines ( AST#expression#Left 2 AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_scenes_item_text_font_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.key_board_item_font_color' 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.string.key_board_scenes_main_page_margin_top' 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.string.key_board_scenes_main_page_margin_top' 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 . textOverflow ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left overflow AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left TextOverflow AST#expression#Right . Ellipsis AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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 . linearGradient ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left angle AST#property_name#Right : AST#expression#Left 180 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left colors AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.key_board_item_background_color1' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left 0 AST#expression#Right ] AST#array_literal#Right AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.key_board_item_background_color2' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left 1 AST#expression#Right ] AST#array_literal#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_components_weight' 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.string.key_board_scenes_main_page_list_borderRadius' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_scenes_item_gap_half' 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#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 scalingComponents 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 Scroll ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scrollerForScaling AST#member_expression#Right AST#expression#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Grid ( ) AST#container_content_body#Left { AST#ui_control_flow#Left AST#lazy_for_each_statement#Left LazyForEach ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataSource AST#member_expression#Right AST#expression#Right , AST#ui_builder_arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#ui_arrow_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left GridItem ( ) AST#container_content_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scalingContentComponent 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#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_arrow_function_body#Right AST#ui_builder_arrow_function#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left item AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#lazy_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#resource_expression#Left $r ( AST#expression#Left 'app.color.key_board_page_background_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . cachedCount ( AST#expression#Left AST#call_expression#Left AST#expression#Left Number AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.key_board_grid_cache_count' 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#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 'KeyboardAvoidScalingComponents' AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_components_weight' AST#expression#Right ) AST#resource_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 . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . End AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#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#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_lift_up_components_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Left . visibility ( 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 . isScalingShow AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left Visibility AST#expression#Right . Visible AST#member_expression#Right AST#expression#Right : AST#expression#Left Visibility AST#expression#Right AST#conditional_expression#Right AST#expression#Right . None AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_scenes_main_page_list_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#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 scalingContentComponent AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left '' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 8 AST#expression#Right ) AST#modifier_chain_expression#Left . objectFit ( AST#expression#Left AST#member_expression#Left AST#expression#Left ImageFit AST#expression#Right . Contain AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( 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 . keyboardHeight 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#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_scenes_item_small_image_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_scenes_item_big_image_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . keyboardHeight 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#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_scenes_item_small_image_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_scenes_item_big_image_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.key_board_item_image_background_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_scenes_item_gap_half' 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#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 item AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Black AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_scenes_item_text_font_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.key_board_item_font_color' 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.string.key_board_scenes_main_page_margin_top' 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.string.key_board_scenes_main_page_margin_top' 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 . textOverflow ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left overflow AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left TextOverflow AST#expression#Right . Ellipsis AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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 . linearGradient ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left angle AST#property_name#Right : AST#expression#Left 180 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left colors AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.key_board_item_background_color1' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left 0 AST#expression#Right ] AST#array_literal#Right AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.key_board_item_background_color2' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left 1 AST#expression#Right ] AST#array_literal#Right AST#expression#Right ] AST#array_literal#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 HorizontalAlign 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 . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( 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 . keyboardHeight 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#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_scenes_item_small_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_scenes_item_big_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . keyboardHeight 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#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_scenes_item_small_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_scenes_item_big_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_scenes_main_page_list_borderRadius' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_scenes_item_gap_half' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . liftUpComponents AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scalingComponents 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#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left TextInput ( ) AST#ui_component#Right // TODO:知识点:输入框自动获焦 AST#modifier_chain_expression#Left . id ( AST#expression#Left 'keyboardAvoidTextInput' AST#expression#Right ) AST#modifier_chain_expression#Left . defaultFocus ( AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . key ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_text_input_key_string' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . border ( 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.key_board_text_input_border_width' 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#resource_expression#Left $r ( AST#expression#Left 'app.color.key_board_input_border_color' 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 . opacity ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_scenes_item_image_opacity' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.key_board_scenes_tab_bar_image_more_row_margin' 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#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 Button ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_button_input_string' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . id ( AST#expression#Left 'KeyboardAvoidButtonPopUpKeyboard' AST#expression#Right ) AST#modifier_chain_expression#Left . opacity ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . keyboardHeight AST#member_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left 0.5 AST#expression#Right : AST#expression#Left 1 AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { // TODO:知识点:使用focusControl.requestFocus API实现textInput获焦拉起键盘 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 AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_text_input_key_string' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_button_lift_up_string' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . id ( AST#expression#Left 'KeyboardAvoidButtonLiftUp' AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLiftUpShow AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . White AST#member_expression#Right AST#expression#Right : AST#expression#Left Color AST#expression#Right AST#conditional_expression#Right AST#expression#Right . Black AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLiftUpShow AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.key_board_button_selected_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.key_board_button_unselected_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . opacity ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLiftUpShow AST#member_expression#Right AST#expression#Right ? AST#expression#Left 1 AST#expression#Right : AST#expression#Left 0.8 AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { // 点击按钮实现上抬组件显示,缩放组件隐藏 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLiftUpShow 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 . isScalingShow AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#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 Button ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_button_scaling_string' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . id ( AST#expression#Left 'KeyboardAvoidButtonScaling' AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isScalingShow AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . White AST#member_expression#Right AST#expression#Right : AST#expression#Left Color AST#expression#Right AST#conditional_expression#Right AST#expression#Right . Black AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isScalingShow AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.key_board_button_selected_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.key_board_button_unselected_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . opacity ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isScalingShow AST#member_expression#Right AST#expression#Right ? AST#expression#Left 1 AST#expression#Right : AST#expression#Left 0.8 AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { // 点击按钮实现缩放组件显示,上抬组件隐藏 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isScalingShow 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 . isLiftUpShow AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#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 . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . SpaceAround AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_components_weight' 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.integer.key_board_scenes_tab_bar_image_more_row_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#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 'KeyboardAvoidBlank' AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left px2vp AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . avoidAreaBottomToModule AST#member_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 . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.key_board_components_weight' 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.string.key_board_components_height' 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#block_statement#Left { // 点击收起键盘 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left inputMethod AST#expression#Right . getController AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . stopInputSession AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Component export struct KeyboardAvoid { @State keyboardHeight: number = 0; @State contentData: string[] = ['第一条数据', '第二条数据', '第三条数据', '第四条数据', '第五条数据', '第六条数据', '第七条数据', '第八条数据', '第九条数据', '第十条数据', '第十一条数据', '第十二条数据']; @State isLiftUpShow: boolean = true; @State isScalingShow: boolean = false; @StorageLink('avoidAreaBottomToModule') avoidAreaBottomToModule: number = 0; private scrollerForLiftUp: Scroller = new Scroller(); private scrollerForScaling: Scroller = new Scroller(); private dataSource: KeyboardDataSource = new KeyboardDataSource(this.contentData); aboutToAppear(): void { let context = getContext(this) as common.UIAbilityContext; context.windowStage.getMainWindowSync().getUIContext().setKeyboardAvoidMode(KeyboardAvoidMode.RESIZE); window.getLastWindow(getContext(this)).then(currentWindow => { currentWindow.on('keyboardHeightChange', (data: number) => { this.keyboardHeight = px2vp(data); }) }) } @Builder liftUpComponents() { Scroll(this.scrollerForLiftUp) { Column() { LazyForEach(this.dataSource, (item: string) => { this.liftUpContentComponent(item) }, (item: string) => item) } .id('KeyboardAvoidLiftUpComponents') .width($r('app.string.key_board_components_weight')) .alignItems(HorizontalAlign.Center) .justifyContent(FlexAlign.End) .backgroundColor($r('app.color.key_board_page_background_color')) } .height($r('app.string.key_board_lift_up_components_height')) .layoutWeight(1) .visibility(this.isLiftUpShow ? Visibility.Visible : Visibility.None) .borderRadius($r('app.string.key_board_scenes_main_page_list_borderRadius')) } 成员 @Builder liftUpContentComponent(item: string) { Row() { Image('') .borderRadius($r('app.string.key_board_scenes_item_image_border_radius')) .objectFit(ImageFit.Contain) .width($r('app.string.key_board_scenes_item_image_height')) .height($r('app.string.key_board_scenes_item_image_height')) .backgroundColor($r('app.color.key_board_item_image_background_color')) .margin($r('app.string.key_board_scenes_item_image_border_radius')) Text(item) .padding({ left: $r('app.string.key_board_scenes_main_page_padding6'), right: $r('app.string.key_board_scenes_main_page_padding6') }) .width($r('app.string.key_board_components_weight')) .textAlign(TextAlign.Start) .maxLines(2) .fontSize($r('app.string.key_board_scenes_item_text_font_size')) .fontColor($r('app.color.key_board_item_font_color')) .margin({ top: $r('app.string.key_board_scenes_main_page_margin_top'), bottom: $r('app.string.key_board_scenes_main_page_margin_top') }) .textOverflow({ overflow: TextOverflow.Ellipsis }) } .linearGradient({ angle: 180, colors: [[$r('app.color.key_board_item_background_color1'), 0], [$r('app.color.key_board_item_background_color2'), 1]] }) .width($r('app.string.key_board_components_weight')) .borderRadius($r('app.string.key_board_scenes_main_page_list_borderRadius')) .margin($r('app.string.key_board_scenes_item_gap_half')) } @Builder scalingComponents() { Scroll(this.scrollerForScaling) { Column() { Grid() { LazyForEach(this.dataSource, (item: string) => { GridItem() { this.scalingContentComponent(item) } }, (item: string) => item) } .backgroundColor($r('app.color.key_board_page_background_color')) .cachedCount(Number($r('app.integer.key_board_grid_cache_count'))) } .id('KeyboardAvoidScalingComponents') .width($r('app.string.key_board_components_weight')) .alignItems(HorizontalAlign.Center) .justifyContent(FlexAlign.End) } .height($r('app.string.key_board_lift_up_components_height')) .layoutWeight(1) .visibility(this.isScalingShow ? Visibility.Visible : Visibility.None) .borderRadius($r('app.string.key_board_scenes_main_page_list_borderRadius')) } 成员 @Builder scalingContentComponent(item: string) { Column() { Image('') .borderRadius(8) .objectFit(ImageFit.Contain) .width(this.keyboardHeight > 0 ? $r('app.string.key_board_scenes_item_small_image_height') : $r('app.string.key_board_scenes_item_big_image_height')) .height(this.keyboardHeight > 0 ? $r('app.string.key_board_scenes_item_small_image_height') : $r('app.string.key_board_scenes_item_big_image_height')) .backgroundColor($r('app.color.key_board_item_image_background_color')) .margin($r('app.string.key_board_scenes_item_gap_half')) Text(item) .fontColor(Color.Black) .textAlign(TextAlign.Center) .fontSize($r('app.string.key_board_scenes_item_text_font_size')) .fontColor($r('app.color.key_board_item_font_color')) .margin({ top: $r('app.string.key_board_scenes_main_page_margin_top'), bottom: $r('app.string.key_board_scenes_main_page_margin_top') }) .textOverflow({ overflow: TextOverflow.Ellipsis }) } .linearGradient({ angle: 180, colors: [[$r('app.color.key_board_item_background_color1'), 0], [$r('app.color.key_board_item_background_color2'), 1]] }) .alignItems(HorizontalAlign.Center) .justifyContent(FlexAlign.Center) .width(this.keyboardHeight > 0 ? $r('app.string.key_board_scenes_item_small_height') : $r('app.string.key_board_scenes_item_big_height')) .height(this.keyboardHeight > 0 ? $r('app.string.key_board_scenes_item_small_height') : $r('app.string.key_board_scenes_item_big_height')) .borderRadius($r('app.string.key_board_scenes_main_page_list_borderRadius')) .margin($r('app.string.key_board_scenes_item_gap_half')) } build() { Column() { this.liftUpComponents() this.scalingComponents() TextInput() .id('keyboardAvoidTextInput') .defaultFocus(true) .key($r('app.string.key_board_text_input_key_string').toString()) .border({ width: $r('app.integer.key_board_text_input_border_width'), color: $r('app.color.key_board_input_border_color') }) .opacity($r('app.string.key_board_scenes_item_image_opacity')) .margin($r('app.integer.key_board_scenes_tab_bar_image_more_row_margin')) Row() { Button($r('app.string.key_board_button_input_string')) .id('KeyboardAvoidButtonPopUpKeyboard') .opacity(this.keyboardHeight > 0 ? 0.5 : 1) .onClick(() => { focusControl.requestFocus($r('app.string.key_board_text_input_key_string').toString()); }) Button($r('app.string.key_board_button_lift_up_string')) .id('KeyboardAvoidButtonLiftUp') .fontColor(this.isLiftUpShow ? Color.White : Color.Black) .backgroundColor(this.isLiftUpShow ? $r('app.color.key_board_button_selected_color') : $r('app.color.key_board_button_unselected_color')) .opacity(this.isLiftUpShow ? 1 : 0.8) .onClick(() => { this.isLiftUpShow = true; this.isScalingShow = false; }) Button($r('app.string.key_board_button_scaling_string')) .id('KeyboardAvoidButtonScaling') .fontColor(this.isScalingShow ? Color.White : Color.Black) .backgroundColor(this.isScalingShow ? $r('app.color.key_board_button_selected_color') : $r('app.color.key_board_button_unselected_color')) .opacity(this.isScalingShow ? 1 : 0.8) .onClick(() => { this.isScalingShow = true; this.isLiftUpShow = false; }) } .justifyContent(FlexAlign.SpaceAround) .width($r('app.string.key_board_components_weight')) .margin({ bottom: $r('app.integer.key_board_scenes_tab_bar_image_more_row_margin') }) } .id('KeyboardAvoidBlank') .padding({ bottom: px2vp(this.avoidAreaBottomToModule) }) .width($r('app.string.key_board_components_weight')) .height($r('app.string.key_board_components_height')) .onClick(() => { inputMethod.getController().stopInputSession(); }) } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/keyboardavoid/src/main/ets/components/KeyboardAvoidIndex.ets#L33-L238
5c6d18613a8899a138b90bc4ba96671ea1b18424
gitee
HomoArk/Homogram.git
8a6e85898b6194fdd04ead75e732d348888a0c07
features/home/src/main/ets/views/Chat/ChatDetailBottomPhotoPicker.ets
arkts
onExitPhotoBrowser
退出大图页回调
private onExitPhotoBrowser(photoBrowserInfo: PhotoBrowserInfo): boolean { console.info('onExitPhotoBrowser' + JSON.stringify(photoBrowserInfo)); return false; }
AST#method_declaration#Left private onExitPhotoBrowser AST#parameter_list#Left ( AST#parameter#Left photoBrowserInfo : AST#type_annotation#Left AST#primary_type#Left PhotoBrowserInfo 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'onExitPhotoBrowser' 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 photoBrowserInfo AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private onExitPhotoBrowser(photoBrowserInfo: PhotoBrowserInfo): boolean { console.info('onExitPhotoBrowser' + JSON.stringify(photoBrowserInfo)); return false; }
https://github.com/HomoArk/Homogram.git/blob/8a6e85898b6194fdd04ead75e732d348888a0c07/features/home/src/main/ets/views/Chat/ChatDetailBottomPhotoPicker.ets#L126-L129
4fed348e6248e33dbfc56b84db909e889b68005f
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/common/router/AppRouter.ets
arkts
goGreetingSend
跳转到祝福语发送页面 @param contactId 联系人ID @param greetingId 祝福语ID(可选)
async goGreetingSend(contactId: string, greetingId?: string): Promise<void> { const params: RouteParams = { contactId: contactId, greetingId: greetingId }; const options: RouteOptions = { params: params }; await this.push(RoutePaths.GREETING_SEND, options); }
AST#method_declaration#Left async goGreetingSend AST#parameter_list#Left ( AST#parameter#Left contactId : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left greetingId ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left params : AST#type_annotation#Left AST#primary_type#Left RouteParams AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left contactId AST#property_name#Right : AST#expression#Left contactId AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left greetingId AST#property_name#Right : AST#expression#Left greetingId 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 options : AST#type_annotation#Left AST#primary_type#Left RouteOptions AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left params AST#property_name#Right : AST#expression#Left params AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left RoutePaths AST#expression#Right . GREETING_SEND AST#member_expression#Right AST#expression#Right , AST#expression#Left options AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async goGreetingSend(contactId: string, greetingId?: string): Promise<void> { const params: RouteParams = { contactId: contactId, greetingId: greetingId }; const options: RouteOptions = { params: params }; await this.push(RoutePaths.GREETING_SEND, options); }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/router/AppRouter.ets#L295-L299
4e92b350d1164c6241f0ab80818c945db052cc0b
github
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
core/navigation/src/main/ets/auth/AuthNavigator.ets
arkts
toLogin
跳转到登录主页 @returns {void} 无返回值
static toLogin(): void { navigateTo(AuthRoutes.Login); }
AST#method_declaration#Left static toLogin 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 navigateTo ( AST#expression#Left AST#member_expression#Left AST#expression#Left AuthRoutes AST#expression#Right . Login AST#member_expression#Right AST#expression#Right ) ; AST#ui_custom_component_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
static toLogin(): void { navigateTo(AuthRoutes.Login); }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/navigation/src/main/ets/auth/AuthNavigator.ets#L13-L15
c8162902a9444e1d6ea8c3b48fbfa8fb8514894a
github
bigbear20240612/planner_build-.git
89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1
entry/src/main/ets/viewmodel/WeatherManager.ets
arkts
getRandomWeatherText
获取随机天气描述
private getRandomWeatherText(): string { const weatherTexts = ['晴', '多云', '阴', '小雨', '中雨', '雷阵雨', '雨夹雪']; return weatherTexts[Math.floor(Math.random() * weatherTexts.length)]; }
AST#method_declaration#Left private getRandomWeatherText AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left weatherTexts = AST#expression#Left AST#array_literal#Left [ AST#expression#Left '晴' AST#expression#Right , AST#expression#Left '多云' AST#expression#Right , AST#expression#Left '阴' AST#expression#Right , AST#expression#Left '小雨' AST#expression#Right , AST#expression#Left '中雨' AST#expression#Right , AST#expression#Left '雷阵雨' AST#expression#Right , AST#expression#Left '雨夹雪' AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#subscript_expression#Left AST#expression#Left weatherTexts AST#expression#Right [ 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#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . random AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right * AST#expression#Left weatherTexts AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private getRandomWeatherText(): string { const weatherTexts = ['晴', '多云', '阴', '小雨', '中雨', '雷阵雨', '雨夹雪']; return weatherTexts[Math.floor(Math.random() * weatherTexts.length)]; }
https://github.com/bigbear20240612/planner_build-.git/blob/89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1/entry/src/main/ets/viewmodel/WeatherManager.ets#L157-L160
dffe51e7386473bd932dedc943048c4d20352e51
github
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
ComponentReuse/entry/src/main/ets/view/UsageRules.ets
arkts
[End usage_rules] xxx.ets
export class Message { value: string | undefined; constructor(value: string) { this.value = value } }
AST#export_declaration#Left export AST#class_declaration#Left class Message AST#class_body#Left { AST#property_declaration#Left value : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . value 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#constructor_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class Message { value: string | undefined; constructor(value: string) { this.value = value } }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/ComponentReuse/entry/src/main/ets/view/UsageRules.ets#L18-L25
d6d55b2d26c7ff2d052fafc6f28d9c031f3d6ed4
gitee
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_json/src/main/ets/json/JSONObject.ets
arkts
convertString
迭代转换json @param iter 迭代器 @returns json字符串
private convertString(iter: IterableIterator<string>, map?: HashMap<string, JSONValue>): string { //转换的字符串 let sb: StringBuilder = new StringBuilder(); //拼接左括号 sb.append(Const.zkh); // 是否为第一个字符 let isFirst: boolean = true; //迭代获取值转换成字符串 for (const key of iter) { if (!isFirst) { //拼接逗号 sb.append(Const.dh); } isFirst = false; //获取值 let val: JSONValue = ''; if (map && map.length > 0) { val = map.get(key); } //判断类型 if (val instanceof JSONObject) { sb.append(Const.quot + key + Const.quot + Const.mh + (val as JSONObject).toString()); } else if (val instanceof Array) { let jArr = new JSONArray(); (val as Array<JSONValue>).forEach(item => { jArr.push(item); }); sb.append(Const.quot + key + Const.quot + Const.mh + jArr.toString()); } else if (val instanceof JSONArray) { sb.append(Const.quot + key + Const.quot + Const.mh + (val as JSONArray).toString()); } else if (val instanceof JSONArrayList) { sb.append(Const.quot + key + Const.quot + Const.mh + (val as JSONArrayList).toString()); } else if (val instanceof Date) { sb.append(Const.quot + key + Const.quot + Const.mh + Const.quot + DateUtil.format((val as Date), DateConst.YMD_HLINE_HMS) + Const.quot); } else if (val instanceof Object) { //转换成字符串 let str = JSON.stringify(val); //转换成json对象 let jVal: Record<string, JSONValue> = JSON.parse(str); //接收 let jo = new JSONObject(); //循环赋值 Object.entries(jVal).forEach((item) => { jo.set(item[0], item[1]); }) sb.append(Const.quot + key + Const.quot + Const.mh + jo.toString()); } else if (typeof val === 'string') { // if (DateUtil.isDate(val)) { // sb.append(Const.quot + key + Const.quot + Const.mh + Const.quot + // DateUtil.formatDate(val, DateConst.YMD_HLINE_HMS) + Const.quot); // } else { // sb.append(Const.quot + key + Const.quot + Const.mh + Const.quot + val + Const.quot); // } sb.append(Const.quot + key + Const.quot + Const.mh + Const.quot + val + Const.quot); } else if (typeof val === 'number' || typeof val === 'boolean') { sb.append(Const.quot + key + Const.quot + Const.mh + val); } else { sb.append(Const.quot + key + Const.quot + Const.mh + null); } } //拼接右括号 sb.append(Const.ykh); return sb.toString(); }
AST#method_declaration#Left private convertString AST#parameter_list#Left ( AST#parameter#Left iter : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left IterableIterator AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left map ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left HashMap AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left JSONValue 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 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 sb : AST#type_annotation#Left AST#primary_type#Left StringBuilder 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 StringBuilder 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 sb AST#expression#Right . append AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . zkh 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 let AST#variable_declarator#Left isFirst : 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right //迭代获取值转换成字符串 AST#statement#Left AST#for_statement#Left for ( const key of AST#expression#Left iter AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left isFirst AST#expression#Right AST#unary_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 sb AST#expression#Right . append AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . dh AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left isFirst = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right //获取值 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left val : AST#type_annotation#Left AST#primary_type#Left JSONValue 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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left map AST#expression#Right && AST#expression#Left map AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left val = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left map AST#expression#Right . get 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#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right //判断类型 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left val AST#expression#Right instanceof AST#expression#Left JSONObject 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 sb AST#expression#Right . append 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 AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . quot AST#member_expression#Right AST#expression#Right + AST#expression#Left key AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . quot AST#member_expression#Right AST#expression#Right + AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . mh AST#member_expression#Right AST#expression#Right + AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left val AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left JSONObject 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 . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left val AST#expression#Right instanceof AST#expression#Left Array 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 jArr = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left JSONArray AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left val AST#expression#Right as 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 JSONValue 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#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . forEach 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left jArr AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left item AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } 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 sb AST#expression#Right . append 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 AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . quot AST#member_expression#Right AST#expression#Right + AST#expression#Left key AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . quot AST#member_expression#Right AST#expression#Right + AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . mh AST#member_expression#Right AST#expression#Right + AST#expression#Left jArr AST#expression#Right AST#binary_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left val AST#expression#Right instanceof AST#expression#Left JSONArray 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 sb AST#expression#Right . append 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 AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . quot AST#member_expression#Right AST#expression#Right + AST#expression#Left key AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . quot AST#member_expression#Right AST#expression#Right + AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . mh AST#member_expression#Right AST#expression#Right + AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left val AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left JSONArray 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 . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left val AST#expression#Right instanceof AST#expression#Left JSONArrayList 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 sb AST#expression#Right . append 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 AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . quot AST#member_expression#Right AST#expression#Right + AST#expression#Left key AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . quot AST#member_expression#Right AST#expression#Right + AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . mh AST#member_expression#Right AST#expression#Right + AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left val AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left JSONArrayList 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 . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left val AST#expression#Right instanceof AST#expression#Left Date 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 sb AST#expression#Right . append AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . quot AST#member_expression#Right AST#expression#Right + AST#expression#Left key AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . quot AST#member_expression#Right AST#expression#Right + AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . mh AST#member_expression#Right AST#expression#Right + AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . quot AST#member_expression#Right AST#expression#Right + AST#expression#Left DateUtil AST#expression#Right AST#binary_expression#Right AST#expression#Right . format AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left val AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left Date 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#member_expression#Left AST#expression#Left DateConst AST#expression#Right . YMD_HLINE_HMS AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . quot 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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left val AST#expression#Right instanceof AST#expression#Left Object 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 str = 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 val 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 //转换成json对象 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left jVal : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Record AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left JSONValue 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 JSON AST#expression#Right . parse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left str AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right //接收 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left jo = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left JSONObject AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right //循环赋值 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Object AST#expression#Right . entries AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left jVal AST#expression#Right ) AST#argument_list#Right AST#call_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 item 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 jo AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left item AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right , AST#expression#Left AST#subscript_expression#Left AST#expression#Left item AST#expression#Right [ AST#expression#Left 1 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#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 sb AST#expression#Right . append 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 AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . quot AST#member_expression#Right AST#expression#Right + AST#expression#Left key AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . quot AST#member_expression#Right AST#expression#Right + AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . mh AST#member_expression#Right AST#expression#Right + AST#expression#Left jo AST#expression#Right AST#binary_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left val AST#expression#Right AST#unary_expression#Right AST#expression#Right === AST#expression#Left 'string' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { // if (DateUtil.isDate(val)) { // sb.append(Const.quot + key + Const.quot + Const.mh + Const.quot + // DateUtil.formatDate(val, DateConst.YMD_HLINE_HMS) + Const.quot); // } else { // sb.append(Const.quot + key + Const.quot + Const.mh + Const.quot + val + Const.quot); // } AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left sb AST#expression#Right . append AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#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 AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . quot AST#member_expression#Right AST#expression#Right + AST#expression#Left key AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . quot AST#member_expression#Right AST#expression#Right + AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . mh AST#member_expression#Right AST#expression#Right + AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . quot AST#member_expression#Right AST#expression#Right + AST#expression#Left val AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . quot 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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left val 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#expression#Left AST#binary_expression#Left AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left val AST#expression#Right AST#unary_expression#Right AST#expression#Right === AST#expression#Left 'boolean' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left sb AST#expression#Right . append 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#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 Const AST#expression#Right . quot AST#member_expression#Right AST#expression#Right + AST#expression#Left key AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . quot AST#member_expression#Right AST#expression#Right + AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . mh AST#member_expression#Right AST#expression#Right + AST#expression#Left val 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 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 sb AST#expression#Right . append 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#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 Const AST#expression#Right . quot AST#member_expression#Right AST#expression#Right + AST#expression#Left key AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . quot AST#member_expression#Right AST#expression#Right + AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . mh 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#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#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right //拼接右括号 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left sb AST#expression#Right . append AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . ykh AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left sb AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private convertString(iter: IterableIterator<string>, map?: HashMap<string, JSONValue>): string { let sb: StringBuilder = new StringBuilder(); sb.append(Const.zkh); let isFirst: boolean = true; for (const key of iter) { if (!isFirst) { sb.append(Const.dh); } isFirst = false; let val: JSONValue = ''; if (map && map.length > 0) { val = map.get(key); } if (val instanceof JSONObject) { sb.append(Const.quot + key + Const.quot + Const.mh + (val as JSONObject).toString()); } else if (val instanceof Array) { let jArr = new JSONArray(); (val as Array<JSONValue>).forEach(item => { jArr.push(item); }); sb.append(Const.quot + key + Const.quot + Const.mh + jArr.toString()); } else if (val instanceof JSONArray) { sb.append(Const.quot + key + Const.quot + Const.mh + (val as JSONArray).toString()); } else if (val instanceof JSONArrayList) { sb.append(Const.quot + key + Const.quot + Const.mh + (val as JSONArrayList).toString()); } else if (val instanceof Date) { sb.append(Const.quot + key + Const.quot + Const.mh + Const.quot + DateUtil.format((val as Date), DateConst.YMD_HLINE_HMS) + Const.quot); } else if (val instanceof Object) { let str = JSON.stringify(val); let jVal: Record<string, JSONValue> = JSON.parse(str); let jo = new JSONObject(); Object.entries(jVal).forEach((item) => { jo.set(item[0], item[1]); }) sb.append(Const.quot + key + Const.quot + Const.mh + jo.toString()); } else if (typeof val === 'string') { val + Const.quot); sb.append(Const.quot + key + Const.quot + Const.mh + Const.quot + val + Const.quot); } else if (typeof val === 'number' || typeof val === 'boolean') { sb.append(Const.quot + key + Const.quot + Const.mh + val); } else { sb.append(Const.quot + key + Const.quot + Const.mh + null); } } sb.append(Const.ykh); return sb.toString(); }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_json/src/main/ets/json/JSONObject.ets#L187-L251
ca69501f2165a815fad0ebe09321c51df804954a
gitee
open9527/OpenHarmony
fdea69ed722d426bf04e817ec05bff4002e81a4e
libs/core/src/main/ets/utils/ScanUtils.ets
arkts
decode
识别二维码图片 @param imagePath 本地图片地址 @param options @returns
static decode(imagePath: string, options: scanBarcode.ScanOptions = { scanTypes: [scanCore.ScanType.ALL], enableMultiMode: true, enableAlbum: false }): Promise<Array<scanBarcode.ScanResult>> { return new Promise<Array<scanBarcode.ScanResult>>((resolve, reject) => { try { detectBarcode.decode({ uri: imagePath }, options).then((result) => { LogUtils.debug('ScanUtils', `decode result: ${JSON.stringify(result)}`) resolve(result) }).catch((error: BusinessError) => { LogUtils.error('ScanUtils', `decode error: ${JSON.stringify(error)}`) reject(error) }) } catch (error) { LogUtils.error('ScanUtils', `decode catch: ${JSON.stringify(error)}`) reject(error) } }) }
AST#method_declaration#Left static decode AST#parameter_list#Left ( AST#parameter#Left imagePath : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left options : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left scanBarcode . ScanOptions 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 scanTypes AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left scanCore AST#expression#Right . ScanType AST#member_expression#Right AST#expression#Right . ALL AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left enableMultiMode 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 enableAlbum 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#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 Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left scanBarcode . ScanResult 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 { 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 Promise AST#expression#Right AST#new_expression#Right AST#expression#Right 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 AST#qualified_type#Left scanBarcode . ScanResult 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#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left resolve AST#parameter#Right , AST#parameter#Left reject AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#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 detectBarcode AST#expression#Right . decode 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 uri AST#property_name#Right : AST#expression#Left imagePath AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , AST#expression#Left options AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left result 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 LogUtils AST#expression#Right . debug AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'ScanUtils' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` decode result: 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 result AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left resolve 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#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . catch AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left error : AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LogUtils AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'ScanUtils' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` decode error: 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#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left reject AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LogUtils AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'ScanUtils' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` decode catch: 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#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left reject AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static decode(imagePath: string, options: scanBarcode.ScanOptions = { scanTypes: [scanCore.ScanType.ALL], enableMultiMode: true, enableAlbum: false }): Promise<Array<scanBarcode.ScanResult>> { return new Promise<Array<scanBarcode.ScanResult>>((resolve, reject) => { try { detectBarcode.decode({ uri: imagePath }, options).then((result) => { LogUtils.debug('ScanUtils', `decode result: ${JSON.stringify(result)}`) resolve(result) }).catch((error: BusinessError) => { LogUtils.error('ScanUtils', `decode error: ${JSON.stringify(error)}`) reject(error) }) } catch (error) { LogUtils.error('ScanUtils', `decode catch: ${JSON.stringify(error)}`) reject(error) } }) }
https://github.com/open9527/OpenHarmony/blob/fdea69ed722d426bf04e817ec05bff4002e81a4e/libs/core/src/main/ets/utils/ScanUtils.ets#L34-L53
27684c50255ac61d675c396dfeeed26a0831e745
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
picker_utils/src/main/ets/Utils.ets
arkts
isNotEmpty
判断字符串是否为非空。true为非空空,否则false @param str @returns
static isNotEmpty(str: string | undefined | null): boolean { return false === Utils.isEmpty(str); }
AST#method_declaration#Left static isNotEmpty AST#parameter_list#Left ( AST#parameter#Left str : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return 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#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right === AST#expression#Left Utils AST#expression#Right AST#binary_expression#Right AST#expression#Right . isEmpty 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
static isNotEmpty(str: string | undefined | null): boolean { return false === Utils.isEmpty(str); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/picker_utils/src/main/ets/Utils.ets#L41-L43
47f55a15c6a96fe7b4f86538bd287849ecb4627f
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/imagecomment/src/main/ets/components/model/CommentModel.ets
arkts
pushData
TODO:知识点:存储数据到懒加载数据源中
pushData(data: Comment): void { this.comments.push(data); // 在数组头部添加数据 this.notifyDataAdd(this.comments.length - 1); }
AST#method_declaration#Left pushData AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left Comment 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 . comments AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left data AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right // 在数组头部添加数据 AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . notifyDataAdd AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . comments AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right - AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
pushData(data: Comment): void { this.comments.push(data); this.notifyDataAdd(this.comments.length - 1); }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/imagecomment/src/main/ets/components/model/CommentModel.ets#L117-L121
3078f697e0e9fcfb48fec6fb29ee24b637ebf3fe
gitee
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
feature/goods/src/main/ets/component/GoodsDetailRichImageItem.ets
arkts
构建商品详情图片项 @returns {void} 无返回值
build(): void { ColumnStart({ widthValue: P100, paddingValue: { left: $r("app.float.space_horizontal_medium"), right: $r("app.float.space_horizontal_medium") } }) { NetWorkImage({ model: this.pic, widthValue: P100, imageFit: ImageFit.Contain, cornerRadius: this.isLast ? $r("app.float.radius_medium") : 0 }); if (this.isLast) { SpaceVerticalSmall(); } } }
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 ColumnStart ( AST#component_parameters#Left { AST#component_parameter#Left widthValue : AST#expression#Left P100 AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left paddingValue : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left 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#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#ui_custom_component_statement#Left NetWorkImage ( AST#component_parameters#Left { AST#component_parameter#Left model : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . pic AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left widthValue : AST#expression#Left P100 AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left imageFit : AST#expression#Left AST#member_expression#Left AST#expression#Left ImageFit AST#expression#Right . Contain AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left cornerRadius : AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLast AST#member_expression#Right AST#expression#Right ? 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#expression#Left 0 AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) ; AST#ui_custom_component_statement#Right 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 . isLast AST#member_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left SpaceVerticalSmall ( ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#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(): void { ColumnStart({ widthValue: P100, paddingValue: { left: $r("app.float.space_horizontal_medium"), right: $r("app.float.space_horizontal_medium") } }) { NetWorkImage({ model: this.pic, widthValue: P100, imageFit: ImageFit.Contain, cornerRadius: this.isLast ? $r("app.float.radius_medium") : 0 }); if (this.isLast) { SpaceVerticalSmall(); } } }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/goods/src/main/ets/component/GoodsDetailRichImageItem.ets#L25-L44
93034fa31214b0df3ad2d1c2f6b16e6ab05b0253
github
iichen-bycode/ArkTsWanandroid.git
ad128756a6c703d9a72cf7f6da128c27fc63bd00
entry/src/main/ets/model/BannerModel.ets
arkts
{ "desc": "我们支持订阅啦~", "id": 30, "imagePath": "https://www.wanandroid.com/blogimgs/42da12d8-de56-4439-b40c-eab66c227a4b.png", "isVisible": 1, "order": 2, "title": "我们支持订阅啦~", "type": 0, "url": "https://www.wanandroid.com/blog/show/3352" }
export class Banner { id: number; desc: string; imagePath: string; isVisible: number; type: number; order: number; title: string; url: string; }
AST#export_declaration#Left export AST#class_declaration#Left class Banner 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 desc : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left imagePath : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left isVisible : 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 type : 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 order : 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 title : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left url : AST#type_annotation#Left AST#primary_type#Left string 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 Banner { id: number; desc: string; imagePath: string; isVisible: number; type: number; order: number; title: string; url: string; }
https://github.com/iichen-bycode/ArkTsWanandroid.git/blob/ad128756a6c703d9a72cf7f6da128c27fc63bd00/entry/src/main/ets/model/BannerModel.ets#L13-L22
3a427c8894e2cdae239e2c7463b937ba10f4c104
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/ai/SimpleAIService.ets
arkts
getCurrentConfig
获取当前配置
getCurrentConfig(): AIModelConfig | null { return this.currentConfig; }
AST#method_declaration#Left getCurrentConfig AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AIModelConfig AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentConfig AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
getCurrentConfig(): AIModelConfig | null { return this.currentConfig; }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/ai/SimpleAIService.ets#L105-L107
d9ecbc868a2115036d283d5483b477ee09d53c82
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/bluetooth/src/main/ets/uicomponents/HeartRateGraph.ets
arkts
calculateLayoutConfig
调整布局
calculateLayoutConfig() { this.mCoordinateLineEndX = this.viewWidth - PADDING_HORIZONTAL; this.mOffset = (this.viewWidth - START_X - PADDING_HORIZONTAL * 2) / (SIZE - 1); this.mHeightRatio = (this.viewHeight - PADDING_VERTICAL * 2 - X_COORDINATE_TEXT_HEIGHT * 2) / MAX_HEART_RATE; let heartRateCoordinate: number = MAX_HEART_RATE / (COORDINATE_SIZE - 1); this.mHeartRateCoordinateArr = [0, heartRateCoordinate, heartRateCoordinate * 2, heartRateCoordinate * 3, heartRateCoordinate * 4]; Log.showInfo(TAG, `calculateLayoutConfig: mOffset = ${this.mOffset}, mHeightRatio = ${this.mHeightRatio}`); }
AST#method_declaration#Left calculateLayoutConfig 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 . mCoordinateLineEndX AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . viewWidth AST#member_expression#Right AST#expression#Right - AST#expression#Left PADDING_HORIZONTAL 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 . mOffset 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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . viewWidth AST#member_expression#Right AST#expression#Right - AST#expression#Left START_X AST#expression#Right AST#binary_expression#Right AST#expression#Right - AST#expression#Left AST#binary_expression#Left AST#expression#Left PADDING_HORIZONTAL AST#expression#Right * AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right / AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left SIZE AST#expression#Right - AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#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 . mHeightRatio 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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . viewHeight AST#member_expression#Right AST#expression#Right - AST#expression#Left AST#binary_expression#Left AST#expression#Left PADDING_VERTICAL AST#expression#Right * AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right - AST#expression#Left AST#binary_expression#Left AST#expression#Left X_COORDINATE_TEXT_HEIGHT AST#expression#Right * AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right / AST#expression#Left MAX_HEART_RATE 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#variable_declaration#Left let AST#variable_declarator#Left heartRateCoordinate : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left MAX_HEART_RATE AST#expression#Right / AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left COORDINATE_SIZE AST#expression#Right - AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mHeartRateCoordinateArr AST#member_expression#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left 0 AST#expression#Right , AST#expression#Left heartRateCoordinate AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left heartRateCoordinate AST#expression#Right * AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left heartRateCoordinate AST#expression#Right * AST#expression#Left 3 AST#expression#Right AST#binary_expression#Right AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left heartRateCoordinate AST#expression#Right * AST#expression#Left 4 AST#expression#Right AST#binary_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Log AST#expression#Right . showInfo 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 ` calculateLayoutConfig: mOffset = AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mOffset AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , mHeightRatio = AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mHeightRatio 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#method_declaration#Right
calculateLayoutConfig() { this.mCoordinateLineEndX = this.viewWidth - PADDING_HORIZONTAL; this.mOffset = (this.viewWidth - START_X - PADDING_HORIZONTAL * 2) / (SIZE - 1); this.mHeightRatio = (this.viewHeight - PADDING_VERTICAL * 2 - X_COORDINATE_TEXT_HEIGHT * 2) / MAX_HEART_RATE; let heartRateCoordinate: number = MAX_HEART_RATE / (COORDINATE_SIZE - 1); this.mHeartRateCoordinateArr = [0, heartRateCoordinate, heartRateCoordinate * 2, heartRateCoordinate * 3, heartRateCoordinate * 4]; Log.showInfo(TAG, `calculateLayoutConfig: mOffset = ${this.mOffset}, mHeightRatio = ${this.mHeightRatio}`); }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/bluetooth/src/main/ets/uicomponents/HeartRateGraph.ets#L90-L98
b1d302e1a40ce4b3e2daec98e213cbafdc8492ca
gitee
dcm23333/FishManager.git
952dde4475268ac16f3480f3d55f82033aa6b467
FishManager/entry/src/main/ets/common/contants/commonContants.ets
arkts
fontWeight
export const FONT_WEIGHT_400: number = 400;
AST#export_declaration#Left export AST#variable_declaration#Left const AST#variable_declarator#Left FONT_WEIGHT_400 : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 400 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#export_declaration#Right
export const FONT_WEIGHT_400: number = 400;
https://github.com/dcm23333/FishManager.git/blob/952dde4475268ac16f3480f3d55f82033aa6b467/FishManager/entry/src/main/ets/common/contants/commonContants.ets#L83-L83
20dfac3747113ff5264d2fcfc4a93ea48bc3906a
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/citysearch/src/main/ets/model/DetailData.ets
arkts
定义城市类型类 name: 数据名称的首字母 dataList: 字母对应的列表数据
export class AlphabetListItemType { name: string; dataList: string[]; constructor(name: string, dataList: string[]) { this.name = name; this.dataList = dataList; } }
AST#export_declaration#Left export AST#class_declaration#Left class AlphabetListItemType AST#class_body#Left { AST#property_declaration#Left name : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left dataList : 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#property_declaration#Right AST#constructor_declaration#Left constructor 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 dataList : 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#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 . name AST#member_expression#Right = AST#expression#Left name 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 . dataList AST#member_expression#Right = AST#expression#Left dataList 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 AlphabetListItemType { name: string; dataList: string[]; constructor(name: string, dataList: string[]) { this.name = name; this.dataList = dataList; } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/citysearch/src/main/ets/model/DetailData.ets#L37-L45
42347bd2bcdeeea59223d615ff50982a0dc28497
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/FileUtil.ets
arkts
lstatSync
获取链接文件信息,以同步方法。 @param path string 文件的应用沙箱路径。 @returns
static lstatSync(path: string): fs.Stat { return fs.lstatSync(path); }
AST#method_declaration#Left static lstatSync AST#parameter_list#Left ( AST#parameter#Left path : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left fs . Stat 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 fs AST#expression#Right . lstatSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left path AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static lstatSync(path: string): fs.Stat { return fs.lstatSync(path); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/FileUtil.ets#L726-L728
28075544b6a429ebbde4e185edf769ceb344442a
gitee
Joker-x-dev/HarmonyKit.git
f97197ce157df7f303244fba42e34918306dfb08
feature/demo/src/main/ets/viewmodel/NavigationResultViewModel.ets
arkts
updateDescInput
更新说明输入 @param {string} value - 说明输入内容 @returns {void} 无返回值
updateDescInput(value: string): void { this.descInput = value; }
AST#method_declaration#Left updateDescInput AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 . descInput AST#member_expression#Right = AST#expression#Left value AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
updateDescInput(value: string): void { this.descInput = value; }
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/feature/demo/src/main/ets/viewmodel/NavigationResultViewModel.ets#L35-L37
193cf68f0c4ba6c5bd9adf754822e77405e728aa
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/theme/ThemeManager.ets
arkts
isSystemDarkMode
判断是否为系统深色模式
private isSystemDarkMode(): boolean { const hour = new Date().getHours(); return hour < 7 || hour >= 19; // 简单的时间判断 }
AST#method_declaration#Left private isSystemDarkMode AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left hour = 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 . getHours 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#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left hour AST#expression#Right < AST#expression#Left 7 AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left AST#binary_expression#Left AST#expression#Left hour AST#expression#Right >= AST#expression#Left 19 AST#expression#Right AST#binary_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
private isSystemDarkMode(): boolean { const hour = new Date().getHours(); return hour < 7 || hour >= 19; }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/theme/ThemeManager.ets#L818-L821
1604fbdbdd4514649a01fc7235259e6a19eec182
github
openharmony/interface_sdk-js
c349adc73e2ec1f61f6fca489b5af059e3ed6999
api/@ohos.arkui.advanced.Dialog.d.ets
arkts
LoadingDialog
Declare CustomDialog LoadingDialog @syscap SystemCapability.ArkUI.ArkUI.Full @since 10 Declare CustomDialog LoadingDialog @syscap SystemCapability.ArkUI.ArkUI.Full @atomicservice @since 11 Declare CustomDialog LoadingDialog @syscap SystemCapability.ArkUI.ArkUI.Full @crossplatform @atomicservice @since 18
@CustomDialog export declare struct LoadingDialog { /** * Sets the LoadingDialog Controller. * @type { CustomDialogController }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 10 */ /** * Sets the LoadingDialog Controller. * @type { CustomDialogController }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 11 */ /** * Sets the LoadingDialog Controller. * @type { CustomDialogController }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 18 */ Controller: CustomDialogController; /** * Sets the LoadingDialog content. * @type { ?ResourceStr }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 10 */ /** * Sets the LoadingDialog content. * @type { ?ResourceStr }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 11 */ /** * Sets the LoadingDialog content. * @type { ?ResourceStr }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 18 */ content?: ResourceStr; /** * Custom Theme. * * @type { ?(Theme | CustomTheme) } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ theme?: Theme | CustomTheme; /** * Sets the LoadingDialog dark or light Mode. * * @type { ?ThemeColorMode } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ themeColorMode?: ThemeColorMode; }
AST#decorated_export_declaration#Left AST#decorator#Left @ CustomDialog AST#decorator#Right export AST#ERROR#Left declare AST#ERROR#Right struct LoadingDialog AST#component_body#Left { /** * Sets the LoadingDialog Controller. * @type { CustomDialogController }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 10 */ /** * Sets the LoadingDialog Controller. * @type { CustomDialogController }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 11 */ /** * Sets the LoadingDialog Controller. * @type { CustomDialogController }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 18 */ AST#property_declaration#Left Controller : AST#type_annotation#Left AST#primary_type#Left CustomDialogController AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Sets the LoadingDialog content. * @type { ?ResourceStr }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 10 */ /** * Sets the LoadingDialog content. * @type { ?ResourceStr }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 11 */ /** * Sets the LoadingDialog content. * @type { ?ResourceStr }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 18 */ AST#property_declaration#Left content ? : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Custom Theme. * * @type { ?(Theme | CustomTheme) } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ AST#property_declaration#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#property_declaration#Right /** * Sets the LoadingDialog dark or light Mode. * * @type { ?ThemeColorMode } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ AST#property_declaration#Left themeColorMode ? : AST#type_annotation#Left AST#primary_type#Left ThemeColorMode AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@CustomDialog export declare struct LoadingDialog { Controller: CustomDialogController; content?: ResourceStr; theme?: Theme | CustomTheme; themeColorMode?: ThemeColorMode; }
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.arkui.advanced.Dialog.d.ets#L1011-L1077
3a5e325c6988c8b7261bb165216c8e2a6d978cc7
gitee
ashcha0/line-inspection-terminal-frontend_arkts.git
c82616097e8a3b257b7b01e75b6b83ce428b518c
entry/src/main/ets/services/ConfigService.ets
arkts
摄像头设备接口
export interface CameraDevice { id: string; name: string; status: string; ip?: string; port?: number; username?: string; password?: string; }
AST#export_declaration#Left export AST#interface_declaration#Left interface CameraDevice AST#object_type#Left { AST#type_member#Left id : 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 name : 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 status : 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 ip ? : 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 port ? : 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 username ? : 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 password ? : 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 CameraDevice { id: string; name: string; status: string; ip?: string; port?: number; username?: string; password?: string; }
https://github.com/ashcha0/line-inspection-terminal-frontend_arkts.git/blob/c82616097e8a3b257b7b01e75b6b83ce428b518c/entry/src/main/ets/services/ConfigService.ets#L28-L36
a68ffeafaaeb145742059c6011b7db9a7496e098
github
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/FileUtil.ets
arkts
readTextSync
基于文本方式读取文件(即直接读取文件的文本内容),以同步方法。 @param filePath 文件的应用沙箱路径。 @param options 支持如下选项: offset,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读取。 length,number类型,表示期望读取数据的长度。可选,默认文件长度。 encoding,string类型,当数据是 string 类型时有效,表示数据的编码方式,默认 'utf-8',仅支持 'utf-8'。 @returns
static readTextSync(filePath: string, options?: ReadTextOptions): string { return fs.readTextSync(filePath, options); }
AST#method_declaration#Left static readTextSync AST#parameter_list#Left ( AST#parameter#Left filePath : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left options ? : AST#type_annotation#Left AST#primary_type#Left ReadTextOptions 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#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fs AST#expression#Right . readTextSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left filePath AST#expression#Right , AST#expression#Left options AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static readTextSync(filePath: string, options?: ReadTextOptions): string { return fs.readTextSync(filePath, options); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/FileUtil.ets#L464-L466
f82e399e0f4f900a75297f5ab192bb3ced5d8110
gitee
azhuge233/ASFShortcut-HN.git
d1669c920c56317611b5b0375aa5315c1b91211b
entry/src/main/ets/viewmodel/CommandEntryListViewModel.ets
arkts
updateEntriesOrder
私有方法 删除条目后,重新计算每个指令条目的位置 并同步到数据库
private async updateEntriesOrder(): Promise<boolean> { // 重新设置当前列表条目的位置下标,生成新的列表 const reorderedEntriesWithNewIndex = this.commandEntries.map((entry, index) => { entry.orderIndex = index; return entry; }); // 提取新列表的 [id - 位置] 下标映射(长度为2的数组) const updatePayload = reorderedEntriesWithNewIndex.map((entry, index) => [entry.id, index]); // 更新到数据库 const success = await this.dataModel.updateEntriesOrder(updatePayload); if(success) { await this.loadCommandEntries(); return true; } return false; }
AST#method_declaration#Left private async updateEntriesOrder AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { // 重新设置当前列表条目的位置下标,生成新的列表 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left reorderedEntriesWithNewIndex = 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 . commandEntries AST#member_expression#Right AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left entry AST#parameter#Right , AST#parameter#Left index AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left entry AST#expression#Right . orderIndex AST#member_expression#Right = AST#expression#Left index AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left entry AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 提取新列表的 [id - 位置] 下标映射(长度为2的数组) AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left updatePayload = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left reorderedEntriesWithNewIndex AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left entry AST#parameter#Right , AST#parameter#Left index AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left entry AST#expression#Right . id AST#member_expression#Right AST#expression#Right , AST#expression#Left index AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 更新到数据库 AST#statement#Left AST#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#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 . dataModel AST#member_expression#Right AST#expression#Right . updateEntriesOrder AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left updatePayload 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 AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . loadCommandEntries AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#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#method_declaration#Right
private async updateEntriesOrder(): Promise<boolean> { const reorderedEntriesWithNewIndex = this.commandEntries.map((entry, index) => { entry.orderIndex = index; return entry; }); const updatePayload = reorderedEntriesWithNewIndex.map((entry, index) => [entry.id, index]); const success = await this.dataModel.updateEntriesOrder(updatePayload); if(success) { await this.loadCommandEntries(); return true; } return false; }
https://github.com/azhuge233/ASFShortcut-HN.git/blob/d1669c920c56317611b5b0375aa5315c1b91211b/entry/src/main/ets/viewmodel/CommandEntryListViewModel.ets#L114-L131
68f86362e150cd886bd31fe2b221681985fadec1
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/pages/Index.ets
arkts
buildTabItem
Tab项
@Builder buildTabItem(icon: string, title: string, index: number) { Column({ space: 4 }) { Text(icon) .fontSize(20) .opacity(this.currentTab === index ? 1 : 0.6) Text(title) .fontSize(10) .fontColor(this.currentTab === index ? this.COLORS.primary : this.COLORS.textTertiary) .fontWeight(this.currentTab === index ? FontWeight.Bold : FontWeight.Normal) } .width('20%') .height('100%') .justifyContent(FlexAlign.Center) .onClick(() => { this.currentTab = index; }) }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildTabItem AST#parameter_list#Left ( AST#parameter#Left icon : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left title : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 4 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left icon AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 20 AST#expression#Right ) AST#modifier_chain_expression#Left . opacity ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentTab AST#member_expression#Right AST#expression#Right === AST#expression#Left index AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left 1 AST#expression#Right : AST#expression#Left 0.6 AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left title AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 10 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentTab AST#member_expression#Right AST#expression#Right === AST#expression#Left index AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . COLORS AST#member_expression#Right AST#expression#Right . primary AST#member_expression#Right AST#expression#Right : AST#expression#Left this AST#expression#Right AST#conditional_expression#Right AST#expression#Right . COLORS AST#member_expression#Right AST#expression#Right . textTertiary AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentTab AST#member_expression#Right AST#expression#Right === AST#expression#Left index AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Bold AST#member_expression#Right AST#expression#Right : AST#expression#Left FontWeight AST#expression#Right AST#conditional_expression#Right AST#expression#Right . Normal AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '20%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( 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 . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentTab AST#member_expression#Right = AST#expression#Left index AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
@Builder buildTabItem(icon: string, title: string, index: number) { Column({ space: 4 }) { Text(icon) .fontSize(20) .opacity(this.currentTab === index ? 1 : 0.6) Text(title) .fontSize(10) .fontColor(this.currentTab === index ? this.COLORS.primary : this.COLORS.textTertiary) .fontWeight(this.currentTab === index ? FontWeight.Bold : FontWeight.Normal) } .width('20%') .height('100%') .justifyContent(FlexAlign.Center) .onClick(() => { this.currentTab = index; }) }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/Index.ets#L3940-L3958
74bba16edc44c242da892a9daab38da3ce461973
github
harmonyos/samples
f5d967efaa7666550ee3252d118c3c73a77686f5
HarmonyOS_NEXT/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/download/model/FileModel.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 enum FileType { FOLDER = 'folder', IMAGE = 'image', Video = 'video', MUSIC = 'music', DOCUMENT = 'document' }
AST#export_declaration#Left export AST#enum_declaration#Left enum FileType AST#enum_body#Left { AST#enum_member#Left FOLDER = AST#expression#Left 'folder' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left IMAGE = AST#expression#Left 'image' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left Video = AST#expression#Left 'video' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left MUSIC = AST#expression#Left 'music' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left DOCUMENT = AST#expression#Left 'document' AST#expression#Right AST#enum_member#Right } AST#enum_body#Right AST#enum_declaration#Right AST#export_declaration#Right
export enum FileType { FOLDER = 'folder', IMAGE = 'image', Video = 'video', MUSIC = 'music', DOCUMENT = 'document' }
https://github.com/harmonyos/samples/blob/f5d967efaa7666550ee3252d118c3c73a77686f5/HarmonyOS_NEXT/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/download/model/FileModel.ets#L16-L22
099bcf54214b981f83688d62986609a90a7faa61
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/cuberotateanimation/Index.ets
arkts
CubeRotateAnimationSwiper
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.
export { CubeRotateAnimationSwiper } from './src/main/ets/components/CubeRotateAnimationSwiper';
AST#export_declaration#Left export { CubeRotateAnimationSwiper } from './src/main/ets/components/CubeRotateAnimationSwiper' ; AST#export_declaration#Right
export { CubeRotateAnimationSwiper } from './src/main/ets/components/CubeRotateAnimationSwiper';
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/cuberotateanimation/Index.ets#L29-L29
4c47added0e31b1e1a6242e8d4b06685d1123ab4
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/common/router/AppRouter.ets
arkts
goCalendar
跳转到日历页面
async goCalendar(): Promise<void> { await this.push(RoutePaths.CALENDAR); }
AST#method_declaration#Left async goCalendar AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left RoutePaths AST#expression#Right . CALENDAR AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
async goCalendar(): Promise<void> { await this.push(RoutePaths.CALENDAR); }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/router/AppRouter.ets#L250-L252
e6a8acf38e203d8ade118c9d8a4535664add995c
github
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
feature/main/src/main/ets/viewmodel/CartViewModel.ets
arkts
get
是否全选 @returns {boolean} 是否全选
get isAllSelected(): boolean { if (this.cartList.length === 0) { return false; } for (const cart of this.cartList) { for (const spec of cart.spec) { const key = `${cart.goodsId}_${spec.id}`; if (!this.selectedSpecIds.has(key)) { return false; } } } return true; }
AST#method_declaration#Left get AST#ERROR#Left isAllSelected AST#ERROR#Right AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cartList AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#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#for_statement#Left for ( const cart of AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cartList AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#for_statement#Left for ( const spec of AST#expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . spec AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left key = AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . goodsId AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right _ AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left spec AST#expression#Right . id AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . selectedSpecIds AST#member_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#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#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
get isAllSelected(): boolean { if (this.cartList.length === 0) { return false; } for (const cart of this.cartList) { for (const spec of cart.spec) { const key = `${cart.goodsId}_${spec.id}`; if (!this.selectedSpecIds.has(key)) { return false; } } } return true; }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/main/src/main/ets/viewmodel/CartViewModel.ets#L71-L84
c2531697c7a0556ebedf574403249197ea53206f
github
bigbear20240612/planner_build-.git
89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1
entry/src/main/ets/viewmodel/TaskViewModel.ets
arkts
calculateCompletionTimeAnalysis
计算任务完成时间分析
private calculateCompletionTimeAnalysis(): CompletionTimeAnalysis { const completedTasks = this.getCompletedTasks().filter(task => task.completedAt && task.timeRecord?.totalTimeSpent); if (completedTasks.length === 0) { return { averageCompletionTime: 0, fastestCompletion: 0, slowestCompletion: 0, completionsByTimeOfDay: new Array(24).fill(0), completionsByDayOfWeek: new Array(7).fill(0) }; } const completionTimes = completedTasks.map(task => task.timeRecord!.totalTimeSpent); const averageCompletionTime = Math.round(completionTimes.reduce((sum, time) => sum + time, 0) / completionTimes.length); const fastestCompletion = completionTimes.reduce((min, time) => Math.min(min, time), completionTimes[0] || 0); const slowestCompletion = completionTimes.reduce((max, time) => Math.max(max, time), completionTimes[0] || 0); // 计算时段完成分布 const completionsByTimeOfDay: number[] = new Array(24).fill(0); const completionsByDayOfWeek: number[] = new Array(7).fill(0); completedTasks.forEach(task => { if (task.completedAt) { const hour = task.completedAt.getHours(); const dayOfWeek = task.completedAt.getDay(); completionsByTimeOfDay[hour]++; completionsByDayOfWeek[dayOfWeek]++; } }); return { averageCompletionTime, fastestCompletion, slowestCompletion, completionsByTimeOfDay, completionsByDayOfWeek }; }
AST#method_declaration#Left private calculateCompletionTimeAnalysis AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left CompletionTimeAnalysis AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left completedTasks = 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 . getCompletedTasks AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . filter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left task => AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left task AST#expression#Right . completedAt AST#member_expression#Right AST#expression#Right && AST#expression#Left task AST#expression#Right AST#binary_expression#Right AST#expression#Right . timeRecord AST#member_expression#Right AST#expression#Right ?. totalTimeSpent AST#member_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right 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 completedTasks AST#expression#Right . length AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left averageCompletionTime AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left fastestCompletion AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left slowestCompletion AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left completionsByTimeOfDay AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 24 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fill AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 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 completionsByDayOfWeek AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 7 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fill AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 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#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left completionTimes = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left completedTasks AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left task => AST#expression#Left AST#member_expression#Left AST#expression#Left AST#non_null_assertion_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left task AST#expression#Right . timeRecord AST#member_expression#Right AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right . totalTimeSpent AST#member_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left averageCompletionTime = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . round AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left completionTimes AST#expression#Right . reduce 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 sum AST#parameter#Right , AST#parameter#Left time AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#binary_expression#Left AST#expression#Left sum AST#expression#Right + AST#expression#Left time AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right , AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right / AST#expression#Left completionTimes AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left fastestCompletion = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left completionTimes AST#expression#Right . reduce 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 min AST#parameter#Right , AST#parameter#Left time AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . min AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left min AST#expression#Right , AST#expression#Left time AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left completionTimes AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right || AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left slowestCompletion = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left completionTimes AST#expression#Right . reduce 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 max AST#parameter#Right , AST#parameter#Left time AST#parameter#Right ) AST#parameter_list#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 max AST#expression#Right , AST#expression#Left time AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left completionTimes AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right || AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 计算时段完成分布 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left completionsByTimeOfDay : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left number [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 24 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fill AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left completionsByDayOfWeek : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left number [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 7 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . fill AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left completedTasks AST#expression#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left task => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left task AST#expression#Right . completedAt AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left hour = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left task AST#expression#Right . completedAt AST#member_expression#Right AST#expression#Right . getHours 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 dayOfWeek = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left task AST#expression#Right . completedAt AST#member_expression#Right AST#expression#Right . getDay 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#update_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left completionsByTimeOfDay AST#expression#Right [ AST#expression#Left hour AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#update_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left completionsByDayOfWeek AST#expression#Right [ AST#expression#Left dayOfWeek AST#expression#Right ] AST#subscript_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#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 averageCompletionTime AST#property_assignment#Right , AST#property_assignment#Left fastestCompletion AST#property_assignment#Right , AST#property_assignment#Left slowestCompletion AST#property_assignment#Right , AST#property_assignment#Left completionsByTimeOfDay AST#property_assignment#Right , AST#property_assignment#Left completionsByDayOfWeek AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private calculateCompletionTimeAnalysis(): CompletionTimeAnalysis { const completedTasks = this.getCompletedTasks().filter(task => task.completedAt && task.timeRecord?.totalTimeSpent); if (completedTasks.length === 0) { return { averageCompletionTime: 0, fastestCompletion: 0, slowestCompletion: 0, completionsByTimeOfDay: new Array(24).fill(0), completionsByDayOfWeek: new Array(7).fill(0) }; } const completionTimes = completedTasks.map(task => task.timeRecord!.totalTimeSpent); const averageCompletionTime = Math.round(completionTimes.reduce((sum, time) => sum + time, 0) / completionTimes.length); const fastestCompletion = completionTimes.reduce((min, time) => Math.min(min, time), completionTimes[0] || 0); const slowestCompletion = completionTimes.reduce((max, time) => Math.max(max, time), completionTimes[0] || 0); const completionsByTimeOfDay: number[] = new Array(24).fill(0); const completionsByDayOfWeek: number[] = new Array(7).fill(0); completedTasks.forEach(task => { if (task.completedAt) { const hour = task.completedAt.getHours(); const dayOfWeek = task.completedAt.getDay(); completionsByTimeOfDay[hour]++; completionsByDayOfWeek[dayOfWeek]++; } }); return { averageCompletionTime, fastestCompletion, slowestCompletion, completionsByTimeOfDay, completionsByDayOfWeek }; }
https://github.com/bigbear20240612/planner_build-.git/blob/89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1/entry/src/main/ets/viewmodel/TaskViewModel.ets#L586-L624
e468febc83672c4832be7640f6c48fc01fed420c
github
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/EmitterUtil.ets
arkts
off
取消事件订阅,支持取消指定事件回调 @param eventId 事件ID,string类型的eventId不支持空字符串。 @param callback 取消该事件的回调处理函数。不传callback,取消事件ID为eventId的所有订阅
static off<T>(eventId: string | number, callback?: Callback<emitter.GenericEventData<T>>) { if (callback) { emitter.off(eventId.toString(), callback); } else { emitter.off(eventId.toString()); //取消事件ID为eventId的所有订阅 } }
AST#method_declaration#Left static off AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right > AST#type_parameters#Right AST#parameter_list#Left ( AST#parameter#Left eventId : 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#union_type#Right AST#type_annotation#Right AST#parameter#Right , 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 AST#generic_type#Left AST#qualified_type#Left emitter . GenericEventData AST#qualified_type#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#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#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 emitter AST#expression#Right . off 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 eventId AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left 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 emitter AST#expression#Right . off 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 eventId AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right //取消事件ID为eventId的所有订阅 } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
static off<T>(eventId: string | number, callback?: Callback<emitter.GenericEventData<T>>) { if (callback) { emitter.off(eventId.toString(), callback); } else { emitter.off(eventId.toString()); } }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/EmitterUtil.ets#L107-L113
af673cabd74ec701b836ff39cbb4cdbc785f30a0
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/action/DialogUtil.ets
arkts
setDefaultConfig
默认样式 设置默认统一样式 @param configs
static setDefaultConfig(configs: (config: DialogConfig) => void): void { configs(DialogUtil.defaultConfig); }
AST#method_declaration#Left static setDefaultConfig AST#parameter_list#Left ( AST#parameter#Left configs : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left config : AST#type_annotation#Left AST#primary_type#Left DialogConfig AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#ui_custom_component_statement#Left configs ( AST#expression#Left AST#member_expression#Left AST#expression#Left DialogUtil AST#expression#Right . defaultConfig AST#member_expression#Right AST#expression#Right ) ; AST#ui_custom_component_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
static setDefaultConfig(configs: (config: DialogConfig) => void): void { configs(DialogUtil.defaultConfig); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/action/DialogUtil.ets#L44-L46
3a1fb1c05f10834c41f258bdd504857e7849c47c
gitee
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
core/data/src/main/ets/repository/AuthRepository.ets
arkts
@file 认证相关仓库类,封装认证模块请求 @author Joker.X
export class AuthRepository { /** * 认证网络数据源 */ private networkDataSource: AuthNetworkDataSource; /** * 构造函数 * @param networkDataSource 可选的认证网络数据源实例 */ constructor(networkDataSource?: AuthNetworkDataSource) { this.networkDataSource = networkDataSource ?? new AuthNetworkDataSourceImpl(); } /** * 微信 APP 授权登录 * @param {Record<string, string>} params - 微信授权参数 * @returns {Promise<NetworkResponse<Auth>>} 认证结果 */ async loginByWxApp(params: Record<string, string>): Promise<NetworkResponse<Auth>> { return this.networkDataSource.loginByWxApp(params); } /** * QQ APP 授权登录 * @param {QQLoginRequest} params - QQ 授权参数 * @returns {Promise<NetworkResponse<Auth>>} 认证结果 */ async loginByQqApp(params: QQLoginRequest): Promise<NetworkResponse<Auth>> { return this.networkDataSource.loginByQqApp(params); } /** * 用户注册 * @param {Record<string, string>} params - 注册参数 * @returns {Promise<NetworkResponse<Auth>>} 注册结果 */ async register(params: Record<string, string>): Promise<NetworkResponse<Auth>> { return this.networkDataSource.register(params); } /** * 获取短信验证码 * @param {Record<string, string>} params - 验证码请求参数 * @returns {Promise<NetworkResponse<string>>} 短信发送结果 */ async getSmsCode(params: Record<string, string>): Promise<NetworkResponse<string>> { return this.networkDataSource.getSmsCode(params); } /** * 刷新 Token * @param {Record<string, string>} params - 刷新参数 * @returns {Promise<NetworkResponse<Auth>>} 刷新后的认证信息 */ async refreshToken(params: Record<string, string>): Promise<NetworkResponse<Auth>> { return this.networkDataSource.refreshToken(params); } /** * 手机号验证码登录 * @param {Record<string, string>} params - 登录参数 * @returns {Promise<NetworkResponse<Auth>>} 登录结果 */ async loginByPhone(params: Record<string, string>): Promise<NetworkResponse<Auth>> { return this.networkDataSource.loginByPhone(params); } /** * 密码登录 * @param params 登录参数,包含用户名、密码等 * @returns 包含认证信息的网络响应 */ async loginByPassword(params: PasswordLoginRequest): Promise<NetworkResponse<Auth>> { return this.networkDataSource.loginByPassword(params); } /** * 获取图片验证码 * @returns {Promise<NetworkResponse<Captcha>>} 图片验证码 */ async getCaptcha(): Promise<NetworkResponse<Captcha>> { return this.networkDataSource.getCaptcha(); } }
AST#export_declaration#Left export AST#class_declaration#Left class AuthRepository AST#class_body#Left { /** * 认证网络数据源 */ AST#property_declaration#Left private networkDataSource : AST#type_annotation#Left AST#primary_type#Left AuthNetworkDataSource AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * 构造函数 * @param networkDataSource 可选的认证网络数据源实例 */ AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left networkDataSource ? : AST#type_annotation#Left AST#primary_type#Left AuthNetworkDataSource 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 . networkDataSource AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left networkDataSource AST#expression#Right ?? AST#expression#Left AST#new_expression#Left new AST#expression#Left AuthNetworkDataSourceImpl AST#expression#Right AST#new_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right /** * 微信 APP 授权登录 * @param {Record<string, string>} params - 微信授权参数 * @returns {Promise<NetworkResponse<Auth>>} 认证结果 */ AST#method_declaration#Left async loginByWxApp AST#parameter_list#Left ( AST#parameter#Left params : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Record AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#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 Auth AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . networkDataSource AST#member_expression#Right AST#expression#Right . loginByWxApp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left params 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 /** * QQ APP 授权登录 * @param {QQLoginRequest} params - QQ 授权参数 * @returns {Promise<NetworkResponse<Auth>>} 认证结果 */ AST#method_declaration#Left async loginByQqApp AST#parameter_list#Left ( AST#parameter#Left params : AST#type_annotation#Left AST#primary_type#Left QQLoginRequest 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 Auth AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . networkDataSource AST#member_expression#Right AST#expression#Right . loginByQqApp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left params AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 用户注册 * @param {Record<string, string>} params - 注册参数 * @returns {Promise<NetworkResponse<Auth>>} 注册结果 */ AST#method_declaration#Left async register AST#parameter_list#Left ( AST#parameter#Left params : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Record AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#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 Auth AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . networkDataSource AST#member_expression#Right AST#expression#Right . register AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left params AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 获取短信验证码 * @param {Record<string, string>} params - 验证码请求参数 * @returns {Promise<NetworkResponse<string>>} 短信发送结果 */ AST#method_declaration#Left async getSmsCode AST#parameter_list#Left ( AST#parameter#Left params : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Record AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#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 string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . networkDataSource AST#member_expression#Right AST#expression#Right . getSmsCode AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left params 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 /** * 刷新 Token * @param {Record<string, string>} params - 刷新参数 * @returns {Promise<NetworkResponse<Auth>>} 刷新后的认证信息 */ AST#method_declaration#Left async refreshToken AST#parameter_list#Left ( AST#parameter#Left params : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Record AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#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 Auth AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . networkDataSource AST#member_expression#Right AST#expression#Right . refreshToken AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left params AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 手机号验证码登录 * @param {Record<string, string>} params - 登录参数 * @returns {Promise<NetworkResponse<Auth>>} 登录结果 */ AST#method_declaration#Left async loginByPhone AST#parameter_list#Left ( AST#parameter#Left params : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Record AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#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 Auth AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . networkDataSource AST#member_expression#Right AST#expression#Right . loginByPhone AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left params AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 密码登录 * @param params 登录参数,包含用户名、密码等 * @returns 包含认证信息的网络响应 */ AST#method_declaration#Left async loginByPassword AST#parameter_list#Left ( AST#parameter#Left params : AST#type_annotation#Left AST#primary_type#Left PasswordLoginRequest 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 Auth AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . networkDataSource AST#member_expression#Right AST#expression#Right . loginByPassword AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left params AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 获取图片验证码 * @returns {Promise<NetworkResponse<Captcha>>} 图片验证码 */ AST#method_declaration#Left async getCaptcha 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#generic_type#Left NetworkResponse AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left Captcha AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . networkDataSource AST#member_expression#Right AST#expression#Right . getCaptcha AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class AuthRepository { private networkDataSource: AuthNetworkDataSource; constructor(networkDataSource?: AuthNetworkDataSource) { this.networkDataSource = networkDataSource ?? new AuthNetworkDataSourceImpl(); } async loginByWxApp(params: Record<string, string>): Promise<NetworkResponse<Auth>> { return this.networkDataSource.loginByWxApp(params); } async loginByQqApp(params: QQLoginRequest): Promise<NetworkResponse<Auth>> { return this.networkDataSource.loginByQqApp(params); } async register(params: Record<string, string>): Promise<NetworkResponse<Auth>> { return this.networkDataSource.register(params); } async getSmsCode(params: Record<string, string>): Promise<NetworkResponse<string>> { return this.networkDataSource.getSmsCode(params); } async refreshToken(params: Record<string, string>): Promise<NetworkResponse<Auth>> { return this.networkDataSource.refreshToken(params); } async loginByPhone(params: Record<string, string>): Promise<NetworkResponse<Auth>> { return this.networkDataSource.loginByPhone(params); } async loginByPassword(params: PasswordLoginRequest): Promise<NetworkResponse<Auth>> { return this.networkDataSource.loginByPassword(params); } async getCaptcha(): Promise<NetworkResponse<Captcha>> { return this.networkDataSource.getCaptcha(); } }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/data/src/main/ets/repository/AuthRepository.ets#L8-L92
f541ed8fc2303f88758f35988b1ff68c075a64da
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/livedetectionandencryptiond/src/main/ets/components/Encode.ets
arkts
加密或者解密 @param plainText 加密或者解密内容 @param cryptoMode 加密或者解密模式 cryptoFramework.CryptoMode.DECRYPT_MODE--解密模式、cryptoFramework.CryptoMode.ENCRYPT_MODE--加密模式 @returns
export async function encryptMessagePromise(plainText: string, cryptoMode: cryptoFramework.CryptoMode) { let base = new util.Base64Helper(); // 通过指定算法名称,获取相应的Cipher实例。Cipher:提供加解密的算法操作功能。 let cipher = cryptoFramework.createCipher('AES128|ECB|PKCS7'); // 通过指定算法名称的字符串,获取相应的对称密钥生成器实例 let symKeyGenerator = cryptoFramework.createSymKeyGenerator('AES128'); let keyMaterialBlob = genKeyMaterialBlob(); // 异步根据指定数据生成对称密钥,通过注册回调函数获取结果。 let promiseSymKey = await symKeyGenerator.convertKey(keyMaterialBlob); // 初始化加解密的cipher对象 await cipher.init(cryptoMode, promiseSymKey, null); // 加密或者解密的数据 let text: cryptoFramework.DataBlob = cryptoMode === cryptoFramework.CryptoMode.ENCRYPT_MODE ? { data: stringToUint8Array(plainText) } : { data: base.decodeSync(plainText) }; const promise = new Promise<Uint8Array>(async (resolve, reject) => { // 获取加密数据 await cipher.doFinal(text).then((res) => { resolve(res.data); }).catch((err: BusinessError) => { reject(err); }) }) return promise; }
AST#export_declaration#Left export AST#function_declaration#Left async function encryptMessagePromise AST#parameter_list#Left ( AST#parameter#Left plainText : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left cryptoMode : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . CryptoMode 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 base = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left util AST#expression#Right AST#new_expression#Right AST#expression#Right . Base64Helper AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 通过指定算法名称,获取相应的Cipher实例。Cipher:提供加解密的算法操作功能。 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left cipher = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . createCipher AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'AES128|ECB|PKCS7' 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 symKeyGenerator = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . createSymKeyGenerator AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'AES128' 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 keyMaterialBlob = AST#expression#Left AST#call_expression#Left AST#expression#Left genKeyMaterialBlob 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 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 . convertKey AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left keyMaterialBlob 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 // 初始化加解密的cipher对象 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 cipher AST#expression#Right AST#await_expression#Right AST#expression#Right . init AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left cryptoMode AST#expression#Right , AST#expression#Left promiseSymKey AST#expression#Right , AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 加密或者解密的数据 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left text : 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#expression#Left AST#conditional_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 cryptoMode AST#expression#Right === AST#expression#Left cryptoFramework AST#expression#Right AST#binary_expression#Right AST#expression#Right . CryptoMode AST#member_expression#Right AST#expression#Right . ENCRYPT_MODE AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left data AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left stringToUint8Array AST#expression#Right AST#argument_list#Left ( AST#expression#Left plainText 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 data AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left base AST#expression#Right . decodeSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left plainText 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#conditional_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left promise = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Promise AST#expression#Right AST#new_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left Uint8Array AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left async AST#parameter_list#Left ( AST#parameter#Left resolve AST#parameter#Right , AST#parameter#Left reject AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { // 获取加密数据 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left cipher AST#expression#Right AST#await_expression#Right AST#expression#Right . doFinal AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left text AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left res 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 resolve AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left res AST#expression#Right . data 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#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 reject AST#expression#Right AST#argument_list#Left ( AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left promise AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export async function encryptMessagePromise(plainText: string, cryptoMode: cryptoFramework.CryptoMode) { let base = new util.Base64Helper(); let cipher = cryptoFramework.createCipher('AES128|ECB|PKCS7'); let symKeyGenerator = cryptoFramework.createSymKeyGenerator('AES128'); let keyMaterialBlob = genKeyMaterialBlob(); let promiseSymKey = await symKeyGenerator.convertKey(keyMaterialBlob); await cipher.init(cryptoMode, promiseSymKey, null); let text: cryptoFramework.DataBlob = cryptoMode === cryptoFramework.CryptoMode.ENCRYPT_MODE ? { data: stringToUint8Array(plainText) } : { data: base.decodeSync(plainText) }; const promise = new Promise<Uint8Array>(async (resolve, reject) => { await cipher.doFinal(text).then((res) => { resolve(res.data); }).catch((err: BusinessError) => { reject(err); }) }) return promise; }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/livedetectionandencryptiond/src/main/ets/components/Encode.ets#L52-L77
a9e565c00d5b44d3e8d7344dce6170ecf9945497
gitee
harmonyos/samples
f5d967efaa7666550ee3252d118c3c73a77686f5
HarmonyOS_NEXT/Media/Image/photomodify/src/main/ets/components/util/ImageUtil.ets
arkts
计算,当固定容器宽高,选择Contain模式后,图片的实际宽高 @param componentW 容器宽 @param componentH @param imageW 图片宽 @param imageH @returns
export function getContainSize(componentW: number, componentH: number, imageW: number, imageH: number): Size { const size: Size = new Size(); const isWidthMax: boolean = componentW / componentH - imageW / imageH <= 0; if (isWidthMax) { size.width = componentW; size.height = componentW / imageW * imageH; } else { size.height = componentH; size.width = componentH / imageH * imageW; } size.scale = size.width / imageW; return size; }
AST#export_declaration#Left export AST#function_declaration#Left function getContainSize AST#parameter_list#Left ( AST#parameter#Left componentW : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left componentH : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left imageW : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left imageH : 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 Size AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left size : AST#type_annotation#Left AST#primary_type#Left Size 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 Size 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 isWidthMax : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left componentW AST#expression#Right / AST#expression#Left componentH AST#expression#Right AST#binary_expression#Right AST#expression#Right - AST#expression#Left AST#binary_expression#Left AST#expression#Left imageW AST#expression#Right / AST#expression#Left imageH AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right <= AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left isWidthMax 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 size AST#expression#Right . width AST#member_expression#Right = AST#expression#Left componentW 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 size AST#expression#Right . height AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left componentW AST#expression#Right / AST#expression#Left imageW AST#expression#Right AST#binary_expression#Right AST#expression#Right * AST#expression#Left imageH 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 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 size AST#expression#Right . height AST#member_expression#Right = AST#expression#Left componentH 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 size AST#expression#Right . width AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left componentH AST#expression#Right / AST#expression#Left imageH AST#expression#Right AST#binary_expression#Right AST#expression#Right * AST#expression#Left imageW AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left size AST#expression#Right . scale AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left size AST#expression#Right . width AST#member_expression#Right AST#expression#Right / AST#expression#Left imageW 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 size AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export function getContainSize(componentW: number, componentH: number, imageW: number, imageH: number): Size { const size: Size = new Size(); const isWidthMax: boolean = componentW / componentH - imageW / imageH <= 0; if (isWidthMax) { size.width = componentW; size.height = componentW / imageW * imageH; } else { size.height = componentH; size.width = componentH / imageH * imageW; } size.scale = size.width / imageW; return size; }
https://github.com/harmonyos/samples/blob/f5d967efaa7666550ee3252d118c3c73a77686f5/HarmonyOS_NEXT/Media/Image/photomodify/src/main/ets/components/util/ImageUtil.ets#L24-L36
50afaf19cf20c40cd022a4285eac8b119b5a57fd
gitee
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
core/ui/src/main/ets/component/icon/ArrowLeftIcon.ets
arkts
构建左箭头图标 @returns {void} 无返回值
build(): void { CommonIcon({ icon: $r("app.media.ic_left"), iconSize: this.iconSize, tintColor: this.tintColor, onTap: 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#ui_custom_component_statement#Left CommonIcon ( AST#component_parameters#Left { AST#component_parameter#Left icon : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.media.ic_left" AST#expression#Right ) AST#resource_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 . tintColor AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left onTap : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . onTap 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 { CommonIcon({ icon: $r("app.media.ic_left"), iconSize: this.iconSize, tintColor: this.tintColor, onTap: this.onTap }); }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/ui/src/main/ets/component/icon/ArrowLeftIcon.ets#L29-L36
fb6e3cd1ac7c9efa71d564364cb8bb3a88464ce4
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/common/routermodule/src/main/ets/foldableRouter/FoldableRouter.ets
arkts
设置导航栏显示改变模式枚举值
export enum NavMode { DefaultMode, // 默认模式 FoldMode, // 折叠模式 ChildPageMode, // 进入子页面模式 HomePageMode // 返回首页模式 }
AST#export_declaration#Left export AST#enum_declaration#Left enum NavMode AST#enum_body#Left { AST#enum_member#Left DefaultMode AST#enum_member#Right , // 默认模式 AST#enum_member#Left FoldMode AST#enum_member#Right , // 折叠模式 AST#enum_member#Left ChildPageMode AST#enum_member#Right , // 进入子页面模式 AST#enum_member#Left HomePageMode AST#enum_member#Right // 返回首页模式 } AST#enum_body#Right AST#enum_declaration#Right AST#export_declaration#Right
export enum NavMode { DefaultMode, FoldMode, ChildPageMode, HomePageMode }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/common/routermodule/src/main/ets/foldableRouter/FoldableRouter.ets#L27-L32
aea560f8067c87d104dcec1f11c325524cb77855
gitee
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/app/constants/AppSettings.ets
arkts
MARK: - QQ config
export class CfgQQ { static readonly AppId = "1105391403" //QQ: WordTree static readonly AppKey = "loNT3AlvXvEbSmb0" static readonly Url = "https://www.dancishu.com" }
AST#export_declaration#Left export AST#class_declaration#Left class CfgQQ AST#class_body#Left { AST#property_declaration#Left static readonly AppId = AST#expression#Left "1105391403" AST#expression#Right //QQ: WordTree AST#property_declaration#Right AST#property_declaration#Left static readonly AppKey = AST#expression#Left "loNT3AlvXvEbSmb0" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left static readonly Url = AST#expression#Left "https://www.dancishu.com" AST#expression#Right AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class CfgQQ { static readonly AppId = "1105391403" static readonly AppKey = "loNT3AlvXvEbSmb0" static readonly Url = "https://www.dancishu.com" }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/app/constants/AppSettings.ets#L40-L45
30415e32f17acefaf39ee393557074f0c77be1f7
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/common/data/FestivalData2025.ets
arkts
getSolarTerms
获取二十四节气
public static getSolarTerms(): FestivalInfo[] { return SOLAR_TERMS; }
AST#method_declaration#Left public static getSolarTerms AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left FestivalInfo [ ] 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 SOLAR_TERMS AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
public static getSolarTerms(): FestivalInfo[] { return SOLAR_TERMS; }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/data/FestivalData2025.ets#L214-L216
df2facb1b52de2ccd3b6bbae29cf6c4fdd6882e6
github
kumaleap/ArkSwipeDeck.git
5afa77b9b2a2a531595d31f895c54a3371e4249a
library/src/main/ets/utils/GestureUtils.ets
arkts
calculateSwipeProgress
计算滑动进度 @param deltaX - X轴位移 @param cardWidth - 卡片宽度 @returns 滑动进度(0-1)
static calculateSwipeProgress(deltaX: number, cardWidth: number): number { const progress: number = Math.abs(deltaX) / cardWidth; return Math.min(progress, 1); }
AST#method_declaration#Left static calculateSwipeProgress AST#parameter_list#Left ( AST#parameter#Left deltaX : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left cardWidth : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left progress : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . abs AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left deltaX AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right / AST#expression#Left cardWidth AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . min AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left progress AST#expression#Right , AST#expression#Left 1 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 calculateSwipeProgress(deltaX: number, cardWidth: number): number { const progress: number = Math.abs(deltaX) / cardWidth; return Math.min(progress, 1); }
https://github.com/kumaleap/ArkSwipeDeck.git/blob/5afa77b9b2a2a531595d31f895c54a3371e4249a/library/src/main/ets/utils/GestureUtils.ets#L197-L200
e9240cff6413b23540f66b1d5c53b6dcb79dc05b
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/videotrimmer/src/main/ets/model/ShareInfo.ets
arkts
分享信息
export interface ShareInfo { // 是否下载类别 isDownloadType: boolean; // 图片 image: Resource; // 标题 title: string; // 点击事件 onClick?: () => void; }
AST#export_declaration#Left export AST#interface_declaration#Left interface ShareInfo AST#object_type#Left { // 是否下载类别 AST#type_member#Left isDownloadType : 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 image : AST#type_annotation#Left AST#primary_type#Left Resource 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 string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; // 点击事件 AST#type_member#Left onClick ? : 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#type_member#Right ; } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
export interface ShareInfo { isDownloadType: boolean; image: Resource; title: string; onClick?: () => void; }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/videotrimmer/src/main/ets/model/ShareInfo.ets#L20-L32
fc74b716a921e8365d409a6a155920faeeedf48f
gitee
HomoArk/Homogram.git
8a6e85898b6194fdd04ead75e732d348888a0c07
features/home/src/main/ets/viewmodel/Chat/ChatPhotoNodeController.ets
arkts
ChatPhotoBuilder
async function customGetImage(context: Context, src: string | PixelMap | Resource): Promise<ArrayBuffer | undefined> { let pixelMap = createCircleLetterPixelMap("T", undefined); let info = pixelMap.getImageInfoSync(); let size = info.size.width * info.size.height * 4 * 2; let buffer = new ArrayBuffer(size); pixelMap.readPixelsToBuffer(buffer); return buffer; }
@Builder async function ChatPhotoBuilder(data: ChatPhotoData, myThis?: Object | undefined) { ImageKnifeComponent({ imageKnifeOption: new ImageKnifeOption({ loadSrc: "file://" + data.path, placeholderSrc: data.thumb, // errorholderSrc: createCircleLetterPixelMap("T", myThis), errorholderSrc: $r('app.media.fallback_vibrant_orange_gradient'), objectFit: ImageFit.Auto, border: { radius: 50 }, // customGetImage: customGetImage, }) }) .width(HomeConstants.PROFILE_PHOTO_SIZE) .height(HomeConstants.PROFILE_PHOTO_SIZE) .id(data.chatId?.toString()) }
AST#decorated_function_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right async function ChatPhotoBuilder AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left ChatPhotoData AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left myThis ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Object AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left ImageKnifeComponent ( AST#component_parameters#Left { AST#component_parameter#Left imageKnifeOption : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ImageKnifeOption 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 loadSrc AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left "file://" AST#expression#Right + AST#expression#Left data AST#expression#Right AST#binary_expression#Right AST#expression#Right . path AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left placeholderSrc AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . thumb AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , // errorholderSrc: createCircleLetterPixelMap("T", myThis), AST#property_assignment#Left AST#property_name#Left errorholderSrc AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.fallback_vibrant_orange_gradient' AST#expression#Right ) AST#resource_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 . Auto AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left border AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left radius AST#property_name#Right : AST#expression#Left 50 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right , // customGetImage: customGetImage, } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left HomeConstants AST#expression#Right . PROFILE_PHOTO_SIZE AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left HomeConstants AST#expression#Right . PROFILE_PHOTO_SIZE AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . id ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . chatId AST#member_expression#Right AST#expression#Right ?. toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#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#decorated_function_declaration#Right
@Builder async function ChatPhotoBuilder(data: ChatPhotoData, myThis?: Object | undefined) { ImageKnifeComponent({ imageKnifeOption: new ImageKnifeOption({ loadSrc: "file://" + data.path, placeholderSrc: data.thumb, errorholderSrc: $r('app.media.fallback_vibrant_orange_gradient'), objectFit: ImageFit.Auto, border: { radius: 50 }, }) }) .width(HomeConstants.PROFILE_PHOTO_SIZE) .height(HomeConstants.PROFILE_PHOTO_SIZE) .id(data.chatId?.toString()) }
https://github.com/HomoArk/Homogram.git/blob/8a6e85898b6194fdd04ead75e732d348888a0c07/features/home/src/main/ets/viewmodel/Chat/ChatPhotoNodeController.ets#L68-L86
0c327b8045c5bbfaca1bec91157fcd483a60263a
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/app/views/LinkView.ets
arkts
shareUrl
分享URL功能
private shareUrl() { ShareUtils.shareLink(this.url, getString(this.title)) }
AST#method_declaration#Left private shareUrl 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 ShareUtils AST#expression#Right . shareLink 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 . url AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left getString AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . title 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#builder_function_body#Right AST#method_declaration#Right
private shareUrl() { ShareUtils.shareLink(this.url, getString(this.title)) }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/app/views/LinkView.ets#L113-L115
6c40e848d17c1d211033d994fa45c302e8f5eb25
github
waylau/harmonyos-tutorial
74e23dfa769317f8f057cc77c2d09f0b1f2e0773
samples/ArkUIExperience/entry/src/main/ets/pages/Index.ets
arkts
confirm
确定事件
confirm() { LogUtil.info(TAG, 'click confirm:startLottery'); this.startLottery(); }
AST#method_declaration#Left confirm 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 LogUtil 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 'click confirm:startLottery' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . startLottery AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
confirm() { LogUtil.info(TAG, 'click confirm:startLottery'); this.startLottery(); }
https://github.com/waylau/harmonyos-tutorial/blob/74e23dfa769317f8f057cc77c2d09f0b1f2e0773/samples/ArkUIExperience/entry/src/main/ets/pages/Index.ets#L88-L91
7ff56957d5f31cf08bcb75e85920b8c5380f9cb7
gitee
openharmony/interface_sdk-js
c349adc73e2ec1f61f6fca489b5af059e3ed6999
api/arkui/component/gesture.d.ets
arkts
Defines LongPressGesture. @extends Gesture @syscap SystemCapability.ArkUI.ArkUI.Full @crossplatform @atomicservice @since 20
export declare class LongPressGesture extends Gesture { /** * Set the value. * fingers: Indicates the hand index that triggers the long press. * repeat: Indicates whether to trigger event callback continuously. * duration: Minimum press and hold time, in milliseconds. * * @param { function } factory * @param { LongPressGestureHandlerOptions } value * @returns { LongPressGesture } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * * @since 11 */ static $_instantiate(factory: () => LongPressGesture, value?: LongPressGestureHandlerOptions): LongPressGesture; /** * LongPress gesture recognition success callback. * * @param { Callback<GestureEvent> } event * @returns { LongPressGesture } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * * @since 20 */ onAction(event: Callback<GestureEvent>): LongPressGesture; /** * The LongPress gesture is successfully recognized. When the finger is lifted, the callback is triggered. * * @param { Callback<GestureEvent> } event * @returns { LongPressGesture } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * * @since 20 */ onActionEnd(event: Callback<GestureEvent>): LongPressGesture; /** * The LongPress gesture is successfully recognized and a callback is triggered when the touch cancel event * is received. * * @param { Callback<void> } event * @returns { LongPressGesture } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * * @since 20 */ onActionCancel(event: Callback<void>): LongPressGesture; }
AST#export_declaration#Left export AST#ERROR#Left declare AST#ERROR#Right AST#class_declaration#Left class LongPressGesture extends AST#type_annotation#Left AST#primary_type#Left Gesture AST#primary_type#Right AST#type_annotation#Right AST#class_body#Left { /** * Set the value. * fingers: Indicates the hand index that triggers the long press. * repeat: Indicates whether to trigger event callback continuously. * duration: Minimum press and hold time, in milliseconds. * * @param { function } factory * @param { LongPressGestureHandlerOptions } value * @returns { LongPressGesture } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * * @since 11 */ AST#method_declaration#Left static $_instantiate AST#parameter_list#Left ( AST#parameter#Left factory : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left LongPressGesture AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left value ? : AST#type_annotation#Left AST#primary_type#Left LongPressGestureHandlerOptions AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left LongPressGesture AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right /** * LongPress gesture recognition success callback. * * @param { Callback<GestureEvent> } event * @returns { LongPressGesture } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * * @since 20 */ AST#method_declaration#Left onAction AST#parameter_list#Left ( AST#parameter#Left event : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Callback AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left GestureEvent AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left LongPressGesture AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right /** * The LongPress gesture is successfully recognized. When the finger is lifted, the callback is triggered. * * @param { Callback<GestureEvent> } event * @returns { LongPressGesture } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * * @since 20 */ AST#method_declaration#Left onActionEnd AST#parameter_list#Left ( AST#parameter#Left event : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Callback AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left GestureEvent AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left LongPressGesture AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right /** * The LongPress gesture is successfully recognized and a callback is triggered when the touch cancel event * is received. * * @param { Callback<void> } event * @returns { LongPressGesture } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * * @since 20 */ AST#method_declaration#Left onActionCancel AST#parameter_list#Left ( AST#parameter#Left event : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Callback AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left LongPressGesture 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 LongPressGesture extends Gesture { static $_instantiate(factory: () => LongPressGesture, value?: LongPressGestureHandlerOptions): LongPressGesture; onAction(event: Callback<GestureEvent>): LongPressGesture; onActionEnd(event: Callback<GestureEvent>): LongPressGesture; onActionCancel(event: Callback<void>): LongPressGesture; }
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/arkui/component/gesture.d.ets#L401-L455
9e8b1586fea6305e8fbbd647307f84098b6d7988
gitee
liuchao0739/arkTS_universal_starter.git
0ca845f5ae0e78db439dc09f712d100c0dd46ed3
entry/src/main/ets/core/device/DeviceManager.ets
arkts
setContext
设置 Context
setContext(context: common.UIAbilityContext): void { this.context = context; }
AST#method_declaration#Left setContext AST#parameter_list#Left ( AST#parameter#Left context : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . UIAbilityContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 . context AST#member_expression#Right = AST#expression#Left context AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
setContext(context: common.UIAbilityContext): void { this.context = context; }
https://github.com/liuchao0739/arkTS_universal_starter.git/blob/0ca845f5ae0e78db439dc09f712d100c0dd46ed3/entry/src/main/ets/core/device/DeviceManager.ets#L59-L61
45afe7c2c78ed04fc3ca9388411a6103cf9b3b18
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/Performance/PerformanceLibrary/feature/dynamicImport/src/main/ets/model/GoodsModel.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 class GoodResponse { code: number = 0; data: Records = new Records(); error: string = ''; }
AST#export_declaration#Left export AST#class_declaration#Left class GoodResponse AST#class_body#Left { AST#property_declaration#Left code : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left data : AST#type_annotation#Left AST#primary_type#Left Records 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 Records 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 error : 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#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class GoodResponse { code: number = 0; data: Records = new Records(); error: string = ''; }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/Performance/PerformanceLibrary/feature/dynamicImport/src/main/ets/model/GoodsModel.ets#L16-L20
a265da007ae1f39453e786f80b7a70a350015794
gitee
awa_Liny/LinysBrowser_NEXT
a5cd96a9aa8114cae4972937f94a8967e55d4a10
home/src/main/ets/blocks/modules/meowTabsHost.ets
arkts
on_THE_LORD_OF_THE_WINDOWS_change
Called when THE_LORD_OF_THE_WINDOWS changes (the #0 is closed).
on_THE_LORD_OF_THE_WINDOWS_change() { console.warn(`[meowTabsVertical][on_THE_LORD_OF_THE_WINDOWS_change] LORD ${this.THE_LORD_OF_THE_WINDOWS}`); console.warn(`[meowTabsVertical][on_THE_LORD_OF_THE_WINDOWS_change] MYID ${this.my_window_id}`); if (this.my_window_id == this.THE_LORD_OF_THE_WINDOWS) { // Save web states this.bunch_of_tabs.clear_all_web_state(); if (!this.is_zone) { this.bunch_of_tabs.re_save_web_state(0, 'continue'); // Save tab continue data this.bunch_of_tabs.save_tab_index_stats('[on_THE_LORD_OF_THE_WINDOWS_change]'); } } }
AST#method_declaration#Left on_THE_LORD_OF_THE_WINDOWS_change 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 console AST#expression#Right . warn AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` [meowTabsVertical][on_THE_LORD_OF_THE_WINDOWS_change] LORD AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . THE_LORD_OF_THE_WINDOWS 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . warn AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` [meowTabsVertical][on_THE_LORD_OF_THE_WINDOWS_change] MYID AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . my_window_id AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#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 this AST#expression#Right . my_window_id AST#member_expression#Right AST#expression#Right == AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . THE_LORD_OF_THE_WINDOWS AST#member_expression#Right AST#expression#Right ) { // Save web states 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 . bunch_of_tabs AST#member_expression#Right AST#expression#Right . clear_all_web_state 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_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . is_zone 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 . bunch_of_tabs AST#member_expression#Right AST#expression#Right . re_save_web_state AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left 'continue' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right // Save tab continue data 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 . bunch_of_tabs AST#member_expression#Right AST#expression#Right . save_tab_index_stats AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '[on_THE_LORD_OF_THE_WINDOWS_change]' 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#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
on_THE_LORD_OF_THE_WINDOWS_change() { console.warn(`[meowTabsVertical][on_THE_LORD_OF_THE_WINDOWS_change] LORD ${this.THE_LORD_OF_THE_WINDOWS}`); console.warn(`[meowTabsVertical][on_THE_LORD_OF_THE_WINDOWS_change] MYID ${this.my_window_id}`); if (this.my_window_id == this.THE_LORD_OF_THE_WINDOWS) { this.bunch_of_tabs.clear_all_web_state(); if (!this.is_zone) { this.bunch_of_tabs.re_save_web_state(0, 'continue'); this.bunch_of_tabs.save_tab_index_stats('[on_THE_LORD_OF_THE_WINDOWS_change]'); } } }
https://github.com/awa_Liny/LinysBrowser_NEXT/blob/a5cd96a9aa8114cae4972937f94a8967e55d4a10/home/src/main/ets/blocks/modules/meowTabsHost.ets#L576-L588
db8888e8377f60009b2a92d4be94b865f2443654
gitee
chongzi/Lucky-ArkTs.git
84fc104d4a68def780a483e2543ebf9f53e793fd
entry/src/main/ets/pages/ApiQueryPage.ets
arkts
filterApis
搜索和筛选API
filterApis() { let filtered = this.apiList; // 按分类筛选 if (this.selectedCategory !== '全部') { filtered = filtered.filter(api => api.category === this.selectedCategory); } // 按搜索文本筛选 if (this.searchText.trim() !== '') { const searchLower = this.searchText.toLowerCase(); filtered = filtered.filter(api => api.name.toLowerCase().includes(searchLower) || api.description.toLowerCase().includes(searchLower) ); } this.filteredApiList = filtered; }
AST#method_declaration#Left filterApis AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left filtered = AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . apiList AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 按分类筛选 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedCategory AST#member_expression#Right AST#expression#Right !== AST#expression#Left '全部' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left filtered = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left filtered AST#expression#Right . filter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left api => AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left api AST#expression#Right . category AST#member_expression#Right AST#expression#Right === AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . selectedCategory AST#member_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 按搜索文本筛选 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . searchText AST#member_expression#Right AST#expression#Right . trim AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right !== AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left searchLower = 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 . searchText AST#member_expression#Right AST#expression#Right . toLowerCase AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right 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 filtered = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left filtered AST#expression#Right . filter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left api => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_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 api AST#expression#Right . name AST#member_expression#Right AST#expression#Right . toLowerCase AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . includes AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left searchLower AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right || AST#expression#Left api AST#expression#Right AST#binary_expression#Right AST#expression#Right . description AST#member_expression#Right AST#expression#Right . toLowerCase AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . includes AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left searchLower AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#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 . filteredApiList AST#member_expression#Right = AST#expression#Left filtered 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
filterApis() { let filtered = this.apiList; if (this.selectedCategory !== '全部') { filtered = filtered.filter(api => api.category === this.selectedCategory); } if (this.searchText.trim() !== '') { const searchLower = this.searchText.toLowerCase(); filtered = filtered.filter(api => api.name.toLowerCase().includes(searchLower) || api.description.toLowerCase().includes(searchLower) ); } this.filteredApiList = filtered; }
https://github.com/chongzi/Lucky-ArkTs.git/blob/84fc104d4a68def780a483e2543ebf9f53e793fd/entry/src/main/ets/pages/ApiQueryPage.ets#L928-L946
dac9f7a80f68afc7cafc8f0cc21128d3efdae415
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/models/managers/plan/plancurve/PlanManager.ets
arkts
savePreference
MARK: - 保存 & 加载 保存当前planId
private async savePreference(): Promise<void> { if (!this.prefs) return; await this.prefs.put(Prefs.kCurrentPlanId, this.currentPlanId ?? 0); await this.prefs.flush(); // 确保保存 }
AST#method_declaration#Left private async savePreference 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#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . prefs AST#member_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . prefs AST#member_expression#Right AST#expression#Right . put AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left Prefs AST#expression#Right . kCurrentPlanId AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentPlanId AST#member_expression#Right AST#expression#Right ?? AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#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 . prefs 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#method_declaration#Right
private async savePreference(): Promise<void> { if (!this.prefs) return; await this.prefs.put(Prefs.kCurrentPlanId, this.currentPlanId ?? 0); await this.prefs.flush(); }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/managers/plan/plancurve/PlanManager.ets#L109-L113
a34e24eeab2a445f6e766c220986dfe5341af2f3
github
lulululing/calendar.git
c87b7e3ffb50a34941a5db50afe6a513c113bd0b
entry/src/main/ets/manager/DataManager.ets
arkts
init
初始化数据存储
async init(context: Context): Promise<void> { try { this.preferences = await preferences.getPreferences(context, this.STORE_NAME) console.info('DataManager initialized successfully') } catch (err) { console.error('Failed to initialize DataManager:', JSON.stringify(err)) } }
AST#method_declaration#Left async init AST#parameter_list#Left ( AST#parameter#Left context : AST#type_annotation#Left AST#primary_type#Left Context AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . preferences AST#member_expression#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 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#member_expression#Left AST#expression#Left this AST#expression#Right . STORE_NAME AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'DataManager initialized 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#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 'Failed to initialize DataManager:' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async init(context: Context): Promise<void> { try { this.preferences = await preferences.getPreferences(context, this.STORE_NAME) console.info('DataManager initialized successfully') } catch (err) { console.error('Failed to initialize DataManager:', JSON.stringify(err)) } }
https://github.com/lulululing/calendar.git/blob/c87b7e3ffb50a34941a5db50afe6a513c113bd0b/entry/src/main/ets/manager/DataManager.ets#L21-L28
16ba2806a0c199ab6a049bab6d53ad45283faddc
github
iotjin/JhHarmonyDemo.git
819e6c3b1db9984c042a181967784550e171b2e8
JhCommon/src/main/ets/JhCommon/utils/JhPreferencesUtils.ets
arkts
saveBool
/ 存 boolean
public static saveBool(key: string, value: boolean) { const newValue = value == true ? 'TRUE' : 'FALSE' JhAESPreferencesUtils.saveString(key, newValue) }
AST#method_declaration#Left public static saveBool 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 boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left newValue = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left value AST#expression#Right == AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left 'TRUE' AST#expression#Right : AST#expression#Left 'FALSE' AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#ERROR#Left JhAESPreferencesUtils AST#ERROR#Right . saveString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right , AST#expression#Left newValue AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
public static saveBool(key: string, value: boolean) { const newValue = value == true ? 'TRUE' : 'FALSE' JhAESPreferencesUtils.saveString(key, newValue) }
https://github.com/iotjin/JhHarmonyDemo.git/blob/819e6c3b1db9984c042a181967784550e171b2e8/JhCommon/src/main/ets/JhCommon/utils/JhPreferencesUtils.ets#L26-L29
3fc4f470d517bbeb36403cc4daf91f705d1321f1
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/Solutions/InputMethod/KikaInput/entry/src/main/ets/components/ReturnItem.ets
arkts
ReturnItem
返回组件
@Component export struct ReturnItem { @StorageLink('enterKeyType') enterKeyType: EnterKeyType = EnterKeyType.Done; @StorageLink('inputStyle') inputStyle: KeyStyle = StyleConfiguration.getSavedInputStyle(); private returnWidth: Resource | undefined = undefined; build() { if (this.returnWidth) { Stack() { if (this.enterKeyType === EnterKeyType.Send) { Text(EntryKey.Send) .fontSize(this.inputStyle.symbol_fontSize) .fontColor(Color.Black) } else if (this.enterKeyType === EnterKeyType.Search) { Text(EntryKey.Search) .fontSize(this.inputStyle.symbol_fontSize) .fontColor(Color.Black) } else if (this.enterKeyType === EnterKeyType.Go) { Text(EntryKey.Go) .fontSize(this.inputStyle.symbol_fontSize) .fontColor(Color.Black) } else { Image($rawfile('return.svg')) .width(this.inputStyle.returnPicSize) .height(this.inputStyle.returnPicSize) } } .backgroundColor($r('app.color.key_item_gray')) .width(this.returnWidth) .borderRadius(4) .height('100%') .shadow({ radius: 1, color: $r('app.color.shadow'), offsetY: 3 }) .onClick(() => { InputHandler.getInstance().sendKeyFunction(); }) .stateStyles({ normal: normalStyles, pressed: pressedStyles }) } } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct ReturnItem AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ StorageLink ( AST#expression#Left 'enterKeyType' AST#expression#Right ) AST#decorator#Right enterKeyType : AST#type_annotation#Left AST#primary_type#Left EnterKeyType AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left EnterKeyType AST#expression#Right . Done AST#member_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ StorageLink ( AST#expression#Left 'inputStyle' AST#expression#Right ) AST#decorator#Right inputStyle : AST#type_annotation#Left AST#primary_type#Left KeyStyle 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 StyleConfiguration AST#expression#Right . getSavedInputStyle AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private returnWidth : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Resource 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#build_method#Left build ( ) AST#build_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . returnWidth AST#member_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Stack ( ) 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 this AST#expression#Right . enterKeyType AST#member_expression#Right AST#expression#Right === AST#expression#Left EnterKeyType AST#expression#Right AST#binary_expression#Right AST#expression#Right . Send AST#member_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left EntryKey AST#expression#Right . Send AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . inputStyle AST#member_expression#Right AST#expression#Right . symbol_fontSize AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Black 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 } 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 this AST#expression#Right . enterKeyType AST#member_expression#Right AST#expression#Right === AST#expression#Left EnterKeyType AST#expression#Right AST#binary_expression#Right AST#expression#Right . Search AST#member_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left EntryKey AST#expression#Right . Search AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . inputStyle AST#member_expression#Right AST#expression#Right . symbol_fontSize AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Black 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 } 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 this AST#expression#Right . enterKeyType AST#member_expression#Right AST#expression#Right === AST#expression#Left EnterKeyType AST#expression#Right AST#binary_expression#Right AST#expression#Right . Go AST#member_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left EntryKey AST#expression#Right . Go AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . inputStyle AST#member_expression#Right AST#expression#Right . symbol_fontSize AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Black 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 } else { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#call_expression#Left AST#expression#Left $rawfile AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'return.svg' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . inputStyle AST#member_expression#Right AST#expression#Right . returnPicSize AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . inputStyle AST#member_expression#Right AST#expression#Right . returnPicSize AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_if_statement#Right AST#ui_if_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 . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.key_item_gray' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . returnWidth AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 4 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . shadow ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left radius AST#property_name#Right : AST#expression#Left 1 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.shadow' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offsetY AST#property_name#Right : AST#expression#Left 3 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#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 InputHandler AST#expression#Right . getInstance AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . sendKeyFunction 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#Left . stateStyles ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left normal AST#property_name#Right : AST#expression#Left normalStyles AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left pressed AST#property_name#Right : AST#expression#Left pressedStyles 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#ui_if_statement#Right AST#ui_control_flow#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Component export struct ReturnItem { @StorageLink('enterKeyType') enterKeyType: EnterKeyType = EnterKeyType.Done; @StorageLink('inputStyle') inputStyle: KeyStyle = StyleConfiguration.getSavedInputStyle(); private returnWidth: Resource | undefined = undefined; build() { if (this.returnWidth) { Stack() { if (this.enterKeyType === EnterKeyType.Send) { Text(EntryKey.Send) .fontSize(this.inputStyle.symbol_fontSize) .fontColor(Color.Black) } else if (this.enterKeyType === EnterKeyType.Search) { Text(EntryKey.Search) .fontSize(this.inputStyle.symbol_fontSize) .fontColor(Color.Black) } else if (this.enterKeyType === EnterKeyType.Go) { Text(EntryKey.Go) .fontSize(this.inputStyle.symbol_fontSize) .fontColor(Color.Black) } else { Image($rawfile('return.svg')) .width(this.inputStyle.returnPicSize) .height(this.inputStyle.returnPicSize) } } .backgroundColor($r('app.color.key_item_gray')) .width(this.returnWidth) .borderRadius(4) .height('100%') .shadow({ radius: 1, color: $r('app.color.shadow'), offsetY: 3 }) .onClick(() => { InputHandler.getInstance().sendKeyFunction(); }) .stateStyles({ normal: normalStyles, pressed: pressedStyles }) } } }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/Solutions/InputMethod/KikaInput/entry/src/main/ets/components/ReturnItem.ets#L34-L74
f62ccc4d88dfa41b10900bf8b88b565a3204cd52
gitee
openharmony/applications_systemui
413f701448a7923a18a761e3cb54f0b871cfef40
features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/settingDialog.ets
arkts
SettingDialog
Setting dialog
@CustomDialog export default struct SettingDialog { @Prop itemData: NotificationItemData public controller: CustomDialogController public action: () => void = () => {} build() { Column() { Column({ space: 4 }) { Row({ space: 4 }) { if (!CheckEmptyUtils.isEmpty(this.itemData.smallIcon)) { Image(this.itemData.smallIcon) .objectFit(ImageFit.Contain) .width($r('app.float.title_image_width')) .height($r('app.float.title_image_height')) } Text(this.itemData.appName) .fontSize($r('app.float.setting_title_fontsize')) .fontWeight(500) }.width($r('app.float.setting_dialog_row_width')) .margin({ top: $r('app.float.notification_appname_margin_top') }) .height($r('app.float.title_font_height')) Row() { Column() { Text($r('app.string.closeNotification')) .fontSize($r('app.float.setting_cont_fontsize')) .fontColor($r('app.color.dialog_font_color')) .height($r('app.float.setting_dialog_row_height')) }.alignItems(HorizontalAlign.Center) .width(Constants.SETTING_CONTENT_WITH) } .width($r('app.float.setting_dialog_row_width')) .alignItems(VerticalAlign.Center) .align(Alignment.Center) .margin({ top: $r('app.float.close_notification_margin_top') }) .border({ width: $r('app.float.setting_border_width'), color: Color.White, radius: $r('app.float.setting_border_radius') }) .backgroundColor($r('app.color.dialog_font_back_color')) .onClick(this.closeNotification.bind(this)) Row() { Column() { Text($r('app.string.moreSettings')) .fontSize($r('app.float.setting_cont_fontsize')) .fontColor($r('app.color.button_text_color')) .height($r('app.float.setting_dialog_row_height')) }.alignItems(HorizontalAlign.Center) .width(Constants.SETTING_CONTENT_WITH) .align(Alignment.Center) } .width($r('app.float.setting_dialog_row_width')) .alignItems(VerticalAlign.Center) .border({ width: $r('app.float.setting_border_width'), color: Color.White, radius: $r('app.float.setting_border_radius') }) .backgroundColor($r('app.color.action_button_click_color')) .onClick(this.openAbility.bind(this)) Row() { Column() { Text($r('app.string.cancel')) .maxLines(Constants.DEFAULT_MAX_LINES) .textOverflow({ overflow: TextOverflow.Ellipsis }) .fontSize($r('app.float.setting_cont_fontsize')) .fontColor($r('app.color.button_text_color')) }.alignItems(HorizontalAlign.Center) .width(Constants.SETTING_CONTENT_WITH) } .width($r('app.float.setting_dialog_row_width')) .margin({ top: $r('app.float.notification_cancle_margin_top') }) .alignItems(VerticalAlign.Center) .align(Alignment.Center) .border({ width: $r('app.float.setting_border_width'), color: Color.White, radius: $r('app.float.setting_border_radius') }) .backgroundColor($r('app.color.dialog_font_color')) .onClick(this.closeAbility.bind(this)) } .height($r('app.float.setting_dialog_height')) .width(deviceTypeInfo === 'phone' ? '100%' : $r('app.float.setting_dialog_width')) .backgroundColor('#FFFFFF') .margin({ left: 20, right: 20 }) .border({ width: $r('app.float.setting_border_width'), color: Color.White, radius: $r('app.float.notification_border_radius') }) } .margin({ left: $r("app.float.confirm_dialog_margin"), right: $r("app.float.confirm_dialog_margin") }) } closeNotification() { this.action() this.closeAbility() } openAbility() { Log.showInfo(TAG, ` openAbility:showNotificationManagement`); EventManager.publish(obtainStartAbility('com.ohos.systemui', 'com.ohos.systemui.notificationmanagement.MainAbility', { 'migrateUri': 'pages/setEnable', 'migrateBundle': this.itemData.bundleName })) this.closeAbility() } closeAbility() { Log.showInfo(TAG, `closeAbility`); this.controller.close() } }
AST#decorated_export_declaration#Left AST#decorator#Left @ CustomDialog AST#decorator#Right export default struct SettingDialog AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right itemData : AST#type_annotation#Left AST#primary_type#Left NotificationItemData AST#primary_type#Right AST#type_annotation#Right AST#property_declaration#Right AST#property_declaration#Left public controller : AST#type_annotation#Left AST#primary_type#Left CustomDialogController AST#primary_type#Right AST#type_annotation#Right AST#property_declaration#Right AST#property_declaration#Left public action : 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#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 4 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 4 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left CheckEmptyUtils AST#expression#Right AST#unary_expression#Right AST#expression#Right . isEmpty AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . itemData AST#member_expression#Right AST#expression#Right . smallIcon AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . itemData AST#member_expression#Right AST#expression#Right . smallIcon 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 . Contain AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.title_image_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.title_image_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . itemData AST#member_expression#Right AST#expression#Right . appName 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.setting_title_fontsize' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left 500 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 AST#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_dialog_row_width' 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.notification_appname_margin_top' 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 . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.title_font_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#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 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.closeNotification' 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_cont_fontsize' 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.dialog_font_color' 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_dialog_row_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . 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 . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . SETTING_CONTENT_WITH 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 . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_dialog_row_width' AST#expression#Right ) AST#resource_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 . align ( AST#expression#Left AST#member_expression#Left AST#expression#Left Alignment AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . 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.close_notification_margin_top' 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 . border ( 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.float.setting_border_width' 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 . White 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#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_border_radius' 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.dialog_font_back_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( 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 . closeNotification AST#member_expression#Right AST#expression#Right . bind AST#member_expression#Right 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#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left 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.moreSettings' 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_cont_fontsize' 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.button_text_color' 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_dialog_row_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . 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 . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . SETTING_CONTENT_WITH AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . align ( AST#expression#Left AST#member_expression#Left AST#expression#Left Alignment AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_dialog_row_width' AST#expression#Right ) AST#resource_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 . border ( 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.float.setting_border_width' 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 . White 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#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_border_radius' 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.action_button_click_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( 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 . openAbility AST#member_expression#Right AST#expression#Right . bind AST#member_expression#Right 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#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left 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.cancel' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . maxLines ( AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . DEFAULT_MAX_LINES AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . textOverflow ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left overflow AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left TextOverflow AST#expression#Right . Ellipsis AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_cont_fontsize' 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.button_text_color' 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#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 . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . SETTING_CONTENT_WITH 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 . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_dialog_row_width' 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.notification_cancle_margin_top' 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 . align ( AST#expression#Left AST#member_expression#Left AST#expression#Left Alignment AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . border ( 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.float.setting_border_width' 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 . White 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#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_border_radius' 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.dialog_font_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( 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 . closeAbility AST#member_expression#Right AST#expression#Right . bind AST#member_expression#Right 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#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#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_dialog_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left deviceTypeInfo AST#expression#Right === AST#expression#Left 'phone' AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left '100%' AST#expression#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_dialog_width' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#FFFFFF' 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 20 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 20 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . border ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.setting_border_width' 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 . White 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#resource_expression#Left $r ( AST#expression#Left 'app.float.notification_border_radius' 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#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 left AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.float.confirm_dialog_margin" 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.confirm_dialog_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#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right AST#method_declaration#Left closeNotification AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . action AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . closeAbility AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left openAbility 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 Log AST#expression#Right . showInfo 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 ` openAbility:showNotificationManagement ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left EventManager AST#expression#Right . publish AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left obtainStartAbility AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'com.ohos.systemui' AST#expression#Right , AST#expression#Left 'com.ohos.systemui.notificationmanagement.MainAbility' AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left 'migrateUri' AST#property_name#Right : AST#expression#Left 'pages/setEnable' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'migrateBundle' 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 . itemData AST#member_expression#Right AST#expression#Right . bundleName 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#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . closeAbility AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left closeAbility 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 Log AST#expression#Right . showInfo 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 ` closeAbility ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . controller AST#member_expression#Right AST#expression#Right . close AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@CustomDialog export default struct SettingDialog { @Prop itemData: NotificationItemData public controller: CustomDialogController public action: () => void = () => {} build() { Column() { Column({ space: 4 }) { Row({ space: 4 }) { if (!CheckEmptyUtils.isEmpty(this.itemData.smallIcon)) { Image(this.itemData.smallIcon) .objectFit(ImageFit.Contain) .width($r('app.float.title_image_width')) .height($r('app.float.title_image_height')) } Text(this.itemData.appName) .fontSize($r('app.float.setting_title_fontsize')) .fontWeight(500) }.width($r('app.float.setting_dialog_row_width')) .margin({ top: $r('app.float.notification_appname_margin_top') }) .height($r('app.float.title_font_height')) Row() { Column() { Text($r('app.string.closeNotification')) .fontSize($r('app.float.setting_cont_fontsize')) .fontColor($r('app.color.dialog_font_color')) .height($r('app.float.setting_dialog_row_height')) }.alignItems(HorizontalAlign.Center) .width(Constants.SETTING_CONTENT_WITH) } .width($r('app.float.setting_dialog_row_width')) .alignItems(VerticalAlign.Center) .align(Alignment.Center) .margin({ top: $r('app.float.close_notification_margin_top') }) .border({ width: $r('app.float.setting_border_width'), color: Color.White, radius: $r('app.float.setting_border_radius') }) .backgroundColor($r('app.color.dialog_font_back_color')) .onClick(this.closeNotification.bind(this)) Row() { Column() { Text($r('app.string.moreSettings')) .fontSize($r('app.float.setting_cont_fontsize')) .fontColor($r('app.color.button_text_color')) .height($r('app.float.setting_dialog_row_height')) }.alignItems(HorizontalAlign.Center) .width(Constants.SETTING_CONTENT_WITH) .align(Alignment.Center) } .width($r('app.float.setting_dialog_row_width')) .alignItems(VerticalAlign.Center) .border({ width: $r('app.float.setting_border_width'), color: Color.White, radius: $r('app.float.setting_border_radius') }) .backgroundColor($r('app.color.action_button_click_color')) .onClick(this.openAbility.bind(this)) Row() { Column() { Text($r('app.string.cancel')) .maxLines(Constants.DEFAULT_MAX_LINES) .textOverflow({ overflow: TextOverflow.Ellipsis }) .fontSize($r('app.float.setting_cont_fontsize')) .fontColor($r('app.color.button_text_color')) }.alignItems(HorizontalAlign.Center) .width(Constants.SETTING_CONTENT_WITH) } .width($r('app.float.setting_dialog_row_width')) .margin({ top: $r('app.float.notification_cancle_margin_top') }) .alignItems(VerticalAlign.Center) .align(Alignment.Center) .border({ width: $r('app.float.setting_border_width'), color: Color.White, radius: $r('app.float.setting_border_radius') }) .backgroundColor($r('app.color.dialog_font_color')) .onClick(this.closeAbility.bind(this)) } .height($r('app.float.setting_dialog_height')) .width(deviceTypeInfo === 'phone' ? '100%' : $r('app.float.setting_dialog_width')) .backgroundColor('#FFFFFF') .margin({ left: 20, right: 20 }) .border({ width: $r('app.float.setting_border_width'), color: Color.White, radius: $r('app.float.notification_border_radius') }) } .margin({ left: $r("app.float.confirm_dialog_margin"), right: $r("app.float.confirm_dialog_margin") }) } closeNotification() { this.action() this.closeAbility() } openAbility() { Log.showInfo(TAG, ` openAbility:showNotificationManagement`); EventManager.publish(obtainStartAbility('com.ohos.systemui', 'com.ohos.systemui.notificationmanagement.MainAbility', { 'migrateUri': 'pages/setEnable', 'migrateBundle': this.itemData.bundleName })) this.closeAbility() } closeAbility() { Log.showInfo(TAG, `closeAbility`); this.controller.close() } }
https://github.com/openharmony/applications_systemui/blob/413f701448a7923a18a761e3cb54f0b871cfef40/features/noticeitem/src/main/ets/com/ohos/noticeItem/view/item/settingDialog.ets#L31-L137
90d5ec2adb6d480c2801955b71baf8059330d79d
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/common/types/SettingsTypes.ets
arkts
日历视图类型枚举
export enum CalendarViewType { MONTH = 'month', WEEK = 'week', AGENDA = 'agenda' }
AST#export_declaration#Left export AST#enum_declaration#Left enum CalendarViewType AST#enum_body#Left { AST#enum_member#Left MONTH = AST#expression#Left 'month' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left WEEK = AST#expression#Left 'week' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left AGENDA = AST#expression#Left 'agenda' AST#expression#Right AST#enum_member#Right } AST#enum_body#Right AST#enum_declaration#Right AST#export_declaration#Right
export enum CalendarViewType { MONTH = 'month', WEEK = 'week', AGENDA = 'agenda' }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/types/SettingsTypes.ets#L369-L373
410294816a6e9bf7eff3d11c0dab562ac894add9
github
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
WaterFlowSample/entry/src/main/ets/model/BasicDataSource.ets
arkts
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.
export class BasicDataSource<T> implements IDataSource { private listeners: DataChangeListener[] = []; protected dataArray: T[] = []; totalCount(): number { return this.dataArray.length; } getData(index: number): T { return this.dataArray[index]; } registerDataChangeListener(listener: DataChangeListener): void { if (this.listeners.indexOf(listener) < 0) { this.listeners.push(listener); } } unregisterDataChangeListener(listener: DataChangeListener): void { const position: number = this.listeners.indexOf(listener); if (position >= 0) { this.listeners.splice(position, 1); } } notifyDataAdd(index: number): void { this.listeners.forEach(listener => { listener.onDataAdd(index); }); } notifyDataChange(index: number): void { this.listeners.forEach(listener => { listener.onDataChange(index); }); } notifyDataDelete(index: number): void { this.listeners.forEach(listener => { listener.onDataDelete(index); }); } }
AST#export_declaration#Left export AST#class_declaration#Left 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#property_declaration#Left protected dataArray : 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#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#method_declaration#Left totalCount AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataArray AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left getData AST#parameter_list#Left ( AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataArray AST#member_expression#Right AST#expression#Right [ AST#expression#Left index AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right 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 position : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#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 position 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 position 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 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 listener => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left listener AST#expression#Right . onDataAdd AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left index AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left 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 listener => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left listener AST#expression#Right . onDataChange AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left index AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left 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 listener => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left listener AST#expression#Right . onDataDelete AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left index AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class BasicDataSource<T> implements IDataSource { private listeners: DataChangeListener[] = []; protected dataArray: T[] = []; totalCount(): number { return this.dataArray.length; } getData(index: number): T { return this.dataArray[index]; } registerDataChangeListener(listener: DataChangeListener): void { if (this.listeners.indexOf(listener) < 0) { this.listeners.push(listener); } } unregisterDataChangeListener(listener: DataChangeListener): void { const position: number = this.listeners.indexOf(listener); if (position >= 0) { this.listeners.splice(position, 1); } } notifyDataAdd(index: number): void { this.listeners.forEach(listener => { listener.onDataAdd(index); }); } notifyDataChange(index: number): void { this.listeners.forEach(listener => { listener.onDataChange(index); }); } notifyDataDelete(index: number): void { this.listeners.forEach(listener => { listener.onDataDelete(index); }); } }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/WaterFlowSample/entry/src/main/ets/model/BasicDataSource.ets#L16-L58
01776c24e7d0f1d3fa012fd00bdd612a03f64e1a
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/common/types/SyncTypes.ets
arkts
同步相关
export interface SyncOptions { force?: boolean; // 强制同步 direction?: SyncDirection; // 同步方向 dataTypes?: DataType[]; // 要同步的数据类型 conflictStrategy?: ConflictStrategy; // 冲突解决策略 }
AST#export_declaration#Left export AST#interface_declaration#Left interface SyncOptions AST#object_type#Left { AST#type_member#Left force ? : 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 direction ? : AST#type_annotation#Left AST#primary_type#Left SyncDirection AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; // 同步方向 AST#type_member#Left dataTypes ? : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left DataType [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; // 要同步的数据类型 AST#type_member#Left conflictStrategy ? : AST#type_annotation#Left AST#primary_type#Left ConflictStrategy 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 SyncOptions { force?: boolean; direction?: SyncDirection; dataTypes?: DataType[]; conflictStrategy?: ConflictStrategy; }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/types/SyncTypes.ets#L38-L43
6b118ec386040e011c1d17bfa78c4ac52a5cb6d6
github
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
eftool/src/main/ets/core/util/AopUtil.ets
arkts
@Author csx @DateTime 2024/6/11 12:18:06 @TODO AopUtil 提供统一的切面工具类 参考链接 https://developer.huawei.com/consumer/cn/forum/topic/0208150583363295032
export class AopUtil { }
AST#export_declaration#Left export AST#class_declaration#Left class AopUtil AST#class_body#Left { } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class AopUtil { }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/eftool/src/main/ets/core/util/AopUtil.ets#L23-L24
89d67cdc591ca87eb45096ef2d2266d0bbf80266
gitee
ThePivotPoint/ArkTS-LSP-Server-Plugin.git
6231773905435f000d00d94b26504433082ba40b
packages/declarations/ets/api/@ohos.arkui.advanced.ToolBar.d.ets
arkts
ToolBarOptions
Declare ToolBarOptions use in ToolBar @syscap SystemCapability.ArkUI.ArkUI.Full @since 10 Declare ToolBarOptions use in ToolBar @syscap SystemCapability.ArkUI.ArkUI.Full @atomicservice @since 11
@Observed export declare class ToolBarOptions extends Array<ToolBarOption> { }
AST#decorated_export_declaration#Left AST#decorator#Left @ Observed AST#decorator#Right export AST#ERROR#Left declare AST#ERROR#Right class ToolBarOptions extends AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left ToolBarOption AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#class_body#Left { } AST#class_body#Right AST#decorated_export_declaration#Right
@Observed export declare class ToolBarOptions extends Array<ToolBarOption> { }
https://github.com/ThePivotPoint/ArkTS-LSP-Server-Plugin.git/blob/6231773905435f000d00d94b26504433082ba40b/packages/declarations/ets/api/@ohos.arkui.advanced.ToolBar.d.ets#L222-L224
ca77d487d506be941225241f7c77852baf376c58
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/DocsSample/bluetoothSample/entry/src/main/ets/common/ScanData.ets
arkts
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.
export class ScanData { private deviceId: string = ''; private deviceName: string = ''; private rssi: number = 0; private connectable: boolean = false; private data: Uint8Array = new Uint8Array([0xFF, 0xFF, 0xFF, 0xFF]); constructor(deviceId: string = '', deviceName: string = 'null', rssi: number = 0, connectable: boolean = false, data: Uint8Array = new Uint8Array([0xFF, 0xFF, 0xFF, 0xFF])) { this.deviceId = deviceId; this.deviceName = deviceName; this.rssi = rssi; this.connectable = connectable; this.data = data; } public setDeviceId(deviceId: string) { this.deviceId = deviceId; } public setData(data: Uint8Array) { this.data = data; } public getDeviceId(): string { return this.deviceId; } public getData(): Uint8Array { return this.data; } public setDeviceName(deviceName: string) { this.deviceName = deviceName; } public getDeviceName(): string { return this.deviceName; } public setRssi(rssi: number) { this.rssi = rssi; } public getRssi(): number { return this.rssi; } public setConnectable(connectable: boolean) { this.connectable = connectable; } public getConnectable(): boolean { return this.connectable; } }
AST#export_declaration#Left export AST#class_declaration#Left class ScanData AST#class_body#Left { AST#property_declaration#Left private deviceId : 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 private deviceName : 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 private rssi : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private connectable : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private data : AST#type_annotation#Left AST#primary_type#Left Uint8Array AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Uint8Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#array_literal#Left [ AST#expression#Left 0xFF AST#expression#Right , AST#expression#Left 0xFF AST#expression#Right , AST#expression#Left 0xFF AST#expression#Right , AST#expression#Left 0xFF AST#expression#Right ] AST#array_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left deviceId : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '' AST#expression#Right AST#parameter#Right , AST#parameter#Left deviceName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'null' AST#expression#Right AST#parameter#Right , AST#parameter#Left rssi : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right AST#parameter#Right , AST#parameter#Left connectable : 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#Left data : AST#type_annotation#Left AST#primary_type#Left Uint8Array AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Uint8Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#array_literal#Left [ AST#expression#Left 0xFF AST#expression#Right , AST#expression#Left 0xFF AST#expression#Right , AST#expression#Left 0xFF AST#expression#Right , AST#expression#Left 0xFF AST#expression#Right ] AST#array_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#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 . deviceId AST#member_expression#Right = AST#expression#Left deviceId 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 . deviceName AST#member_expression#Right = AST#expression#Left deviceName 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 . rssi AST#member_expression#Right = AST#expression#Left rssi 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 . connectable AST#member_expression#Right = AST#expression#Left connectable 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 . data AST#member_expression#Right = AST#expression#Left data AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right AST#method_declaration#Left public setDeviceId AST#parameter_list#Left ( AST#parameter#Left deviceId : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . deviceId AST#member_expression#Right = AST#expression#Left deviceId AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left public setData AST#parameter_list#Left ( AST#parameter#Left data : 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#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 . data AST#member_expression#Right = AST#expression#Left data AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left public getDeviceId AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . deviceId AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left public getData AST#parameter_list#Left ( ) 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#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this 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 AST#method_declaration#Left public setDeviceName AST#parameter_list#Left ( AST#parameter#Left deviceName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . deviceName AST#member_expression#Right = AST#expression#Left deviceName AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left public getDeviceName AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . deviceName AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left public setRssi AST#parameter_list#Left ( AST#parameter#Left rssi : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rssi AST#member_expression#Right = AST#expression#Left rssi AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left public getRssi 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 . rssi AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left public setConnectable AST#parameter_list#Left ( AST#parameter#Left connectable : 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#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 . connectable AST#member_expression#Right = AST#expression#Left connectable AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left public getConnectable AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . connectable AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class ScanData { private deviceId: string = ''; private deviceName: string = ''; private rssi: number = 0; private connectable: boolean = false; private data: Uint8Array = new Uint8Array([0xFF, 0xFF, 0xFF, 0xFF]); constructor(deviceId: string = '', deviceName: string = 'null', rssi: number = 0, connectable: boolean = false, data: Uint8Array = new Uint8Array([0xFF, 0xFF, 0xFF, 0xFF])) { this.deviceId = deviceId; this.deviceName = deviceName; this.rssi = rssi; this.connectable = connectable; this.data = data; } public setDeviceId(deviceId: string) { this.deviceId = deviceId; } public setData(data: Uint8Array) { this.data = data; } public getDeviceId(): string { return this.deviceId; } public getData(): Uint8Array { return this.data; } public setDeviceName(deviceName: string) { this.deviceName = deviceName; } public getDeviceName(): string { return this.deviceName; } public setRssi(rssi: number) { this.rssi = rssi; } public getRssi(): number { return this.rssi; } public setConnectable(connectable: boolean) { this.connectable = connectable; } public getConnectable(): boolean { return this.connectable; } }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/bluetoothSample/entry/src/main/ets/common/ScanData.ets#L16-L71
7eb8e755c341e50a58992a58ba7e43448d3deee4
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/effectkit/src/main/ets/components/mainpage/MainPage.ets
arkts
MainPageComponent
实现步骤: 1. 通过使用滑动视图容器Swiper,将控制器SwiperController绑定Swiper组件,实现其子组件Image图片滑动轮播显示效果。 2. 在事件onAnimationStart切换动画过程中通过Image模块相关能力,获取图片颜色平均值,使用effectKit包中的ColorPicker智能取色器进行颜色取值。 3. 同时通过接口animateTo开启背景颜色渲染的属性动画。全局界面开启沉浸式状态栏。
@Component export struct MainPageComponent { // 图片资源获取 @State imgData: Resource[] = [ $r('app.media.image4'), $r('app.media.image5'), $r('app.media.image6'), $r('app.media.image7') ]; // 初始背景色赋值 @State bgColor: string = "#fffffff"; // 顶部安全高度赋值 @State topSafeHeight: number = 0; // 创建swiperController private swiperController: SwiperController = new SwiperController(); // swiper自动播放时间间隔 private swiperInterval: number = 3500; // swiper子组件切换动画时长 private swiperDuration: number = 500; // swiper子组件与子组件间隙 private swiperItemSpace: number = 10; async aboutToAppear() { // 顶部安全高度适配 let windowHight: window.Window = await window.getLastWindow(getContext(this)); await windowHight.setWindowLayoutFullScreen(true); this.topSafeHeight = px2vp(windowHight.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM).topRect.height) // TODO 知识点:初始化页面获取第一张图片的颜色 const context = getContext(this); const resourceMgr: resourceManager.ResourceManager = context.resourceManager; const fileData: Uint8Array = await resourceMgr.getMediaContent(this.imgData[0]); const buffer = fileData.buffer as ArrayBuffer; const imageSource: image.ImageSource = image.createImageSource(buffer); const pixelMap: image.PixelMap = await imageSource.createPixelMap(); // TODO 知识点:智能取色器接口使用,初始化背景色 effectKit.createColorPicker(pixelMap, (err, colorPicker) => { let color = colorPicker.getMainColorSync(); // 将取色器选取的color示例转换为十六进制颜色代码 this.bgColor = "#" + color.alpha.toString(16) + color.red.toString(16) + color.green.toString(16) + color.blue.toString(16) }) } build() { Column() { Swiper(this.swiperController) { // TODO 高性能知识点:此处为了演示场景,数量只有4个,使用ForEach,真实场景列表数量较多的场景,推荐使用LazyForEach+组件复用+缓存列表项实现 ForEach(this.imgData, (item: Resource) => { Image(item).borderRadius($r('app.integer.effectKit_image_borderRadius')) .margin({ top: $r('app.integer.effectKit_image_margin_top') }) }) } .width($r('app.string.effectKit_swiper_width')) .padding({ left: $r('app.integer.effectKit_swiper_padding_left'), right: $r('app.integer.effectKit_swiper_padding_right') }) .autoPlay(true) .interval(this.swiperInterval) .duration(this.swiperDuration) .loop(true) .itemSpace(this.swiperItemSpace) .indicator(false) // TODO 知识点:切换动画过程中获取图片平均颜色 .onAnimationStart(async (index, targetIndex) => { try { const context = getContext(this); // 获取resourceManager资源管理器 const resourceMgr: resourceManager.ResourceManager = context.resourceManager; const fileData: Uint8Array = await resourceMgr.getMediaContent(this.imgData[targetIndex]); // 获取图片的ArrayBuffer const buffer = fileData.buffer as ArrayBuffer; // 创建imageSource const imageSource: image.ImageSource = image.createImageSource(buffer); // 创建pixelMap const pixelMap: image.PixelMap = await imageSource.createPixelMap(); effectKit.createColorPicker(pixelMap, (err, colorPicker) => { // 读取图像主色的颜色值,结果写入Color let color = colorPicker.getMainColorSync(); // 开启背景颜色渲染的属性动画 animateTo({ duration: 500, curve: Curve.Linear, iterations: 1 }, () => { // 将取色器选取的color示例转换为十六进制颜色代码 this.bgColor = "#" + color.alpha.toString(16) + color.red.toString(16) + color.green.toString(16) + color.blue.toString(16); }) }) } catch (e) { } }) } .width($r('app.string.effectKit_column_width')) .height($r('app.string.effectKit_column_height')) .linearGradient({ // 渐变方向 direction: GradientDirection.Bottom, // 数组末尾元素占比小于1时,满足重复着色的效果 colors: [[this.bgColor, 0.0], [Color.White, 0.5]] }) .padding({ top: this.topSafeHeight }) } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct MainPageComponent AST#component_body#Left { // 图片资源获取 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right imgData : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Resource [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.image4' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.image5' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.image6' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.image7' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right ; AST#property_declaration#Right // 初始背景色赋值 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right bgColor : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "#fffffff" AST#expression#Right ; AST#property_declaration#Right // 顶部安全高度赋值 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right topSafeHeight : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right // 创建swiperController AST#property_declaration#Left private swiperController : AST#type_annotation#Left AST#primary_type#Left SwiperController 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 SwiperController 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 // swiper自动播放时间间隔 AST#property_declaration#Left private swiperInterval : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 3500 AST#expression#Right ; AST#property_declaration#Right // swiper子组件切换动画时长 AST#property_declaration#Left private swiperDuration : 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 // swiper子组件与子组件间隙 AST#property_declaration#Left private swiperItemSpace : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 10 AST#expression#Right ; AST#property_declaration#Right AST#method_declaration#Left async aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { // 顶部安全高度适配 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left windowHight : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left window AST#expression#Right AST#await_expression#Right AST#expression#Right . getLastWindow 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#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 windowHight AST#expression#Right AST#await_expression#Right AST#expression#Right . setWindowLayoutFullScreen AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; 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 . topSafeHeight AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left px2vp AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowHight AST#expression#Right . getWindowAvoidArea AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . AvoidAreaType AST#member_expression#Right AST#expression#Right . TYPE_SYSTEM AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . 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#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right // TODO 知识点:初始化页面获取第一张图片的颜色 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left context = AST#expression#Left AST#call_expression#Left AST#expression#Left getContext AST#expression#Right AST#argument_list#Left ( AST#expression#Left this AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left resourceMgr : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left resourceManager . ResourceManager AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left context AST#expression#Right . resourceManager AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left fileData : AST#type_annotation#Left AST#primary_type#Left Uint8Array AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left resourceMgr AST#expression#Right AST#await_expression#Right AST#expression#Right . getMediaContent AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . imgData AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left buffer = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fileData AST#expression#Right . buffer AST#member_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left ArrayBuffer AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left imageSource : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left image . ImageSource 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 image AST#expression#Right . createImageSource AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left buffer AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left pixelMap : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left image . PixelMap AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#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#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // TODO 知识点:智能取色器接口使用,初始化背景色 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left effectKit AST#expression#Right . createColorPicker AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left pixelMap AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err AST#parameter#Right , AST#parameter#Left colorPicker AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left color = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left colorPicker AST#expression#Right . getMainColorSync 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 // 将取色器选取的color示例转换为十六进制颜色代码 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 . bgColor AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#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#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left "#" AST#expression#Right + AST#expression#Left color AST#expression#Right AST#binary_expression#Right AST#expression#Right . alpha AST#member_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 16 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left color AST#expression#Right AST#binary_expression#Right AST#expression#Right . red AST#member_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 16 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left color AST#expression#Right AST#binary_expression#Right AST#expression#Right . green AST#member_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 16 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left color AST#expression#Right AST#binary_expression#Right AST#expression#Right . blue AST#member_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 16 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Swiper ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . swiperController AST#member_expression#Right AST#expression#Right ) AST#container_content_body#Left { // TODO 高性能知识点:此处为了演示场景,数量只有4个,使用ForEach,真实场景列表数量较多的场景,推荐使用LazyForEach+组件复用+缓存列表项实现 AST#ui_control_flow#Left AST#for_each_statement#Left ForEach ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . imgData AST#member_expression#Right AST#expression#Right , AST#ui_builder_arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left Resource 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 Image ( AST#expression#Left item AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.effectKit_image_borderRadius' 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.integer.effectKit_image_margin_top' 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#ui_arrow_function_body#Right AST#ui_builder_arrow_function#Right ) AST#for_each_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.effectKit_swiper_width' 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 left AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.effectKit_swiper_padding_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.integer.effectKit_swiper_padding_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#Left . autoPlay ( AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . interval ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . swiperInterval AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . duration ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . swiperDuration AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . loop ( AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . itemSpace ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . swiperItemSpace AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . indicator ( AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ) // TODO 知识点:切换动画过程中获取图片平均颜色 AST#modifier_chain_expression#Left . onAnimationStart ( AST#expression#Left AST#arrow_function#Left async AST#parameter_list#Left ( AST#parameter#Left index AST#parameter#Right , AST#parameter#Left targetIndex AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left context = AST#expression#Left AST#call_expression#Left AST#expression#Left getContext AST#expression#Right AST#argument_list#Left ( AST#expression#Left this AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 获取resourceManager资源管理器 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left resourceMgr : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left resourceManager . ResourceManager AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left context AST#expression#Right . resourceManager AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left fileData : AST#type_annotation#Left AST#primary_type#Left Uint8Array AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left resourceMgr AST#expression#Right AST#await_expression#Right AST#expression#Right . getMediaContent AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . imgData AST#member_expression#Right AST#expression#Right [ AST#expression#Left targetIndex AST#expression#Right ] AST#subscript_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 // 获取图片的ArrayBuffer AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left buffer = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fileData AST#expression#Right . buffer AST#member_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left ArrayBuffer 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 // 创建imageSource AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left imageSource : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left image . ImageSource 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 image AST#expression#Right . createImageSource AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left buffer AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 创建pixelMap AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left pixelMap : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left image . PixelMap AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#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#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 effectKit AST#expression#Right . createColorPicker AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left pixelMap AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err AST#parameter#Right , AST#parameter#Left colorPicker AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { // 读取图像主色的颜色值,结果写入Color AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left color = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left colorPicker AST#expression#Right . getMainColorSync 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 animateTo AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left duration AST#property_name#Right : AST#expression#Left 500 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left curve AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Curve AST#expression#Right . Linear AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left iterations AST#property_name#Right : AST#expression#Left 1 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { // 将取色器选取的color示例转换为十六进制颜色代码 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 . bgColor AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#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#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left "#" AST#expression#Right + AST#expression#Left color AST#expression#Right AST#binary_expression#Right AST#expression#Right . alpha AST#member_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 16 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left color AST#expression#Right AST#binary_expression#Right AST#expression#Right . red AST#member_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 16 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left color AST#expression#Right AST#binary_expression#Right AST#expression#Right . green AST#member_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 16 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left color AST#expression#Right AST#binary_expression#Right AST#expression#Right . blue AST#member_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 16 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( e ) AST#block_statement#Left { } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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#resource_expression#Left $r ( AST#expression#Left 'app.string.effectKit_column_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.string.effectKit_column_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . linearGradient ( AST#expression#Left AST#object_literal#Left { // 渐变方向 AST#property_assignment#Left AST#property_name#Left direction AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left GradientDirection AST#expression#Right . Bottom AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , // 数组末尾元素占比小于1时,满足重复着色的效果 AST#property_assignment#Left AST#property_name#Left colors AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . bgColor AST#member_expression#Right AST#expression#Right , AST#expression#Left 0.0 AST#expression#Right ] AST#array_literal#Right AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . White AST#member_expression#Right AST#expression#Right , AST#expression#Left 0.5 AST#expression#Right ] AST#array_literal#Right AST#expression#Right ] AST#array_literal#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 top AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . topSafeHeight AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Component export struct MainPageComponent { @State imgData: Resource[] = [ $r('app.media.image4'), $r('app.media.image5'), $r('app.media.image6'), $r('app.media.image7') ]; @State bgColor: string = "#fffffff"; @State topSafeHeight: number = 0; private swiperController: SwiperController = new SwiperController(); private swiperInterval: number = 3500; private swiperDuration: number = 500; private swiperItemSpace: number = 10; async aboutToAppear() { let windowHight: window.Window = await window.getLastWindow(getContext(this)); await windowHight.setWindowLayoutFullScreen(true); this.topSafeHeight = px2vp(windowHight.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM).topRect.height) const context = getContext(this); const resourceMgr: resourceManager.ResourceManager = context.resourceManager; const fileData: Uint8Array = await resourceMgr.getMediaContent(this.imgData[0]); const buffer = fileData.buffer as ArrayBuffer; const imageSource: image.ImageSource = image.createImageSource(buffer); const pixelMap: image.PixelMap = await imageSource.createPixelMap(); effectKit.createColorPicker(pixelMap, (err, colorPicker) => { let color = colorPicker.getMainColorSync(); this.bgColor = "#" + color.alpha.toString(16) + color.red.toString(16) + color.green.toString(16) + color.blue.toString(16) }) } build() { Column() { Swiper(this.swiperController) { ForEach(this.imgData, (item: Resource) => { Image(item).borderRadius($r('app.integer.effectKit_image_borderRadius')) .margin({ top: $r('app.integer.effectKit_image_margin_top') }) }) } .width($r('app.string.effectKit_swiper_width')) .padding({ left: $r('app.integer.effectKit_swiper_padding_left'), right: $r('app.integer.effectKit_swiper_padding_right') }) .autoPlay(true) .interval(this.swiperInterval) .duration(this.swiperDuration) .loop(true) .itemSpace(this.swiperItemSpace) .indicator(false) .onAnimationStart(async (index, targetIndex) => { try { const context = getContext(this); const resourceMgr: resourceManager.ResourceManager = context.resourceManager; const fileData: Uint8Array = await resourceMgr.getMediaContent(this.imgData[targetIndex]); const buffer = fileData.buffer as ArrayBuffer; const imageSource: image.ImageSource = image.createImageSource(buffer); const pixelMap: image.PixelMap = await imageSource.createPixelMap(); effectKit.createColorPicker(pixelMap, (err, colorPicker) => { let color = colorPicker.getMainColorSync(); animateTo({ duration: 500, curve: Curve.Linear, iterations: 1 }, () => { this.bgColor = "#" + color.alpha.toString(16) + color.red.toString(16) + color.green.toString(16) + color.blue.toString(16); }) }) } catch (e) { } }) } .width($r('app.string.effectKit_column_width')) .height($r('app.string.effectKit_column_height')) .linearGradient({ direction: GradientDirection.Bottom, colors: [[this.bgColor, 0.0], [Color.White, 0.5]] }) .padding({ top: this.topSafeHeight }) } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/effectkit/src/main/ets/components/mainpage/MainPage.ets#L28-L130
5e5aa7894fb51df6869a3c192a168eadce5cf513
gitee
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
core/navigation/src/main/ets/NavigationParam.ets
arkts
@file 公共导航参数定义 @author Joker.X 商品 ID 参数
export interface GoodsIdParam { /** * 商品 ID */ goodsId: number; }
AST#export_declaration#Left export AST#interface_declaration#Left interface GoodsIdParam AST#object_type#Left { /** * 商品 ID */ AST#type_member#Left goodsId : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
export interface GoodsIdParam { goodsId: number; }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/navigation/src/main/ets/NavigationParam.ets#L9-L14
40936e9d8040ce255b06d09f137e257fbc36df20
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/fitfordarkmode/src/main/ets/view/FitForDarkMode.ets
arkts
FitForDarkModeComponent
字体设置透明度
@Preview @Component export struct FitForDarkModeComponent { @State banner: ResourceStr = ''; // @StorageProp + @Watch 获取并监听当前颜色模式 @StorageProp('currentColorMode') @Watch('onColorModeChange') currentMode: number = 0; // @Watch回调函数,监听颜色模式刷新状态变量 onColorModeChange(): void { this.banner = setBanner(this.currentMode); } // 在自定义组件生命周期aboutToAppear中,根据当前颜色模式刷新banner状态变量,切换不同的图片。 aboutToAppear(): void { const applicationContext = getContext(this).getApplicationContext(); applicationContext.setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); this.banner = setBanner(this.currentMode); } // 在自定义组件生命周期aboutToDisappear中,重置导航栏的背景色避免影响其它页面的导航栏为红色。 aboutToDisappear(): void { const applicationContext = getContext(this).getApplicationContext(); applicationContext.setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT); setStatusBar(ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT); } build() { Column() { Column({ space: COLUM_SPACE }) { Flex({ justifyContent: FlexAlign.SpaceBetween }) { Image($r("app.media.fit_for_dark_mode_logo")) .width($r("app.integer.fit_for_dark_mode_image_width")) .aspectRatio(IMAGE_ASPECT_RATIO) Image($r("app.media.fit_for_dark_mode_scan")) .width($r("app.integer.fit_for_dark_mode_image_width")) .aspectRatio(IMAGE_ASPECT_RATIO) .onClick(() => { promptAction.showToast({ message: $r("app.string.fit_for_dark_mode_mode_other_function") }); }) } .width('100%') .height($r("app.integer.fit_for_dark_mode_flex_height")) .margin({ top: $r("app.integer.fit_for_dark_mode_flex_margin_top") }) Row() { Image($r("app.media.fit_for_dark_mode_search")) .width($r("app.integer.fit_for_dark_mode_search_image_width")) .aspectRatio(IMAGE_ASPECT_RATIO) .margin({ left: $r("app.integer.fit_for_dark_mode_search_image_margin_left") }) // TODO: 知识点:UI组件颜色属性是固定颜色值,深浅模式颜色不变。 // 将Text直接设置成'#000000'固定色值 Text($r("app.string.fit_for_dark_mode_search_text")) .opacity(OPACITY) .fontColor($r("app.color.fit_for_dark_mode_black_font_color")) .margin({ left: $r("app.integer.fit_for_dark_mode_text_margin_left") }) } .width('100%') .height($r("app.integer.fit_for_dark_mode_row_height")) .backgroundColor($r("app.color.fit_for_dark_mode_search_bg_color")) .borderRadius($r("app.integer.fit_for_dark_mode_row_border_radius")) .onClick(() => { promptAction.showToast({ message: $r("app.string.fit_for_dark_mode_mode_other_function") }); }) } .padding({ left: $r("app.integer.fit_for_dark_mode_column_padding"), right: $r("app.integer.fit_for_dark_mode_column_padding") }) // TODO: 知识点:在resources目录下新增dark/element目录,创建深色模式color.json文件,设置深色模式UI组件颜色。(注意事项:颜色name必须相同) // 用资源ID方式设置Column背景色。(浅色模式色值为'#FA5A3C'、深色模式色值为'#000000') .backgroundColor($r("app.color.fit_for_dark_mode_column_bg_color")) .width('100%') .height($r("app.integer.fit_for_dark_mode_column_height")) Scroll() { Column() { Column() { // TODO: 知识点:在深浅模式下,UI布局或逻辑存在差异,采用AbilityStage.onConfigurationUpdate监听实现 Image(this.banner) .width("100%") .height($r("app.integer.fit_for_dark_mode_banner_height")) .borderRadius($r("app.integer.fit_for_dark_mode_banner_border_radius")) Text($r("app.string.fit_for_dark_mode_new_product_text")) .fontColor($r("app.color.fit_for_dark_mode_white_font_color")) .fontSize($r("app.integer.fit_for_dark_mode_new_goods_font")) .fontWeight(FontWeight.Bold) .height($r("app.integer.fit_for_dark_mode_new_goods_height")) .width('100%') .textAlign(TextAlign.Center) .padding({ top: $r("app.integer.fit_for_dark_mode_ew_goods_padding_top") }) } .backgroundColor($r("app.color.fit_for_dark_mode_column_bg_color")) .padding({ left: $r("app.integer.fit_for_dark_mode_column_padding"), right: $r("app.integer.fit_for_dark_mode_column_padding") }) .borderRadius({ bottomLeft: $r("app.integer.fit_for_dark_mode_column_border_radius"), bottomRight: $r("app.integer.fit_for_dark_mode_column_border_radius") }) // 引用产品列表组件 GoodsList() } } .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM]) .backgroundColor($r("app.color.fit_for_dark_mode_list_bg_color")) .width('100%') .height('100%') .layoutWeight(LAYOUT_WEIGHT) .scrollBar(BarState.Off) .align(Alignment.Top) } .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM]) .backgroundColor($r("app.color.fit_for_dark_mode_page_bg_color")) .width('100%') .height('100%') } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Preview AST#decorator#Right AST#decorator#Left @ Component AST#decorator#Right export struct FitForDarkModeComponent AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right banner : 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 // @StorageProp + @Watch 获取并监听当前颜色模式 AST#property_declaration#Left AST#decorator#Left @ StorageProp ( AST#expression#Left 'currentColorMode' AST#expression#Right ) AST#decorator#Right AST#decorator#Left @ Watch ( AST#expression#Left 'onColorModeChange' AST#expression#Right ) AST#decorator#Right currentMode : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right // @Watch回调函数,监听颜色模式刷新状态变量 AST#method_declaration#Left onColorModeChange 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 . banner AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left setBanner AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentMode 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#builder_function_body#Right AST#method_declaration#Right // 在自定义组件生命周期aboutToAppear中,根据当前颜色模式刷新banner状态变量,切换不同的图片。 AST#method_declaration#Left aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left applicationContext = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left getContext AST#expression#Right AST#argument_list#Left ( AST#expression#Left this AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . getApplicationContext AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right 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 applicationContext AST#expression#Right . setColorMode AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ConfigurationConstant AST#expression#Right . ColorMode AST#member_expression#Right AST#expression#Right . COLOR_MODE_NOT_SET AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . banner AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left setBanner AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentMode 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#method_declaration#Right // 在自定义组件生命周期aboutToDisappear中,重置导航栏的背景色避免影响其它页面的导航栏为红色。 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#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left applicationContext = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left getContext AST#expression#Right AST#argument_list#Left ( AST#expression#Left this AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . getApplicationContext AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right 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 applicationContext AST#expression#Right . setColorMode AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ConfigurationConstant AST#expression#Right . ColorMode AST#member_expression#Right AST#expression#Right . COLOR_MODE_LIGHT 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 setStatusBar AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ConfigurationConstant AST#expression#Right . ColorMode AST#member_expression#Right AST#expression#Right . COLOR_MODE_LIGHT 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#method_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left COLUM_SPACE 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 Flex ( AST#component_parameters#Left { AST#component_parameter#Left justifyContent : AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . SpaceBetween AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.media.fit_for_dark_mode_logo" 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.integer.fit_for_dark_mode_image_width" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . aspectRatio ( AST#expression#Left IMAGE_ASPECT_RATIO 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.fit_for_dark_mode_scan" 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.integer.fit_for_dark_mode_image_width" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . aspectRatio ( AST#expression#Left IMAGE_ASPECT_RATIO AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left promptAction AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.fit_for_dark_mode_mode_other_function" 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#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.fit_for_dark_mode_flex_height" 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.integer.fit_for_dark_mode_flex_margin_top" 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#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.fit_for_dark_mode_search" 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.integer.fit_for_dark_mode_search_image_width" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . aspectRatio ( AST#expression#Left IMAGE_ASPECT_RATIO 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.integer.fit_for_dark_mode_search_image_margin_left" 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 // TODO: 知识点:UI组件颜色属性是固定颜色值,深浅模式颜色不变。 // 将Text直接设置成'#000000'固定色值 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.fit_for_dark_mode_search_text" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . opacity ( AST#expression#Left OPACITY AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.color.fit_for_dark_mode_black_font_color" 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 left AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.fit_for_dark_mode_text_margin_left" 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#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.fit_for_dark_mode_row_height" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.color.fit_for_dark_mode_search_bg_color" 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.integer.fit_for_dark_mode_row_border_radius" 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#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left promptAction AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.fit_for_dark_mode_mode_other_function" 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#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . 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.integer.fit_for_dark_mode_column_padding" 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.integer.fit_for_dark_mode_column_padding" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) // TODO: 知识点:在resources目录下新增dark/element目录,创建深色模式color.json文件,设置深色模式UI组件颜色。(注意事项:颜色name必须相同) // 用资源ID方式设置Column背景色。(浅色模式色值为'#FA5A3C'、深色模式色值为'#000000') AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.color.fit_for_dark_mode_column_bg_color" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.fit_for_dark_mode_column_height" 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#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 Scroll ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { // TODO: 知识点:在深浅模式下,UI布局或逻辑存在差异,采用AbilityStage.onConfigurationUpdate监听实现 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . banner AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left "100%" AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.fit_for_dark_mode_banner_height" 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.integer.fit_for_dark_mode_banner_border_radius" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#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.fit_for_dark_mode_new_product_text" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.color.fit_for_dark_mode_white_font_color" 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.integer.fit_for_dark_mode_new_goods_font" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Bold AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.fit_for_dark_mode_new_goods_height" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . 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.integer.fit_for_dark_mode_ew_goods_padding_top" 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 . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.color.fit_for_dark_mode_column_bg_color" 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 left AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.fit_for_dark_mode_column_padding" 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.integer.fit_for_dark_mode_column_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#object_literal#Left { AST#property_assignment#Left AST#property_name#Left bottomLeft AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.fit_for_dark_mode_column_border_radius" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottomRight AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.fit_for_dark_mode_column_border_radius" 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#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left GoodsList ( ) 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#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . expandSafeArea ( AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left SafeAreaType AST#expression#Right . SYSTEM AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left SafeAreaEdge AST#expression#Right . BOTTOM AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.color.fit_for_dark_mode_list_bg_color" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left LAYOUT_WEIGHT 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#Left . align ( AST#expression#Left AST#member_expression#Left AST#expression#Left Alignment AST#expression#Right . Top AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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 . expandSafeArea ( AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left SafeAreaType AST#expression#Right . SYSTEM AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left SafeAreaEdge AST#expression#Right . BOTTOM AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.color.fit_for_dark_mode_page_bg_color" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '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#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Preview @Component export struct FitForDarkModeComponent { @State banner: ResourceStr = ''; @StorageProp('currentColorMode') @Watch('onColorModeChange') currentMode: number = 0; onColorModeChange(): void { this.banner = setBanner(this.currentMode); } aboutToAppear(): void { const applicationContext = getContext(this).getApplicationContext(); applicationContext.setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); this.banner = setBanner(this.currentMode); } aboutToDisappear(): void { const applicationContext = getContext(this).getApplicationContext(); applicationContext.setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT); setStatusBar(ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT); } build() { Column() { Column({ space: COLUM_SPACE }) { Flex({ justifyContent: FlexAlign.SpaceBetween }) { Image($r("app.media.fit_for_dark_mode_logo")) .width($r("app.integer.fit_for_dark_mode_image_width")) .aspectRatio(IMAGE_ASPECT_RATIO) Image($r("app.media.fit_for_dark_mode_scan")) .width($r("app.integer.fit_for_dark_mode_image_width")) .aspectRatio(IMAGE_ASPECT_RATIO) .onClick(() => { promptAction.showToast({ message: $r("app.string.fit_for_dark_mode_mode_other_function") }); }) } .width('100%') .height($r("app.integer.fit_for_dark_mode_flex_height")) .margin({ top: $r("app.integer.fit_for_dark_mode_flex_margin_top") }) Row() { Image($r("app.media.fit_for_dark_mode_search")) .width($r("app.integer.fit_for_dark_mode_search_image_width")) .aspectRatio(IMAGE_ASPECT_RATIO) .margin({ left: $r("app.integer.fit_for_dark_mode_search_image_margin_left") }) Text($r("app.string.fit_for_dark_mode_search_text")) .opacity(OPACITY) .fontColor($r("app.color.fit_for_dark_mode_black_font_color")) .margin({ left: $r("app.integer.fit_for_dark_mode_text_margin_left") }) } .width('100%') .height($r("app.integer.fit_for_dark_mode_row_height")) .backgroundColor($r("app.color.fit_for_dark_mode_search_bg_color")) .borderRadius($r("app.integer.fit_for_dark_mode_row_border_radius")) .onClick(() => { promptAction.showToast({ message: $r("app.string.fit_for_dark_mode_mode_other_function") }); }) } .padding({ left: $r("app.integer.fit_for_dark_mode_column_padding"), right: $r("app.integer.fit_for_dark_mode_column_padding") }) .backgroundColor($r("app.color.fit_for_dark_mode_column_bg_color")) .width('100%') .height($r("app.integer.fit_for_dark_mode_column_height")) Scroll() { Column() { Column() { Image(this.banner) .width("100%") .height($r("app.integer.fit_for_dark_mode_banner_height")) .borderRadius($r("app.integer.fit_for_dark_mode_banner_border_radius")) Text($r("app.string.fit_for_dark_mode_new_product_text")) .fontColor($r("app.color.fit_for_dark_mode_white_font_color")) .fontSize($r("app.integer.fit_for_dark_mode_new_goods_font")) .fontWeight(FontWeight.Bold) .height($r("app.integer.fit_for_dark_mode_new_goods_height")) .width('100%') .textAlign(TextAlign.Center) .padding({ top: $r("app.integer.fit_for_dark_mode_ew_goods_padding_top") }) } .backgroundColor($r("app.color.fit_for_dark_mode_column_bg_color")) .padding({ left: $r("app.integer.fit_for_dark_mode_column_padding"), right: $r("app.integer.fit_for_dark_mode_column_padding") }) .borderRadius({ bottomLeft: $r("app.integer.fit_for_dark_mode_column_border_radius"), bottomRight: $r("app.integer.fit_for_dark_mode_column_border_radius") }) GoodsList() } } .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM]) .backgroundColor($r("app.color.fit_for_dark_mode_list_bg_color")) .width('100%') .height('100%') .layoutWeight(LAYOUT_WEIGHT) .scrollBar(BarState.Off) .align(Alignment.Top) } .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM]) .backgroundColor($r("app.color.fit_for_dark_mode_page_bg_color")) .width('100%') .height('100%') } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/fitfordarkmode/src/main/ets/view/FitForDarkMode.ets#L39-L161
d0b9152e2790b22f76e0521c1b338389ffefc37e
gitee
zqaini002/YaoYaoLingXian.git
5095b12cbeea524a87c42d0824b1702978843d39
YaoYaoLingXian/entry/src/main/ets/services/ApiService.ets
arkts
用户登出 @returns 登出结果Promise
export async function logout(): Promise<ApiResponse<void>> { console.info('发起登出请求'); try { const response = await request<ApiResponse<void>>( RequestMethod.POST, '/auth/logout', EmptyParams ); console.info('登出响应:', JSON.stringify(response)); return response; } catch (error) { console.error('登出请求失败:', error); // 登出功能即使失败也应该允许用户登出 // 创建一个明确类型的响应对象 const mockResponse: ApiResponse<void> = { code: 200, message: '登出成功', data: undefined }; return mockResponse; } }
AST#export_declaration#Left export AST#function_declaration#Left async function logout 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#generic_type#Left ApiResponse 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#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info 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#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left response = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left request AST#expression#Right AST#await_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left ApiResponse 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#type_arguments#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left RequestMethod AST#expression#Right . POST AST#member_expression#Right AST#expression#Right , AST#expression#Left '/auth/logout' AST#expression#Right , AST#expression#Left EmptyParams 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 console AST#expression#Right . info 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 response 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 response 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#expression#Right , AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 登出功能即使失败也应该允许用户登出 // 创建一个明确类型的响应对象 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left mockResponse : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left ApiResponse 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#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left code AST#property_name#Right : AST#expression#Left 200 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 data AST#property_name#Right : AST#expression#Left undefined 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 mockResponse 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#function_declaration#Right AST#export_declaration#Right
export async function logout(): Promise<ApiResponse<void>> { console.info('发起登出请求'); try { const response = await request<ApiResponse<void>>( RequestMethod.POST, '/auth/logout', EmptyParams ); console.info('登出响应:', JSON.stringify(response)); return response; } catch (error) { console.error('登出请求失败:', error); const mockResponse: ApiResponse<void> = { code: 200, message: '登出成功', data: undefined }; return mockResponse; } }
https://github.com/zqaini002/YaoYaoLingXian.git/blob/5095b12cbeea524a87c42d0824b1702978843d39/YaoYaoLingXian/entry/src/main/ets/services/ApiService.ets#L1283-L1304
4b3c38a12ea9d4dbe90166435b2f77cd7c39c579
github
openharmony/xts_acts
5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686
ability/ability_runtime/startup/startupmanualhelp1/entry/src/main/ets/MainAbility/PageAbility4.ets
arkts
onCreate
Sample_009 -> Sample_010 -> Sample_009 -> Sample_011
onCreate(want:Want, launchParam: AbilityConstant.LaunchParam){ hilog.info(0x0000, 'PageAbility4 StartupTest', '%{public}s', 'Ability onCreate'); if (want.parameters && want.parameters?.keepAlive) { console.info('PageAbility4 StartupTest PageAbility4 keepAlive = true'); keepAlive = true; } if (want.parameters && want.parameters?.customConfig) { console.info('StartupTest PageAbility4 customConfig = true'); customConfig = true; } uiContext = this.context; let subscribeInfo: commonEventManager.CommonEventSubscribeInfo = { events: ['StartupSample_009', 'StartupSample_010', 'StartupSample_011', 'StartupTestDefaultConfig'], }; commonEventManager.createSubscriber(subscribeInfo).then(data => { console.info('StartupTest PageAbility4 createSubscriber success'); subscriber = data; commonEventManager.subscribe(subscriber, (err, data)=>{ console.info('StartupTest PageAbility4 receive event, data = ' + JSON.stringify(data)); let event = data.event; if (event === 'StartupSample_009') { startupSampleInit9 = true; startOrder.push(['startupSampleInit9']); let message: string; if (!customConfig) { message = '默认配置 StartupSample_009加载完毕'; } else { message = '自定义配置 StartupSample_009加载完毕'; } commonEventManager.publish('show_msg', { parameters:{ msg:message } },()=>{ console.info('StartupTest PageAbility4 send msg'); }) } if (event === 'StartupSample_010') { startupSampleInit10 = true; startOrder.push(['startupSampleInit10']); let message: string; if (!customConfig) { message = '默认配置 StartupSample_004加载完毕'; } else { message = '自定义配置 StartupSample_004加载完毕'; } commonEventManager.publish('show_msg', { parameters:{ msg:message } },()=>{ console.info('StartupTest PageAbility4 send msg'); }) } if (event === 'StartupSample_011') { startupSampleInit11 = true; startOrder.push(['startupSampleInit11']); let message: string; if (!customConfig) { message = '默认配置 StartupSample_005加载完毕'; } else { message = '自定义配置 StartupSample_005加载完毕'; } commonEventManager.publish('show_msg', { parameters:{ msg:message } },()=>{ console.info('StartupTest PageAbility4 send msg'); }) } if (event === 'StartupTestDefaultConfig') { startupDefaultConfig = true; let message: string; if (!customConfig) { message = '默认配置 配置监听到测试框架加载完毕'; } else { message = '自定义配置 配置监听到测试框架加载完毕'; } commonEventManager.publish('show_msg', { parameters:{ msg:message } },()=>{ console.info('StartupTest PageAbility4 send msg'); }) console.info('StartupTest PageAbility4 terminateSelfWithResult , result = true'); if (!keepAlive) { let startResult = false; if (startupSampleInit9 || startupSampleInit10 || startupSampleInit11) { startResult = true; } setTimeout(()=>{ uiContext?.terminateSelfWithResult({ resultCode: 0, want:{ parameters:{ 'startResult': startResult, 'startOrder': startOrder, 'code' :data.parameters?.error.code // 28800002 } } }) }, 2000) } } }) }).catch((error: BusinessError)=>{ console.info('StartupTest PageAbility4 createSubscriber failed, error=' + JSON.stringify(error)); }) }
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#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 'PageAbility4 StartupTest' AST#expression#Right , AST#expression#Left '%{public}s' 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#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left want AST#expression#Right . parameters AST#member_expression#Right AST#expression#Right && AST#expression#Left want AST#expression#Right AST#binary_expression#Right AST#expression#Right . parameters AST#member_expression#Right AST#expression#Right ?. keepAlive AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'PageAbility4 StartupTest PageAbility4 keepAlive = true' 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 keepAlive = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left want AST#expression#Right . parameters AST#member_expression#Right AST#expression#Right && AST#expression#Left want AST#expression#Right AST#binary_expression#Right AST#expression#Right . parameters AST#member_expression#Right AST#expression#Right ?. customConfig AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'StartupTest PageAbility4 customConfig = true' 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 customConfig = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left uiContext = AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . context 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 subscribeInfo : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left commonEventManager . CommonEventSubscribeInfo 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 events AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left 'StartupSample_009' AST#expression#Right , AST#expression#Left 'StartupSample_010' AST#expression#Right , AST#expression#Left 'StartupSample_011' AST#expression#Right , AST#expression#Left 'StartupTestDefaultConfig' AST#expression#Right ] AST#array_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 commonEventManager AST#expression#Right . createSubscriber AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left subscribeInfo 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 data => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'StartupTest PageAbility4 createSubscriber 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#assignment_expression#Left subscriber = AST#expression#Left data AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left commonEventManager AST#expression#Right . subscribe AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left subscriber AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err AST#parameter#Right , AST#parameter#Left data AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'StartupTest PageAbility4 receive event, data = ' 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 data 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 event = AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . event 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 event AST#expression#Right === AST#expression#Left 'StartupSample_009' 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 startupSampleInit9 = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left startOrder AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#array_literal#Left [ AST#expression#Left 'startupSampleInit9' AST#expression#Right ] AST#array_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left message : AST#type_annotation#Left AST#primary_type#Left string 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#unary_expression#Left ! AST#expression#Left customConfig AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left message = AST#expression#Left '默认配置 StartupSample_009加载完毕' 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 message = AST#expression#Left '自定义配置 StartupSample_009加载完毕' 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 commonEventManager AST#expression#Right . publish AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'show_msg' AST#expression#Right , AST#expression#Left AST#object_literal#Left { 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 msg AST#property_name#Right : AST#expression#Left message 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#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'StartupTest PageAbility4 send msg' 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#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left event AST#expression#Right === AST#expression#Left 'StartupSample_010' 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 startupSampleInit10 = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left startOrder AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#array_literal#Left [ AST#expression#Left 'startupSampleInit10' AST#expression#Right ] AST#array_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left message : AST#type_annotation#Left AST#primary_type#Left string 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#unary_expression#Left ! AST#expression#Left customConfig AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left message = AST#expression#Left '默认配置 StartupSample_004加载完毕' 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 message = AST#expression#Left '自定义配置 StartupSample_004加载完毕' 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 commonEventManager AST#expression#Right . publish AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'show_msg' AST#expression#Right , AST#expression#Left AST#object_literal#Left { 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 msg AST#property_name#Right : AST#expression#Left message 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#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'StartupTest PageAbility4 send msg' 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#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left event AST#expression#Right === AST#expression#Left 'StartupSample_011' 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 startupSampleInit11 = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left startOrder AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#array_literal#Left [ AST#expression#Left 'startupSampleInit11' AST#expression#Right ] AST#array_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left message : AST#type_annotation#Left AST#primary_type#Left string 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#unary_expression#Left ! AST#expression#Left customConfig AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left message = AST#expression#Left '默认配置 StartupSample_005加载完毕' 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 message = AST#expression#Left '自定义配置 StartupSample_005加载完毕' 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 commonEventManager AST#expression#Right . publish AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'show_msg' AST#expression#Right , AST#expression#Left AST#object_literal#Left { 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 msg AST#property_name#Right : AST#expression#Left message 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#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'StartupTest PageAbility4 send msg' 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#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left event AST#expression#Right === AST#expression#Left 'StartupTestDefaultConfig' 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 startupDefaultConfig = 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#variable_declaration#Left let AST#variable_declarator#Left message : AST#type_annotation#Left AST#primary_type#Left string 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#unary_expression#Left ! AST#expression#Left customConfig AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left message = AST#expression#Left '默认配置 配置监听到测试框架加载完毕' 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 message = 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#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left commonEventManager AST#expression#Right . publish AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'show_msg' AST#expression#Right , AST#expression#Left AST#object_literal#Left { 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 msg AST#property_name#Right : AST#expression#Left message 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#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'StartupTest PageAbility4 send msg' 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 console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'StartupTest PageAbility4 terminateSelfWithResult , result = true' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left keepAlive AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left startResult = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#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#binary_expression#Left AST#expression#Left startupSampleInit9 AST#expression#Right || AST#expression#Left startupSampleInit10 AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left startupSampleInit11 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 startResult = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left setTimeout 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 uiContext AST#expression#Right ?. terminateSelfWithResult 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 resultCode AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left want AST#property_name#Right : AST#expression#Left AST#object_literal#Left { 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 'startResult' AST#property_name#Right : AST#expression#Left startResult AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'startOrder' AST#property_name#Right : AST#expression#Left startOrder AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left 'code' 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 data AST#expression#Right . parameters AST#member_expression#Right AST#expression#Right ?. error AST#member_expression#Right AST#expression#Right . code AST#member_expression#Right AST#expression#Right AST#property_assignment#Right // 28800002 } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right , AST#expression#Left 2000 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#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . catch AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left error : AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'StartupTest PageAbility4 createSubscriber failed, 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#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
onCreate(want:Want, launchParam: AbilityConstant.LaunchParam){ hilog.info(0x0000, 'PageAbility4 StartupTest', '%{public}s', 'Ability onCreate'); if (want.parameters && want.parameters?.keepAlive) { console.info('PageAbility4 StartupTest PageAbility4 keepAlive = true'); keepAlive = true; } if (want.parameters && want.parameters?.customConfig) { console.info('StartupTest PageAbility4 customConfig = true'); customConfig = true; } uiContext = this.context; let subscribeInfo: commonEventManager.CommonEventSubscribeInfo = { events: ['StartupSample_009', 'StartupSample_010', 'StartupSample_011', 'StartupTestDefaultConfig'], }; commonEventManager.createSubscriber(subscribeInfo).then(data => { console.info('StartupTest PageAbility4 createSubscriber success'); subscriber = data; commonEventManager.subscribe(subscriber, (err, data)=>{ console.info('StartupTest PageAbility4 receive event, data = ' + JSON.stringify(data)); let event = data.event; if (event === 'StartupSample_009') { startupSampleInit9 = true; startOrder.push(['startupSampleInit9']); let message: string; if (!customConfig) { message = '默认配置 StartupSample_009加载完毕'; } else { message = '自定义配置 StartupSample_009加载完毕'; } commonEventManager.publish('show_msg', { parameters:{ msg:message } },()=>{ console.info('StartupTest PageAbility4 send msg'); }) } if (event === 'StartupSample_010') { startupSampleInit10 = true; startOrder.push(['startupSampleInit10']); let message: string; if (!customConfig) { message = '默认配置 StartupSample_004加载完毕'; } else { message = '自定义配置 StartupSample_004加载完毕'; } commonEventManager.publish('show_msg', { parameters:{ msg:message } },()=>{ console.info('StartupTest PageAbility4 send msg'); }) } if (event === 'StartupSample_011') { startupSampleInit11 = true; startOrder.push(['startupSampleInit11']); let message: string; if (!customConfig) { message = '默认配置 StartupSample_005加载完毕'; } else { message = '自定义配置 StartupSample_005加载完毕'; } commonEventManager.publish('show_msg', { parameters:{ msg:message } },()=>{ console.info('StartupTest PageAbility4 send msg'); }) } if (event === 'StartupTestDefaultConfig') { startupDefaultConfig = true; let message: string; if (!customConfig) { message = '默认配置 配置监听到测试框架加载完毕'; } else { message = '自定义配置 配置监听到测试框架加载完毕'; } commonEventManager.publish('show_msg', { parameters:{ msg:message } },()=>{ console.info('StartupTest PageAbility4 send msg'); }) console.info('StartupTest PageAbility4 terminateSelfWithResult , result = true'); if (!keepAlive) { let startResult = false; if (startupSampleInit9 || startupSampleInit10 || startupSampleInit11) { startResult = true; } setTimeout(()=>{ uiContext?.terminateSelfWithResult({ resultCode: 0, want:{ parameters:{ 'startResult': startResult, 'startOrder': startOrder, 'code' :data.parameters?.error.code } } }) }, 2000) } } }) }).catch((error: BusinessError)=>{ console.info('StartupTest PageAbility4 createSubscriber failed, error=' + JSON.stringify(error)); }) }
https://github.com/openharmony/xts_acts/blob/5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686/ability/ability_runtime/startup/startupmanualhelp1/entry/src/main/ets/MainAbility/PageAbility4.ets#L41-L153
9a7c5d17334511848d2ceeef1f702dd0db002cc2
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_web/src/main/ets/arkweb/ArkJsObject.ets
arkts
clearWebCacheEasy
清除Web缓存
clearWebCacheEasy() { try { this.controller?.removeCache(true); this.controller?.clearHistory(); this.controller?.clearMatches(); this.controller?.clearSslCache(); this.controller?.clearClientAuthenticationCache(); } catch (e) { let err = e as BusinessError; Tools.logError("clearWebCache-异常: " + err.message); } }
AST#method_declaration#Left clearWebCacheEasy AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . controller AST#member_expression#Right AST#expression#Right ?. removeCache AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . controller AST#member_expression#Right AST#expression#Right ?. clearHistory AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . controller AST#member_expression#Right AST#expression#Right ?. clearMatches AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . controller AST#member_expression#Right AST#expression#Right ?. clearSslCache AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . controller AST#member_expression#Right AST#expression#Right ?. clearClientAuthenticationCache AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( e ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left err = AST#expression#Left AST#as_expression#Left AST#expression#Left e 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 Tools AST#expression#Right . logError AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left "clearWebCache-异常: " AST#expression#Right + AST#expression#Left err AST#expression#Right AST#binary_expression#Right AST#expression#Right . message AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
clearWebCacheEasy() { try { this.controller?.removeCache(true); this.controller?.clearHistory(); this.controller?.clearMatches(); this.controller?.clearSslCache(); this.controller?.clearClientAuthenticationCache(); } catch (e) { let err = e as BusinessError; Tools.logError("clearWebCache-异常: " + err.message); } }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_web/src/main/ets/arkweb/ArkJsObject.ets#L99-L110
fa27468ee3c6868825c7c361fb482c3c80d46787
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/BasicFeature/Connectivity/StageSocket/entry/src/main/ets/socket/TlsSocket.ets
arkts
createSocket
创建Socket @param localIp @param port
async createSocket(localIp: string, port: number): Promise<boolean> { Logger.info(`${TAG} tls bind localIp: ${localIp}`); try { if (this.tlsSocket) { await this.closeSocket(); } this.tlsSocket = socket.constructTLSSocketInstance(); await this.tlsSocket.bind({ address: localIp, port: port, family: 1, }); Logger.info(`${TAG} tls bind sucess`); return true; } catch (e) { Logger.error(`${TAG} tls bind error ${JSON.stringify(e)}}`); } return false; }
AST#method_declaration#Left async createSocket AST#parameter_list#Left ( AST#parameter#Left localIp : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left port : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left 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#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#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left TAG AST#expression#Right } AST#template_substitution#Right tls bind localIp: AST#template_substitution#Left $ { AST#expression#Left localIp 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#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 . tlsSocket AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . closeSocket AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . tlsSocket AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left socket AST#expression#Right . constructTLSSocketInstance AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 . tlsSocket AST#member_expression#Right AST#expression#Right . bind 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 address AST#property_name#Right : AST#expression#Left localIp AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left port AST#property_name#Right : AST#expression#Left port AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left family AST#property_name#Right : AST#expression#Left 1 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 Logger AST#expression#Right . info 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 TAG AST#expression#Right } AST#template_substitution#Right tls bind sucess ` 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#catch_clause#Left catch ( e ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left TAG AST#expression#Right } AST#template_substitution#Right tls bind error 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 e AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right } ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right AST#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#method_declaration#Right
async createSocket(localIp: string, port: number): Promise<boolean> { Logger.info(`${TAG} tls bind localIp: ${localIp}`); try { if (this.tlsSocket) { await this.closeSocket(); } this.tlsSocket = socket.constructTLSSocketInstance(); await this.tlsSocket.bind({ address: localIp, port: port, family: 1, }); Logger.info(`${TAG} tls bind sucess`); return true; } catch (e) { Logger.error(`${TAG} tls bind error ${JSON.stringify(e)}}`); } return false; }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/BasicFeature/Connectivity/StageSocket/entry/src/main/ets/socket/TlsSocket.ets#L101-L121
825f78412b6e4b1474b493fd40ee46f76de0cda4
gitee
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
ETSUI/OHLayoutAlign/entry/src/main/ets/view/FlexMainAlignRadioList.ets
arkts
FlexMainAlignRadioList
Set Main Alignment in Flex
@Component export struct FlexMainAlignRadioList { private flexModuleList: ContainerModuleItem[] = getFlexModuleList(); private groupName: string = this.flexModuleList[1].groupName; private moduleName: Resource = this.flexModuleList[1].moduleName; private radioList: Array<string> = this.flexModuleList[1].attributeList; build() { Column({ space: MARGIN_FONT_SIZE_SPACE.FIRST_MARGIN }) { Row() { Text(this.moduleName) .fontSize(MARGIN_FONT_SIZE_SPACE.FOURTH_MARGIN) } .margin({ left: MARGIN_FONT_SIZE_SPACE.SECOND_MARGIN }) Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween, wrap: FlexWrap.NoWrap }) { ForEach(this.radioList, (item: string, index: number | undefined) => { MainAlignRadioItem({ textName: item, groupName: this.groupName, isChecked: index === 0 ? true : false }) .margin({ right: MARGIN_FONT_SIZE_SPACE.COMMON_MARGIN }) }, (item: string) => JSON.stringify(item)) } .width(ALL_PERCENT) .height(MARGIN_FONT_SIZE_SPACE.SEVENTH_MARGIN) } .width(ALL_PERCENT) .justifyContent(FlexAlign.Start) .alignItems(HorizontalAlign.Start) } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct FlexMainAlignRadioList AST#component_body#Left { AST#property_declaration#Left private flexModuleList : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left ContainerModuleItem [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left getFlexModuleList AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private groupName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . flexModuleList AST#member_expression#Right AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . groupName AST#member_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private moduleName : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . flexModuleList AST#member_expression#Right AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . moduleName AST#member_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private radioList : 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#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . flexModuleList AST#member_expression#Right AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . attributeList 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#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left AST#member_expression#Left AST#expression#Left MARGIN_FONT_SIZE_SPACE AST#expression#Right . FIRST_MARGIN AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . moduleName AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#member_expression#Left AST#expression#Left MARGIN_FONT_SIZE_SPACE AST#expression#Right . FOURTH_MARGIN 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 . 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#member_expression#Left AST#expression#Left MARGIN_FONT_SIZE_SPACE AST#expression#Right . SECOND_MARGIN 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#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Flex ( AST#component_parameters#Left { AST#component_parameter#Left direction : AST#expression#Left AST#member_expression#Left AST#expression#Left FlexDirection AST#expression#Right . Row AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left justifyContent : AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . SpaceBetween AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left wrap : AST#expression#Left AST#member_expression#Left AST#expression#Left FlexWrap AST#expression#Right . NoWrap AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#ui_control_flow#Left AST#for_each_statement#Left ForEach ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . radioList AST#member_expression#Right AST#expression#Right , AST#ui_builder_arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left index : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left number AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#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 MainAlignRadioItem ( AST#component_parameters#Left { AST#component_parameter#Left textName : AST#expression#Left item AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left groupName : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . groupName AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left isChecked : AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#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 right AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left MARGIN_FONT_SIZE_SPACE AST#expression#Right . COMMON_MARGIN 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#ui_arrow_function_body#Right AST#ui_builder_arrow_function#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_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 . width ( AST#expression#Left ALL_PERCENT AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left MARGIN_FONT_SIZE_SPACE AST#expression#Right . SEVENTH_MARGIN 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 . width ( AST#expression#Left ALL_PERCENT 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#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#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Component export struct FlexMainAlignRadioList { private flexModuleList: ContainerModuleItem[] = getFlexModuleList(); private groupName: string = this.flexModuleList[1].groupName; private moduleName: Resource = this.flexModuleList[1].moduleName; private radioList: Array<string> = this.flexModuleList[1].attributeList; build() { Column({ space: MARGIN_FONT_SIZE_SPACE.FIRST_MARGIN }) { Row() { Text(this.moduleName) .fontSize(MARGIN_FONT_SIZE_SPACE.FOURTH_MARGIN) } .margin({ left: MARGIN_FONT_SIZE_SPACE.SECOND_MARGIN }) Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween, wrap: FlexWrap.NoWrap }) { ForEach(this.radioList, (item: string, index: number | undefined) => { MainAlignRadioItem({ textName: item, groupName: this.groupName, isChecked: index === 0 ? true : false }) .margin({ right: MARGIN_FONT_SIZE_SPACE.COMMON_MARGIN }) }, (item: string) => JSON.stringify(item)) } .width(ALL_PERCENT) .height(MARGIN_FONT_SIZE_SPACE.SEVENTH_MARGIN) } .width(ALL_PERCENT) .justifyContent(FlexAlign.Start) .alignItems(HorizontalAlign.Start) } }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/ETSUI/OHLayoutAlign/entry/src/main/ets/view/FlexMainAlignRadioList.ets#L23-L56
e59fc29e272bc5b0f4a2589a0471025b92296c05
gitee
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
Media/ImageEdit/entry/src/main/ets/viewModel/CropShow.ets
arkts
getImageRect
Get image rect. @returns
getImageRect(): RectF { let image = new RectF(); image.set(this.imageRect.left, this.imageRect.top, this.imageRect.right, this.imageRect.bottom); return image; }
AST#method_declaration#Left getImageRect AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left RectF AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left image = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left RectF 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 image AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . imageRect AST#member_expression#Right AST#expression#Right . left AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . imageRect AST#member_expression#Right AST#expression#Right . top AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . imageRect AST#member_expression#Right AST#expression#Right . right AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . imageRect AST#member_expression#Right AST#expression#Right . bottom AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left image AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
getImageRect(): RectF { let image = new RectF(); image.set(this.imageRect.left, this.imageRect.top, this.imageRect.right, this.imageRect.bottom); return image; }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Media/ImageEdit/entry/src/main/ets/viewModel/CropShow.ets#L104-L108
f89ee94743650654dbc067cff711911cbe142153
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/common/utils/LunarCalendar.ets
arkts
getSpringFestivalDate
获取指定年份的春节日期 @param year 农历年份 @returns 春节的公历日期
static getSpringFestivalDate(year: number): SolarDate | null { return LunarCalendar.lunarToSolar(year, 1, 1, false); }
AST#method_declaration#Left static getSpringFestivalDate AST#parameter_list#Left ( AST#parameter#Left year : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left SolarDate AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LunarCalendar AST#expression#Right . lunarToSolar AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left year AST#expression#Right , AST#expression#Left 1 AST#expression#Right , AST#expression#Left 1 AST#expression#Right , AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static getSpringFestivalDate(year: number): SolarDate | null { return LunarCalendar.lunarToSolar(year, 1, 1, false); }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/utils/LunarCalendar.ets#L675-L677
724f49f7d5ae5b72398017ff7643169c9b6d9270
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/BasicFeature/Media/Camera/entry/src/main/ets/pages/Index.ets
arkts
aboutToAppear
Entry initialization function
async aboutToAppear() { await this.requestPermissionsFn(); let mDisplay = display.getDefaultDisplaySync(); this.screenWidth = px2vp(mDisplay.width); this.screenHeight = px2vp(mDisplay.height); this.initXComponentSize(); }
AST#method_declaration#Left async aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . requestPermissionsFn 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#variable_declaration#Left let AST#variable_declarator#Left mDisplay = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left display AST#expression#Right . getDefaultDisplaySync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . screenWidth AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left px2vp AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left mDisplay AST#expression#Right . width AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . screenHeight AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left px2vp AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left mDisplay AST#expression#Right . height AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . initXComponentSize 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#method_declaration#Right
async aboutToAppear() { await this.requestPermissionsFn(); let mDisplay = display.getDefaultDisplaySync(); this.screenWidth = px2vp(mDisplay.width); this.screenHeight = px2vp(mDisplay.height); this.initXComponentSize(); }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/BasicFeature/Media/Camera/entry/src/main/ets/pages/Index.ets#L101-L107
083a0424d59bb4e2e284d11cde72f786570ba756
gitee
openharmony/interface_sdk-js
c349adc73e2ec1f61f6fca489b5af059e3ed6999
api/@ohos.file.RecentPhotoComponent.d.ets
arkts
RecentPhotoComponent
Declare struct RecentPhotoComponent @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core @atomicservice @since 12
@Component export declare struct RecentPhotoComponent { /** * recentPhotoOptions * * @type { ?recentPhotoOptions } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 12 */ recentPhotoOptions?: RecentPhotoOptions; /** * Callback when check whether photos or videos exists * * @type { ?function } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 12 */ onRecentPhotoCheckResult?: RecentPhotoCheckResultCallback; /** * Callback when select photos or videos * * @type { ?function } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 12 */ onRecentPhotoClick: RecentPhotoClickCallback; /** * Callback when check whether photos or videos exists and return the recent photo info * * @type { ?function } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 13 */ onRecentPhotoCheckInfo?: RecentPhotoCheckInfoCallback; }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export AST#ERROR#Left declare AST#ERROR#Right struct RecentPhotoComponent AST#component_body#Left { /** * recentPhotoOptions * * @type { ?recentPhotoOptions } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 12 */ AST#property_declaration#Left recentPhotoOptions ? : AST#type_annotation#Left AST#primary_type#Left RecentPhotoOptions AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Callback when check whether photos or videos exists * * @type { ?function } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 12 */ AST#property_declaration#Left onRecentPhotoCheckResult ? : AST#type_annotation#Left AST#primary_type#Left RecentPhotoCheckResultCallback AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Callback when select photos or videos * * @type { ?function } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 12 */ AST#property_declaration#Left onRecentPhotoClick : AST#type_annotation#Left AST#primary_type#Left RecentPhotoClickCallback AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Callback when check whether photos or videos exists and return the recent photo info * * @type { ?function } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 13 */ AST#property_declaration#Left onRecentPhotoCheckInfo ? : AST#type_annotation#Left AST#primary_type#Left RecentPhotoCheckInfoCallback AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Component export declare struct RecentPhotoComponent { recentPhotoOptions?: RecentPhotoOptions; onRecentPhotoCheckResult?: RecentPhotoCheckResultCallback; onRecentPhotoClick: RecentPhotoClickCallback; onRecentPhotoCheckInfo?: RecentPhotoCheckInfoCallback; }
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.file.RecentPhotoComponent.d.ets#L31-L72
15edc56662c355dfec6a110f1def31f5152d78e4
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/foldablescreencases/src/main/ets/pages/MusicPlayerPage.ets
arkts
stackStyle
通用样式
@Styles stackStyle() { .height("100%") .width("100%") .backgroundImage(this.viewModel.curMusicModel?.coverRes) .backgroundImageSize(ImageSize.Cover) .backgroundImagePosition(Alignment.Center) .backgroundBlurStyle(BlurStyle.BACKGROUND_THIN) }
AST#method_declaration#Left AST#decorator#Left @ Styles AST#decorator#Right stackStyle AST#parameter_list#Left ( ) AST#parameter_list#Right AST#extend_function_body#Left { AST#modifier_chain_expression#Left . height ( AST#expression#Left "100%" AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left "100%" 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . viewModel AST#member_expression#Right AST#expression#Right . curMusicModel AST#member_expression#Right AST#expression#Right ?. coverRes AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundImageSize ( AST#expression#Left AST#member_expression#Left AST#expression#Left ImageSize AST#expression#Right . Cover AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundImagePosition ( AST#expression#Left AST#member_expression#Left AST#expression#Left Alignment AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundBlurStyle ( AST#expression#Left AST#member_expression#Left AST#expression#Left BlurStyle AST#expression#Right . BACKGROUND_THIN 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#extend_function_body#Right AST#method_declaration#Right
@Styles stackStyle() { .height("100%") .width("100%") .backgroundImage(this.viewModel.curMusicModel?.coverRes) .backgroundImageSize(ImageSize.Cover) .backgroundImagePosition(Alignment.Center) .backgroundBlurStyle(BlurStyle.BACKGROUND_THIN) }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/foldablescreencases/src/main/ets/pages/MusicPlayerPage.ets#L46-L54
9d1b8d5d7be6cda2648bad3859f1a4995ea2aed5
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/clickanimation/src/main/ets/model/ClickIconDataModel.ets
arkts
ClickIconItem 点击出现的图标项。 包含唯一标识符、图标的资源引用以及其在界面上的位置信息。
export interface ClickIconItem { id: string; // 图标唯一标识 icon: Resource; // 图标资源 position: Position; // 图标位置 }
AST#export_declaration#Left export AST#interface_declaration#Left interface ClickIconItem AST#object_type#Left { AST#type_member#Left id : 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 icon : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; // 图标资源 AST#type_member#Left position : AST#type_annotation#Left AST#primary_type#Left Position 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 ClickIconItem { id: string; icon: Resource; position: Position; }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/clickanimation/src/main/ets/model/ClickIconDataModel.ets#L22-L26
217f44286eac0090de33b0b57ef11f5e8db1f47a
gitee
openharmony/developtools_profiler
73d26bb5acfcafb2b1f4f94ead5640241d1e5f73
host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/highlight/ChartHighlighter.ets
arkts
getValsForTouch
Returns a recyclable MPPointD instance. Returns the corresponding xPos for a given touch-position in pixels. @param x @param y @return
protected getValsForTouch(x: number, y: number): MPPointD { // take any transformer to determine the x-axis value var pos: MPPointD = this.mChart.getTransformer(AxisDependency.LEFT).getValuesByTouchPoint(x, y); return pos; }
AST#method_declaration#Left protected getValsForTouch AST#parameter_list#Left ( AST#parameter#Left x : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left y : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left MPPointD AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { // take any transformer to determine the x-axis value AST#statement#Left AST#variable_declaration#Left var AST#variable_declarator#Left pos : AST#type_annotation#Left AST#primary_type#Left MPPointD AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mChart AST#member_expression#Right AST#expression#Right . getTransformer AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AxisDependency AST#expression#Right . LEFT AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . getValuesByTouchPoint AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left x AST#expression#Right , AST#expression#Left y AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left pos AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
protected getValsForTouch(x: number, y: number): MPPointD { var pos: MPPointD = this.mChart.getTransformer(AxisDependency.LEFT).getValuesByTouchPoint(x, y); return pos; }
https://github.com/openharmony/developtools_profiler/blob/73d26bb5acfcafb2b1f4f94ead5640241d1e5f73/host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/highlight/ChartHighlighter.ets#L61-L65
b5aa7dc94155f17d7a9900adbe4882e02cb651d8
gitee
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_ui/src/main/ets/ui/base/NotificationUtil.ets
arkts
authorizeNotification
添加跳转设置权限开启通知 https://developer.huawei.com/consumer/cn/forum/topic/0208150584794898034 校验是否已授权通知服务 @param callBack 回调函数 @returns
static async authorizeNotification(callBack: (index: number) => void): Promise<void> { //判断用户是否授权通知服务 let isAuth = await notificationManager.isNotificationEnabled(); //true为授权 if (!isAuth) { //未授权,尝试拉起授权 notificationManager.requestEnableNotification(getContext() as common.UIAbilityContext, (err: Base.BusinessError) => { if (err) { callBack(-1); } else { callBack(1); } }) } else { callBack(1); } }
AST#method_declaration#Left static async authorizeNotification AST#parameter_list#Left ( AST#parameter#Left callBack : AST#type_annotation#Left AST#function_type#Left 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#function_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { //判断用户是否授权通知服务 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left isAuth = 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 notificationManager AST#expression#Right AST#await_expression#Right AST#expression#Right . isNotificationEnabled 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 //true为授权 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left isAuth AST#expression#Right AST#unary_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 notificationManager AST#expression#Right . requestEnableNotification AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left getContext AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . UIAbilityContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left Base . BusinessError AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left err AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left callBack AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#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 callBack AST#expression#Right AST#argument_list#Left ( AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#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 else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left callBack AST#expression#Right AST#argument_list#Left ( AST#expression#Left 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
static async authorizeNotification(callBack: (index: number) => void): Promise<void> { let isAuth = await notificationManager.isNotificationEnabled(); if (!isAuth) { notificationManager.requestEnableNotification(getContext() as common.UIAbilityContext, (err: Base.BusinessError) => { if (err) { callBack(-1); } else { callBack(1); } }) } else { callBack(1); } }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_ui/src/main/ets/ui/base/NotificationUtil.ets#L39-L56
e2f1f6ee66e848fdfc82f0e83d43fa9bdc600a23
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/Solutions/Shopping/OrangeShopping/feature/navigationHome/src/main/ets/components/feature/EmitterClass.ets
arkts
showEventsDialog
单次订阅回调
public showEventsDialog(callback: () => void): void { let dialogShowEventsId: EventsId = new EventsId(EmitterConst.DIALOG_EVENT_ID); let dialogShowEventsData: EventsData = new EventsData(new Data(EmitterConst.DIALOG_EVENT_ID)); // 单次订阅事件--广告 emitter.once(dialogShowEventsId, callback); // 事件发布 emitter.emit(dialogShowEventsId, dialogShowEventsData); }
AST#method_declaration#Left public showEventsDialog AST#parameter_list#Left ( AST#parameter#Left callback : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#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 dialogShowEventsId : AST#type_annotation#Left AST#primary_type#Left EventsId 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 EventsId AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left EmitterConst AST#expression#Right . DIALOG_EVENT_ID 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 dialogShowEventsData : AST#type_annotation#Left AST#primary_type#Left EventsData 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 EventsData 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 Data AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left EmitterConst AST#expression#Right . DIALOG_EVENT_ID AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#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 emitter AST#expression#Right . once AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left dialogShowEventsId AST#expression#Right , AST#expression#Left callback AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#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 emitter AST#expression#Right . emit AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left dialogShowEventsId AST#expression#Right , AST#expression#Left dialogShowEventsData 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
public showEventsDialog(callback: () => void): void { let dialogShowEventsId: EventsId = new EventsId(EmitterConst.DIALOG_EVENT_ID); let dialogShowEventsData: EventsData = new EventsData(new Data(EmitterConst.DIALOG_EVENT_ID)); emitter.once(dialogShowEventsId, callback); emitter.emit(dialogShowEventsId, dialogShowEventsData); }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/Solutions/Shopping/OrangeShopping/feature/navigationHome/src/main/ets/components/feature/EmitterClass.ets#L47-L54
e15a4a6bc2bc3a61610f74fb4de1cb3d171dca7b
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/BasicFeature/Connectivity/StageSocket/entry/src/main/ets/components/ToolComponent.ets
arkts
功能数组 暂只有语音通话
build() { Row() { ForEach(this.toolArray, (item: ToolData, index) => { Button() { Image(item.getImgResource()) .width(40) .height(40) .objectFit(ImageFit.Contain) } .width(100) .height(100) .borderRadius(10) .type(ButtonType.Normal) .backgroundColor(Color.White) .margin({ left: 10 }) .onClick(() => { let want: Want = { bundleName: item.getBundleName(), abilityName: item.getAbilityName(), parameters: item.getParameters() }; AppStorage.setOrCreate('indexMsg', Constants.START_ABILITY_EVENT_ANSWER); AppStorage.setOrCreate('indexMsg', 'clear'); startAbility(want); }) }, (item: ToolData) => JSON.stringify(item)) } .width('100%') .height('99%') .margin(10) .alignItems(VerticalAlign.Top) }
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#ui_control_flow#Left AST#for_each_statement#Left ForEach ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . toolArray AST#member_expression#Right AST#expression#Right , AST#ui_builder_arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left ToolData AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left index 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 Button ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . getImgResource AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 40 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 40 AST#expression#Right ) AST#modifier_chain_expression#Left . objectFit ( AST#expression#Left AST#member_expression#Left AST#expression#Left ImageFit AST#expression#Right . Contain AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 100 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 100 AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 10 AST#expression#Right ) AST#modifier_chain_expression#Left . type ( AST#expression#Left AST#member_expression#Left AST#expression#Left ButtonType AST#expression#Right . Normal AST#member_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 . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 10 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#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 bundleName AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . getBundleName AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left abilityName AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . getAbilityName AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left parameters AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . getParameters 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#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 'indexMsg' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . START_ABILITY_EVENT_ANSWER 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 AppStorage AST#expression#Right . setOrCreate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'indexMsg' AST#expression#Right , AST#expression#Left 'clear' 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 startAbility AST#expression#Right AST#argument_list#Left ( AST#expression#Left want AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#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 ToolData 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 . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '99%' AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left 10 AST#expression#Right ) AST#modifier_chain_expression#Left . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left VerticalAlign AST#expression#Right . Top 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#build_body#Right AST#build_method#Right
build() { Row() { ForEach(this.toolArray, (item: ToolData, index) => { Button() { Image(item.getImgResource()) .width(40) .height(40) .objectFit(ImageFit.Contain) } .width(100) .height(100) .borderRadius(10) .type(ButtonType.Normal) .backgroundColor(Color.White) .margin({ left: 10 }) .onClick(() => { let want: Want = { bundleName: item.getBundleName(), abilityName: item.getAbilityName(), parameters: item.getParameters() }; AppStorage.setOrCreate('indexMsg', Constants.START_ABILITY_EVENT_ANSWER); AppStorage.setOrCreate('indexMsg', 'clear'); startAbility(want); }) }, (item: ToolData) => JSON.stringify(item)) } .width('100%') .height('99%') .margin(10) .alignItems(VerticalAlign.Top) }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/BasicFeature/Connectivity/StageSocket/entry/src/main/ets/components/ToolComponent.ets#L25-L56
5004011d75ffece0e1097b61dea18f90c0efc286
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/common/routermodule/src/main/ets/interceptor/Interceptor.ets
arkts
Navigation路由拦截: 如何封装: 1、在路由模块增加路由拦截器interceptor.ets,定义拦截容器、注册方法和公共拦截逻辑。 2、当点击本案例时,触发在路由模块的动态路由.pushUri()中的interceptor的公共拦截方法(此处需动态路由完成加载后执行否则首次路由拦截失败)。 3、子模块中定义业务具体拦截逻辑,做具体的拦截实现:通过routerInfo判断目的地为"我的页面"时判断登录状态是"未登录",此时执行跳转到登录页并返回true给拦截容器list(告知需拦截),已登录返回false,放行。并且注册到拦截器容器list中 4、拦截器获取拦截容器list中所有注册过的子模块的拦截函数,如果子模块拦截函数返回true,即需要拦截,否则放行。 5、通过循环拦截容器list得到返回true时通知动态路由不再继续跳转, 否则返回false,通知动态路由继续执行跳转,跳转到我的页面。 6、在登录页点击:手机号码一键登录后,登陆成功,登陆状态置为true,且跳转到主页。 7、详情页中点击:注销登录,登录状态置为false,退出登录。 Navigation参考文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V2/arkts-navigation-navigation-0000001453365116-V2 定义拦截实现接口 @param routerInfo 需要拦截的路由名 @param param 路由参数
export interface InterceptorExecute { executeFunction(appUri: string, param?: string): boolean; }
AST#export_declaration#Left export AST#interface_declaration#Left interface InterceptorExecute AST#object_type#Left { AST#type_member#Left executeFunction AST#parameter_list#Left ( AST#parameter#Left appUri : 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 string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
export interface InterceptorExecute { executeFunction(appUri: string, param?: string): boolean; }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/common/routermodule/src/main/ets/interceptor/Interceptor.ets#L35-L37
4d08b87290e7afc25359f5d06f89bc5336b46ba1
gitee