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
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
ETSUI/SwiperArkTS/entry/src/main/ets/view/common/TopBar.ets
arkts
TopBar
TopBar component.
@Component export struct TopBar { // Double binding of index values to achieve linkage effect. @Link index: number; private tabArray: Array<TopBarItem> = initializeOnStartup(); build() { Row({ space: CommonConstants.SPACE_TOP_BAR }) { ForEach(this.tabArray, (item: TopBarItem) => { Text(item.name) .fontSize(this.index === item.id ? $r('app.float.font_size_checked') : $r('app.float.font_size_unchecked')) .fontColor(Color.Black) .textAlign(TextAlign.Center) .fontWeight(this.index === item.id ? FontWeight.Bold : FontWeight.Regular) .onClick(() => { this.index = item.id; }) }, (item: TopBarItem) => JSON.stringify(item)) } .margin({ left: CommonConstants.ADS_LEFT }) .width(CommonConstants.FULL_WIDTH) .height(CommonConstants.TOP_BAR_HEIGHT) } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct TopBar AST#component_body#Left { // Double binding of index values to achieve linkage effect. AST#property_declaration#Left AST#decorator#Left @ Link AST#decorator#Right index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left private tabArray : 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 TopBarItem 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 initializeOnStartup AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_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 Row ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . SPACE_TOP_BAR 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 . tabArray 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 TopBarItem AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#ui_arrow_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . name AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . index AST#member_expression#Right AST#expression#Right === AST#expression#Left item AST#expression#Right AST#binary_expression#Right AST#expression#Right . id AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.font_size_checked' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.font_size_unchecked' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#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 . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . index AST#member_expression#Right AST#expression#Right === AST#expression#Left item AST#expression#Right AST#binary_expression#Right AST#expression#Right . id AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Bold AST#member_expression#Right AST#expression#Right : AST#expression#Left FontWeight AST#expression#Right AST#conditional_expression#Right AST#expression#Right . Regular 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 . index AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . id AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#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 TopBarItem 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 . 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 CommonConstants AST#expression#Right . ADS_LEFT AST#member_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#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . FULL_WIDTH AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . TOP_BAR_HEIGHT 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 TopBar { @Link index: number; private tabArray: Array<TopBarItem> = initializeOnStartup(); build() { Row({ space: CommonConstants.SPACE_TOP_BAR }) { ForEach(this.tabArray, (item: TopBarItem) => { Text(item.name) .fontSize(this.index === item.id ? $r('app.float.font_size_checked') : $r('app.float.font_size_unchecked')) .fontColor(Color.Black) .textAlign(TextAlign.Center) .fontWeight(this.index === item.id ? FontWeight.Bold : FontWeight.Regular) .onClick(() => { this.index = item.id; }) }, (item: TopBarItem) => JSON.stringify(item)) } .margin({ left: CommonConstants.ADS_LEFT }) .width(CommonConstants.FULL_WIDTH) .height(CommonConstants.TOP_BAR_HEIGHT) } }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/ETSUI/SwiperArkTS/entry/src/main/ets/view/common/TopBar.ets#L23-L47
2719e7fcb93ea5880e1ef76f938eb454d1c99299
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/media/MediaManager.ets
arkts
generateContactAvatar
生成联系人头像
async generateContactAvatar(contact: Contact, options?: ImageProcessOptions): Promise<string> { try { // 如果联系人已有头像,则处理现有头像 if (contact.avatar) { return await this.processImage(contact.avatar, { width: 120, height: 120, quality: 85, format: 'jpeg', ...options }); } // 否则生成默认头像 return await this.createDefaultAvatar(contact.name, options); } catch (error) { hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to generate contact avatar: ${error}`); throw error; } }
AST#method_declaration#Left async generateContactAvatar AST#parameter_list#Left ( AST#parameter#Left contact : AST#type_annotation#Left AST#primary_type#Left Contact AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left options ? : AST#type_annotation#Left AST#primary_type#Left ImageProcessOptions AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#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 contact AST#expression#Right . avatar AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . processImage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left contact AST#expression#Right . avatar AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left 120 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left height AST#property_name#Right : AST#expression#Left 120 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left quality AST#property_name#Right : AST#expression#Left 85 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left format AST#property_name#Right : AST#expression#Left 'jpeg' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left ... AST#expression#Left options AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 否则生成默认头像 AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . createDefaultAvatar AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left contact AST#expression#Right . name 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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Failed to generate contact avatar: AST#template_substitution#Left $ { AST#expression#Left error AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#throw_statement#Left throw AST#expression#Left error AST#expression#Right ; AST#throw_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async generateContactAvatar(contact: Contact, options?: ImageProcessOptions): Promise<string> { try { if (contact.avatar) { return await this.processImage(contact.avatar, { width: 120, height: 120, quality: 85, format: 'jpeg', ...options }); } return await this.createDefaultAvatar(contact.name, options); } catch (error) { hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to generate contact avatar: ${error}`); throw error; } }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/media/MediaManager.ets#L312-L331
623dd3424621d8ff6425c060c9fde2285f1a41ae
github
openharmony/arkui_ace_engine
30c7d1ee12fbedf0fabece54291d75897e2ad44f
examples/Select/entry/src/main/ets/pages/components/form.ets
arkts
validateAgreement
验证协议
private validateAgreement() { if (!this.formData.agree) { this.validation.agree = { valid: false, message: '请阅读并同意用户协议' } } else { this.validation.agree = { valid: true, message: '' } } }
AST#method_declaration#Left private validateAgreement AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . formData AST#member_expression#Right AST#expression#Right . agree AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . validation AST#member_expression#Right AST#expression#Right . agree AST#member_expression#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left valid AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left '请阅读并同意用户协议' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right } else { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . validation AST#member_expression#Right AST#expression#Right . agree AST#member_expression#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left valid 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 message AST#property_name#Right : AST#expression#Left '' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
private validateAgreement() { if (!this.formData.agree) { this.validation.agree = { valid: false, message: '请阅读并同意用户协议' } } else { this.validation.agree = { valid: true, message: '' } } }
https://github.com/openharmony/arkui_ace_engine/blob/30c7d1ee12fbedf0fabece54291d75897e2ad44f/examples/Select/entry/src/main/ets/pages/components/form.ets#L170-L176
dc526a1c67ee8ea39f8f6a5878ba48eeeae29bc1
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/game/InteractiveGameService.ets
arkts
pauseGame
暂停游戏
pauseGame(sessionId: string): boolean { try { const session = this.activeSessions.get(sessionId); if (!session || session.state !== GameState.PLAYING) { return false; } session.state = GameState.PAUSED; return true; } catch (error) { hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to pause game: ${error}`); return false; } }
AST#method_declaration#Left pauseGame AST#parameter_list#Left ( AST#parameter#Left sessionId : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left session = 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 . activeSessions AST#member_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sessionId 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 AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left session AST#expression#Right AST#unary_expression#Right AST#expression#Right || AST#expression#Left session AST#expression#Right AST#binary_expression#Right AST#expression#Right . state AST#member_expression#Right AST#expression#Right !== AST#expression#Left GameState AST#expression#Right AST#binary_expression#Right AST#expression#Right . PLAYING AST#member_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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left session AST#expression#Right . state AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left GameState AST#expression#Right . PAUSED 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#return_statement#Left return AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Failed to pause game: AST#template_substitution#Left $ { AST#expression#Left error AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
pauseGame(sessionId: string): boolean { try { const session = this.activeSessions.get(sessionId); if (!session || session.state !== GameState.PLAYING) { return false; } session.state = GameState.PAUSED; return true; } catch (error) { hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to pause game: ${error}`); return false; } }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/game/InteractiveGameService.ets#L316-L330
a9c37f464a63e227e18b352636766d28d328dbd8
github
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
Distributed/OpenHarmonyPictureGame/entry/src/main/ets/MainAbility/pages/index.ets
arkts
sendMessageToRemoteService
连接成功后发送消息
async function sendMessageToRemoteService(imageIndexForPosition) { if (mRemote == null) { prompt.showToast({ message: "mRemote is null" }); return; } let option = new rpc.MessageOption(); let data = new rpc.MessageParcel(); let reply = new rpc.MessageParcel(); data.writeIntArray(JSON.parse(imageIndexForPosition)); await mRemote.sendRequest(1, data, reply, option); let msg = reply.readInt(); }
AST#function_declaration#Left async function sendMessageToRemoteService AST#parameter_list#Left ( AST#parameter#Left imageIndexForPosition AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left mRemote AST#expression#Right == AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left prompt AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left "mRemote is null" 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#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left option = 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 rpc AST#expression#Right AST#new_expression#Right AST#expression#Right . MessageOption AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left data = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left rpc AST#expression#Right AST#new_expression#Right AST#expression#Right . MessageParcel AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left reply = 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 rpc AST#expression#Right AST#new_expression#Right AST#expression#Right . MessageParcel 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 data AST#expression#Right . writeIntArray 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 JSON AST#expression#Right . parse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left imageIndexForPosition AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left mRemote AST#expression#Right AST#await_expression#Right AST#expression#Right . sendRequest AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 1 AST#expression#Right , AST#expression#Left data AST#expression#Right , AST#expression#Left reply AST#expression#Right , AST#expression#Left option 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 msg = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left reply AST#expression#Right . readInt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right
async function sendMessageToRemoteService(imageIndexForPosition) { if (mRemote == null) { prompt.showToast({ message: "mRemote is null" }); return; } let option = new rpc.MessageOption(); let data = new rpc.MessageParcel(); let reply = new rpc.MessageParcel(); data.writeIntArray(JSON.parse(imageIndexForPosition)); await mRemote.sendRequest(1, data, reply, option); let msg = reply.readInt(); }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Distributed/OpenHarmonyPictureGame/entry/src/main/ets/MainAbility/pages/index.ets#L138-L152
b0c531a41f2d91cf768160bfd6338caeaec2b77f
gitee
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
UseSendable/entry/src/main/ets/pages/ConcurrentTaskManagement4.ets
arkts
ConcurrentTaskManagement4
[End execcolorinfo]
@Component export struct ConcurrentTaskManagement4 { @Styles buttonStyles() { .width('100%') .height(40) } build() { NavDestination() { Column() { Button($r('app.string.priority_scheduling_title')) .buttonStyles() .margin({ bottom: 16 }) .onClick(() => { executeTaskPool(new ArrayBuffer(16)); }) } .width('100%') .height('100%') .justifyContent(FlexAlign.End) .padding({ right: 24, bottom: 16, left: 24 }) } .title($r('app.string.priority_scheduling_title')) } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct ConcurrentTaskManagement4 AST#component_body#Left { AST#method_declaration#Left AST#decorator#Left @ Styles AST#decorator#Right buttonStyles AST#parameter_list#Left ( ) AST#parameter_list#Right AST#extend_function_body#Left { AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 40 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right } AST#extend_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 NavDestination ( ) 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 Button ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.priority_scheduling_title' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . buttonStyles ( ) 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 16 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 executeTaskPool AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ArrayBuffer AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 16 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#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 . 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 . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 24 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 24 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . title ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.priority_scheduling_title' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Component export struct ConcurrentTaskManagement4 { @Styles buttonStyles() { .width('100%') .height(40) } build() { NavDestination() { Column() { Button($r('app.string.priority_scheduling_title')) .buttonStyles() .margin({ bottom: 16 }) .onClick(() => { executeTaskPool(new ArrayBuffer(16)); }) } .width('100%') .height('100%') .justifyContent(FlexAlign.End) .padding({ right: 24, bottom: 16, left: 24 }) } .title($r('app.string.priority_scheduling_title')) } }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/UseSendable/entry/src/main/ets/pages/ConcurrentTaskManagement4.ets#L51-L82
da45bf89968a8c2b1131394984739cf7e91c36c8
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/DocsSample/NetWork_Kit/NetWorkKit_Datatransmission/Socket/entry/src/main/ets/connect/TcpClient.ets
arkts
closeConnection
关闭连接
closeConnection() { let tcpMessage: TcpMessage = { type: 'disConnect', }; workerPort.postMessage( tcpMessage ); workerPort.onmessage = (e: MessageEvents) => { const response: TcpMessage = e.data; if (response.type === 'Connection closed') { this.msgHistory += 'Connection closed.\n'; } else if (response.type === 'Close connection failed') { this.msgHistory += `Close connection failed`; } } }
AST#method_declaration#Left closeConnection AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left tcpMessage : AST#type_annotation#Left AST#primary_type#Left TcpMessage AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left type AST#property_name#Right : AST#expression#Left 'disConnect' 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 workerPort AST#expression#Right . postMessage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left tcpMessage 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 workerPort AST#expression#Right . onmessage AST#member_expression#Right = AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left e : AST#type_annotation#Left AST#primary_type#Left MessageEvents 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 response : AST#type_annotation#Left AST#primary_type#Left TcpMessage AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left e AST#expression#Right . data 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 response AST#expression#Right . type AST#member_expression#Right AST#expression#Right === AST#expression#Left 'Connection closed' 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 . msgHistory AST#member_expression#Right += AST#expression#Left 'Connection closed.\n' 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 response AST#expression#Right . type AST#member_expression#Right AST#expression#Right === AST#expression#Left 'Close connection failed' 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 . msgHistory AST#member_expression#Right += AST#expression#Left AST#template_literal#Left ` Close connection failed ` AST#template_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
closeConnection() { let tcpMessage: TcpMessage = { type: 'disConnect', }; workerPort.postMessage( tcpMessage ); workerPort.onmessage = (e: MessageEvents) => { const response: TcpMessage = e.data; if (response.type === 'Connection closed') { this.msgHistory += 'Connection closed.\n'; } else if (response.type === 'Close connection failed') { this.msgHistory += `Close connection failed`; } } }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/NetWork_Kit/NetWorkKit_Datatransmission/Socket/entry/src/main/ets/connect/TcpClient.ets#L219-L235
a218172a98324cd1b266f731ea7c39230a58e08f
gitee
BohanSu/LumosAgent-HarmonyOS.git
9eee81c93b67318d9c1c5d5a831ffc1c1fa08e76
entry/src/main/ets/pages/SettingsPage.ets
arkts
loadSettings
加载设置
private async loadSettings(): Promise<void> { try { // 获取脱敏的API密钥 this.apiKeyMasked = await this.configService.getMaskedApiKey(); // 获取TTS状态 this.isTTSEnabled = this.ttsService.isEnabled(); // 获取语音提醒状态 this.isVoiceReminderEnabled = this.notificationService.isVoiceReminderEnabled(); // 通知状态(默认开启) this.isNotificationEnabled = true; } catch (error) { console.error('[SettingsPage] 加载设置失败'); } }
AST#method_declaration#Left private async loadSettings AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { // 获取脱敏的API密钥 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 . apiKeyMasked AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . configService AST#member_expression#Right AST#expression#Right . getMaskedApiKey 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 // 获取TTS状态 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 . isTTSEnabled AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . ttsService AST#member_expression#Right AST#expression#Right . isEnabled AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 获取语音提醒状态 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isVoiceReminderEnabled AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . notificationService AST#member_expression#Right AST#expression#Right . isVoiceReminderEnabled AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 通知状态(默认开启) AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isNotificationEnabled AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( 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 '[SettingsPage] 加载设置失败' 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 loadSettings(): Promise<void> { try { this.apiKeyMasked = await this.configService.getMaskedApiKey(); this.isTTSEnabled = this.ttsService.isEnabled(); this.isVoiceReminderEnabled = this.notificationService.isVoiceReminderEnabled(); this.isNotificationEnabled = true; } catch (error) { console.error('[SettingsPage] 加载设置失败'); } }
https://github.com/BohanSu/LumosAgent-HarmonyOS.git/blob/9eee81c93b67318d9c1c5d5a831ffc1c1fa08e76/entry/src/main/ets/pages/SettingsPage.ets#L43-L59
19050ff5c6244c20c617d26724c84a0bed474c6e
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/common/types/GlobalTypes.ets
arkts
性别枚举
export enum Gender { MALE = 'male', FEMALE = 'female', OTHER = 'other' }
AST#export_declaration#Left export AST#enum_declaration#Left enum Gender AST#enum_body#Left { AST#enum_member#Left MALE = AST#expression#Left 'male' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left FEMALE = AST#expression#Left 'female' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left OTHER = AST#expression#Left 'other' AST#expression#Right AST#enum_member#Right } AST#enum_body#Right AST#enum_declaration#Right AST#export_declaration#Right
export enum Gender { MALE = 'male', FEMALE = 'female', OTHER = 'other' }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/types/GlobalTypes.ets#L68-L72
40a9815655cea7dcf96ea27c38d4e5184eedb8f8
github
awa_Liny/LinysBrowser_NEXT
a5cd96a9aa8114cae4972937f94a8967e55d4a10
home/src/main/ets/utils/ui_tools.ets
arkts
Statuses Gets current tabs style is whether horizontal or not. @returns a boolean. True for is horizontal.
export function current_tabs_style_is_horizontal(storage: LocalStorage) { let tablet_mode = storage.get('tablet_mode') as boolean; let tabs_style = AppStorage.get('tabs_style') as string; let tabs_style_non_tablet_mode = AppStorage.get('tabs_style_non_tablet_mode') as string; if (tablet_mode) { return tabs_style == 'horizontal'; } else { return tabs_style_non_tablet_mode == 'horizontal'; } }
AST#export_declaration#Left export AST#function_declaration#Left function current_tabs_style_is_horizontal AST#parameter_list#Left ( AST#parameter#Left storage : AST#type_annotation#Left AST#primary_type#Left LocalStorage 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 tablet_mode = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left storage AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'tablet_mode' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left tabs_style = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'tabs_style' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left tabs_style_non_tablet_mode = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'tabs_style_non_tablet_mode' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left tablet_mode AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left tabs_style AST#expression#Right == AST#expression#Left 'horizontal' AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left tabs_style_non_tablet_mode AST#expression#Right == AST#expression#Left 'horizontal' AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export function current_tabs_style_is_horizontal(storage: LocalStorage) { let tablet_mode = storage.get('tablet_mode') as boolean; let tabs_style = AppStorage.get('tabs_style') as string; let tabs_style_non_tablet_mode = AppStorage.get('tabs_style_non_tablet_mode') as string; if (tablet_mode) { return tabs_style == 'horizontal'; } else { return tabs_style_non_tablet_mode == 'horizontal'; } }
https://github.com/awa_Liny/LinysBrowser_NEXT/blob/a5cd96a9aa8114cae4972937f94a8967e55d4a10/home/src/main/ets/utils/ui_tools.ets#L16-L25
b7e1f391f82c85a405729b0e6326ec032069e2ba
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/DocsSample/bluetoothSample/entry/src/main/ets/bluetoothService/BluetoothAdvertising.ets
arkts
stopAdvertising
6 完全关闭广播,释放广播资源
public async stopAdvertising() { try { this.toastReport.showResult('bluetooth advertising stop success'); await ble.stopAdvertising(this.advHandle); ble.off('advertisingStateChange', (data: ble.AdvertisingStateChangeInfo) => { console.info(TAG, 'bluetooth advertising state = ' + JSON.stringify(data)); this.toastReport.showResult('bluetooth advertising stop'); }); } catch (err) { this.toastReport.showResult('bluetooth advertising stop fail'); console.error(TAG, 'errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message); } }
AST#method_declaration#Left public async stopAdvertising 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 . toastReport AST#member_expression#Right AST#expression#Right . showResult AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'bluetooth advertising stop success' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left ble AST#expression#Right AST#await_expression#Right AST#expression#Right . stopAdvertising 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 . advHandle 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 ble AST#expression#Right . off AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'advertisingStateChange' AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left ble . AdvertisingStateChangeInfo 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 console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'bluetooth advertising state = ' 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#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 . toastReport AST#member_expression#Right AST#expression#Right . showResult AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'bluetooth advertising stop' 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 ( 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . toastReport AST#member_expression#Right AST#expression#Right . showResult AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'bluetooth advertising stop fail' 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 . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'errCode: ' AST#expression#Right + AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left err AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . code AST#member_expression#Right AST#expression#Right + AST#expression#Left ', errMessage: ' AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left err AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right 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
public async stopAdvertising() { try { this.toastReport.showResult('bluetooth advertising stop success'); await ble.stopAdvertising(this.advHandle); ble.off('advertisingStateChange', (data: ble.AdvertisingStateChangeInfo) => { console.info(TAG, 'bluetooth advertising state = ' + JSON.stringify(data)); this.toastReport.showResult('bluetooth advertising stop'); }); } catch (err) { this.toastReport.showResult('bluetooth advertising stop fail'); console.error(TAG, 'errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message); } }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/bluetoothSample/entry/src/main/ets/bluetoothService/BluetoothAdvertising.ets#L166-L178
234dd4535765fb6311588f4b7fdadc72276b9016
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/videocreategif/src/main/ets/components/RangeSeekBarView.ets
arkts
touchInMiddleThumb
是否触摸在选取框的中间 @param event @returns
touchInMiddleThumb(event?: GestureEvent): boolean { let pointX: number = this.clearUndefined(event?.fingerList[0].localX); if (pointX >= (this.leftThumbRect[2] + 10) && pointX <= (this.rightThumbRect[0] - 10)) { return true; } else { return false; } }
AST#method_declaration#Left touchInMiddleThumb AST#parameter_list#Left ( AST#parameter#Left event ? : AST#type_annotation#Left AST#primary_type#Left GestureEvent 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#variable_declaration#Left let AST#variable_declarator#Left pointX : 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 this AST#expression#Right . clearUndefined AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left event AST#expression#Right ?. fingerList AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . localX AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left pointX AST#expression#Right >= AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . leftThumbRect AST#member_expression#Right AST#expression#Right [ AST#expression#Left 2 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right + AST#expression#Left 10 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#expression#Left AST#binary_expression#Left AST#expression#Left pointX AST#expression#Right <= AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rightThumbRect AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right - AST#expression#Left 10 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#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
touchInMiddleThumb(event?: GestureEvent): boolean { let pointX: number = this.clearUndefined(event?.fingerList[0].localX); if (pointX >= (this.leftThumbRect[2] + 10) && pointX <= (this.rightThumbRect[0] - 10)) { return true; } else { return false; } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/videocreategif/src/main/ets/components/RangeSeekBarView.ets#L400-L411
a8d9819a740d253ddf4d1ae9e6cda15f425f1261
gitee
lentozi/DailyPlan.git
96ce0bec8f545511c51b577c4aa8327c2c5bb0c8
entry/src/main/ets/databaseability/tables/TodoTable.ets
arkts
insertData
插入数据
insertData(todoItem: TodoItem, callback: Function) { const valueBucket: relationalStore.ValuesBucket = generateBucket(todoItem); this.todoTable.insertData(valueBucket, callback); }
AST#method_declaration#Left insertData AST#parameter_list#Left ( AST#parameter#Left todoItem : AST#type_annotation#Left AST#primary_type#Left TodoItem AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left callback : AST#type_annotation#Left AST#primary_type#Left Function 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 valueBucket : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left relationalStore . ValuesBucket AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left generateBucket AST#expression#Right AST#argument_list#Left ( AST#expression#Left todoItem AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . todoTable AST#member_expression#Right AST#expression#Right . insertData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left valueBucket 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#block_statement#Right AST#method_declaration#Right
insertData(todoItem: TodoItem, callback: Function) { const valueBucket: relationalStore.ValuesBucket = generateBucket(todoItem); this.todoTable.insertData(valueBucket, callback); }
https://github.com/lentozi/DailyPlan.git/blob/96ce0bec8f545511c51b577c4aa8327c2c5bb0c8/entry/src/main/ets/databaseability/tables/TodoTable.ets#L33-L36
db549333d716b651e7b8bc2bc3d416976e9ab0f0
github
L1rics06/arkTS-.git
991fd131bfdb11e2933152133c97453d86092ac0
entry/src/main/ets/pages/NetworkUtil.ets
arkts
requestRegister
用户注册
static async requestRegister( user: RegisterInfo, avatarFile: string, ): Promise<RegisterResult> { let registerResult: ResponseDao<string>; try { const response: AxiosResponse<ResponseDao<string>> = await axios.post( `${BASE_URL}/ddchat/index/register`, user, { headers: NetworkUtil.mergeHeaders('application/json'), } ); registerResult = response.data; } catch (error) { console.error('Register error:', JSON.stringify(error)); throw new Error(`Registration failed: ${JSON.stringify(error)}`); } const file = fileIo.openSync(avatarFile,fileIo.OpenMode.READ_ONLY); const filePath = getContext().cacheDir+'/'+ file.name; fileIo.copyFileSync(file.fd,filePath) fileIo.closeSync(file.fd); const userId = registerResult.data; const formData = new FormData(); formData.append('userId', userId+''); formData.append('image', `internal://cache/${file.name}`); axios({ method: 'POST', url: `${BASE_URL}/ddchat/image/uploadAvatar`, data: formData, headers:{ 'Content-Type': 'multipart/form-data' }, context:null }).then((res:AxiosResponse<ResponseDao<AvatarUploadResult>>)=>{ console.log("respond:"+JSON.stringify(res)) const data:ResponseDao<AvatarUploadResult> = res.data; if(data.code === "S1"){ console.log('头像上传成功') } }) return { registerResult, }; }
AST#method_declaration#Left static async requestRegister AST#parameter_list#Left ( AST#parameter#Left user : AST#type_annotation#Left AST#primary_type#Left RegisterInfo AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left avatarFile : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left 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 RegisterResult 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 registerResult : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left ResponseDao AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left response : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left AxiosResponse AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left ResponseDao AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left 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#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left axios AST#expression#Right AST#await_expression#Right AST#expression#Right . post AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left BASE_URL AST#expression#Right } AST#template_substitution#Right /ddchat/index/register ` AST#template_literal#Right AST#expression#Right , AST#expression#Left user AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left headers AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left NetworkUtil AST#expression#Right . mergeHeaders AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'application/json' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left registerResult = AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . data AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right 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 'Register error:' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#throw_statement#Left throw AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Error AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` Registration failed: AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#throw_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left file = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fileIo AST#expression#Right . openSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left avatarFile AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fileIo AST#expression#Right . OpenMode AST#member_expression#Right AST#expression#Right . READ_ONLY 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 filePath = 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#call_expression#Left AST#expression#Left getContext AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . cacheDir AST#member_expression#Right AST#expression#Right + AST#expression#Left '/' AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left file AST#expression#Right AST#binary_expression#Right AST#expression#Right . name AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fileIo AST#expression#Right . copyFileSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left file AST#expression#Right . fd AST#member_expression#Right AST#expression#Right , AST#expression#Left filePath 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 fileIo AST#expression#Right . closeSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left file AST#expression#Right . fd AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left userId = AST#expression#Left AST#member_expression#Left AST#expression#Left registerResult AST#expression#Right . data 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 formData = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left FormData 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 formData AST#expression#Right . append AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'userId' AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left userId AST#expression#Right + AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left formData AST#expression#Right . append AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'image' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` internal://cache/ AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left file AST#expression#Right . name AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left axios AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left method AST#property_name#Right : AST#expression#Left 'POST' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left url AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left BASE_URL AST#expression#Right } AST#template_substitution#Right /ddchat/image/uploadAvatar ` AST#template_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left data AST#property_name#Right : AST#expression#Left formData 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 'multipart/form-data' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left context AST#property_name#Right : AST#expression#Left AST#null_literal#Left null AST#null_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 . 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#type_annotation#Left AST#primary_type#Left AST#generic_type#Left AxiosResponse AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left ResponseDao AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AvatarUploadResult 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#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left "respond:" 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 res AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left data : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left ResponseDao AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AvatarUploadResult 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 res AST#expression#Right . data 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 data AST#expression#Right . code AST#member_expression#Right AST#expression#Right === AST#expression#Left "S1" AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '头像上传成功' AST#expression#Right ) AST#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#statement#Left AST#return_statement#Left return AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left registerResult 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
static async requestRegister( user: RegisterInfo, avatarFile: string, ): Promise<RegisterResult> { let registerResult: ResponseDao<string>; try { const response: AxiosResponse<ResponseDao<string>> = await axios.post( `${BASE_URL}/ddchat/index/register`, user, { headers: NetworkUtil.mergeHeaders('application/json'), } ); registerResult = response.data; } catch (error) { console.error('Register error:', JSON.stringify(error)); throw new Error(`Registration failed: ${JSON.stringify(error)}`); } const file = fileIo.openSync(avatarFile,fileIo.OpenMode.READ_ONLY); const filePath = getContext().cacheDir+'/'+ file.name; fileIo.copyFileSync(file.fd,filePath) fileIo.closeSync(file.fd); const userId = registerResult.data; const formData = new FormData(); formData.append('userId', userId+''); formData.append('image', `internal://cache/${file.name}`); axios({ method: 'POST', url: `${BASE_URL}/ddchat/image/uploadAvatar`, data: formData, headers:{ 'Content-Type': 'multipart/form-data' }, context:null }).then((res:AxiosResponse<ResponseDao<AvatarUploadResult>>)=>{ console.log("respond:"+JSON.stringify(res)) const data:ResponseDao<AvatarUploadResult> = res.data; if(data.code === "S1"){ console.log('头像上传成功') } }) return { registerResult, }; }
https://github.com/L1rics06/arkTS-.git/blob/991fd131bfdb11e2933152133c97453d86092ac0/entry/src/main/ets/pages/NetworkUtil.ets#L288-L336
72f731f214ed65dfaab708a0ff6d772984dbadd5
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/list/SwipeableListItem.ets
arkts
itemEnd
[Start build_the_tail_slide_out_component]
@Builder itemEnd(index: number) { // 构建尾端滑出组件 Button({ type: ButtonType.Circle }) { Image($r('sys.media.ohos_ic_bottomsheet_close')) .width(40) .height(40) } // [StartExclude build_the_tail_slide_out_component] .backgroundColor('#FFE1E2E3') // [EndExclude build_the_tail_slide_out_component] .onClick(() => { // this.messages为列表数据源,可根据实际场景构造。点击后从数据源删除指定数据项。 this.arr.splice(index, 1); }) }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right itemEnd AST#parameter_list#Left ( AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { // 构建尾端滑出组件 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#component_parameters#Left { AST#component_parameter#Left type : AST#expression#Left AST#member_expression#Left AST#expression#Left ButtonType AST#expression#Right . Circle 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 'sys.media.ohos_ic_bottomsheet_close' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 40 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 40 AST#expression#Right ) AST#modifier_chain_expression#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 // [StartExclude build_the_tail_slide_out_component] AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#FFE1E2E3' AST#expression#Right ) // [EndExclude build_the_tail_slide_out_component] 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 { // this.messages为列表数据源,可根据实际场景构造。点击后从数据源删除指定数据项。 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 . arr AST#member_expression#Right AST#expression#Right . splice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left index AST#expression#Right , AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
@Builder itemEnd(index: number) { Button({ type: ButtonType.Circle }) { Image($r('sys.media.ohos_ic_bottomsheet_close')) .width(40) .height(40) } .backgroundColor('#FFE1E2E3') .onClick(() => { this.arr.splice(index, 1); }) }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/list/SwipeableListItem.ets#L25-L40
a2be27a401585d7e9344dcd42faea6594c8fb918
gitee
2763981847/Clock-Alarm.git
8949bedddb7d011021848196735f30ffe2bd1daf
entry/src/main/ets/viewmodel/AlarmClockViewModel.ets
arkts
disableExpiredReminders
禁用已过期的提醒。
disableExpiredReminders() { this.reminderService.getValidReminders( (remindRequests: Array<reminderAgentManager.ReminderRequest>) => { let remindRequestIds = remindRequests.map(remindRequest => remindRequest.notificationId); this.alarms .filter(alarm =>!remindRequestIds.includes(alarm.notificationId) && alarm.isOpen) .forEach(alarm => this.openAlarm(alarm.id, false)); } ); }
AST#method_declaration#Left disableExpiredReminders AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . reminderService AST#member_expression#Right AST#expression#Right . getValidReminders 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 remindRequests : 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 reminderAgentManager . ReminderRequest 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#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left remindRequestIds = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left remindRequests AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left remindRequest => AST#expression#Left AST#member_expression#Left AST#expression#Left remindRequest AST#expression#Right . notificationId 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . alarms AST#member_expression#Right AST#expression#Right . filter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left alarm => 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#unary_expression#Left ! AST#expression#Left remindRequestIds AST#expression#Right AST#unary_expression#Right AST#expression#Right . includes AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left alarm AST#expression#Right . notificationId AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right && AST#expression#Left alarm AST#expression#Right AST#binary_expression#Right AST#expression#Right . isOpen 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 . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left alarm => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . openAlarm AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left alarm AST#expression#Right . id AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right 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#builder_function_body#Right AST#method_declaration#Right
disableExpiredReminders() { this.reminderService.getValidReminders( (remindRequests: Array<reminderAgentManager.ReminderRequest>) => { let remindRequestIds = remindRequests.map(remindRequest => remindRequest.notificationId); this.alarms .filter(alarm =>!remindRequestIds.includes(alarm.notificationId) && alarm.isOpen) .forEach(alarm => this.openAlarm(alarm.id, false)); } ); }
https://github.com/2763981847/Clock-Alarm.git/blob/8949bedddb7d011021848196735f30ffe2bd1daf/entry/src/main/ets/viewmodel/AlarmClockViewModel.ets#L81-L90
17139803a9b1e513f021c2c00f2807780112ba90
github
openharmony-tpc/ohos_mpchart
4fb43a7137320ef2fee2634598f53d93975dfb4a
library/src/main/ets/components/data/BarEntry.ets
arkts
getPositiveSum
Reuturns the sum of all positive values this entry (if stacked) contains. @return
public getPositiveSum(): number { return this.mPositiveSum; }
AST#method_declaration#Left public getPositiveSum 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 . mPositiveSum AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
public getPositiveSum(): number { return this.mPositiveSum; }
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/data/BarEntry.ets#L106-L108
ed8edfaedf864976272a700cd0116263ffb5f322
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/toolbox/src/main/ets/model/ChildTool.ets
arkts
ChildTool
工具项组件
@Component export struct ChildTool { // 工具项UI builder?: WrappedBuilder<[ToolInterface]>; // 工具项静态参数 params?: CustomParams; // 工具项动效参数 @ObjectLink animationAttribute: CustomAnimation; build() { Column() { this.builder!.builder({params: this.params, animation: this.animationAttribute}); } } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct ChildTool AST#component_body#Left { // 工具项UI AST#property_declaration#Left builder ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left WrappedBuilder AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#tuple_type#Left [ AST#type_annotation#Left AST#primary_type#Left ToolInterface AST#primary_type#Right AST#type_annotation#Right ] AST#tuple_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right // 工具项静态参数 AST#property_declaration#Left params ? : AST#type_annotation#Left AST#primary_type#Left CustomParams AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right // 工具项动效参数 AST#property_declaration#Left AST#decorator#Left @ ObjectLink AST#decorator#Right animationAttribute : AST#type_annotation#Left AST#primary_type#Left CustomAnimation 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 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 AST#non_null_assertion_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . builder AST#member_expression#Right AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right . builder 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 params AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . params AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left animation AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . animationAttribute AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Component export struct ChildTool { builder?: WrappedBuilder<[ToolInterface]>; params?: CustomParams; @ObjectLink animationAttribute: CustomAnimation; build() { Column() { this.builder!.builder({params: this.params, animation: this.animationAttribute}); } } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/toolbox/src/main/ets/model/ChildTool.ets#L23-L38
b62d75db0dccc6339841e4b9542ad9d7e3b164ad
gitee
zeroone001/harmonyAPP.git
49c8fa1b56de89cb7513b25f3b1b753ba857968a
features/quickstart/src/main/ets/view/Banner.ets
arkts
aboutToAppear(): void { this.getBannerDataFromJSON(); } getBannerDataFromJSON() { getContext(this).resourceManager.getRawFileContent('BannerData.json').then(value => { this.bannerList = JSON.parse(bufferToString(value)) as BannerClass[]; }) }
build() { Swiper() { ForEach(this.bannerList, (item: BannerClass) => { Image($r(item.imageSrc)) .objectFit(ImageFit.Contain) .width('100%') .borderRadius(16) .padding({ top: 11, left: 16, right: 16 }) .onClick(() => { // 把 item 塞到 bannerDetailPage 这里 this.articlePathStack.pushPathByName('bannerDetailPage', item); }) }, (item: BannerClass) => item.id) } .autoPlay(true) .loop(true) .indicator( new DotIndicator() .color('#1a000000') .selectedColor('#0A59F7')) }
AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Swiper ( ) 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 . bannerList 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 BannerClass 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 AST#resource_expression#Left $r ( AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . imageSrc AST#member_expression#Right AST#expression#Right ) AST#resource_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 '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 16 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 11 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { // 把 item 塞到 bannerDetailPage 这里 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 . articlePathStack AST#member_expression#Right AST#expression#Right . pushPathByName AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'bannerDetailPage' AST#expression#Right , 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#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 BannerClass AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . id AST#member_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#for_each_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . autoPlay ( AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#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 . indicator ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left DotIndicator 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 . color AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '#1a000000' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . selectedColor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '#0A59F7' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right
build() { Swiper() { ForEach(this.bannerList, (item: BannerClass) => { Image($r(item.imageSrc)) .objectFit(ImageFit.Contain) .width('100%') .borderRadius(16) .padding({ top: 11, left: 16, right: 16 }) .onClick(() => { this.articlePathStack.pushPathByName('bannerDetailPage', item); }) }, (item: BannerClass) => item.id) } .autoPlay(true) .loop(true) .indicator( new DotIndicator() .color('#1a000000') .selectedColor('#0A59F7')) }
https://github.com/zeroone001/harmonyAPP.git/blob/49c8fa1b56de89cb7513b25f3b1b753ba857968a/features/quickstart/src/main/ets/view/Banner.ets#L52-L72
456ae6efa4e1a34b328b0ea1c5b93e794ab7bb70
github
wasd09090030/MyHongmengProject.git
a8ed386b658ceeac69ef5bc42a92d78c7980821c
entry/src/main/ets/viewmodels/ReviewViewModel.ets
arkts
getFilteredTasks
根据筛选模式获取过滤后的任务
static getFilteredTasks(completedTasks: TaskItem[], filterMode: 'all' | 'week' | 'month'): TaskItem[] { const now = Date.now(); const dayMs = 24 * 60 * 60 * 1000; switch (filterMode) { case 'week': return completedTasks.filter(t => now - (t.completedTime || 0) <= 7 * dayMs); case 'month': return completedTasks.filter(t => now - (t.completedTime || 0) <= 30 * dayMs); default: return completedTasks; }
AST#method_declaration#Left static getFilteredTasks AST#parameter_list#Left ( AST#parameter#Left completedTasks : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left TaskItem [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left filterMode AST#parameter#Right AST#ERROR#Left : 'all' | 'week' | 'month' AST#ERROR#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left TaskItem [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left now = 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 dayMs = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 24 AST#expression#Right * AST#expression#Left 60 AST#expression#Right AST#binary_expression#Right AST#expression#Right * AST#expression#Left 60 AST#expression#Right AST#binary_expression#Right AST#expression#Right * AST#expression#Left 1000 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 switch AST#expression#Right AST#argument_list#Left ( AST#expression#Left filterMode AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left { AST#ERROR#Left AST#property_name#Left case AST#property_name#Right AST#ERROR#Right AST#property_assignment#Left AST#property_name#Left 'week' AST#property_name#Right : AST#expression#Left return AST#expression#Right AST#property_assignment#Right comp AST#ERROR#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left letedTasks AST#expression#Right . filter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left t => AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left now AST#expression#Right - AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left t AST#expression#Right . completedTime AST#member_expression#Right AST#expression#Right || AST#expression#Left 0 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#expression#Left AST#binary_expression#Left AST#expression#Left 7 AST#expression#Right * AST#expression#Left dayMs AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left 'month' AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left : AST#ERROR#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 completedTasks AST#expression#Right . filter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left t => AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left now AST#expression#Right - AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left t AST#expression#Right . completedTime AST#member_expression#Right AST#expression#Right || AST#expression#Left 0 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#expression#Left AST#binary_expression#Left AST#expression#Left 30 AST#expression#Right * AST#expression#Left dayMs AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left default AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left : return comp AST#ERROR#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left letedTasks AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static getFilteredTasks(completedTasks: TaskItem[], filterMode: 'all' | 'week' | 'month'): TaskItem[] { const now = Date.now(); const dayMs = 24 * 60 * 60 * 1000; switch (filterMode) { case 'week': return completedTasks.filter(t => now - (t.completedTime || 0) <= 7 * dayMs); case 'month': return completedTasks.filter(t => now - (t.completedTime || 0) <= 30 * dayMs); default: return completedTasks; }
https://github.com/wasd09090030/MyHongmengProject.git/blob/a8ed386b658ceeac69ef5bc42a92d78c7980821c/entry/src/main/ets/viewmodels/ReviewViewModel.ets#L164-L175
e03c2d1577e2987e87a06bf0110f0f93dec06518
github
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_crypto/src/main/ets/crypto/encryption/SM3Sync.ets
arkts
hmac
消息认证码计算 @param str 计算字符串 @param resultCoding 返回结果编码方式(hex/base64)-默认不传为base64格式 @returns
static hmac(str: string, resultCoding: buffer.BufferEncoding = 'base64'): string { return DynamicSyncUtil.hmac(str, 'SM3', resultCoding); }
AST#method_declaration#Left static hmac AST#parameter_list#Left ( AST#parameter#Left str : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left resultCoding : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left buffer . BufferEncoding AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'base64' AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 DynamicSyncUtil AST#expression#Right . hmac AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left str AST#expression#Right , AST#expression#Left 'SM3' AST#expression#Right , AST#expression#Left resultCoding 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 hmac(str: string, resultCoding: buffer.BufferEncoding = 'base64'): string { return DynamicSyncUtil.hmac(str, 'SM3', resultCoding); }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto/src/main/ets/crypto/encryption/SM3Sync.ets#L44-L46
1d9e733e4e27ee6e8a51cb0b32887ef892e8febf
gitee
sedlei/Smart-park-system.git
253228f73e419e92fd83777f564889d202f7c699
src/main/ets/pages/Index.ets
arkts
onSelectedIndexChange
当前页面监听:当进入第三页时关闭菜单栏侧滑
@Monitor('selectedIndex') onSelectedIndexChange(monitor: IMonitor) { const newIndex = monitor.value()?.now as number; this.disableSwipeOpen = (newIndex === 3 || newIndex === 4); }
AST#method_declaration#Left AST#decorator#Left @ Monitor ( AST#expression#Left 'selectedIndex' AST#expression#Right ) AST#decorator#Right onSelectedIndexChange AST#parameter_list#Left ( AST#parameter#Left monitor : AST#type_annotation#Left AST#primary_type#Left IMonitor 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 newIndex = AST#expression#Left AST#as_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 monitor AST#expression#Right . value AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ?. now AST#member_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#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 . disableSwipeOpen AST#member_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 newIndex 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 newIndex AST#expression#Right === AST#expression#Left 4 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#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
@Monitor('selectedIndex') onSelectedIndexChange(monitor: IMonitor) { const newIndex = monitor.value()?.now as number; this.disableSwipeOpen = (newIndex === 3 || newIndex === 4); }
https://github.com/sedlei/Smart-park-system.git/blob/253228f73e419e92fd83777f564889d202f7c699/src/main/ets/pages/Index.ets#L50-L54
36f1e78d05940247ccfdb2c0aa3d40d32dfa6262
github
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
feature/main/src/main/ets/view/MePage.ets
arkts
getCurrentUser
获取当前用户信息 @returns {User} 用户信息
private getCurrentUser(): User { return this.userState.getUserInfo(); }
AST#method_declaration#Left private getCurrentUser AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left User 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 . userState AST#member_expression#Right AST#expression#Right . getUserInfo 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 getCurrentUser(): User { return this.userState.getUserInfo(); }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/main/src/main/ets/view/MePage.ets#L206-L208
a0bc2a5a10bfb88139c6827f071315ba31220103
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/models/managers/plan/plancurve/Box.ets
arkts
compareTo
MARK: - Comparable 比较 比较两个Box的大小 @param other - 另一个Box对象
compareTo(other: Box): number { if (this.num === other.num) { return this.distance - other.distance; } else { return this.num - other.num; } }
AST#method_declaration#Left compareTo AST#parameter_list#Left ( AST#parameter#Left other : AST#type_annotation#Left AST#primary_type#Left Box AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . num AST#member_expression#Right AST#expression#Right === AST#expression#Left other AST#expression#Right AST#binary_expression#Right AST#expression#Right . num AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . distance AST#member_expression#Right AST#expression#Right - AST#expression#Left other AST#expression#Right AST#binary_expression#Right AST#expression#Right . distance AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . num AST#member_expression#Right AST#expression#Right - AST#expression#Left other AST#expression#Right AST#binary_expression#Right AST#expression#Right . num AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
compareTo(other: Box): number { if (this.num === other.num) { return this.distance - other.distance; } else { return this.num - other.num; } }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/managers/plan/plancurve/Box.ets#L70-L76
87998f28b38c43308370c5ea4812d974c39537b1
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/dynamicattributes/src/main/ets/common/AttributeModifier.ets
arkts
枚举文本类型
export enum TextType { TYPE_ONE, TYPE_TWO, TYPE_Three, TYPE_FOUR }
AST#export_declaration#Left export AST#enum_declaration#Left enum TextType AST#enum_body#Left { AST#enum_member#Left TYPE_ONE AST#enum_member#Right , AST#enum_member#Left TYPE_TWO AST#enum_member#Right , AST#enum_member#Left TYPE_Three AST#enum_member#Right , AST#enum_member#Left TYPE_FOUR AST#enum_member#Right } AST#enum_body#Right AST#enum_declaration#Right AST#export_declaration#Right
export enum TextType { TYPE_ONE, TYPE_TWO, TYPE_Three, TYPE_FOUR }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/dynamicattributes/src/main/ets/common/AttributeModifier.ets#L121-L126
db8eecd537a509343be6b76383a3d4fd3796557a
gitee
pangpang20/wavecast.git
d3da8a0009eb44a576a2b9d9d9fe6195a2577e32
entry/src/main/ets/service/DownloadService.ets
arkts
isDownloadPaused
检查下载是否暂停
isDownloadPaused(episodeId: string): boolean { const task = this.downloadTasks.get(episodeId); return task ? task.isPaused : false; }
AST#method_declaration#Left isDownloadPaused AST#parameter_list#Left ( AST#parameter#Left episodeId : 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#variable_declaration#Left const AST#variable_declarator#Left task = 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 . downloadTasks AST#member_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left episodeId AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#conditional_expression#Left AST#expression#Left task AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left task AST#expression#Right . isPaused AST#member_expression#Right AST#expression#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
isDownloadPaused(episodeId: string): boolean { const task = this.downloadTasks.get(episodeId); return task ? task.isPaused : false; }
https://github.com/pangpang20/wavecast.git/blob/d3da8a0009eb44a576a2b9d9d9fe6195a2577e32/entry/src/main/ets/service/DownloadService.ets#L221-L224
7cad2f2f5da1ab6ab087055857a8c4719717565f
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/secondarylinkage/src/main/ets/pages/SecondaryLinkExample.ets
arkts
tagListItemBuilder
左侧类别视图
@Builder tagListItemBuilder(item: string, index: number) { ListItem() { Text(item) .width('100%') .height(COMPONENT_STYLE.TAG_TEXT_HEIGHT) .fontWeight(FontWeight.Regular) .fontColor($r('sys.color.ohos_fa_text_secondary')) .textAlign(TextAlign.Center) .backgroundColor(this.currentTagIndex === index ? $r('sys.color.ohos_id_color_background') : '') .onTouch((event: TouchEvent) => { if (event.type === TouchType.Down) { this.isClickTagList = true; // 当前点击的是一级列表 } }) .onClick(() => { // TODO:知识点: 3.点击一级列表后,通过一级列表索引获取二级列表索引,分别操作不同的Scroller对象使列表滚动到指定位置 this.currentTagIndex = index; const itemIndex = this.findItemIndex(index); this.scroller.scrollToIndex(itemIndex, true); }) } .id(this.currentTagIndex === index ? 'type_' + index : 'type_' + index + '_selected') }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right tagListItemBuilder AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left ListItem ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left item 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#member_expression#Left AST#expression#Left COMPONENT_STYLE AST#expression#Right . TAG_TEXT_HEIGHT AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Regular AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'sys.color.ohos_fa_text_secondary' 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 . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentTagIndex 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#resource_expression#Left $r ( AST#expression#Left 'sys.color.ohos_id_color_background' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left '' AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onTouch ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left event : AST#type_annotation#Left AST#primary_type#Left TouchEvent AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left event AST#expression#Right . type AST#member_expression#Right AST#expression#Right === AST#expression#Left TouchType AST#expression#Right AST#binary_expression#Right AST#expression#Right . Down AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isClickTagList AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 当前点击的是一级列表 } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#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:知识点: 3.点击一级列表后,通过一级列表索引获取二级列表索引,分别操作不同的Scroller对象使列表滚动到指定位置 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 . currentTagIndex 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#variable_declaration#Left const AST#variable_declarator#Left itemIndex = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . findItemIndex 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scroller AST#member_expression#Right AST#expression#Right . scrollToIndex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left itemIndex AST#expression#Right , AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . id ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentTagIndex AST#member_expression#Right AST#expression#Right === AST#expression#Left index AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#ERROR#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 'type_' AST#expression#Right + AST#ERROR#Left index : AST#ERROR#Right AST#expression#Left 'type_' AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left index AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left '_selected' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#ERROR#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 tagListItemBuilder(item: string, index: number) { ListItem() { Text(item) .width('100%') .height(COMPONENT_STYLE.TAG_TEXT_HEIGHT) .fontWeight(FontWeight.Regular) .fontColor($r('sys.color.ohos_fa_text_secondary')) .textAlign(TextAlign.Center) .backgroundColor(this.currentTagIndex === index ? $r('sys.color.ohos_id_color_background') : '') .onTouch((event: TouchEvent) => { if (event.type === TouchType.Down) { this.isClickTagList = true; } }) .onClick(() => { this.currentTagIndex = index; const itemIndex = this.findItemIndex(index); this.scroller.scrollToIndex(itemIndex, true); }) } .id(this.currentTagIndex === index ? 'type_' + index : 'type_' + index + '_selected') }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/secondarylinkage/src/main/ets/pages/SecondaryLinkExample.ets#L190-L213
13552488fed8c4325c452470c766f88e5d05b818
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/pages/calendar/BirthdayListPage.ets
arkts
aboutToAppear
页面生命周期 - 即将出现
aboutToAppear() { hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, 'BirthdayListPage aboutToAppear'); this.loadBirthdays(); }
AST#method_declaration#Left aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left 'BirthdayListPage aboutToAppear' 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 . loadBirthdays 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
aboutToAppear() { hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, 'BirthdayListPage aboutToAppear'); this.loadBirthdays(); }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/calendar/BirthdayListPage.ets#L36-L39
9ab1b296a042b978e4857aa4462adeb0664407a0
github
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
china_area/src/main/ets/AreaHelper.ets
arkts
unit8ArrayToStr
Uint8Array转字符串 @param src Uint8Array @returns 字符串
private static unit8ArrayToStr(src: Uint8Array, encoding: buffer.BufferEncoding = 'utf-8'): string { let textDecoder = util.TextDecoder.create(encoding, { ignoreBOM: true }) let result = textDecoder.decodeWithStream(src, { stream: true }); return result; }
AST#method_declaration#Left private static unit8ArrayToStr AST#parameter_list#Left ( AST#parameter#Left src : AST#type_annotation#Left AST#primary_type#Left Uint8Array AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left encoding : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left buffer . BufferEncoding AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'utf-8' AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left textDecoder = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left util AST#expression#Right . TextDecoder AST#member_expression#Right AST#expression#Right . create AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left encoding AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left ignoreBOM AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left result = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left textDecoder AST#expression#Right . decodeWithStream AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left src AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left stream AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left result AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private static unit8ArrayToStr(src: Uint8Array, encoding: buffer.BufferEncoding = 'utf-8'): string { let textDecoder = util.TextDecoder.create(encoding, { ignoreBOM: true }) let result = textDecoder.decodeWithStream(src, { stream: true }); return result; }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/china_area/src/main/ets/AreaHelper.ets#L155-L159
4aef9c27bbc6d1ad8053dfd32b29562834daddfc
gitee
jxdiaodeyi/YX_Sports.git
af5346bd3d5003c33c306ff77b4b5e9184219893
YX_Sports/entry/src/main/ets/pages/practice/TrainRecordPage.ets
arkts
practiceGraphType
统计图样式 ***************************************统计图************************************************88 UI
@Builder practiceGraphType(type:string,workoutdata:WorkoutData,isTime:boolean,totalTime:number,totalCarolie:number){ Column(){ // 标题行 Row(){ //左边标题 Text((isTime)?'锻炼时长':'卡路里') .fontSize(24) .fontColor('#333333') .fontWeight(500) .margin({left:15}) //右边数据 Row(){ Text((isTime)?workoutdata.allTime.toString():workoutdata.allCalories.toString()) .fontSize(34) .fontColor('#6249E3') .fontWeight(500) .margin({right:5}) Text((isTime)?'分钟':'千卡') .fontSize(22) .fontColor('#939EB5') } .margin({right:15}) } .margin({top:15}) .width('100%') .justifyContent(FlexAlign.SpaceBetween) // 柱状图部分 Scroll(){ Row() { // 遍历 dailyData 数组,为每一天创建一个柱子 ForEach(workoutdata.weekInfo, (item:DailyWorkout, index: number) => { Column() { Progress({value:(isTime)?(totalTime-item.stime):(totalCarolie-item.calorie),total:(isTime)?totalTime:totalCarolie,type:ProgressType.Capsule}) .width(10) .height(100) .style({strokeWidth:1}) .backgroundColor('#6C55E3') .color('#E5E5E5') if(type==='day'){ // 星期标识 Text(this.weekName[getWeekDayName(this.firstDayOfWeek, index)]) .fontSize(14) .fontColor('#333333') .margin({ top: 8 }); } else if(type==='week'){ //周标识 Text(this.weekCount[index]) .fontSize(14) .fontColor('#333333') .margin({ top: 8 }); } else if(type==='month'){ // // 月标识 Text(this.MonthName[index]) .fontSize(14) .fontColor('#333333') .margin({ top: 8 }); } else if(type==='all'){ // 星期标识 Text(this.YearName[index]) .fontSize(14) .fontColor('#333333') .margin({ top: 8 }); } } .width('100%') .height(150) .layoutWeight(1); // 让每个柱子在Row中平均分配空间 }); } .margin({top:15}) //.width('100%') .justifyContent(FlexAlign.SpaceAround); // 柱子之间平均分配间距 } .scrollBar(BarState.Off) .scrollable(ScrollDirection.Horizontal) } .width('100%') .height(200) .backgroundColor('#FFFFFF') .borderRadius(8) .margin({top:15}) .onClick(()=>{ if(isTime){ router.pushUrl({url:'pages/practice/TrainTimePage'}) } else{ router.pushUrl({url:'pages/practice/CaloriePage'}) } }) }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right practiceGraphType AST#parameter_list#Left ( AST#parameter#Left type : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left workoutdata : AST#type_annotation#Left AST#primary_type#Left WorkoutData AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left isTime : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left totalTime : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left totalCarolie : 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#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#conditional_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left isTime AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ? AST#expression#Left '锻炼时长' AST#expression#Right : AST#expression#Left '卡路里' AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 24 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#333333' AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left 500 AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 15 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right //右边数据 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left isTime AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left workoutdata AST#expression#Right . allTime AST#member_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right : AST#expression#Left workoutdata AST#expression#Right AST#conditional_expression#Right AST#expression#Right . allCalories 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#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 34 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#6249E3' AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left 500 AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 5 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left isTime AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ? AST#expression#Left '分钟' AST#expression#Right : AST#expression#Left '千卡' AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 22 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#939EB5' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 15 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 15 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . 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 // 柱状图部分 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 Row ( ) AST#container_content_body#Left { // 遍历 dailyData 数组,为每一天创建一个柱子 AST#ui_control_flow#Left AST#for_each_statement#Left ForEach ( AST#expression#Left AST#member_expression#Left AST#expression#Left workoutdata AST#expression#Right . weekInfo 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 DailyWorkout AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#ui_arrow_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Progress ( AST#component_parameters#Left { AST#component_parameter#Left value : AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left isTime AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ? AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left totalTime AST#expression#Right - AST#expression#Left item AST#expression#Right AST#binary_expression#Right AST#expression#Right . stime AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right : AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left totalCarolie AST#expression#Right - AST#expression#Left item AST#expression#Right AST#binary_expression#Right AST#expression#Right . calorie AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left total : AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left isTime AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#component_parameter#Right AST#ERROR#Left ? totalTime : AST#type_annotation#Left AST#primary_type#Left totalCarolie AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Right , AST#component_parameter#Left type : AST#expression#Left AST#member_expression#Left AST#expression#Left ProgressType AST#expression#Right . Capsule AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 10 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 100 AST#expression#Right ) AST#modifier_chain_expression#Left . style ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left strokeWidth AST#property_name#Right : AST#expression#Left 1 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#6C55E3' AST#expression#Right ) AST#modifier_chain_expression#Left . color ( AST#expression#Left '#E5E5E5' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left type AST#expression#Right === AST#expression#Left 'day' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { // 星期标识 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . weekName AST#member_expression#Right AST#expression#Right [ AST#expression#Left AST#call_expression#Left AST#expression#Left getWeekDayName AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . firstDayOfWeek AST#member_expression#Right AST#expression#Right , AST#expression#Left index AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#333333' 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 8 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right } else AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left type AST#expression#Right === AST#expression#Left 'week' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { //周标识 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . weekCount AST#member_expression#Right AST#expression#Right [ AST#expression#Left index AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#333333' 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 8 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right } else AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left type AST#expression#Right === AST#expression#Left 'month' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { // // 月标识 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . MonthName AST#member_expression#Right AST#expression#Right [ AST#expression#Left index AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#333333' 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 8 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right } else AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left type AST#expression#Right === AST#expression#Left 'all' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { // 星期标识 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . YearName AST#member_expression#Right AST#expression#Right [ AST#expression#Left index AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#333333' 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 8 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right } AST#ui_if_statement#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 . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 150 AST#expression#Right ) AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right // 让每个柱子在Row中平均分配空间 } AST#ui_arrow_function_body#Right AST#ui_builder_arrow_function#Right ) AST#for_each_statement#Right AST#ui_control_flow#Right AST#ERROR#Left ; AST#ERROR#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 15 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) //.width('100%') 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#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right // 柱子之间平均分配间距 } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . 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 . scrollable ( AST#expression#Left AST#member_expression#Left AST#expression#Left ScrollDirection AST#expression#Right . Horizontal 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 200 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#FFFFFF' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 8 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 15 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left isTime 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 router AST#expression#Right . pushUrl AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left url AST#property_name#Right : AST#expression#Left 'pages/practice/TrainTimePage' 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 else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left router AST#expression#Right . pushUrl AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left url AST#property_name#Right : AST#expression#Left 'pages/practice/CaloriePage' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
@Builder practiceGraphType(type:string,workoutdata:WorkoutData,isTime:boolean,totalTime:number,totalCarolie:number){ Column(){ Row(){ Text((isTime)?'锻炼时长':'卡路里') .fontSize(24) .fontColor('#333333') .fontWeight(500) .margin({left:15}) Row(){ Text((isTime)?workoutdata.allTime.toString():workoutdata.allCalories.toString()) .fontSize(34) .fontColor('#6249E3') .fontWeight(500) .margin({right:5}) Text((isTime)?'分钟':'千卡') .fontSize(22) .fontColor('#939EB5') } .margin({right:15}) } .margin({top:15}) .width('100%') .justifyContent(FlexAlign.SpaceBetween) Scroll(){ Row() { ForEach(workoutdata.weekInfo, (item:DailyWorkout, index: number) => { Column() { Progress({value:(isTime)?(totalTime-item.stime):(totalCarolie-item.calorie),total:(isTime)?totalTime:totalCarolie,type:ProgressType.Capsule}) .width(10) .height(100) .style({strokeWidth:1}) .backgroundColor('#6C55E3') .color('#E5E5E5') if(type==='day'){ Text(this.weekName[getWeekDayName(this.firstDayOfWeek, index)]) .fontSize(14) .fontColor('#333333') .margin({ top: 8 }); } else if(type==='week'){ Text(this.weekCount[index]) .fontSize(14) .fontColor('#333333') .margin({ top: 8 }); } else if(type==='month'){ Text(this.MonthName[index]) .fontSize(14) .fontColor('#333333') .margin({ top: 8 }); } else if(type==='all'){ Text(this.YearName[index]) .fontSize(14) .fontColor('#333333') .margin({ top: 8 }); } } .width('100%') .height(150) .layoutWeight(1); }); } .margin({top:15}) .justifyContent(FlexAlign.SpaceAround); } .scrollBar(BarState.Off) .scrollable(ScrollDirection.Horizontal) } .width('100%') .height(200) .backgroundColor('#FFFFFF') .borderRadius(8) .margin({top:15}) .onClick(()=>{ if(isTime){ router.pushUrl({url:'pages/practice/TrainTimePage'}) } else{ router.pushUrl({url:'pages/practice/CaloriePage'}) } }) }
https://github.com/jxdiaodeyi/YX_Sports.git/blob/af5346bd3d5003c33c306ff77b4b5e9184219893/YX_Sports/entry/src/main/ets/pages/practice/TrainRecordPage.ets#L109-L208
c2b1d9a7bc5740b04230cae95b3518f8ec8e3596
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/pages/Index.ets
arkts
applyThemeSettings
应用主题设置
private applyThemeSettings(): void { // 更新全局颜色系统 this.updateGlobalColors(); // 关闭对话框 this.showThemeSettings = false; // 显示成功提示 promptAction.showToast({ message: `主题已应用 - ${this.getThemeColorName()}`, duration: 2000 }); }
AST#method_declaration#Left private applyThemeSettings AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { // 更新全局颜色系统 AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . updateGlobalColors AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right // 关闭对话框 AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showThemeSettings AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right // 显示成功提示 AST#expression_statement#Left AST#expression#Left AST#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#template_literal#Left ` 主题已应用 - AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getThemeColorName AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left duration AST#property_name#Right : AST#expression#Left 2000 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
private applyThemeSettings(): void { this.updateGlobalColors(); this.showThemeSettings = false; promptAction.showToast({ message: `主题已应用 - ${this.getThemeColorName()}`, duration: 2000 }); }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/Index.ets#L5840-L5852
9cf5785315f083a539e3ca23efce9615db60a09a
github
awa_Liny/LinysBrowser_NEXT
a5cd96a9aa8114cae4972937f94a8967e55d4a10
home/src/main/ets/hosts/bunch_of_history.ets
arkts
shift_time
Increases this history's accessed_time by one (1).
shift_time() { this.accessed_time++; }
AST#method_declaration#Left shift_time AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#update_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . accessed_time AST#member_expression#Right AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
shift_time() { this.accessed_time++; }
https://github.com/awa_Liny/LinysBrowser_NEXT/blob/a5cd96a9aa8114cae4972937f94a8967e55d4a10/home/src/main/ets/hosts/bunch_of_history.ets#L38-L40
c8a48adc30f631884470a64c90f42016f11dcdc6
gitee
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
Card/StepsCardJS/entry/src/main/ets/common/utils/ChartDataUtils.ets
arkts
getChartValues
Get chart values. @param {number} stepsValue Value of steps. @param {DataRdb.RdbStore} rdbStore RDB database. @return {ChartValues} chartValues.
async getChartValues(stepsValue: number, rdbStore: DataRdb.RdbStore) { let chartValues: ChartValues = new ChartValues(); // Set fill color. chartValues.fillColor = CommonConstants.CHART_VALUES_FILL_COLOR; // Set the color of the line. chartValues.strokeColor = CommonConstants.CHART_VALUES_STROKE_COLOR; chartValues.gradient = true; // Gets a collection of points from the previous three days. let chartPoints: ChartPoint[]; await this.getChartPoints(rdbStore).then((pointArray: ChartPoint[] | void) => { chartPoints = pointArray as ChartPoint[]; let nowChartPoint: ChartPoint = this.getChartPoint(stepsValue); // Join today's steps value. chartPoints.push(nowChartPoint); chartValues.data = chartPoints; }).catch((error: Error) => { Logger.error(CommonConstants.TAG_CHART, 'getChartPoints error ' + JSON.stringify(error)); }); return chartValues; }
AST#method_declaration#Left async getChartValues AST#parameter_list#Left ( AST#parameter#Left stepsValue : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left rdbStore : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left DataRdb . RdbStore 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 chartValues : AST#type_annotation#Left AST#primary_type#Left ChartValues 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 ChartValues 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 // Set fill color. AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left chartValues AST#expression#Right . fillColor AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . CHART_VALUES_FILL_COLOR AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // Set the color of the line. AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left chartValues AST#expression#Right . strokeColor AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . CHART_VALUES_STROKE_COLOR AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left chartValues AST#expression#Right . gradient 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 // Gets a collection of points from the previous three days. AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left chartPoints : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left ChartPoint [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#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#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . getChartPoints AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left rdbStore 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 pointArray : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#array_type#Left ChartPoint [ ] AST#array_type#Right AST#primary_type#Right | AST#primary_type#Left void AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left chartPoints = AST#expression#Left AST#as_expression#Left AST#expression#Left pointArray AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left ChartPoint [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left nowChartPoint : AST#type_annotation#Left AST#primary_type#Left ChartPoint AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getChartPoint AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left stepsValue 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 // Join today's steps value. AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left chartPoints AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left nowChartPoint 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 chartValues AST#expression#Right . data AST#member_expression#Right = AST#expression#Left chartPoints AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . catch AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left error : AST#type_annotation#Left AST#primary_type#Left Error AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . TAG_CHART AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'getChartPoints 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#statement#Left AST#return_statement#Left return AST#expression#Left chartValues AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async getChartValues(stepsValue: number, rdbStore: DataRdb.RdbStore) { let chartValues: ChartValues = new ChartValues(); chartValues.fillColor = CommonConstants.CHART_VALUES_FILL_COLOR; chartValues.strokeColor = CommonConstants.CHART_VALUES_STROKE_COLOR; chartValues.gradient = true; let chartPoints: ChartPoint[]; await this.getChartPoints(rdbStore).then((pointArray: ChartPoint[] | void) => { chartPoints = pointArray as ChartPoint[]; let nowChartPoint: ChartPoint = this.getChartPoint(stepsValue); chartPoints.push(nowChartPoint); chartValues.data = chartPoints; }).catch((error: Error) => { Logger.error(CommonConstants.TAG_CHART, 'getChartPoints error ' + JSON.stringify(error)); }); return chartValues; }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Card/StepsCardJS/entry/src/main/ets/common/utils/ChartDataUtils.ets#L49-L68
07aecd4a64356730b03c7ed231f28a94d38c5427
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/pulltorefreshnews/src/main/ets/viewModel/BasicDataSource.ets
arkts
notifyDataChange
通知LazyForEach组件需要在index对应索引处添加子组件
notifyDataChange(index: number): void { this.listeners.forEach(listener => { listener.onDataChange(index); }) }
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
notifyDataChange(index: number): void { this.listeners.forEach(listener => { listener.onDataChange(index); }) }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/pulltorefreshnews/src/main/ets/viewModel/BasicDataSource.ets#L57-L61
f9148992eaebb696d81460a25dd94b86eec3b2ea
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/shortcut/ShortcutManager.ets
arkts
dailyUpdate
每日更新快捷方式
async dailyUpdate(): Promise<void> { try { hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, 'Starting daily shortcut update'); // 移除过期的快捷方式 await this.removeExpiredShortcuts(); // 重新创建动态快捷方式 await this.createDynamicShortcuts(); hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, 'Daily shortcut update completed'); } catch (error) { hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Daily shortcut update failed: ${error}`); } }
AST#method_declaration#Left async dailyUpdate AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left 'Starting daily shortcut update' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 移除过期的快捷方式 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . removeExpiredShortcuts 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#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . createDynamicShortcuts AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left 'Daily shortcut update completed' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Daily shortcut update failed: AST#template_substitution#Left $ { AST#expression#Left error AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async dailyUpdate(): Promise<void> { try { hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, 'Starting daily shortcut update'); await this.removeExpiredShortcuts(); await this.createDynamicShortcuts(); hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, 'Daily shortcut update completed'); } catch (error) { hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Daily shortcut update failed: ${error}`); } }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/shortcut/ShortcutManager.ets#L320-L334
79b8bdd8a0c2df8378a40a2248adcc55e513db73
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/DocsSample/CoreFile/UserFile/ManagingExternalStorageDevices/entry/src/main/ets/pages/Index.ets
arkts
receiveBroadcastNotifications
[End subscribe_events_2] [Start subscribe_events_3]
receiveBroadcastNotifications() { // [StartExclude subscribe_events_3] Logger.info('receiveBroadcastNotifications() begin'); if (subscriber === undefined) { Logger.error('Subscriber is not defined. Please subscribe to events first.'); return; } // [EndExclude subscribe_events_3] commonEventManager.subscribe(subscriber, (err: BusinessError, data: commonEventManager.CommonEventData) => { // [StartExclude subscribe_events_3] if (err) { Logger.error('Subscription failed: ' + JSON.stringify(err)); return; } // [EndExclude subscribe_events_3] if (data.event === 'usual.event.data.VOLUME_MOUNTED' && data.parameters !== undefined) { let volId: string = data.parameters.id; volumeManager.getVolumeById(volId, (error: BusinessError, vol: volumeManager.Volume) => { if (error) { Logger.error('volumeManager getVolumeById failed for ' + JSON.stringify(error)); } else { Logger.info('volumeManager getVolumeById successfully, the volume state is ' + vol.state); // [StartExclude subscribe_events_3] this.message = 'Successfully obtained volume device information'; // [EndExclude subscribe_events_3] } }); } }); }
AST#method_declaration#Left receiveBroadcastNotifications AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { // [StartExclude subscribe_events_3] 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 'receiveBroadcastNotifications() begin' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left subscriber AST#expression#Right === AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Subscriber is not defined. Please subscribe to events first.' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left return AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right // [EndExclude subscribe_events_3] 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#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 commonEventManager . CommonEventData AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { // [StartExclude subscribe_events_3] 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 'Subscription failed: ' AST#expression#Right + AST#expression#Left JSON AST#expression#Right AST#binary_expression#Right AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#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 // [EndExclude subscribe_events_3] AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . event AST#member_expression#Right AST#expression#Right === AST#expression#Left 'usual.event.data.VOLUME_MOUNTED' AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left data AST#expression#Right AST#binary_expression#Right AST#expression#Right . parameters AST#member_expression#Right AST#expression#Right !== AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left volId : 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#member_expression#Left AST#expression#Left data AST#expression#Right . parameters AST#member_expression#Right AST#expression#Right . id AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left volumeManager AST#expression#Right . getVolumeById AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left volId 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 vol : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left volumeManager . Volume 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 { 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 'volumeManager getVolumeById failed for ' 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 else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'volumeManager getVolumeById successfully, the volume state is ' AST#expression#Right + AST#expression#Left vol AST#expression#Right AST#binary_expression#Right AST#expression#Right . state 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 // [StartExclude subscribe_events_3] AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . message AST#member_expression#Right = AST#expression#Left 'Successfully obtained volume device information' AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // [EndExclude subscribe_events_3] } 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#builder_function_body#Right AST#method_declaration#Right
receiveBroadcastNotifications() { Logger.info('receiveBroadcastNotifications() begin'); if (subscriber === undefined) { Logger.error('Subscriber is not defined. Please subscribe to events first.'); return; } commonEventManager.subscribe(subscriber, (err: BusinessError, data: commonEventManager.CommonEventData) => { if (err) { Logger.error('Subscription failed: ' + JSON.stringify(err)); return; } if (data.event === 'usual.event.data.VOLUME_MOUNTED' && data.parameters !== undefined) { let volId: string = data.parameters.id; volumeManager.getVolumeById(volId, (error: BusinessError, vol: volumeManager.Volume) => { if (error) { Logger.error('volumeManager getVolumeById failed for ' + JSON.stringify(error)); } else { Logger.info('volumeManager getVolumeById successfully, the volume state is ' + vol.state); this.message = 'Successfully obtained volume device information'; } }); } }); }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/CoreFile/UserFile/ManagingExternalStorageDevices/entry/src/main/ets/pages/Index.ets#L111-L140
33a8c14d7057aaadd9aa1d7efb054cf1459368b2
gitee
Joker-x-dev/HarmonyKit.git
f97197ce157df7f303244fba42e34918306dfb08
core/state/src/main/ets/DemoCounterState.ets
arkts
@file 全局计数器状态(ArkTS V2),提供跨页面共享的响应式状态 @author Joker.X AppStorageV2 键名
export const DEMO_COUNTER_KEY: string = "demo_counter_state";
AST#export_declaration#Left export AST#variable_declaration#Left const AST#variable_declarator#Left DEMO_COUNTER_KEY : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "demo_counter_state" AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#export_declaration#Right
export const DEMO_COUNTER_KEY: string = "demo_counter_state";
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/state/src/main/ets/DemoCounterState.ets#L11-L11
768bee46c3c34997888b9a471c97c2ad2f7b65b4
github
Joker-x-dev/HarmonyKit.git
f97197ce157df7f303244fba42e34918306dfb08
core/ibestui/Index.ets
arkts
@file ibestui 模块统一导出 @author Joker.X
export * from "@ibestservices/ibest-ui-v2";
AST#export_declaration#Left export * from "@ibestservices/ibest-ui-v2" ; AST#export_declaration#Right
export * from "@ibestservices/ibest-ui-v2";
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/ibestui/Index.ets#L6-L6
88cb427d1a697c1fc7b47db6ba47ca39e7c3d6d6
github
wangjinyuan/JS-TS-ArkTS-database.git
a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26
npm/alprazolamdiv/11.5.1/package/src/client/rest/RequestHandlers/RequestHandler.ets
arkts
构造函数参数类型标注(约束1)
constructor(restManager: RESTManager) { this.restManager = restManager; }
AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left restManager : AST#type_annotation#Left AST#primary_type#Left RESTManager 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 . restManager AST#member_expression#Right = AST#expression#Left restManager AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right
constructor(restManager: RESTManager) { this.restManager = restManager; }
https://github.com/wangjinyuan/JS-TS-ArkTS-database.git/blob/a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26/npm/alprazolamdiv/11.5.1/package/src/client/rest/RequestHandlers/RequestHandler.ets#L15-L17
815c7c898b24ab9217acc1c163984d7997adfd56
github
ccccjiemo/egl.git
d18849c3da975ccf9373fd09874aa5637ccbe6bd
BuildProfile.ets
arkts
Use these variables when you tailor your ArkTS code. They must be of the const type.
export const HAR_VERSION = '0.3.3';
AST#export_declaration#Left export AST#variable_declaration#Left const AST#variable_declarator#Left HAR_VERSION = AST#expression#Left '0.3.3' AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#export_declaration#Right
export const HAR_VERSION = '0.3.3';
https://github.com/ccccjiemo/egl.git/blob/d18849c3da975ccf9373fd09874aa5637ccbe6bd/BuildProfile.ets#L4-L4
d7a6190f55c01bb3e44bac4836899211b05c0eed
github
zqaini002/YaoYaoLingXian.git
5095b12cbeea524a87c42d0824b1702978843d39
YaoYaoLingXian/entry/src/main/ets/pages/community/PostDetailPage.ets
arkts
handleCommentLike
处理评论点赞
handleCommentLike(comment: Comment): void { if (comment && comment.likeCount !== undefined) { if (comment.isLiked) { comment.likeCount = Math.max(0, comment.likeCount - 1); } else { comment.likeCount += 1; } comment.isLiked = !comment.isLiked; } }
AST#method_declaration#Left handleCommentLike AST#parameter_list#Left ( AST#parameter#Left comment : 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#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left comment AST#expression#Right && AST#expression#Left comment AST#expression#Right AST#binary_expression#Right AST#expression#Right . likeCount AST#member_expression#Right AST#expression#Right !== AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left comment AST#expression#Right . isLiked 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 comment AST#expression#Right . likeCount AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . max AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left comment AST#expression#Right . likeCount 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#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } else { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left comment AST#expression#Right . likeCount AST#member_expression#Right += AST#expression#Left 1 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left comment AST#expression#Right . isLiked AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left comment AST#expression#Right AST#unary_expression#Right AST#expression#Right . isLiked AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
handleCommentLike(comment: Comment): void { if (comment && comment.likeCount !== undefined) { if (comment.isLiked) { comment.likeCount = Math.max(0, comment.likeCount - 1); } else { comment.likeCount += 1; } comment.isLiked = !comment.isLiked; } }
https://github.com/zqaini002/YaoYaoLingXian.git/blob/5095b12cbeea524a87c42d0824b1702978843d39/YaoYaoLingXian/entry/src/main/ets/pages/community/PostDetailPage.ets#L315-L324
f360857fd1b7b410df726d84e277335e387b80df
github
azhuge233/Wake-HarmonyOS.git
68c4e961f9cf5fab8699af99313dd5854ea313a1
entry/src/main/ets/model/DeviceList.ets
arkts
updateAllFormBelongsToDevice
以下为桌面卡片(Form)相关 仅更改持久化存储,不刷新卡片 UI 卡片 UI 在 ViewModel 刷新
private async updateAllFormBelongsToDevice(device: Device): Promise<string[]> { const updatedFormIDs = await this.pm.updateByDevice(device); Logger.debug(this.LOG_TAG, `已更新 ${updatedFormIDs.length} 个相关卡片`); return updatedFormIDs; }
AST#method_declaration#Left private async updateAllFormBelongsToDevice AST#parameter_list#Left ( AST#parameter#Left device : AST#type_annotation#Left AST#primary_type#Left Device AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left updatedFormIDs = 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 . pm AST#member_expression#Right AST#expression#Right . updateByDevice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left device AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . debug AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . LOG_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` 已更新 AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left updatedFormIDs AST#expression#Right . length AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right 个相关卡片 ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left updatedFormIDs AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private async updateAllFormBelongsToDevice(device: Device): Promise<string[]> { const updatedFormIDs = await this.pm.updateByDevice(device); Logger.debug(this.LOG_TAG, `已更新 ${updatedFormIDs.length} 个相关卡片`); return updatedFormIDs; }
https://github.com/azhuge233/Wake-HarmonyOS.git/blob/68c4e961f9cf5fab8699af99313dd5854ea313a1/entry/src/main/ets/model/DeviceList.ets#L119-L123
c686a4590800b20c2bdafb4d4733bf07047205ea
github
openharmony/arkui_ace_engine
30c7d1ee12fbedf0fabece54291d75897e2ad44f
frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/arkui/src/CallbackTransformer.ets
arkts
throw
Improve: need invert dependency: createUiDetachedRoot should be imported from @koalaui/arkoala same as in TS
export type UIDetachedRootCreator = ( peerFactory: () => PeerNode, @memo builder: () => void ) => PeerNode function createUiDetachedRootStub( factory: () => PeerNode, @memo builder: () => void ): PeerNode { throw
AST#export_declaration#Left export AST#ERROR#Left type UIDetachedRootCreator = ( AST#parameter#Left peerFactory : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left PeerNode AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#parameter#Right , AST#decorator#Left @ memo AST#ERROR#Left build er : AST#ERROR#Right ( ) AST#decorator#Right => void ) => PeerNode function createUiDetachedRootStub ( 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 PeerNode AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#parameter#Right , AST#decorator#Left @ memo AST#ERROR#Left build er : AST#ERROR#Right ( ) AST#decorator#Right => void ) : PeerNode AST#ERROR#Right { throw AST#export_declaration#Right
export type UIDetachedRootCreator = ( peerFactory: () => PeerNode, @memo builder: () => void ) => PeerNode function createUiDetachedRootStub( factory: () => PeerNode, @memo builder: () => void ): PeerNode { throw
https://github.com/openharmony/arkui_ace_engine/blob/30c7d1ee12fbedf0fabece54291d75897e2ad44f/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/arkui/src/CallbackTransformer.ets#L23-L34
0028bf367fbc95182cf3fb86a281d38441a55aa8
gitee
wangjinyuan/JS-TS-ArkTS-database.git
a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26
npm/alprazolamdiv/11.5.1/package/src/client/websocket/packets/handlers/RelationshipRemove.ets
arkts
应用约束60:使用export default代替module.exports
export default RelationshipRemoveHandler;
AST#export_declaration#Left export default AST#expression#Left RelationshipRemoveHandler AST#expression#Right ; AST#export_declaration#Right
export default RelationshipRemoveHandler;
https://github.com/wangjinyuan/JS-TS-ArkTS-database.git/blob/a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26/npm/alprazolamdiv/11.5.1/package/src/client/websocket/packets/handlers/RelationshipRemove.ets#L42-L42
3f37f79e719b9ecc2ebd4ee5a97807e9c6529515
github
Piagari/arkts_example.git
a63b868eaa2a50dc480d487b84c4650cc6a40fc8
hmos_app-main/hmos_app-main/coolmall-master/entry/src/main/ets/models/CommonModels.ets
arkts
子分类数据模型
export interface CategoryChild { id: number; name: string; pic: string; }
AST#export_declaration#Left export AST#interface_declaration#Left interface CategoryChild AST#object_type#Left { AST#type_member#Left id : 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 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 pic : 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 CategoryChild { id: number; name: string; pic: string; }
https://github.com/Piagari/arkts_example.git/blob/a63b868eaa2a50dc480d487b84c4650cc6a40fc8/hmos_app-main/hmos_app-main/coolmall-master/entry/src/main/ets/models/CommonModels.ets#L48-L52
634229be5fb21c877d274ed10fa9f92178bbe520
github
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
ComponentReuse/negative/src/main/ets/common/CustomRoutes.ets
arkts
Copyright (c) 2024 Huawei Device Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
export class CustomRoutes { static readonly ROUTES: Route[] = [ { title: '未使用组件复用', child: [ { text: '场景1', title: '列表项结构类型相同', to: 'NoReuseScene1' }, { text: '场景2', title: '列表项结构类型相同-结构一', to: 'NoReuseScene2_StructureOne' }, { text: '场景2', title: '列表项结构类型相同-结构二', to: 'NoReuseScene2_StructureTwo' }, { text: '场景3', title: '列表项内子组件可拆分组合', to: 'NoReuseScene3' } ] }, { title: '组件复用使用不当', child: [ { text: '场景1', title: '父组件未使用复用,子组件使用复用', to: 'ImproperReuseOfComponentsScene1' }, { text: '场景2', title: '复用嵌套', to: 'ImproperReuseOfComponentsScene2' }, { text: '场景3', title: 'reuseId分类过粗', to: 'ImproperReuseOfComponentsScene3' } ] } ] }
AST#export_declaration#Left export AST#class_declaration#Left class CustomRoutes AST#class_body#Left { AST#property_declaration#Left static readonly ROUTES : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Route [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left title AST#property_name#Right : AST#expression#Left '未使用组件复用' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left child AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left text AST#property_name#Right : AST#expression#Left '场景1' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left title AST#property_name#Right : AST#expression#Left '列表项结构类型相同' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left to AST#property_name#Right : AST#expression#Left 'NoReuseScene1' 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 text AST#property_name#Right : AST#expression#Left '场景2' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left title AST#property_name#Right : AST#expression#Left '列表项结构类型相同-结构一' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left to AST#property_name#Right : AST#expression#Left 'NoReuseScene2_StructureOne' 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 text AST#property_name#Right : AST#expression#Left '场景2' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left title AST#property_name#Right : AST#expression#Left '列表项结构类型相同-结构二' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left to AST#property_name#Right : AST#expression#Left 'NoReuseScene2_StructureTwo' 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 text AST#property_name#Right : AST#expression#Left '场景3' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left title AST#property_name#Right : AST#expression#Left '列表项内子组件可拆分组合' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left to AST#property_name#Right : AST#expression#Left 'NoReuseScene3' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left title AST#property_name#Right : AST#expression#Left '组件复用使用不当' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left child AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left text AST#property_name#Right : AST#expression#Left '场景1' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left title AST#property_name#Right : AST#expression#Left '父组件未使用复用,子组件使用复用' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left to AST#property_name#Right : AST#expression#Left 'ImproperReuseOfComponentsScene1' 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 text AST#property_name#Right : AST#expression#Left '场景2' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left title AST#property_name#Right : AST#expression#Left '复用嵌套' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left to AST#property_name#Right : AST#expression#Left 'ImproperReuseOfComponentsScene2' 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 text AST#property_name#Right : AST#expression#Left '场景3' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left title AST#property_name#Right : AST#expression#Left 'reuseId分类过粗' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left to AST#property_name#Right : AST#expression#Left 'ImproperReuseOfComponentsScene3' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class CustomRoutes { static readonly ROUTES: Route[] = [ { title: '未使用组件复用', child: [ { text: '场景1', title: '列表项结构类型相同', to: 'NoReuseScene1' }, { text: '场景2', title: '列表项结构类型相同-结构一', to: 'NoReuseScene2_StructureOne' }, { text: '场景2', title: '列表项结构类型相同-结构二', to: 'NoReuseScene2_StructureTwo' }, { text: '场景3', title: '列表项内子组件可拆分组合', to: 'NoReuseScene3' } ] }, { title: '组件复用使用不当', child: [ { text: '场景1', title: '父组件未使用复用,子组件使用复用', to: 'ImproperReuseOfComponentsScene1' }, { text: '场景2', title: '复用嵌套', to: 'ImproperReuseOfComponentsScene2' }, { text: '场景3', title: 'reuseId分类过粗', to: 'ImproperReuseOfComponentsScene3' } ] } ] }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/ComponentReuse/negative/src/main/ets/common/CustomRoutes.ets#L16-L36
73826a27c9747cdf08b6d2af35d88bbda00d5ba0
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/FormatUtil.ets
arkts
getPhoneLocationName
获取电话号码归属地 @param phone @param locale string 区域ID country string 表示电话号码所属国家或地区代码。 options PhoneNumberFormatOptions 电话号码格式化对象的相关选项。默认值:NATIONAL。 @returns
static getPhoneLocationName(phone: string, locale: string = "zh-CN", country: string = "CN", option?: i18n.PhoneNumberFormatOptions): string { const phoneNumberFormat: i18n.PhoneNumberFormat = new i18n.PhoneNumberFormat(country, option); return phoneNumberFormat.getLocationName(phone, locale); }
AST#method_declaration#Left static getPhoneLocationName AST#parameter_list#Left ( AST#parameter#Left phone : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left locale : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "zh-CN" AST#expression#Right AST#parameter#Right , AST#parameter#Left country : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "CN" AST#expression#Right AST#parameter#Right , AST#parameter#Left option ? : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left i18n . PhoneNumberFormatOptions AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left phoneNumberFormat : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left i18n . PhoneNumberFormat AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left i18n AST#expression#Right AST#new_expression#Right AST#expression#Right . PhoneNumberFormat AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left country AST#expression#Right , AST#expression#Left option AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left phoneNumberFormat AST#expression#Right . getLocationName AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left phone AST#expression#Right , AST#expression#Left locale 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 getPhoneLocationName(phone: string, locale: string = "zh-CN", country: string = "CN", option?: i18n.PhoneNumberFormatOptions): string { const phoneNumberFormat: i18n.PhoneNumberFormat = new i18n.PhoneNumberFormat(country, option); return phoneNumberFormat.getLocationName(phone, locale); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/FormatUtil.ets#L63-L67
376d2b580c7e172a27bba110e4bcbd5e640ee0a5
gitee
wangjinyuan/JS-TS-ArkTS-database.git
a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26
npm/alprazolamdiv/11.5.1/package/src/client/actions/GuildEmojiCreate.ets
arkts
Emitted whenever a custom emoji is created in a guild. @event Client#emojiCreate @param {Emoji} emoji The emoji that was created 应用约束60: 使用ES模块导出
export default GuildEmojiCreateAction;
AST#export_declaration#Left export default AST#expression#Left GuildEmojiCreateAction AST#expression#Right ; AST#export_declaration#Right
export default GuildEmojiCreateAction;
https://github.com/wangjinyuan/JS-TS-ArkTS-database.git/blob/a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26/npm/alprazolamdiv/11.5.1/package/src/client/actions/GuildEmojiCreate.ets#L32-L32
4ee611b9d0dbc747f93d0910021002610147ac80
github
XiangRui_FuZi/harmony-oscourse
da885f9a777a1eace7a07e1cd81137746687974b
class1/entry/src/main/ets/model/DataModel.ets
arkts
getData
Retrieve data at the specified index.
public getData(index: number): string { return this.tabContent[index]; }
AST#method_declaration#Left public getData AST#parameter_list#Left ( AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . tabContent AST#member_expression#Right AST#expression#Right [ AST#expression#Left index AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
public getData(index: number): string { return this.tabContent[index]; }
https://github.com/XiangRui_FuZi/harmony-oscourse/blob/da885f9a777a1eace7a07e1cd81137746687974b/class1/entry/src/main/ets/model/DataModel.ets#L60-L62
18d2e4bb4db6a8fbfd9e131eb3808ec85a57ca17
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/RegexUtil.ets
arkts
isEmail
判断传入的邮箱格式是否正确 @param content @returns
static isEmail(content: string): boolean { return RegexUtil.isMatch(content, RegexUtil.REG_EMAIL); }
AST#method_declaration#Left static isEmail AST#parameter_list#Left ( AST#parameter#Left content : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_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 RegexUtil AST#expression#Right . isMatch AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left content AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left RegexUtil AST#expression#Right . REG_EMAIL AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static isEmail(content: string): boolean { return RegexUtil.isMatch(content, RegexUtil.REG_EMAIL); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/RegexUtil.ets#L237-L239
54f8b4195239abb53735d8e4cedf1b12f725da9c
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/foldablescreencases/src/main/ets/viewmodel/MusicPlayViewModel.ets
arkts
playNext
播放后一首(根据当前循环模式)
async playNext() { switch (this.curLoopMode) { case AVSessionManager.LoopMode.LOOP_MODE_SINGLE: { this.seek(0); break; } case AVSessionManager.LoopMode.LOOP_MODE_LIST: { this.curMusicModelIndex = (this.curMusicModelIndex + 1) % this.musicModelArr.length; this.curMusicModelRaw = this.musicModelArr[this.curMusicModelIndex]; await this.reset(); await this.avsessionModel?.setSessionInfo(this.curMusicModelRaw); await this.prepare(() => { this.play(); }); break; }
AST#method_declaration#Left async playNext 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 switch ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . curLoopMode AST#member_expression#Right AST#expression#Right ) AST#container_content_body#Left { AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AVSessionManager AST#expression#Right . LoopMode AST#member_expression#Right AST#expression#Right . LOOP_MODE_SINGLE AST#member_expression#Right AST#expression#Right AST#expression_statement#Right AST#ERROR#Left : AST#ERROR#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left this AST#property_assignment#Right AST#object_literal#Right AST#expression#Right . seek AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left break 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#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AVSessionManager AST#expression#Right . LoopMode AST#member_expression#Right AST#expression#Right . LOOP_MODE_LIST AST#member_expression#Right AST#expression#Right AST#expression_statement#Right AST#ERROR#Left : AST#ERROR#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left this AST#property_assignment#Right AST#object_literal#Right AST#expression#Right . curMusicModelIndex AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . curMusicModelIndex AST#member_expression#Right AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right % AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . musicModelArr AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . curMusicModelRaw AST#member_expression#Right = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . musicModelArr AST#member_expression#Right AST#expression#Right [ AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . curMusicModelIndex AST#member_expression#Right AST#expression#Right ] AST#subscript_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#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . reset AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 . avsessionModel AST#member_expression#Right AST#expression#Right ?. setSessionInfo 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 . curMusicModelRaw AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . prepare AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . play AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left break AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
async playNext() { switch (this.curLoopMode) { case AVSessionManager.LoopMode.LOOP_MODE_SINGLE: { this.seek(0); break; } case AVSessionManager.LoopMode.LOOP_MODE_LIST: { this.curMusicModelIndex = (this.curMusicModelIndex + 1) % this.musicModelArr.length; this.curMusicModelRaw = this.musicModelArr[this.curMusicModelIndex]; await this.reset(); await this.avsessionModel?.setSessionInfo(this.curMusicModelRaw); await this.prepare(() => { this.play(); }); break; }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/foldablescreencases/src/main/ets/viewmodel/MusicPlayViewModel.ets#L356-L372
f773f86ef36c0cc3fd069c3ad7205ed424fa67e8
gitee
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/models/managers/plan/plancurve/Plan.ets
arkts
deleteWordIds
/ 删除wordIds
async deleteWordIds(wordIds: number[]): Promise<void> { await PlanManager.deleteWordIds(wordIds, this); }
AST#method_declaration#Left async deleteWordIds AST#parameter_list#Left ( AST#parameter#Left wordIds : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left number [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#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 PlanManager AST#expression#Right AST#await_expression#Right AST#expression#Right . deleteWordIds AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left wordIds AST#expression#Right , AST#expression#Left this 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 deleteWordIds(wordIds: number[]): Promise<void> { await PlanManager.deleteWordIds(wordIds, this); }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/managers/plan/plancurve/Plan.ets#L496-L498
e09c43551225040fde4cb56dc4641ef0a182914a
github
FantasyWind/fwrouter
eea785a7bf728862de1f88de487ef3857dee3364
router/src/main/ets/RouterManagerForNavigation.ets
arkts
init
RouterHandler相关方法
init(uiAbility: UIAbility): void { this.observerPageLifecycle(uiAbility) }
AST#method_declaration#Left init AST#parameter_list#Left ( AST#parameter#Left uiAbility : AST#type_annotation#Left AST#primary_type#Left UIAbility AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . observerPageLifecycle AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left uiAbility AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
init(uiAbility: UIAbility): void { this.observerPageLifecycle(uiAbility) }
https://github.com/FantasyWind/fwrouter/blob/eea785a7bf728862de1f88de487ef3857dee3364/router/src/main/ets/RouterManagerForNavigation.ets#L104-L106
af055ee7b64b6e0e301a5e2aba2a916504eae643
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/pendingitems/src/main/ets/pages/ToDoList.ets
arkts
itemEnd
item左滑显示工具栏
@Builder itemEnd(item: ToDo) { Row({ space: STYLE_CONFIG.ICON_GUTTER }) { Image($r('app.media.pendingitems_ic_public_settings_filled')).imageStyle() .onClick(() => { promptAction.showToast({ message: $r('app.string.pendingitems_incomplete') }); }) Image($r('app.media.pendingitems_ic_public_detail_filled')).imageStyle() .onClick(() => { promptAction.showToast({ message: $r('app.string.pendingitems_incomplete') }); }) Image($r('app.media.pendingitems_ic_public_delete_filled')).imageStyle() .id('delete_item') .onClick(() => { this.deleteTodoItem(item); }) } .padding(STYLE_CONFIG.OPERATION_BUTTON_PADDING) .justifyContent(FlexAlign.SpaceEvenly) }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right itemEnd AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left ToDo 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#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left AST#member_expression#Left AST#expression#Left STYLE_CONFIG AST#expression#Right . ICON_GUTTER 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.pendingitems_ic_public_settings_filled' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . imageStyle ( ) 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.pendingitems_incomplete' 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#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.pendingitems_ic_public_detail_filled' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . imageStyle ( ) 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.pendingitems_incomplete' 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#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.pendingitems_ic_public_delete_filled' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . imageStyle ( ) AST#modifier_chain_expression#Left . id ( AST#expression#Left 'delete_item' 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 this AST#expression#Right . deleteTodoItem 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#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#member_expression#Left AST#expression#Left STYLE_CONFIG AST#expression#Right . OPERATION_BUTTON_PADDING AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . SpaceEvenly AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#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 itemEnd(item: ToDo) { Row({ space: STYLE_CONFIG.ICON_GUTTER }) { Image($r('app.media.pendingitems_ic_public_settings_filled')).imageStyle() .onClick(() => { promptAction.showToast({ message: $r('app.string.pendingitems_incomplete') }); }) Image($r('app.media.pendingitems_ic_public_detail_filled')).imageStyle() .onClick(() => { promptAction.showToast({ message: $r('app.string.pendingitems_incomplete') }); }) Image($r('app.media.pendingitems_ic_public_delete_filled')).imageStyle() .id('delete_item') .onClick(() => { this.deleteTodoItem(item); }) } .padding(STYLE_CONFIG.OPERATION_BUTTON_PADDING) .justifyContent(FlexAlign.SpaceEvenly) }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/pendingitems/src/main/ets/pages/ToDoList.ets#L132-L151
4dce52b91b306f48f5be301c6731979f31ac0d1e
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/pages/Index_backup.ets
arkts
aboutToDisappear
页面生命周期 - 页面即将消失
aboutToDisappear() { hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, 'Index page aboutToDisappear'); }
AST#method_declaration#Left aboutToDisappear 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 hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left 'Index page aboutToDisappear' 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
aboutToDisappear() { hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, 'Index page aboutToDisappear'); }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/Index_backup.ets#L169-L171
97a7e7b0584f94faeb0b07073236a4af334bfbbc
github
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
Security/StringCipherArkTS/entry/src/main/ets/model/UserTableApi.ets
arkts
getListFromResultSet
Encapsulates the query result into the user information corresponding to the user. @param resultSet Query result set. @returns Result set of the user object type.
getListFromResultSet(resultSet: dataRdb.ResultSet): User[] { if (!resultSet) { Logger.error(`resultSet is null or undefined`); } let userList: User[] = []; for (let i = 0; i < resultSet.rowCount; i++) { resultSet.goToNextRow(); let user = new User(resultSet.getDouble(resultSet.getColumnIndex('id')), resultSet.getString(resultSet.getColumnIndex('username')), resultSet.getString(resultSet.getColumnIndex('password')), resultSet.getString(resultSet.getColumnIndex('authTag'))); userList.push(user); } return userList; }
AST#method_declaration#Left getListFromResultSet AST#parameter_list#Left ( AST#parameter#Left resultSet : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left dataRdb . ResultSet 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#array_type#Left User [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left resultSet 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 Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` resultSet is null or undefined ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left userList : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left User [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left resultSet AST#expression#Right AST#binary_expression#Right AST#expression#Right . rowCount AST#member_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resultSet AST#expression#Right . goToNextRow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left user = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left User AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resultSet AST#expression#Right . getDouble AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resultSet AST#expression#Right . getColumnIndex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'id' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resultSet AST#expression#Right . getString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resultSet AST#expression#Right . getColumnIndex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'username' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resultSet AST#expression#Right . getString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resultSet AST#expression#Right . getColumnIndex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'password' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resultSet AST#expression#Right . getString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resultSet AST#expression#Right . getColumnIndex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'authTag' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#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 userList AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left user AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left userList AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
getListFromResultSet(resultSet: dataRdb.ResultSet): User[] { if (!resultSet) { Logger.error(`resultSet is null or undefined`); } let userList: User[] = []; for (let i = 0; i < resultSet.rowCount; i++) { resultSet.goToNextRow(); let user = new User(resultSet.getDouble(resultSet.getColumnIndex('id')), resultSet.getString(resultSet.getColumnIndex('username')), resultSet.getString(resultSet.getColumnIndex('password')), resultSet.getString(resultSet.getColumnIndex('authTag'))); userList.push(user); } return userList; }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Security/StringCipherArkTS/entry/src/main/ets/model/UserTableApi.ets#L59-L73
0b00f7456ff0236eddd72a403ee04e637d8cb007
gitee
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_crypto/src/main/ets/crypto/encryption/sm2/SM2Sync.ets
arkts
@Author csx @DateTime 2024/3/18 10:33:03 @TODO SM2Sync SM2同步操作类 @Use 详细使用方法以及文档详见ohpm官网,地址https://ohpm.openharmony.cn/#/cn/detail/@yunkss%2Fef_crypto
export class SM2Sync { /** * 生成SM2的非对称密钥 * @param resultCoding 返回结果编码方式(hex/base64)-默认不传为base64格式 * @returns SM2密钥{publicKey:公钥,privateKey:私钥} */ static generateSM2Key(resultCoding: buffer.BufferEncoding = 'base64'): CryptoKey { return CryptoSyncUtil.generateCryptoKey('SM2_256', resultCoding); } /** * 加密 * @param encodeStr 待加密的字符串 * @param pubKey SM2公钥 * @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式 * @param resultCoding 返回结果编码方式(hex/base64)-默认不传为base64格式 */ static encode(str: string, pubKey: string, keyCoding: buffer.BufferEncoding, resultCoding: buffer.BufferEncoding = 'base64'): string { return CryptoSyncUtil.encodeAsym(str, pubKey, 'SM2_256', 'SM2_256|SM3', 256, keyCoding, resultCoding, false); } /** * 解密 * @param decodeStr 待解密的字符串 * @param priKey SM2私钥 * @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式 * @param dataCoding 入参字符串编码方式(hex/base64) - 不传默认为base64 */ static decode(str: string, priKey: string, keyCoding: buffer.BufferEncoding, dataCoding: buffer.BufferEncoding = 'base64'): string { return CryptoSyncUtil.decodeAsym(str, priKey, 'SM2_256', 'SM2_256|SM3', 256, keyCoding, dataCoding, false); } /** * 签名 * @param str 需要签名的字符串 * @param priKey 私钥 * @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式 * @param resultCoding 返回结果编码方式(hex/base64)-默认不传为base64格式 * @returns string 签名对象 */ static sign(str: string, priKey: string, keyCoding: buffer.BufferEncoding, resultCoding: buffer.BufferEncoding = 'base64'): string { return CryptoSyncUtil.sign(str, priKey, 'SM2_256', 'SM2_256|SM3', 256, keyCoding, resultCoding, false); } /** * 验签 * @param signStr 已签名的字符串 * @param verifyStr 需要验签的字符串 * @param pubKey SM2公钥 * @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式 * @param dataCoding 入参字符串编码方式(hex/base64) - 不传默认为base64 * @returns 验签结果,其中Msg为验签结果 */ static verify(signStr: string, verifyStr: string, pubKey: string, keyCoding: buffer.BufferEncoding, dataCoding: buffer.BufferEncoding = 'base64'): string { return CryptoSyncUtil.verify(signStr, verifyStr, pubKey, 'SM2_256', 'SM2_256|SM3', 256, keyCoding, dataCoding, false); } /** * 将服务器端生成的16进制的长度为130位的04开头的C1C3C2格式的SM2公钥转换为前端所需的ASN.1格式公钥字符串 * @param pubKey 04开头的16进制的130位的公钥字符串 * @returns 转换后的公钥字符串 */ static convertSM2PubKey(pubKey: string): string { if (pubKey.length != 130) { return '服务器端SM2公钥长度不正确~'; } //截取x参数 let px = pubKey.substring(2, 66); //截取y参数 let py = pubKey.substring(66); //转16进制放入对应的位置 04+x+y let pk: cryptoFramework.Point = { x: BigInt("0x" + px), y: BigInt("0x" + py) } //构建SM2公钥参数对象 let keyPair: cryptoFramework.ECCPubKeySpec = { params: cryptoFramework.ECCKeyUtil.genECCCommonParamsSpec('NID_sm2'), pk: pk, algName: 'SM2', specType: cryptoFramework.AsyKeySpecType.PUBLIC_KEY_SPEC } //创建密钥生成器 let keyPairGenerator = cryptoFramework.createAsyKeyGeneratorBySpec(keyPair); //生成uint8Array格式密钥 let unit8PubKey = keyPairGenerator.generatePubKeySync(); //转换成鸿蒙所需公钥字符串 return StrAndUintUtil.unitArray2String(unit8PubKey.getEncoded().data); } /** * 将服务器端生成的16进制的长度为64位的C1C3C2格式的SM2私钥转换为前端所需的ASN.1格式SM2私钥字符串 * @param priKey 16进制的64位的私钥字符串 * @returns 转换后的私钥字符串 */ static convertSM2PriKey(priKey: string): string { if (priKey.length != 64) { return '服务器端SM2私钥长度不正确~'; } //构建SM2私钥参数对象 let keyPair: cryptoFramework.ECCPriKeySpec = { params: cryptoFramework.ECCKeyUtil.genECCCommonParamsSpec('NID_sm2'), algName: 'SM2', sk: BigInt('0x' + priKey), specType: cryptoFramework.AsyKeySpecType.PRIVATE_KEY_SPEC } //创建密钥生成器 let keyPairGenerator = cryptoFramework.createAsyKeyGeneratorBySpec(keyPair); //生成uint8Array格式密钥 let unit8PriKey = keyPairGenerator.generatePriKeySync(); //转换成鸿蒙所需私钥字符串 return StrAndUintUtil.unitArray2String(unit8PriKey.getEncoded().data); } }
AST#export_declaration#Left export AST#class_declaration#Left class SM2Sync AST#class_body#Left { /** * 生成SM2的非对称密钥 * @param resultCoding 返回结果编码方式(hex/base64)-默认不传为base64格式 * @returns SM2密钥{publicKey:公钥,privateKey:私钥} */ AST#method_declaration#Left static generateSM2Key AST#parameter_list#Left ( AST#parameter#Left resultCoding : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left buffer . BufferEncoding AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'base64' AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left CryptoKey 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 CryptoSyncUtil AST#expression#Right . generateCryptoKey AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'SM2_256' AST#expression#Right , AST#expression#Left resultCoding 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 encodeStr 待加密的字符串 * @param pubKey SM2公钥 * @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式 * @param resultCoding 返回结果编码方式(hex/base64)-默认不传为base64格式 */ AST#method_declaration#Left static encode AST#parameter_list#Left ( AST#parameter#Left str : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left pubKey : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left keyCoding : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left buffer . BufferEncoding AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left resultCoding : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left buffer . BufferEncoding AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'base64' AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 CryptoSyncUtil AST#expression#Right . encodeAsym AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left str AST#expression#Right , AST#expression#Left pubKey AST#expression#Right , AST#expression#Left 'SM2_256' AST#expression#Right , AST#expression#Left 'SM2_256|SM3' AST#expression#Right , AST#expression#Left 256 AST#expression#Right , AST#expression#Left keyCoding AST#expression#Right , AST#expression#Left resultCoding 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 /** * 解密 * @param decodeStr 待解密的字符串 * @param priKey SM2私钥 * @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式 * @param dataCoding 入参字符串编码方式(hex/base64) - 不传默认为base64 */ AST#method_declaration#Left static decode AST#parameter_list#Left ( AST#parameter#Left str : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left priKey : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left keyCoding : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left buffer . BufferEncoding AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left dataCoding : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left buffer . BufferEncoding AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'base64' AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 CryptoSyncUtil AST#expression#Right . decodeAsym AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left str AST#expression#Right , AST#expression#Left priKey AST#expression#Right , AST#expression#Left 'SM2_256' AST#expression#Right , AST#expression#Left 'SM2_256|SM3' AST#expression#Right , AST#expression#Left 256 AST#expression#Right , AST#expression#Left keyCoding AST#expression#Right , AST#expression#Left dataCoding 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 /** * 签名 * @param str 需要签名的字符串 * @param priKey 私钥 * @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式 * @param resultCoding 返回结果编码方式(hex/base64)-默认不传为base64格式 * @returns string 签名对象 */ AST#method_declaration#Left static sign AST#parameter_list#Left ( AST#parameter#Left str : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left priKey : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left keyCoding : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left buffer . BufferEncoding AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left resultCoding : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left buffer . BufferEncoding AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'base64' AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 CryptoSyncUtil AST#expression#Right . sign AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left str AST#expression#Right , AST#expression#Left priKey AST#expression#Right , AST#expression#Left 'SM2_256' AST#expression#Right , AST#expression#Left 'SM2_256|SM3' AST#expression#Right , AST#expression#Left 256 AST#expression#Right , AST#expression#Left keyCoding AST#expression#Right , AST#expression#Left resultCoding 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 /** * 验签 * @param signStr 已签名的字符串 * @param verifyStr 需要验签的字符串 * @param pubKey SM2公钥 * @param keyCoding 密钥编码方式(utf8/hex/base64) 普通字符串则选择utf8格式 * @param dataCoding 入参字符串编码方式(hex/base64) - 不传默认为base64 * @returns 验签结果,其中Msg为验签结果 */ AST#method_declaration#Left static verify AST#parameter_list#Left ( AST#parameter#Left signStr : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left verifyStr : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left pubKey : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left keyCoding : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left buffer . BufferEncoding AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left dataCoding : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left buffer . BufferEncoding AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'base64' AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 CryptoSyncUtil AST#expression#Right . verify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left signStr AST#expression#Right , AST#expression#Left verifyStr AST#expression#Right , AST#expression#Left pubKey AST#expression#Right , AST#expression#Left 'SM2_256' AST#expression#Right , AST#expression#Left 'SM2_256|SM3' AST#expression#Right , AST#expression#Left 256 AST#expression#Right , AST#expression#Left keyCoding AST#expression#Right , AST#expression#Left dataCoding 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 /** * 将服务器端生成的16进制的长度为130位的04开头的C1C3C2格式的SM2公钥转换为前端所需的ASN.1格式公钥字符串 * @param pubKey 04开头的16进制的130位的公钥字符串 * @returns 转换后的公钥字符串 */ AST#method_declaration#Left static convertSM2PubKey AST#parameter_list#Left ( AST#parameter#Left pubKey : 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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left pubKey AST#expression#Right . length AST#member_expression#Right AST#expression#Right != AST#expression#Left 130 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 '服务器端SM2公钥长度不正确~' AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right //截取x参数 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left px = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left pubKey AST#expression#Right . substring AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 2 AST#expression#Right , AST#expression#Left 66 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 //截取y参数 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left py = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left pubKey AST#expression#Right . substring AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 66 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 //转16进制放入对应的位置 04+x+y AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left pk : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . Point AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left BigInt AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left "0x" AST#expression#Right + AST#expression#Left px AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left BigInt AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left "0x" AST#expression#Right + AST#expression#Left py AST#expression#Right AST#binary_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#variable_declarator#Right //构建SM2公钥参数对象 AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left keyPair : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . ECCPubKeySpec 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 params AST#property_name#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 cryptoFramework AST#expression#Right . ECCKeyUtil AST#member_expression#Right AST#expression#Right . genECCCommonParamsSpec AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'NID_sm2' 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 pk AST#property_name#Right : AST#expression#Left pk AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left algName AST#property_name#Right : AST#expression#Left 'SM2' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left specType AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . AsyKeySpecType AST#member_expression#Right AST#expression#Right . PUBLIC_KEY_SPEC AST#member_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#variable_declaration#Left let AST#variable_declarator#Left keyPairGenerator = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . createAsyKeyGeneratorBySpec AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left keyPair 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 //生成uint8Array格式密钥 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left unit8PubKey = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left keyPairGenerator AST#expression#Right . generatePubKeySync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right //转换成鸿蒙所需公钥字符串 AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left StrAndUintUtil AST#expression#Right . unitArray2String AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left unit8PubKey AST#expression#Right . getEncoded AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . data AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 将服务器端生成的16进制的长度为64位的C1C3C2格式的SM2私钥转换为前端所需的ASN.1格式SM2私钥字符串 * @param priKey 16进制的64位的私钥字符串 * @returns 转换后的私钥字符串 */ AST#method_declaration#Left static convertSM2PriKey AST#parameter_list#Left ( AST#parameter#Left priKey : 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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left priKey AST#expression#Right . length AST#member_expression#Right AST#expression#Right != AST#expression#Left 64 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 '服务器端SM2私钥长度不正确~' AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right //构建SM2私钥参数对象 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left keyPair : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . ECCPriKeySpec 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 params AST#property_name#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 cryptoFramework AST#expression#Right . ECCKeyUtil AST#member_expression#Right AST#expression#Right . genECCCommonParamsSpec AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'NID_sm2' 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 algName AST#property_name#Right : AST#expression#Left 'SM2' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left sk AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left BigInt AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left '0x' AST#expression#Right + AST#expression#Left priKey AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left specType AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . AsyKeySpecType AST#member_expression#Right AST#expression#Right . PRIVATE_KEY_SPEC AST#member_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#variable_declaration#Left let AST#variable_declarator#Left keyPairGenerator = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . createAsyKeyGeneratorBySpec AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left keyPair 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 //生成uint8Array格式密钥 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left unit8PriKey = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left keyPairGenerator AST#expression#Right . generatePriKeySync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right //转换成鸿蒙所需私钥字符串 AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left StrAndUintUtil AST#expression#Right . unitArray2String AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left unit8PriKey AST#expression#Right . getEncoded AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . data AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class SM2Sync { static generateSM2Key(resultCoding: buffer.BufferEncoding = 'base64'): CryptoKey { return CryptoSyncUtil.generateCryptoKey('SM2_256', resultCoding); } static encode(str: string, pubKey: string, keyCoding: buffer.BufferEncoding, resultCoding: buffer.BufferEncoding = 'base64'): string { return CryptoSyncUtil.encodeAsym(str, pubKey, 'SM2_256', 'SM2_256|SM3', 256, keyCoding, resultCoding, false); } static decode(str: string, priKey: string, keyCoding: buffer.BufferEncoding, dataCoding: buffer.BufferEncoding = 'base64'): string { return CryptoSyncUtil.decodeAsym(str, priKey, 'SM2_256', 'SM2_256|SM3', 256, keyCoding, dataCoding, false); } static sign(str: string, priKey: string, keyCoding: buffer.BufferEncoding, resultCoding: buffer.BufferEncoding = 'base64'): string { return CryptoSyncUtil.sign(str, priKey, 'SM2_256', 'SM2_256|SM3', 256, keyCoding, resultCoding, false); } static verify(signStr: string, verifyStr: string, pubKey: string, keyCoding: buffer.BufferEncoding, dataCoding: buffer.BufferEncoding = 'base64'): string { return CryptoSyncUtil.verify(signStr, verifyStr, pubKey, 'SM2_256', 'SM2_256|SM3', 256, keyCoding, dataCoding, false); } static convertSM2PubKey(pubKey: string): string { if (pubKey.length != 130) { return '服务器端SM2公钥长度不正确~'; } let px = pubKey.substring(2, 66); let py = pubKey.substring(66); let pk: cryptoFramework.Point = { x: BigInt("0x" + px), y: BigInt("0x" + py) } let keyPair: cryptoFramework.ECCPubKeySpec = { params: cryptoFramework.ECCKeyUtil.genECCCommonParamsSpec('NID_sm2'), pk: pk, algName: 'SM2', specType: cryptoFramework.AsyKeySpecType.PUBLIC_KEY_SPEC } let keyPairGenerator = cryptoFramework.createAsyKeyGeneratorBySpec(keyPair); let unit8PubKey = keyPairGenerator.generatePubKeySync(); return StrAndUintUtil.unitArray2String(unit8PubKey.getEncoded().data); } static convertSM2PriKey(priKey: string): string { if (priKey.length != 64) { return '服务器端SM2私钥长度不正确~'; } let keyPair: cryptoFramework.ECCPriKeySpec = { params: cryptoFramework.ECCKeyUtil.genECCCommonParamsSpec('NID_sm2'), algName: 'SM2', sk: BigInt('0x' + priKey), specType: cryptoFramework.AsyKeySpecType.PRIVATE_KEY_SPEC } let keyPairGenerator = cryptoFramework.createAsyKeyGeneratorBySpec(keyPair); let unit8PriKey = keyPairGenerator.generatePriKeySync(); return StrAndUintUtil.unitArray2String(unit8PriKey.getEncoded().data); } }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto/src/main/ets/crypto/encryption/sm2/SM2Sync.ets#L28-L146
05e895299229f6da7c55dba94f921333ef7cc0ee
gitee
hqj201013136012/HarmonyMiliUiPro.git
0625e681e07b771998a0ac4430824627d0eb60ed
entry/src/main/ets/view/launcher/BannerCards.ets
arkts
aboutToAppear
onPageShow(): void { console.log("homeAddCardsData onPageShow ") this.initData() }
aboutToAppear(): void { console.log("homeAddCardsData aboutToAppear ") this.initData() }
AST#method_declaration#Left aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "homeAddCardsData aboutToAppear " 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 . initData 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
aboutToAppear(): void { console.log("homeAddCardsData aboutToAppear ") this.initData() }
https://github.com/hqj201013136012/HarmonyMiliUiPro.git/blob/0625e681e07b771998a0ac4430824627d0eb60ed/entry/src/main/ets/view/launcher/BannerCards.ets#L35-L38
0a21bf0a09953812b979f24234ee9111ef22f6a1
github
vhall/VHLive_SDK_Harmony
29c820e5301e17ae01bc6bdcc393a4437b518e7c
watchKit/src/main/ets/components/watch/VHLinkTextView.ets
arkts
openLink
打开链接
private openLink(url: string) { const params=new WebViewParams("e.vhall.com",url); this.contentNode = new ComponentContent(this.getUIContext(), wrapBuilder(WebViewPageBuilder),params); PromptActionClass.setContext(this.getUIContext()); PromptActionClass.setContentNode(this.contentNode); PromptActionClass.setOptions({alignment: DialogAlignment.Center, offset: { dx: 0, dy: 50 } ,isModal: true,maskRect:{x: 0, y: 0, width: '100%', height: '100%' }}); PromptActionClass.openDialog(); }
AST#method_declaration#Left private openLink AST#parameter_list#Left ( AST#parameter#Left url : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left params = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left WebViewParams AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "e.vhall.com" AST#expression#Right , AST#expression#Left url AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . contentNode AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ComponentContent AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getUIContext AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left wrapBuilder AST#expression#Right AST#argument_list#Left ( AST#expression#Left WebViewPageBuilder AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left params 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 PromptActionClass AST#expression#Right . setContext 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 this AST#expression#Right . getUIContext AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#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 PromptActionClass AST#expression#Right . setContentNode AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . contentNode AST#member_expression#Right AST#expression#Right ) AST#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 PromptActionClass AST#expression#Right . setOptions 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 alignment AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left DialogAlignment AST#expression#Right . Center AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offset AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left dx AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left dy AST#property_name#Right : AST#expression#Left 50 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left isModal AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left maskRect AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left '100%' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left height AST#property_name#Right : AST#expression#Left '100%' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right } 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 PromptActionClass AST#expression#Right . openDialog 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 openLink(url: string) { const params=new WebViewParams("e.vhall.com",url); this.contentNode = new ComponentContent(this.getUIContext(), wrapBuilder(WebViewPageBuilder),params); PromptActionClass.setContext(this.getUIContext()); PromptActionClass.setContentNode(this.contentNode); PromptActionClass.setOptions({alignment: DialogAlignment.Center, offset: { dx: 0, dy: 50 } ,isModal: true,maskRect:{x: 0, y: 0, width: '100%', height: '100%' }}); PromptActionClass.openDialog(); }
https://github.com/vhall/VHLive_SDK_Harmony/blob/29c820e5301e17ae01bc6bdcc393a4437b518e7c/watchKit/src/main/ets/components/watch/VHLinkTextView.ets#L58-L65
f80a064a9cdded533bc0c3a61fd5eaafdcdf221d
gitee
openharmony/applications_settings
aac607310ec30e30d1d54db2e04d055655f72730
common/component/src/main/ets/default/textComponent.ets
arkts
TextComponentWithEndText
Text title with end text layout with harmony round style used in list item. Note that this does not contains the white padding when is touched. If you want to use it in single touch layout, wrap it with extra container component.
@Component export struct TextComponentWithEndText { @State endText: string = ""; @State isTouched: boolean = false; private title: string | Resource = ''; build() { Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { Row() { Text(this.title) .fontSize($r('app.float.font_16')) .fontColor($r('app.color.font_color_182431')) .fontWeight(FontWeight.Medium) .textAlign(TextAlign.Start); } Row() { Text(this.endText) .fontSize($r('app.float.font_14')) .fontColor($r('app.color.font_color_182431')) .margin({ right: $r('app.float.distance_4') }) .textAlign(TextAlign.End); Image('/res/image/ic_settings_arrow.svg') .width($r('app.float.wh_value_12')) .height($r('app.float.wh_value_24')) .fillColor($r("sys.color.ohos_id_color_primary")) .opacity($r("app.float.opacity_0_2")) } } .padding({ left: $r('sys.float.ohos_id_card_margin_start'), right: $r('sys.float.ohos_id_card_margin_end') }) .height($r('app.float.wh_value_48')) .width(ComponentConfig.WH_100_100) .borderRadius($r('app.float.radius_24')) .onClick(event => this.clickEvent(event)) .linearGradient(this.isTouched ? { angle: 90, direction: GradientDirection.Right, colors: [[$r("app.color.DCEAF9"), 0.0], [$r("app.color.FAFAFA"), 1.0]] } : { angle: 90, direction: GradientDirection.Right, colors: [[$r("sys.color.ohos_id_color_foreground_contrary"), 1], [$r("sys.color.ohos_id_color_foreground_contrary"), 1]] }) .onTouch((event?: TouchEvent | undefined) => { if (event?.type === TouchType.Down) { this.isTouched = true; } if (event?.type === TouchType.Up) { this.isTouched = false; } }); } private clickEvent: (event?: ClickEvent) => void = () => { }; }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct TextComponentWithEndText AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right endText : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "" AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right isTouched : 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 title : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left Resource AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left '' AST#expression#Right ; AST#property_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Flex ( AST#component_parameters#Left { AST#component_parameter#Left 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 alignItems : AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left 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 . title AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.font_16' 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.font_color_182431' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Medium AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . 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#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left 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 . endText 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.font_14' 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.font_color_182431' 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 right AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.distance_4' 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 . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign 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#ERROR#Left ; AST#ERROR#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left '/res/image/ic_settings_arrow.svg' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.wh_value_12' 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.wh_value_24' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fillColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "sys.color.ohos_id_color_primary" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . opacity ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.float.opacity_0_2" 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#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 'sys.float.ohos_id_card_margin_start' 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 'sys.float.ohos_id_card_margin_end' 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.wh_value_48' 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 ComponentConfig AST#expression#Right . WH_100_100 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.float.radius_24' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left event => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . clickEvent AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left event AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Left . linearGradient ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isTouched AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left angle AST#property_name#Right : AST#expression#Left 90 AST#expression#Right AST#property_assignment#Right , AST#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 . Right AST#member_expression#Right 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.DCEAF9" AST#expression#Right ) AST#resource_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#resource_expression#Left $r ( AST#expression#Left "app.color.FAFAFA" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left 1.0 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#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left angle AST#property_name#Right : AST#expression#Left 90 AST#expression#Right AST#property_assignment#Right , AST#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 . Right AST#member_expression#Right 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 "sys.color.ohos_id_color_foreground_contrary" 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#expression#Left AST#array_literal#Left [ AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "sys.color.ohos_id_color_foreground_contrary" 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#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onTouch ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left event ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left TouchEvent 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#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left event AST#expression#Right ?. type AST#member_expression#Right AST#expression#Right === AST#expression#Left TouchType AST#expression#Right AST#binary_expression#Right AST#expression#Right . Down AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isTouched AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left event AST#expression#Right ?. type AST#member_expression#Right AST#expression#Right === AST#expression#Left TouchType AST#expression#Right AST#binary_expression#Right AST#expression#Right . Up AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isTouched AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right } AST#build_body#Right AST#build_method#Right AST#property_declaration#Left private clickEvent : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left event ? : AST#type_annotation#Left AST#primary_type#Left ClickEvent 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#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#component_body#Right AST#decorated_export_declaration#Right
@Component export struct TextComponentWithEndText { @State endText: string = ""; @State isTouched: boolean = false; private title: string | Resource = ''; build() { Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { Row() { Text(this.title) .fontSize($r('app.float.font_16')) .fontColor($r('app.color.font_color_182431')) .fontWeight(FontWeight.Medium) .textAlign(TextAlign.Start); } Row() { Text(this.endText) .fontSize($r('app.float.font_14')) .fontColor($r('app.color.font_color_182431')) .margin({ right: $r('app.float.distance_4') }) .textAlign(TextAlign.End); Image('/res/image/ic_settings_arrow.svg') .width($r('app.float.wh_value_12')) .height($r('app.float.wh_value_24')) .fillColor($r("sys.color.ohos_id_color_primary")) .opacity($r("app.float.opacity_0_2")) } } .padding({ left: $r('sys.float.ohos_id_card_margin_start'), right: $r('sys.float.ohos_id_card_margin_end') }) .height($r('app.float.wh_value_48')) .width(ComponentConfig.WH_100_100) .borderRadius($r('app.float.radius_24')) .onClick(event => this.clickEvent(event)) .linearGradient(this.isTouched ? { angle: 90, direction: GradientDirection.Right, colors: [[$r("app.color.DCEAF9"), 0.0], [$r("app.color.FAFAFA"), 1.0]] } : { angle: 90, direction: GradientDirection.Right, colors: [[$r("sys.color.ohos_id_color_foreground_contrary"), 1], [$r("sys.color.ohos_id_color_foreground_contrary"), 1]] }) .onTouch((event?: TouchEvent | undefined) => { if (event?.type === TouchType.Down) { this.isTouched = true; } if (event?.type === TouchType.Up) { this.isTouched = false; } }); } private clickEvent: (event?: ClickEvent) => void = () => { }; }
https://github.com/openharmony/applications_settings/blob/aac607310ec30e30d1d54db2e04d055655f72730/common/component/src/main/ets/default/textComponent.ets#L107-L165
e14e0b73ebdf9c042c8a8007e156a8eb9e346cdd
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
harmonyos/src/main/ets/services/ai/AIAssistantService.ets
arkts
建议动作接口
export interface SuggestedAction { id: string; type: ActionType; title: string; description: string; priority: number; parameters?: Record<string, any>; }
AST#export_declaration#Left export AST#interface_declaration#Left interface SuggestedAction 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 type : AST#type_annotation#Left AST#primary_type#Left ActionType 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 description : 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 priority : 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 parameters ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Record AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left any AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
export interface SuggestedAction { id: string; type: ActionType; title: string; description: string; priority: number; parameters?: Record<string, any>; }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/harmonyos/src/main/ets/services/ai/AIAssistantService.ets#L192-L199
d6e2149298faf30f61bcac237f6ca4d96c13bff4
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/pages/settings/ThemeCustomizationPage.ets
arkts
buildThemeModeSection
构建主题模式选择
@Builder buildThemeModeSection() { Card() { Column({ space: UIConstants.DEFAULT_PADDING }) { Text('主题模式') .fontSize(UIConstants.FONT_SIZE_HEADING) .fontWeight(FontWeight.Medium) .fontColor($r('app.color.text_primary')) Row({ space: UIConstants.SMALL_PADDING }) { ForEach([ { mode: ThemeMode.LIGHT, name: '浅色', icon: $r('app.media.ic_light_mode') }, { mode: ThemeMode.DARK, name: '深色', icon: $r('app.media.ic_dark_mode') }, { mode: ThemeMode.AUTO, name: '自动', icon: $r('app.media.ic_auto_mode') } ], (item) => { Column({ space: UIConstants.SMALL_PADDING }) { Button() { Image(item.icon) .width('24vp') .height('24vp') .fillColor(this.selectedThemeMode === item.mode ? Color.White : $r('app.color.text_primary')) } .type(ButtonType.Circle) .width('48vp') .height('48vp') .backgroundColor(this.selectedThemeMode === item.mode ? $r('app.color.primary') : $r('app.color.background')) .onClick(() => this.onThemeModeChange(item.mode)) Text(item.name) .fontSize(UIConstants.FONT_SIZE_CAPTION) .fontColor($r('app.color.text_secondary')) } .alignItems(HorizontalAlign.Center) .layoutWeight(1) }) } .width('100%') } .width('100%') .padding(UIConstants.DEFAULT_PADDING) } }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildThemeModeSection 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 Card ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left AST#member_expression#Left AST#expression#Left UIConstants AST#expression#Right . DEFAULT_PADDING 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 Text ( AST#expression#Left '主题模式' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#member_expression#Left AST#expression#Left UIConstants AST#expression#Right . FONT_SIZE_HEADING AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Medium AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.text_primary' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#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 AST#member_expression#Left AST#expression#Left UIConstants AST#expression#Right . SMALL_PADDING 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#array_literal#Left [ AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left mode AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left ThemeMode AST#expression#Right . LIGHT AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left name AST#property_name#Right : AST#expression#Left '浅色' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left icon AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.ic_light_mode' AST#expression#Right ) AST#resource_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 mode AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left ThemeMode AST#expression#Right . DARK AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left name AST#property_name#Right : AST#expression#Left '深色' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left icon AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.ic_dark_mode' AST#expression#Right ) AST#resource_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 mode AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left ThemeMode AST#expression#Right . AUTO AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left name AST#property_name#Right : AST#expression#Left '自动' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left icon AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.ic_auto_mode' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right , AST#ui_builder_arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item AST#parameter#Right ) AST#parameter_list#Right => AST#ui_arrow_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left AST#member_expression#Left AST#expression#Left UIConstants AST#expression#Right . SMALL_PADDING AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . icon AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '24vp' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '24vp' AST#expression#Right ) AST#modifier_chain_expression#Left . fillColor ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedThemeMode AST#member_expression#Right AST#expression#Right === AST#expression#Left item AST#expression#Right AST#binary_expression#Right AST#expression#Right . mode 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 AST#resource_expression#Left $r ( AST#expression#Left 'app.color.text_primary' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#conditional_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 . type ( AST#expression#Left AST#member_expression#Left AST#expression#Left ButtonType AST#expression#Right . Circle AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '48vp' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '48vp' 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 AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedThemeMode AST#member_expression#Right AST#expression#Right === AST#expression#Left item AST#expression#Right AST#binary_expression#Right AST#expression#Right . mode AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.primary' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.background' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#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#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . onThemeModeChange AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . mode AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . name AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#member_expression#Left AST#expression#Left UIConstants AST#expression#Right . FONT_SIZE_CAPTION AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.text_secondary' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . 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 . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#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 '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#member_expression#Left AST#expression#Left UIConstants AST#expression#Right . DEFAULT_PADDING 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#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
@Builder buildThemeModeSection() { Card() { Column({ space: UIConstants.DEFAULT_PADDING }) { Text('主题模式') .fontSize(UIConstants.FONT_SIZE_HEADING) .fontWeight(FontWeight.Medium) .fontColor($r('app.color.text_primary')) Row({ space: UIConstants.SMALL_PADDING }) { ForEach([ { mode: ThemeMode.LIGHT, name: '浅色', icon: $r('app.media.ic_light_mode') }, { mode: ThemeMode.DARK, name: '深色', icon: $r('app.media.ic_dark_mode') }, { mode: ThemeMode.AUTO, name: '自动', icon: $r('app.media.ic_auto_mode') } ], (item) => { Column({ space: UIConstants.SMALL_PADDING }) { Button() { Image(item.icon) .width('24vp') .height('24vp') .fillColor(this.selectedThemeMode === item.mode ? Color.White : $r('app.color.text_primary')) } .type(ButtonType.Circle) .width('48vp') .height('48vp') .backgroundColor(this.selectedThemeMode === item.mode ? $r('app.color.primary') : $r('app.color.background')) .onClick(() => this.onThemeModeChange(item.mode)) Text(item.name) .fontSize(UIConstants.FONT_SIZE_CAPTION) .fontColor($r('app.color.text_secondary')) } .alignItems(HorizontalAlign.Center) .layoutWeight(1) }) } .width('100%') } .width('100%') .padding(UIConstants.DEFAULT_PADDING) } }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/settings/ThemeCustomizationPage.ets#L339-L380
f9b9bdbef71b9ef68a1093bbf9e5d7831aa103bf
github
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/CharUtil.ets
arkts
isLetter
判断字符串char是否是字母 @param char @returns
static isLetter(char: string): boolean { return i18n.Unicode.isLetter(char); }
AST#method_declaration#Left static isLetter AST#parameter_list#Left ( AST#parameter#Left char : 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 i18n AST#expression#Right . Unicode AST#member_expression#Right AST#expression#Right . isLetter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left char AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static isLetter(char: string): boolean { return i18n.Unicode.isLetter(char); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/CharUtil.ets#L40-L42
d2219089c3bfbf7c34a65353b39c6838716b06ce
gitee
openharmony-tpc-incubate/photo-deal-demo
01382ce30b1785f8fc8bc14f6b94f0a670a5b50b
library/src/main/ets/controller/EditController.ets
arkts
操作数据
export type OperateData = TextInputData | CropData | MosaicData | PaletteData;
AST#export_declaration#Left export AST#type_declaration#Left type OperateData = AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left TextInputData AST#primary_type#Right | AST#primary_type#Left CropData AST#primary_type#Right | AST#primary_type#Left MosaicData AST#primary_type#Right | AST#primary_type#Left PaletteData AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right ; AST#type_declaration#Right AST#export_declaration#Right
export type OperateData = TextInputData | CropData | MosaicData | PaletteData;
https://github.com/openharmony-tpc-incubate/photo-deal-demo/blob/01382ce30b1785f8fc8bc14f6b94f0a670a5b50b/library/src/main/ets/controller/EditController.ets#L25-L25
31db8f782fb93c11ec30cef92b5aa2edbcc11404
gitee
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
CommonEventAndNotification/AlarmClock/entry/src/main/ets/view/Main/ClockArea.ets
arkts
startDrawTask
启动绘画任务
private startDrawTask() { let that = this; that.renderContext.translate( this.canvasSize / CommonConstants.DEFAULT_DOUBLE, this.canvasSize / CommonConstants.DEFAULT_DOUBLE); that.drawClockArea(); this.drawInterval = setInterval(() => { that.drawClockArea(); }, MainConstant.DEFAULT_ONE_SECOND_MS); }
AST#method_declaration#Left private startDrawTask AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left that = AST#expression#Left this AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left that AST#expression#Right . renderContext AST#member_expression#Right AST#expression#Right . translate 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 this AST#expression#Right . canvasSize AST#member_expression#Right AST#expression#Right / AST#expression#Left CommonConstants AST#expression#Right AST#binary_expression#Right AST#expression#Right . DEFAULT_DOUBLE AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . canvasSize AST#member_expression#Right AST#expression#Right / AST#expression#Left CommonConstants AST#expression#Right AST#binary_expression#Right AST#expression#Right . DEFAULT_DOUBLE 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 that AST#expression#Right . drawClockArea AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . drawInterval AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left setInterval AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left that AST#expression#Right . drawClockArea 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#expression#Left AST#member_expression#Left AST#expression#Left MainConstant AST#expression#Right . DEFAULT_ONE_SECOND_MS 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
private startDrawTask() { let that = this; that.renderContext.translate( this.canvasSize / CommonConstants.DEFAULT_DOUBLE, this.canvasSize / CommonConstants.DEFAULT_DOUBLE); that.drawClockArea(); this.drawInterval = setInterval(() => { that.drawClockArea(); }, MainConstant.DEFAULT_ONE_SECOND_MS); }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/CommonEventAndNotification/AlarmClock/entry/src/main/ets/view/Main/ClockArea.ets#L56-L65
1f828bf398054a2bb40e9d64d05a49cf515f558e
gitee
Application-Security-Automation/Arktan.git
3ad9cb05235e38b00cd5828476aa59a345afa1c0
dataset/completeness/function_call/chained_call/chained_call_002_F.ets
arkts
Introduction 链式调用
export function chained_call_002_F(taint_src : string) { new A().setData("_").clearData().setData("clean").f(); }
AST#export_declaration#Left export AST#function_declaration#Left function chained_call_002_F 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left A 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 . setData 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 . clearData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . setData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "clean" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . f 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#function_declaration#Right AST#export_declaration#Right
export function chained_call_002_F(taint_src : string) { new A().setData("_").clearData().setData("clean").f(); }
https://github.com/Application-Security-Automation/Arktan.git/blob/3ad9cb05235e38b00cd5828476aa59a345afa1c0/dataset/completeness/function_call/chained_call/chained_call_002_F.ets#L6-L9
82e3377a0cfd0069d0f89279bf1124f9c3903d13
github
zhongte/TaoYao
80850f3800dd6037216d3f7c58a2bf34a881c93f
taoyao/src/main/ets/shijing/taoyao/runtime/NormalPermissionRequest.ets
arkts
checkOtherConfig
检查权限的其它配置 @param permissions
checkOtherConfig(permissions: Array<Permissions>) { const locationPermissionIndex = permissions.indexOf(this.LOCATION_PERMISSION) const locationBackgroundIndex = permissions.indexOf(this.LOCATION_IN_BACKGROUND) if (locationPermissionIndex >= 0 && locationBackgroundIndex < 0) { /* * 对于位置权限,有两种情况 * 第一:申请模糊位置权限,大部分情况下,不会申请模糊位置权限,更多的是第二种情况。 * 第二:申请精确位置权限,需要先申请模糊位置权限。 */ permissions = [] permissions.push(this.APPROXIMATELY_LOCATION) permissions.push(this.LOCATION_PERMISSION) } if (locationBackgroundIndex >= 0) { // 申请后台位置权限,需要先申请模糊位置权限和精确位置权限。当用户点击弹窗授予前台位置权限后,应用通过弹窗、提示窗等形式告知用户前往设置界面授予后台位置权限。 permissions = [] permissions.push(this.APPROXIMATELY_LOCATION) permissions.push(this.LOCATION_PERMISSION) permissions.push(this.LOCATION_IN_BACKGROUND) } this.setNewPermission(permissions) }
AST#method_declaration#Left checkOtherConfig AST#parameter_list#Left ( AST#parameter#Left permissions : 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 Permissions AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left locationPermissionIndex = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left permissions AST#expression#Right . indexOf 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 . LOCATION_PERMISSION 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 locationBackgroundIndex = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left permissions AST#expression#Right . indexOf 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 . LOCATION_IN_BACKGROUND AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left locationPermissionIndex AST#expression#Right >= AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left locationBackgroundIndex 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#block_statement#Left { /* * 对于位置权限,有两种情况 * 第一:申请模糊位置权限,大部分情况下,不会申请模糊位置权限,更多的是第二种情况。 * 第二:申请精确位置权限,需要先申请模糊位置权限。 */ AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left permissions = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left permissions AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . APPROXIMATELY_LOCATION 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 permissions AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . LOCATION_PERMISSION 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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left locationBackgroundIndex 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 permissions = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left permissions AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . APPROXIMATELY_LOCATION 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 permissions AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . LOCATION_PERMISSION 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 permissions AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . LOCATION_IN_BACKGROUND 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . setNewPermission AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left permissions 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
checkOtherConfig(permissions: Array<Permissions>) { const locationPermissionIndex = permissions.indexOf(this.LOCATION_PERMISSION) const locationBackgroundIndex = permissions.indexOf(this.LOCATION_IN_BACKGROUND) if (locationPermissionIndex >= 0 && locationBackgroundIndex < 0) { permissions = [] permissions.push(this.APPROXIMATELY_LOCATION) permissions.push(this.LOCATION_PERMISSION) } if (locationBackgroundIndex >= 0) { permissions = [] permissions.push(this.APPROXIMATELY_LOCATION) permissions.push(this.LOCATION_PERMISSION) permissions.push(this.LOCATION_IN_BACKGROUND) } this.setNewPermission(permissions) }
https://github.com/zhongte/TaoYao/blob/80850f3800dd6037216d3f7c58a2bf34a881c93f/taoyao/src/main/ets/shijing/taoyao/runtime/NormalPermissionRequest.ets#L16-L37
63e9865fe953de298d8d23bc4f48405f3adfdea9
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/game/VirtualEconomyService.ets
arkts
交易记录接口
export interface Transaction { id: string; userId: string; type: TransactionType; itemId?: string; currencyType: CurrencyType; amount: number; balanceBefore: number; balanceAfter: number; reason: string; metadata: Record<string, any>; timestamp: string; }
AST#export_declaration#Left export AST#interface_declaration#Left interface Transaction 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 userId : 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 type : AST#type_annotation#Left AST#primary_type#Left TransactionType AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left itemId ? : 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 currencyType : AST#type_annotation#Left AST#primary_type#Left CurrencyType AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left amount : 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 balanceBefore : 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 balanceAfter : 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 reason : 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 metadata : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Record AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left any AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left timestamp : 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 Transaction { id: string; userId: string; type: TransactionType; itemId?: string; currencyType: CurrencyType; amount: number; balanceBefore: number; balanceAfter: number; reason: string; metadata: Record<string, any>; timestamp: string; }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/game/VirtualEconomyService.ets#L131-L143
c3b8084c76684059b282b4b5b5ff99cf5afa36bb
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/common/utils/AppUtility.ets
arkts
============================================================ 主工具类 ============================================================
export class AppUtility { // ================== 资源相关方法 ================== /** * Used for iab gold icon * @returns 图标资源ID数组 */ static getIabGoldIconResIds(): number[] { const ids: number[] = [ // $r('app.media.gold_iap1'), // $r('app.media.gold_iap2'), // $r('app.media.gold_iap3') ]; return ids; } /** * Used for Quiz Top icon * @returns 测验顶部图标资源ID数组 */ static getQuizTopIconResIds(): number[] { const ids: number[] = [ // $r('app.media.quiz_top_icon_0'), // $r('app.media.quiz_top_icon_1'), // $r('app.media.quiz_top_icon_2'), // $r('app.media.quiz_top_icon_3'), // $r('app.media.quiz_top_icon_4') ]; return ids; } /** * Used for Quiz top Text * @param context 上下文对象 * @returns 测验顶部文本数组 */ static getQuizTopTextStrings(context: common.Context): string[] { const texts: string[] = [ context.resourceManager.getStringSync($r('app.string.test_top_txt_unit').id), context.resourceManager.getStringSync($r('app.string.test_top_txt_all').id), context.resourceManager.getStringSync($r('app.string.test_top_txt_part').id), context.resourceManager.getStringSync($r('app.string.test_top_txt_mistake').id), context.resourceManager.getStringSync($r('app.string.test_top_txt_favorite').id) ]; return texts; } // ================== 数据处理方法 ================== /** * 根据数字返回大小 * @param size 字节大小 * @returns 格式化后的尺寸字符串 */ static getSizeStringFromBytes(size: number): string { const b: number = 1; const k: number = 1024 * b; const m: number = 1024 * k; const g: number = 1024 * m; const gg: number = size / g; if (gg > 1) { return `${gg.toFixed(1)}GB`; } const mm: number = size / m; if (mm > 1) { return `${mm.toFixed(1)}MB`; } const kk: number = size / k; return `${Math.round(kk)}KB`; } /** * 获取收藏等级星号字符串 * @param favoriteLevel 收藏等级 * @returns 星号字符串 */ static getStarOfFavoriteLevel(favoriteLevel: number): string { return "★".repeat(favoriteLevel); } /** * used for section title * @param wrangTimes 错误次数 * @returns 区间名称 */ static getSectionOfWrangTimes(wrangTimes: number): string | null { if (wrangTimes === 1) { return AppUtility.getNameOfMistake("Mistake_1_Only"); } else if (wrangTimes > 1 && wrangTimes <= 3) { return AppUtility.getNameOfMistake("Mistake_1_3"); } else if (wrangTimes > 3 && wrangTimes <= 5) { return AppUtility.getNameOfMistake("Mistake_3_5"); } else if (wrangTimes > 5 && wrangTimes <= 10) { return AppUtility.getNameOfMistake("Mistake_5_10"); } else if (wrangTimes > 10) { return AppUtility.getNameOfMistake("Mistake_10_Over"); } else { return null; // 0次时 } } /** * used for quiz select * @param mistake 错误类型 * @returns 错误类型名称 */ static getNameOfMistake(mistake: string): string { // 需要在实际使用时传入context // 这里返回空字符串,实际使用时应从资源文件获取 return ""; } // ================== 字符串处理方法 ================== /** * 从指定的中文翻译中获取第一个分号前的部分(包含词性.意思,如: n.食物) * @param srcText 源文本 * @returns 处理后的文本 */ private static getFirstPartFrom(srcText: string): string { const strComma: string = STR_COMMA_HALF; const strComma2: string = STR_COMMA_FULL; const strCommaSub: string = STR_COMMA_SUB_HALF; const strCommaSub2: string = STR_COMMA_SUB_FULL; let str: string = srcText; const indexNoFound: number = -1; // (1) 首先按换行符分割出第一行 let index: number = str.indexOf("\n"); if (index !== indexNoFound) { str = str.substring(0, index); } // (2) 查找第二个间隔符之前的部分 index = str.indexOf(strComma, str.indexOf(strComma) + 1); if (index !== indexNoFound) { str = str.substring(0, index); } else { index = str.indexOf(strComma2, str.indexOf(strComma2) + 1); if (index !== indexNoFound) { str = str.substring(0, index); } } // (3) 若太长了,则只查找第一个间隔符之前的部分 let strLength: number = AppUtility.getLengthOfStringWithoutKind(str); if (strLength > (10 + 1)) { index = str.indexOf(strComma); if (index !== indexNoFound) { str = str.substring(0, index); } else { index = str.indexOf(strComma2); if (index !== indexNoFound) { str = str.substring(0, index); } } } // 再次用逗号检查 strLength = AppUtility.getLengthOfStringWithoutKind(str); if (strLength > (12 + 1)) { // (4) 查找第二个子间隔符之前的部分 index = str.indexOf(strCommaSub2, str.indexOf(strCommaSub2) + 1); if (index !== indexNoFound) { str = str.substring(0, index); } else { index = str.indexOf(strCommaSub, str.indexOf(strCommaSub) + 1); if (index !== indexNoFound) { str = str.substring(0, index); } } } // (5) 若太长了,则只查找第一个子间隔符之前的部分 strLength = AppUtility.getLengthOfStringWithoutKind(str); if (strLength > (12 + 1)) { index = str.indexOf(strCommaSub2); if (index !== indexNoFound) { str = str.substring(0, index); } else { index = str.indexOf(strCommaSub); if (index !== indexNoFound) { str = str.substring(0, index); } } } return str; } /// 查找去除kind之后的字符串长度 private static getLengthOfStringWithoutKind(str: string): number { const strPoint: string = STR_POINT_HALF; const indexNoFound: number = -1; let strLength: number = 0; if (str) { strLength = str.length; const index: number = str.indexOf(strPoint); if (index !== indexNoFound) { strLength = str.substring(index).length; } } return strLength; } /// get original kind private static getKindFrom(srcText: string): string | null { let str: string = AppUtility.getFirstPartFrom(srcText); const strPoint: string = STR_POINT_HALF; let kind: string | null = null; const indexNoFound: number = -1; str = AppUtility.replaceOmitAndPoint(str); const index: number = str.lastIndexOf(strPoint); if (index !== indexNoFound) { kind = str.substring(0, index); } return kind; } // replace omit and remove last point private static replaceOmitAndPoint(srcText: string): string { let str: string = srcText; const strPoint: string = STR_POINT_HALF; const strOmitHalf: string = STR_OMIT_HALF; const strOmitFull: string = STR_OMIT_FULL; const indexNoFound: number = -1; str = str.replace(strOmitHalf, strOmitFull); const index: number = str.lastIndexOf(strPoint); if (index !== indexNoFound && index === str.length - 1) { str = str.substring(0, index); } return str; } /// clip cn string to get kind static getKindOfString(srcText: string): string { const str: string | null = AppUtility.getKindFrom(srcText); return AppUtility.getTextOfKindString(str || ""); } /// clip cn string, only get first translation static getClippedStringSeperatedFirstPartFrom(srcText: string): string { let str: string = AppUtility.getFirstPartFrom(srcText); str = AppUtility.getClippedStringWithoutKindFrom(str); return str; } /// clip cn string, only get translation static getClippedStringWithoutKindFrom(srcText: string): string { let str: string = srcText; const kind: string | null = AppUtility.getKindFrom(srcText); if (kind !== null) { const indexNoFound: number = -1; const index: number = str.indexOf(kind); if (index !== indexNoFound) { const indexFromPoint: number = index + kind.length + 1; str = str.substring(indexFromPoint); } } return str; } // ================== 文本处理高级方法 ================== /// 合并相同pos的翻译,并且去除重复part, 返回重新组合好的pos + title数组 static getJoinedTitleItemsByRemovingDuplications(srcTexts: string[], maxParts: number): TitleItem[] { const titleItems: TitleItem[] = []; for (const srcText of srcTexts) { const srcTextsSub: string[] = srcText.split("\n"); for (const srcTextSub of srcTextsSub) { if (srcTextSub.length === 0) { continue; } const title: string = AppUtility.getClippedStringWithoutKindFrom(srcTextSub); const pos: string | null = AppUtility.getKindFrom(srcTextSub); const titleItem: TitleItem = new TitleItem(); titleItem.pos = AppUtility.getTextOfKindString(pos || ""); titleItem.title = title; const existedIndex: number = titleItems.findIndex(item => item.equals(titleItem)); if (existedIndex !== -1) { const existedItem: TitleItem = titleItems[existedIndex]; existedItem.title += ";" + title; } else { titleItems.push(titleItem); } } } for (const titleItem of titleItems) { // 这里需要StringDealUtility的实现,暂时简化处理 let title: string = titleItem.title; if (maxParts !== 0) { const parts: string[] = title.split(';'); title = parts.slice(0, maxParts).join(';'); } titleItem.title = title; } return titleItems; } /// 合并相同pos的翻译,并且去除重复part static getJoinedStringByRemovingDuplications(srcTexts: string[], maxParts: number): string { const titleItems: TitleItem[] = AppUtility.getJoinedTitleItemsByRemovingDuplications(srcTexts, maxParts); const dstTexts: string[] = []; for (const titleItem of titleItems) { let title: string = titleItem.title; if (titleItem.pos !== null && titleItem.pos.length > 0) { title = titleItem.pos + " " + title; } dstTexts.push(title); } return dstTexts.join("\n"); } // ================== 词性类型转换 ================== /** * 返回单词类型,如:动词,形容词。。 * - kindStr 词性标识符:如:n,v,vt,vi,adj,adv */ static getTextOfKindString(kindStr: string): string { if (kindStr) { // 使用资源引用方式获取本地化字符串 const kindMap: Record<string, ResourceStr> = { "n" : $r('app.string.word_kind_n'), "v" : $r('app.string.word_kind_v'), "vt" : $r('app.string.word_kind_vt'), "vi" : $r('app.string.word_kind_vi'), "vt.& vi" : $r('app.string.word_kind_vt_vi'), "vt.&vi" : $r('app.string.word_kind_vt_vi'), "adj" : $r('app.string.word_kind_adj'), "adv" : $r('app.string.word_kind_adv'), "pron" : $r('app.string.word_kind_pron'), "prep" : $r('app.string.word_kind_prep'), "aux" : $r('app.string.word_kind_aux'), "abbr" : $r('app.string.word_kind_abbr'), "conj" : $r('app.string.word_kind_conj'), "art" : $r('app.string.word_kind_art'), "int" : $r('app.string.word_kind_int'), "interj" : $r('app.string.word_kind_interj'), "det" : $r('app.string.word_kind_det'), "num" : $r('app.string.word_kind_num'), "phr" : $r('app.string.word_kind_phr') }; const resource: ResourceStr | undefined = kindMap[kindStr]; return resource ? getString(resource) : kindStr; } return kindStr } /** * 获取本地化字符串 * @param stringResId 字符串资源ID * @returns 本地化字符串 */ static getLocalizedString(context: common.Context, stringResId: number): string { return context.resourceManager.getStringSync(stringResId); } // ================== JSON处理方法 ================== static getMapFromJson(json: string): Record<string, string> { try { return JSON.parse(json) as Record<string, string>; } catch (error) { console.error("JSON解析错误:", error); return {}; } } static getListFromJson(json: string): Array<Record<string, string>> { try { return JSON.parse(json) as Array<Record<string, string>>; } catch (error) { console.error("JSON解析错误:", error); return []; } } static getJsonFromList(list: Array<Record<string, string>>): string | null { return JSON.stringify(list); } }
AST#export_declaration#Left export AST#class_declaration#Left class AppUtility AST#class_body#Left { // ================== 资源相关方法 ================== /** * Used for iab gold icon * @returns 图标资源ID数组 */ AST#method_declaration#Left static getIabGoldIconResIds AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left number [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left ids : 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#array_literal#Left [ // $r('app.media.gold_iap1'), // $r('app.media.gold_iap2'), // $r('app.media.gold_iap3') ] 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 ids AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * Used for Quiz Top icon * @returns 测验顶部图标资源ID数组 */ AST#method_declaration#Left static getQuizTopIconResIds AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left number [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left ids : 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#array_literal#Left [ // $r('app.media.quiz_top_icon_0'), // $r('app.media.quiz_top_icon_1'), // $r('app.media.quiz_top_icon_2'), // $r('app.media.quiz_top_icon_3'), // $r('app.media.quiz_top_icon_4') ] 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 ids AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * Used for Quiz top Text * @param context 上下文对象 * @returns 测验顶部文本数组 */ AST#method_declaration#Left static getQuizTopTextStrings AST#parameter_list#Left ( AST#parameter#Left context : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . Context AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left texts : 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left context AST#expression#Right . resourceManager AST#member_expression#Right AST#expression#Right . getStringSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.test_top_txt_unit' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right . id AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left context AST#expression#Right . resourceManager AST#member_expression#Right AST#expression#Right . getStringSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.test_top_txt_all' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right . id AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left context AST#expression#Right . resourceManager AST#member_expression#Right AST#expression#Right . getStringSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.test_top_txt_part' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right . id AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left context AST#expression#Right . resourceManager AST#member_expression#Right AST#expression#Right . getStringSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.test_top_txt_mistake' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right . id AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left context AST#expression#Right . resourceManager AST#member_expression#Right AST#expression#Right . getStringSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.test_top_txt_favorite' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right . id AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ] AST#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 texts AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right // ================== 数据处理方法 ================== /** * 根据数字返回大小 * @param size 字节大小 * @returns 格式化后的尺寸字符串 */ AST#method_declaration#Left static getSizeStringFromBytes AST#parameter_list#Left ( AST#parameter#Left size : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left b : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 1 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left k : 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 1024 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#variable_declaration#Left const AST#variable_declarator#Left m : 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 1024 AST#expression#Right * AST#expression#Left k AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left g : 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 1024 AST#expression#Right * AST#expression#Left m AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left gg : 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 size AST#expression#Right / AST#expression#Left g 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 AST#binary_expression#Left AST#expression#Left gg AST#expression#Right > AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left gg AST#expression#Right . toFixed AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right GB ` AST#template_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 mm : 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 size AST#expression#Right / AST#expression#Left m 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 AST#binary_expression#Left AST#expression#Left mm AST#expression#Right > AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left mm AST#expression#Right . toFixed AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right MB ` AST#template_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 kk : 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 size AST#expression#Right / AST#expression#Left k AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . round AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left kk AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right KB ` AST#template_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 获取收藏等级星号字符串 * @param favoriteLevel 收藏等级 * @returns 星号字符串 */ AST#method_declaration#Left static getStarOfFavoriteLevel AST#parameter_list#Left ( AST#parameter#Left favoriteLevel : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left "★" AST#expression#Right . repeat AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left favoriteLevel 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 /** * used for section title * @param wrangTimes 错误次数 * @returns 区间名称 */ AST#method_declaration#Left static getSectionOfWrangTimes AST#parameter_list#Left ( AST#parameter#Left wrangTimes : 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 string AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left wrangTimes AST#expression#Right === AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtility AST#expression#Right . getNameOfMistake AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "Mistake_1_Only" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left wrangTimes AST#expression#Right > AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left wrangTimes AST#expression#Right <= AST#expression#Left 3 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#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtility AST#expression#Right . getNameOfMistake AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "Mistake_1_3" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left wrangTimes 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 wrangTimes AST#expression#Right <= AST#expression#Left 5 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#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtility AST#expression#Right . getNameOfMistake AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "Mistake_3_5" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left wrangTimes AST#expression#Right > AST#expression#Left 5 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left wrangTimes AST#expression#Right <= AST#expression#Left 10 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#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtility AST#expression#Right . getNameOfMistake AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "Mistake_5_10" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left wrangTimes AST#expression#Right > AST#expression#Left 10 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtility AST#expression#Right . getNameOfMistake AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "Mistake_10_Over" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right // 0次时 } 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#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * used for quiz select * @param mistake 错误类型 * @returns 错误类型名称 */ AST#method_declaration#Left static getNameOfMistake AST#parameter_list#Left ( AST#parameter#Left mistake : 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 { // 需要在实际使用时传入context // 这里返回空字符串,实际使用时应从资源文件获取 AST#statement#Left AST#return_statement#Left return AST#expression#Left "" AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right // ================== 字符串处理方法 ================== /** * 从指定的中文翻译中获取第一个分号前的部分(包含词性.意思,如: n.食物) * @param srcText 源文本 * @returns 处理后的文本 */ AST#method_declaration#Left private static getFirstPartFrom AST#parameter_list#Left ( AST#parameter#Left srcText : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left strComma : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left STR_COMMA_HALF 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 strComma2 : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left STR_COMMA_FULL 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 strCommaSub : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left STR_COMMA_SUB_HALF 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 strCommaSub2 : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left STR_COMMA_SUB_FULL AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left str : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left srcText 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 indexNoFound : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // (1) 首先按换行符分割出第一行 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "\n" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right !== AST#expression#Left indexNoFound AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left str = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . substring AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left index 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 // (2) 查找第二个间隔符之前的部分 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left index = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left strComma AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left strComma AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#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 index AST#expression#Right !== AST#expression#Left indexNoFound AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left str = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . substring AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left index AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left index = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left strComma2 AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left strComma2 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#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 index AST#expression#Right !== AST#expression#Left indexNoFound AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left str = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . substring AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left index AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // (3) 若太长了,则只查找第一个间隔符之前的部分 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left strLength : 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 AppUtility AST#expression#Right . getLengthOfStringWithoutKind 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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left strLength AST#expression#Right > AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left 10 AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left index = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left strComma 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 index AST#expression#Right !== AST#expression#Left indexNoFound AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left str = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . substring AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left index AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left index = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left strComma2 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 index AST#expression#Right !== AST#expression#Left indexNoFound AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left str = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . substring AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left index AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_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 strLength = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtility AST#expression#Right . getLengthOfStringWithoutKind 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#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 strLength AST#expression#Right > AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left 12 AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { // (4) 查找第二个子间隔符之前的部分 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left index = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left strCommaSub2 AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left strCommaSub2 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#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 index AST#expression#Right !== AST#expression#Left indexNoFound AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left str = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . substring AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left index AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left index = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left strCommaSub AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left strCommaSub AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#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 index AST#expression#Right !== AST#expression#Left indexNoFound AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left str = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . substring AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left index AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // (5) 若太长了,则只查找第一个子间隔符之前的部分 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left strLength = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtility AST#expression#Right . getLengthOfStringWithoutKind 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#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 strLength AST#expression#Right > AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left 12 AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left index = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left strCommaSub2 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 index AST#expression#Right !== AST#expression#Left indexNoFound AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left str = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . substring AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left index AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left index = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left strCommaSub 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 index AST#expression#Right !== AST#expression#Left indexNoFound AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left str = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . substring AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left index AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left str AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /// 查找去除kind之后的字符串长度 AST#method_declaration#Left private static getLengthOfStringWithoutKind AST#parameter_list#Left ( AST#parameter#Left str : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 strPoint : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left STR_POINT_HALF 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 indexNoFound : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left strLength : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left str AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left strLength = AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left strPoint AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right !== AST#expression#Left indexNoFound 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 strLength = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . substring 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 . length AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left strLength AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /// get original kind AST#method_declaration#Left private static getKindFrom AST#parameter_list#Left ( AST#parameter#Left srcText : 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#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left str : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtility AST#expression#Right . getFirstPartFrom AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left srcText 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 strPoint : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left STR_POINT_HALF 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 kind : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left indexNoFound : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left str = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtility AST#expression#Right . replaceOmitAndPoint 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#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . lastIndexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left strPoint AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right !== AST#expression#Left indexNoFound 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 kind = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . substring AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left index AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left kind AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right // replace omit and remove last point AST#method_declaration#Left private static replaceOmitAndPoint AST#parameter_list#Left ( AST#parameter#Left srcText : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left str : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left srcText 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 strPoint : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left STR_POINT_HALF 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 strOmitHalf : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left STR_OMIT_HALF 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 strOmitFull : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left STR_OMIT_FULL 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 indexNoFound : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left str = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left strOmitHalf AST#expression#Right , AST#expression#Left strOmitFull 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 const AST#variable_declarator#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . lastIndexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left strPoint AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right !== AST#expression#Left indexNoFound AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right === AST#expression#Left str AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right - AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left str = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . substring AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left index AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left str AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /// clip cn string to get kind AST#method_declaration#Left static getKindOfString AST#parameter_list#Left ( AST#parameter#Left srcText : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left str : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtility AST#expression#Right . getKindFrom AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left srcText AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtility AST#expression#Right . getTextOfKindString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left str AST#expression#Right || AST#expression#Left "" AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /// clip cn string, only get first translation AST#method_declaration#Left static getClippedStringSeperatedFirstPartFrom AST#parameter_list#Left ( AST#parameter#Left srcText : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left str : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtility AST#expression#Right . getFirstPartFrom AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left srcText 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 str = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtility AST#expression#Right . getClippedStringWithoutKindFrom 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#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left str AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /// clip cn string, only get translation AST#method_declaration#Left static getClippedStringWithoutKindFrom AST#parameter_list#Left ( AST#parameter#Left srcText : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left str : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left srcText 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 kind : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtility AST#expression#Right . getKindFrom AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left srcText 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 kind AST#expression#Right !== AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left indexNoFound : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left kind AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right !== AST#expression#Left indexNoFound 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 indexFromPoint : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right + AST#expression#Left kind AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left str = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . substring AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left indexFromPoint AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left str AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right // ================== 文本处理高级方法 ================== /// 合并相同pos的翻译,并且去除重复part, 返回重新组合好的pos + title数组 AST#method_declaration#Left static getJoinedTitleItemsByRemovingDuplications AST#parameter_list#Left ( AST#parameter#Left srcTexts : 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#Left maxParts : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left TitleItem [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left titleItems : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left TitleItem [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( const srcText of AST#expression#Left srcTexts AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left srcTextsSub : 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left srcText AST#expression#Right . split AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "\n" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( const srcTextSub of AST#expression#Left srcTextsSub AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left srcTextSub 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#continue_statement#Left continue ; AST#continue_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 title : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtility AST#expression#Right . getClippedStringWithoutKindFrom AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left srcTextSub 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 pos : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtility AST#expression#Right . getKindFrom AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left srcTextSub 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 titleItem : AST#type_annotation#Left AST#primary_type#Left TitleItem 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 TitleItem AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left titleItem AST#expression#Right . pos AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtility AST#expression#Right . getTextOfKindString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left pos AST#expression#Right || AST#expression#Left "" AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#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 titleItem 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#variable_declaration#Left const AST#variable_declarator#Left existedIndex : 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 titleItems AST#expression#Right . findIndex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left item => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . equals AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left titleItem 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#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 existedIndex AST#expression#Right !== AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left existedItem : AST#type_annotation#Left AST#primary_type#Left TitleItem AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#subscript_expression#Left AST#expression#Left titleItems AST#expression#Right [ AST#expression#Left existedIndex 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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left existedItem AST#expression#Right . title AST#member_expression#Right += AST#expression#Left AST#binary_expression#Left AST#expression#Left ";" AST#expression#Right + AST#expression#Left title 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left titleItems AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left titleItem AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( const titleItem of AST#expression#Left titleItems AST#expression#Right ) AST#block_statement#Left { // 这里需要StringDealUtility的实现,暂时简化处理 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left title : 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 titleItem AST#expression#Right . title 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 maxParts AST#expression#Right !== AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left parts : 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left title AST#expression#Right . split AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left ';' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left title = 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 parts AST#expression#Right . slice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left maxParts AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . join AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left ';' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#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 titleItem AST#expression#Right . title AST#member_expression#Right = AST#expression#Left title AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left titleItems AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /// 合并相同pos的翻译,并且去除重复part AST#method_declaration#Left static getJoinedStringByRemovingDuplications AST#parameter_list#Left ( AST#parameter#Left srcTexts : 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#Left maxParts : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left titleItems : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left TitleItem [ ] 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 AppUtility AST#expression#Right . getJoinedTitleItemsByRemovingDuplications AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left srcTexts AST#expression#Right , AST#expression#Left maxParts 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 dstTexts : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( const titleItem of AST#expression#Left titleItems AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left title : 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 titleItem AST#expression#Right . title 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 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 titleItem AST#expression#Right . pos AST#member_expression#Right AST#expression#Right !== AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left titleItem AST#expression#Right AST#binary_expression#Right AST#expression#Right . pos 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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left title = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left titleItem AST#expression#Right . pos AST#member_expression#Right AST#expression#Right + AST#expression#Left " " AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left title 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left dstTexts AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left title AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left dstTexts AST#expression#Right . join AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "\n" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right // ================== 词性类型转换 ================== /** * 返回单词类型,如:动词,形容词。。 * - kindStr 词性标识符:如:n,v,vt,vi,adj,adv */ AST#method_declaration#Left static getTextOfKindString AST#parameter_list#Left ( AST#parameter#Left kindStr : 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 kindStr AST#expression#Right ) AST#block_statement#Left { // 使用资源引用方式获取本地化字符串 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left kindMap : 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 ResourceStr 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 "n" AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.word_kind_n' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left "v" AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.word_kind_v' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left "vt" AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.word_kind_vt' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left "vi" AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.word_kind_vi' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left "vt.& vi" AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.word_kind_vt_vi' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left "vt.&vi" AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.word_kind_vt_vi' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left "adj" AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.word_kind_adj' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left "adv" AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.word_kind_adv' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left "pron" AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.word_kind_pron' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left "prep" AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.word_kind_prep' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left "aux" AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.word_kind_aux' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left "abbr" AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.word_kind_abbr' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left "conj" AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.word_kind_conj' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left "art" AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.word_kind_art' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left "int" AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.word_kind_int' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left "interj" AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.word_kind_interj' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left "det" AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.word_kind_det' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left "num" AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.word_kind_num' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left "phr" AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.word_kind_phr' AST#expression#Right ) AST#resource_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#variable_declaration#Left const AST#variable_declarator#Left resource : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left ResourceStr AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#subscript_expression#Left AST#expression#Left kindMap AST#expression#Right [ AST#expression#Left kindStr 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#return_statement#Left return AST#expression#Left AST#conditional_expression#Left AST#expression#Left resource AST#expression#Right ? AST#expression#Left AST#call_expression#Left AST#expression#Left getString AST#expression#Right AST#argument_list#Left ( AST#expression#Left resource AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right : AST#expression#Left kindStr AST#expression#Right AST#conditional_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left kindStr AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 获取本地化字符串 * @param stringResId 字符串资源ID * @returns 本地化字符串 */ AST#method_declaration#Left static getLocalizedString AST#parameter_list#Left ( AST#parameter#Left context : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . Context AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left stringResId : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#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 context AST#expression#Right . resourceManager AST#member_expression#Right AST#expression#Right . getStringSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left stringResId 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 // ================== JSON处理方法 ================== AST#method_declaration#Left static getMapFromJson AST#parameter_list#Left ( AST#parameter#Left json : 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 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#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . parse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left json AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Record AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#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#as_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "JSON解析错误:" 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#return_statement#Left return AST#expression#Left AST#object_literal#Left { } AST#object_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left static getListFromJson AST#parameter_list#Left ( AST#parameter#Left json : 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 Array AST#type_arguments#Left < 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#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . parse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left json AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < 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#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#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 "JSON解析错误:" 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#return_statement#Left return AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left static getJsonFromList AST#parameter_list#Left ( AST#parameter#Left list : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left 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#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#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left list 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 AppUtility { static getIabGoldIconResIds(): number[] { const ids: number[] = [ ]; return ids; } static getQuizTopIconResIds(): number[] { const ids: number[] = [ ]; return ids; } static getQuizTopTextStrings(context: common.Context): string[] { const texts: string[] = [ context.resourceManager.getStringSync($r('app.string.test_top_txt_unit').id), context.resourceManager.getStringSync($r('app.string.test_top_txt_all').id), context.resourceManager.getStringSync($r('app.string.test_top_txt_part').id), context.resourceManager.getStringSync($r('app.string.test_top_txt_mistake').id), context.resourceManager.getStringSync($r('app.string.test_top_txt_favorite').id) ]; return texts; } static getSizeStringFromBytes(size: number): string { const b: number = 1; const k: number = 1024 * b; const m: number = 1024 * k; const g: number = 1024 * m; const gg: number = size / g; if (gg > 1) { return `${gg.toFixed(1)}GB`; } const mm: number = size / m; if (mm > 1) { return `${mm.toFixed(1)}MB`; } const kk: number = size / k; return `${Math.round(kk)}KB`; } static getStarOfFavoriteLevel(favoriteLevel: number): string { return "★".repeat(favoriteLevel); } static getSectionOfWrangTimes(wrangTimes: number): string | null { if (wrangTimes === 1) { return AppUtility.getNameOfMistake("Mistake_1_Only"); } else if (wrangTimes > 1 && wrangTimes <= 3) { return AppUtility.getNameOfMistake("Mistake_1_3"); } else if (wrangTimes > 3 && wrangTimes <= 5) { return AppUtility.getNameOfMistake("Mistake_3_5"); } else if (wrangTimes > 5 && wrangTimes <= 10) { return AppUtility.getNameOfMistake("Mistake_5_10"); } else if (wrangTimes > 10) { return AppUtility.getNameOfMistake("Mistake_10_Over"); } else { return null; } } static getNameOfMistake(mistake: string): string { return ""; } private static getFirstPartFrom(srcText: string): string { const strComma: string = STR_COMMA_HALF; const strComma2: string = STR_COMMA_FULL; const strCommaSub: string = STR_COMMA_SUB_HALF; const strCommaSub2: string = STR_COMMA_SUB_FULL; let str: string = srcText; const indexNoFound: number = -1; let index: number = str.indexOf("\n"); if (index !== indexNoFound) { str = str.substring(0, index); } index = str.indexOf(strComma, str.indexOf(strComma) + 1); if (index !== indexNoFound) { str = str.substring(0, index); } else { index = str.indexOf(strComma2, str.indexOf(strComma2) + 1); if (index !== indexNoFound) { str = str.substring(0, index); } } let strLength: number = AppUtility.getLengthOfStringWithoutKind(str); if (strLength > (10 + 1)) { index = str.indexOf(strComma); if (index !== indexNoFound) { str = str.substring(0, index); } else { index = str.indexOf(strComma2); if (index !== indexNoFound) { str = str.substring(0, index); } } } strLength = AppUtility.getLengthOfStringWithoutKind(str); if (strLength > (12 + 1)) { index = str.indexOf(strCommaSub2, str.indexOf(strCommaSub2) + 1); if (index !== indexNoFound) { str = str.substring(0, index); } else { index = str.indexOf(strCommaSub, str.indexOf(strCommaSub) + 1); if (index !== indexNoFound) { str = str.substring(0, index); } } } strLength = AppUtility.getLengthOfStringWithoutKind(str); if (strLength > (12 + 1)) { index = str.indexOf(strCommaSub2); if (index !== indexNoFound) { str = str.substring(0, index); } else { index = str.indexOf(strCommaSub); if (index !== indexNoFound) { str = str.substring(0, index); } } } return str; } private static getLengthOfStringWithoutKind(str: string): number { const strPoint: string = STR_POINT_HALF; const indexNoFound: number = -1; let strLength: number = 0; if (str) { strLength = str.length; const index: number = str.indexOf(strPoint); if (index !== indexNoFound) { strLength = str.substring(index).length; } } return strLength; } private static getKindFrom(srcText: string): string | null { let str: string = AppUtility.getFirstPartFrom(srcText); const strPoint: string = STR_POINT_HALF; let kind: string | null = null; const indexNoFound: number = -1; str = AppUtility.replaceOmitAndPoint(str); const index: number = str.lastIndexOf(strPoint); if (index !== indexNoFound) { kind = str.substring(0, index); } return kind; } private static replaceOmitAndPoint(srcText: string): string { let str: string = srcText; const strPoint: string = STR_POINT_HALF; const strOmitHalf: string = STR_OMIT_HALF; const strOmitFull: string = STR_OMIT_FULL; const indexNoFound: number = -1; str = str.replace(strOmitHalf, strOmitFull); const index: number = str.lastIndexOf(strPoint); if (index !== indexNoFound && index === str.length - 1) { str = str.substring(0, index); } return str; } static getKindOfString(srcText: string): string { const str: string | null = AppUtility.getKindFrom(srcText); return AppUtility.getTextOfKindString(str || ""); } static getClippedStringSeperatedFirstPartFrom(srcText: string): string { let str: string = AppUtility.getFirstPartFrom(srcText); str = AppUtility.getClippedStringWithoutKindFrom(str); return str; } static getClippedStringWithoutKindFrom(srcText: string): string { let str: string = srcText; const kind: string | null = AppUtility.getKindFrom(srcText); if (kind !== null) { const indexNoFound: number = -1; const index: number = str.indexOf(kind); if (index !== indexNoFound) { const indexFromPoint: number = index + kind.length + 1; str = str.substring(indexFromPoint); } } return str; } static getJoinedTitleItemsByRemovingDuplications(srcTexts: string[], maxParts: number): TitleItem[] { const titleItems: TitleItem[] = []; for (const srcText of srcTexts) { const srcTextsSub: string[] = srcText.split("\n"); for (const srcTextSub of srcTextsSub) { if (srcTextSub.length === 0) { continue; } const title: string = AppUtility.getClippedStringWithoutKindFrom(srcTextSub); const pos: string | null = AppUtility.getKindFrom(srcTextSub); const titleItem: TitleItem = new TitleItem(); titleItem.pos = AppUtility.getTextOfKindString(pos || ""); titleItem.title = title; const existedIndex: number = titleItems.findIndex(item => item.equals(titleItem)); if (existedIndex !== -1) { const existedItem: TitleItem = titleItems[existedIndex]; existedItem.title += ";" + title; } else { titleItems.push(titleItem); } } } for (const titleItem of titleItems) { let title: string = titleItem.title; if (maxParts !== 0) { const parts: string[] = title.split(';'); title = parts.slice(0, maxParts).join(';'); } titleItem.title = title; } return titleItems; } static getJoinedStringByRemovingDuplications(srcTexts: string[], maxParts: number): string { const titleItems: TitleItem[] = AppUtility.getJoinedTitleItemsByRemovingDuplications(srcTexts, maxParts); const dstTexts: string[] = []; for (const titleItem of titleItems) { let title: string = titleItem.title; if (titleItem.pos !== null && titleItem.pos.length > 0) { title = titleItem.pos + " " + title; } dstTexts.push(title); } return dstTexts.join("\n"); } static getTextOfKindString(kindStr: string): string { if (kindStr) { const kindMap: Record<string, ResourceStr> = { "n" : $r('app.string.word_kind_n'), "v" : $r('app.string.word_kind_v'), "vt" : $r('app.string.word_kind_vt'), "vi" : $r('app.string.word_kind_vi'), "vt.& vi" : $r('app.string.word_kind_vt_vi'), "vt.&vi" : $r('app.string.word_kind_vt_vi'), "adj" : $r('app.string.word_kind_adj'), "adv" : $r('app.string.word_kind_adv'), "pron" : $r('app.string.word_kind_pron'), "prep" : $r('app.string.word_kind_prep'), "aux" : $r('app.string.word_kind_aux'), "abbr" : $r('app.string.word_kind_abbr'), "conj" : $r('app.string.word_kind_conj'), "art" : $r('app.string.word_kind_art'), "int" : $r('app.string.word_kind_int'), "interj" : $r('app.string.word_kind_interj'), "det" : $r('app.string.word_kind_det'), "num" : $r('app.string.word_kind_num'), "phr" : $r('app.string.word_kind_phr') }; const resource: ResourceStr | undefined = kindMap[kindStr]; return resource ? getString(resource) : kindStr; } return kindStr } static getLocalizedString(context: common.Context, stringResId: number): string { return context.resourceManager.getStringSync(stringResId); } static getMapFromJson(json: string): Record<string, string> { try { return JSON.parse(json) as Record<string, string>; } catch (error) { console.error("JSON解析错误:", error); return {}; } } static getListFromJson(json: string): Array<Record<string, string>> { try { return JSON.parse(json) as Array<Record<string, string>>; } catch (error) { console.error("JSON解析错误:", error); return []; } } static getJsonFromList(list: Array<Record<string, string>>): string | null { return JSON.stringify(list); } }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/utils/AppUtility.ets#L49-L449
9265171b82f87c8ba98a0af146ed3ba504c49a8c
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/ets/transcoder/AVTranscoderManager.ets
arkts
releaseTranscoderingProcess
释放转码流程。
async releaseTranscoderingProcess() { if (canIUse('SystemCapability.Multimedia.Media.AVTranscoder')) { if (this.avTranscoder != undefined) { // 1.释放转码实例。 await this.avTranscoder.release(); this.avTranscoder = undefined; // 2.关闭转码目标文件fd。 fs.closeSync(this.avTranscoder!.fdDst); } } }
AST#method_declaration#Left async releaseTranscoderingProcess AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left canIUse AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'SystemCapability.Multimedia.Media.AVTranscoder' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . avTranscoder AST#member_expression#Right AST#expression#Right != AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { // 1.释放转码实例。 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 . avTranscoder AST#member_expression#Right AST#expression#Right . release AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . avTranscoder AST#member_expression#Right = AST#expression#Left undefined AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right // 2.关闭转码目标文件fd。 AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fs AST#expression#Right . closeSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#non_null_assertion_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . avTranscoder AST#member_expression#Right AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right . fdDst AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
async releaseTranscoderingProcess() { if (canIUse('SystemCapability.Multimedia.Media.AVTranscoder')) { if (this.avTranscoder != undefined) { await this.avTranscoder.release(); this.avTranscoder = undefined; fs.closeSync(this.avTranscoder!.fdDst); } } }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/Media/AVTranscoder/AVTranscoderArkTS/entry/src/main/ets/transcoder/AVTranscoderManager.ets#L109-L119
53678529022a862833c482d07541fa69afdecade
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/bottompanelslide/src/main/ets/components/Component.ets
arkts
PanelListItem
panel中list布局样式
@Component export struct PanelListItem { private desc: string = ''; private including: string = ''; build() { Row() { Column() { Text(this.desc) .fontSize(14) .margin({ bottom: $r("app.integer.bottompanelslide_number_10") }) Text(this.including) .fontSize(11) .fontColor(Color.Gray) .alignSelf(ItemAlign.Start) } Radio({ value: 'Radio2', group: 'radioGroup' }) .checked(false) } .margin({ bottom: $r("app.integer.bottompanelslide_number_10") }) .height($r("app.integer.bottompanelslide_number_70")) .width(Constants.NINETY_PERCENT_SIZE) .justifyContent(FlexAlign.SpaceBetween) } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct PanelListItem AST#component_body#Left { AST#property_declaration#Left private desc : 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 including : 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#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left 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 . desc AST#member_expression#Right 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 AST#resource_expression#Left $r ( AST#expression#Left "app.integer.bottompanelslide_number_10" 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#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 . including AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 11 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Gray AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . alignSelf ( AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . 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#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Radio ( AST#component_parameters#Left { AST#component_parameter#Left value : AST#expression#Left 'Radio2' AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left group : AST#expression#Left 'radioGroup' AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . checked ( AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . 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.bottompanelslide_number_10" 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.integer.bottompanelslide_number_70" 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 Constants AST#expression#Right . NINETY_PERCENT_SIZE AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . SpaceBetween AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#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 PanelListItem { private desc: string = ''; private including: string = ''; build() { Row() { Column() { Text(this.desc) .fontSize(14) .margin({ bottom: $r("app.integer.bottompanelslide_number_10") }) Text(this.including) .fontSize(11) .fontColor(Color.Gray) .alignSelf(ItemAlign.Start) } Radio({ value: 'Radio2', group: 'radioGroup' }) .checked(false) } .margin({ bottom: $r("app.integer.bottompanelslide_number_10") }) .height($r("app.integer.bottompanelslide_number_70")) .width(Constants.NINETY_PERCENT_SIZE) .justifyContent(FlexAlign.SpaceBetween) } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/bottompanelslide/src/main/ets/components/Component.ets#L93-L118
6194daa7b84f33e343549382c80346f34ee1e035
gitee
huangwei021230/HarmonyFlow.git
427f918873b0c9efdc975ff4889726b1bfccc546
entry/src/main/ets/ime/text/Key/KeyHintConfiguration.ets
arkts
Helper class for summarizing all hint preferences in one single object.
export class KeyHintConfiguration { symbolHintMode: KeyHintMode; numberHintMode: KeyHintMode; mergeHintPopups: boolean; constructor(symbolHintMode: KeyHintMode, numberHintMode: KeyHintMode, mergeHintPopups: boolean) { this.symbolHintMode = symbolHintMode; this.numberHintMode = numberHintMode; this.mergeHintPopups = mergeHintPopups; } static HINTS_DISABLED: KeyHintConfiguration = new KeyHintConfiguration(KeyHintMode.DISABLED, KeyHintMode.DISABLED, false); }
AST#export_declaration#Left export AST#class_declaration#Left class KeyHintConfiguration AST#class_body#Left { AST#property_declaration#Left symbolHintMode : AST#type_annotation#Left AST#primary_type#Left KeyHintMode AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left numberHintMode : AST#type_annotation#Left AST#primary_type#Left KeyHintMode AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left mergeHintPopups : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left symbolHintMode : AST#type_annotation#Left AST#primary_type#Left KeyHintMode AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left numberHintMode : AST#type_annotation#Left AST#primary_type#Left KeyHintMode AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left mergeHintPopups : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . symbolHintMode AST#member_expression#Right = AST#expression#Left symbolHintMode 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 . numberHintMode AST#member_expression#Right = AST#expression#Left numberHintMode 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 . mergeHintPopups AST#member_expression#Right = AST#expression#Left mergeHintPopups 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#property_declaration#Left static HINTS_DISABLED : AST#type_annotation#Left AST#primary_type#Left KeyHintConfiguration 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 KeyHintConfiguration AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left KeyHintMode AST#expression#Right . DISABLED AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left KeyHintMode AST#expression#Right . DISABLED AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class KeyHintConfiguration { symbolHintMode: KeyHintMode; numberHintMode: KeyHintMode; mergeHintPopups: boolean; constructor(symbolHintMode: KeyHintMode, numberHintMode: KeyHintMode, mergeHintPopups: boolean) { this.symbolHintMode = symbolHintMode; this.numberHintMode = numberHintMode; this.mergeHintPopups = mergeHintPopups; } static HINTS_DISABLED: KeyHintConfiguration = new KeyHintConfiguration(KeyHintMode.DISABLED, KeyHintMode.DISABLED, false); }
https://github.com/huangwei021230/HarmonyFlow.git/blob/427f918873b0c9efdc975ff4889726b1bfccc546/entry/src/main/ets/ime/text/Key/KeyHintConfiguration.ets#L13-L25
175a50cec6e37d45c4e47c460691849ca54a2e23
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/videotrimmer/src/main/ets/videotrimmer/RangeSeekBarView.ets
arkts
onRangeStopScrollChanged
视频范围选择结束
onRangeStopScrollChanged() { let start: number = this.scroller.currentOffset().xOffset; // 计算开始位置 let startPosition: number = start * 1000.0 / this.msPxAvg startPosition = Math.max(0, Math.floor(startPosition)); // 计算结束位置 let endPosition: number = startPosition + this.mRangSeekBarOption.mMaxCountRange + 5; let maxEnd: number = Math.floor(this.mRangSeekBarOption.mRightProgressPos / 1000); endPosition = Math.min(maxEnd, endPosition); if (this.mRangSeekBarListener) { this.mRangSeekBarListener.onRangeSeekBarScrollChanged(startPosition, endPosition); } }
AST#method_declaration#Left onRangeStopScrollChanged AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left start : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scroller AST#member_expression#Right AST#expression#Right . currentOffset AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . xOffset AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 计算开始位置 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left startPosition : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left start AST#expression#Right * AST#expression#Left 1000.0 AST#expression#Right AST#binary_expression#Right AST#expression#Right / AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . msPxAvg AST#member_expression#Right AST#ERROR#Left startPosition AST#ERROR#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . max AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left 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 startPosition AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 计算结束位置 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left endPosition : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left startPosition AST#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . mRangSeekBarOption AST#member_expression#Right AST#expression#Right . mMaxCountRange AST#member_expression#Right AST#expression#Right + AST#expression#Left 5 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 maxEnd : 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 . floor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mRangSeekBarOption AST#member_expression#Right AST#expression#Right . mRightProgressPos AST#member_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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left endPosition = 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 maxEnd AST#expression#Right , AST#expression#Left endPosition AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mRangSeekBarListener AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mRangSeekBarListener AST#member_expression#Right AST#expression#Right . onRangeSeekBarScrollChanged AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left startPosition AST#expression#Right , AST#expression#Left endPosition 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
onRangeStopScrollChanged() { let start: number = this.scroller.currentOffset().xOffset; let startPosition: number = start * 1000.0 / this.msPxAvg startPosition = Math.max(0, Math.floor(startPosition)); let endPosition: number = startPosition + this.mRangSeekBarOption.mMaxCountRange + 5; let maxEnd: number = Math.floor(this.mRangSeekBarOption.mRightProgressPos / 1000); endPosition = Math.min(maxEnd, endPosition); if (this.mRangSeekBarListener) { this.mRangSeekBarListener.onRangeSeekBarScrollChanged(startPosition, endPosition); } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/videotrimmer/src/main/ets/videotrimmer/RangeSeekBarView.ets#L377-L391
75543f20bd683544db208b47b8e51c45d79535d2
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_dialog/src/main/ets/dialog/DialogBuilder.ets
arkts
DatePickerDialogBuilder
DatePickerDialog @param options
@Builder export function DatePickerDialogBuilder(options: DateTimePickerOptions) { DatePickerDialogView({ options: options }); }
AST#decorated_export_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right export function DatePickerDialogBuilder AST#parameter_list#Left ( AST#parameter#Left options : AST#type_annotation#Left AST#primary_type#Left DateTimePickerOptions AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#ui_custom_component_statement#Left DatePickerDialogView ( AST#component_parameters#Left { AST#component_parameter#Left options : AST#expression#Left options AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) ; AST#ui_custom_component_statement#Right } AST#builder_function_body#Right AST#decorated_export_declaration#Right
@Builder export function DatePickerDialogBuilder(options: DateTimePickerOptions) { DatePickerDialogView({ options: options }); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_dialog/src/main/ets/dialog/DialogBuilder.ets#L187-L190
fbe1428bf9906fb131be1b4841465c57b2f42d37
gitee
sithvothykiv/dialog_hub.git
b676c102ef2d05f8994d170abe48dcc40cd39005
custom_dialog/src/main/ets/utils/MD5.ets
arkts
digestSegmentSync
MD5摘要,分段,同步 @param data 待摘要的数据 @param resultCoding 摘要的编码方式(base64/hex),默认不传为hex。 @param len 自定义的数据拆分长度 @returns
static digestSegmentSync(data: string, resultCoding: crypto.BhCoding = 'hex', len: number = 128): string { return CryptoUtil.digestSegmentSync(data, 'MD5', resultCoding, len); }
AST#method_declaration#Left static digestSegmentSync AST#parameter_list#Left ( 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#Left resultCoding : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left crypto . BhCoding AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'hex' AST#expression#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 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 CryptoUtil AST#expression#Right . digestSegmentSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left data AST#expression#Right , AST#expression#Left 'MD5' AST#expression#Right , AST#expression#Left resultCoding AST#expression#Right , AST#expression#Left len 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 digestSegmentSync(data: string, resultCoding: crypto.BhCoding = 'hex', len: number = 128): string { return CryptoUtil.digestSegmentSync(data, 'MD5', resultCoding, len); }
https://github.com/sithvothykiv/dialog_hub.git/blob/b676c102ef2d05f8994d170abe48dcc40cd39005/custom_dialog/src/main/ets/utils/MD5.ets#L70-L72
c0d728e7038d36f50efe426abb3858cb4220ecb4
github
liuchao0739/arkTS_universal_starter.git
0ca845f5ae0e78db439dc09f712d100c0dd46ed3
entry/src/main/ets/core/router/Router.ets
arkts
getParams
获取路由参数
getParams(): RouteParams { try { const params = router.getParams() as Record<string, string>; const result: RouteParams = {}; const userId = params['userId']; const pageId = params['pageId']; const value = params['value']; const productId = params['productId']; const conversationId = params['conversationId']; const roomId = params['roomId']; const url = params['url']; const quantity = params['quantity']; if (userId) { result.userId = userId; } if (pageId) { result.pageId = pageId; } if (value) { result.value = value; } // 支持自定义参数 if (productId) { result.productId = productId; } if (conversationId) { result.conversationId = conversationId; } if (roomId) { result.roomId = roomId; } if (url) { result.url = url; } if (quantity) { result.quantity = Number(quantity); } return result; } catch (error) { Logger.error('Router', `Failed to get params: ${String(error)}`); return {}; } }
AST#method_declaration#Left getParams AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left RouteParams AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left params = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left router AST#expression#Right . getParams AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left AST#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#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 result : 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#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 userId = AST#expression#Left AST#subscript_expression#Left AST#expression#Left params AST#expression#Right [ AST#expression#Left 'userId' 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 const AST#variable_declarator#Left pageId = AST#expression#Left AST#subscript_expression#Left AST#expression#Left params AST#expression#Right [ AST#expression#Left 'pageId' 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 const AST#variable_declarator#Left value = AST#expression#Left AST#subscript_expression#Left AST#expression#Left params AST#expression#Right [ AST#expression#Left 'value' 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 const AST#variable_declarator#Left productId = AST#expression#Left AST#subscript_expression#Left AST#expression#Left params AST#expression#Right [ AST#expression#Left 'productId' 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 const AST#variable_declarator#Left conversationId = AST#expression#Left AST#subscript_expression#Left AST#expression#Left params AST#expression#Right [ AST#expression#Left 'conversationId' 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 const AST#variable_declarator#Left roomId = AST#expression#Left AST#subscript_expression#Left AST#expression#Left params AST#expression#Right [ AST#expression#Left 'roomId' 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 const AST#variable_declarator#Left url = AST#expression#Left AST#subscript_expression#Left AST#expression#Left params AST#expression#Right [ AST#expression#Left 'url' 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 const AST#variable_declarator#Left quantity = AST#expression#Left AST#subscript_expression#Left AST#expression#Left params AST#expression#Right [ AST#expression#Left 'quantity' AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left userId 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 result AST#expression#Right . userId AST#member_expression#Right = AST#expression#Left userId 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 pageId 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 result AST#expression#Right . pageId AST#member_expression#Right = AST#expression#Left pageId 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 value 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 result 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#if_statement#Right AST#statement#Right // 支持自定义参数 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left productId 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 result AST#expression#Right . productId AST#member_expression#Right = AST#expression#Left productId 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 conversationId 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 result AST#expression#Right . conversationId AST#member_expression#Right = AST#expression#Left conversationId 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 roomId 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 result AST#expression#Right . roomId AST#member_expression#Right = AST#expression#Left roomId 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 url 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 result AST#expression#Right . url AST#member_expression#Right = AST#expression#Left url AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left quantity 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 result AST#expression#Right . quantity AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left Number AST#expression#Right AST#argument_list#Left ( AST#expression#Left quantity AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left result 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 Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Router' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Failed to get params: AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left String AST#expression#Right AST#argument_list#Left ( AST#expression#Left 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#return_statement#Left return AST#expression#Left AST#object_literal#Left { } AST#object_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
getParams(): RouteParams { try { const params = router.getParams() as Record<string, string>; const result: RouteParams = {}; const userId = params['userId']; const pageId = params['pageId']; const value = params['value']; const productId = params['productId']; const conversationId = params['conversationId']; const roomId = params['roomId']; const url = params['url']; const quantity = params['quantity']; if (userId) { result.userId = userId; } if (pageId) { result.pageId = pageId; } if (value) { result.value = value; } if (productId) { result.productId = productId; } if (conversationId) { result.conversationId = conversationId; } if (roomId) { result.roomId = roomId; } if (url) { result.url = url; } if (quantity) { result.quantity = Number(quantity); } return result; } catch (error) { Logger.error('Router', `Failed to get params: ${String(error)}`); return {}; } }
https://github.com/liuchao0739/arkTS_universal_starter.git/blob/0ca845f5ae0e78db439dc09f712d100c0dd46ed3/entry/src/main/ets/core/router/Router.ets#L259-L302
e2bd013332e91c270bf85d74f30364e645e988e8
github
wangjinyuan/JS-TS-ArkTS-database.git
a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26
npm/alprazolamdiv/11.5.1/package/src/client/actions/ChannelDelete.ets
arkts
应用约束60: 使用export代替module.exports
export default ChannelDeleteAction;
AST#export_declaration#Left export default AST#expression#Left ChannelDeleteAction AST#expression#Right ; AST#export_declaration#Right
export default ChannelDeleteAction;
https://github.com/wangjinyuan/JS-TS-ArkTS-database.git/blob/a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26/npm/alprazolamdiv/11.5.1/package/src/client/actions/ChannelDelete.ets#L41-L41
e8e720ee484019a6a6fb27b8f72cde5b8af98731
github
openharmony/arkui_ace_engine
30c7d1ee12fbedf0fabece54291d75897e2ad44f
advanced_ui_component/subheaderv2/source/subheaderv2.ets
arkts
getNumberByResource
get resource size @param resourceName resource id @returns resource size
public static getNumberByResource(resourceId: number, defaultNumber: number): number { try { let resourceNumber: number = resourceManager.getSystemResourceManager().getNumber(resourceId); if (resourceNumber === 0) { return defaultNumber; } else { return resourceNumber; } } catch (error) { let code: number = (error as BusinessError).code; let message: string = (error as BusinessError).message; hilog.error(0x3900, 'Ace', `SubHeader getNumberByResource error, code: ${code}, message: ${message}`); return defaultNumber; } }
AST#method_declaration#Left public static getNumberByResource AST#parameter_list#Left ( AST#parameter#Left resourceId : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left defaultNumber : 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#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left resourceNumber : 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resourceManager AST#expression#Right . getSystemResourceManager AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . getNumber AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left resourceId 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 resourceNumber 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 defaultNumber AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left resourceNumber AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left code : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . code AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#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#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . message AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x3900 AST#expression#Right , AST#expression#Left 'Ace' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` SubHeader getNumberByResource error, code: AST#template_substitution#Left $ { AST#expression#Left code AST#expression#Right } AST#template_substitution#Right , message: AST#template_substitution#Left $ { AST#expression#Left message AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left defaultNumber AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
public static getNumberByResource(resourceId: number, defaultNumber: number): number { try { let resourceNumber: number = resourceManager.getSystemResourceManager().getNumber(resourceId); if (resourceNumber === 0) { return defaultNumber; } else { return resourceNumber; } } catch (error) { let code: number = (error as BusinessError).code; let message: string = (error as BusinessError).message; hilog.error(0x3900, 'Ace', `SubHeader getNumberByResource error, code: ${code}, message: ${message}`); return defaultNumber; } }
https://github.com/openharmony/arkui_ace_engine/blob/30c7d1ee12fbedf0fabece54291d75897e2ad44f/advanced_ui_component/subheaderv2/source/subheaderv2.ets#L1268-L1282
7f2a34274a3052f7d8082cde03447cc17227a3c1
gitee
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/models/datas/book/CategoryManager.ets
arkts
reload
/ 重新获取类别
async reload() { this.categories = []; await this.loadCategories(); }
AST#method_declaration#Left async reload 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 . categories AST#member_expression#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . loadCategories AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
async reload() { this.categories = []; await this.loadCategories(); }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/datas/book/CategoryManager.ets#L39-L42
56adc6412e29cb27a303ef8d1cf5d55d904117de
github
openharmony/xts_acts
5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686
ability/ability_runtime/getresourcedirndk/getresourcedirndknothaveres/shared/Index.ets
arkts
add
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 { add } from './src/main/ets/utils/Calc';
AST#export_declaration#Left export { add } from './src/main/ets/utils/Calc' ; AST#export_declaration#Right
export { add } from './src/main/ets/utils/Calc';
https://github.com/openharmony/xts_acts/blob/5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686/ability/ability_runtime/getresourcedirndk/getresourcedirndknothaveres/shared/Index.ets#L16-L16
5c9fd4cb139ab08c134ff8ee2692266d2a6457df
gitee
bigbear20240612/planner_build-.git
89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1
entry/src/main/ets/common/constants/AppConstants.ets
arkts
lightenColor
颜色处理工具方法
private static lightenColor(color: string, percent: number): string { const rgb = AppConstants.hexToRgb(color); if (!rgb) return color; const r = Math.min(255, rgb.r + Math.round((255 - rgb.r) * percent / 100)); const g = Math.min(255, rgb.g + Math.round((255 - rgb.g) * percent / 100)); const b = Math.min(255, rgb.b + Math.round((255 - rgb.b) * percent / 100)); return AppConstants.rgbToHex(r, g, b); }
AST#method_declaration#Left private static lightenColor AST#parameter_list#Left ( AST#parameter#Left color : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left percent : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left rgb = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppConstants AST#expression#Right . hexToRgb AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left color AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left rgb AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return AST#expression#Left color AST#expression#Right ; AST#return_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left r = 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 255 AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left rgb AST#expression#Right . r AST#member_expression#Right AST#expression#Right + AST#expression#Left Math AST#expression#Right AST#binary_expression#Right AST#expression#Right . round AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 255 AST#expression#Right - AST#expression#Left rgb AST#expression#Right AST#binary_expression#Right AST#expression#Right . r AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right * AST#expression#Left percent AST#expression#Right AST#binary_expression#Right AST#expression#Right / AST#expression#Left 100 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left g = 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 255 AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left rgb AST#expression#Right . g AST#member_expression#Right AST#expression#Right + AST#expression#Left Math AST#expression#Right AST#binary_expression#Right AST#expression#Right . round AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 255 AST#expression#Right - AST#expression#Left rgb AST#expression#Right AST#binary_expression#Right AST#expression#Right . g AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right * AST#expression#Left percent AST#expression#Right AST#binary_expression#Right AST#expression#Right / AST#expression#Left 100 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left b = 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 255 AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left rgb AST#expression#Right . b AST#member_expression#Right AST#expression#Right + AST#expression#Left Math AST#expression#Right AST#binary_expression#Right AST#expression#Right . round AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 255 AST#expression#Right - AST#expression#Left rgb AST#expression#Right AST#binary_expression#Right AST#expression#Right . b AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right * AST#expression#Left percent AST#expression#Right AST#binary_expression#Right AST#expression#Right / AST#expression#Left 100 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#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 AppConstants AST#expression#Right . rgbToHex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left r AST#expression#Right , AST#expression#Left g AST#expression#Right , AST#expression#Left b AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private static lightenColor(color: string, percent: number): string { const rgb = AppConstants.hexToRgb(color); if (!rgb) return color; const r = Math.min(255, rgb.r + Math.round((255 - rgb.r) * percent / 100)); const g = Math.min(255, rgb.g + Math.round((255 - rgb.g) * percent / 100)); const b = Math.min(255, rgb.b + Math.round((255 - rgb.b) * percent / 100)); return AppConstants.rgbToHex(r, g, b); }
https://github.com/bigbear20240612/planner_build-.git/blob/89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1/entry/src/main/ets/common/constants/AppConstants.ets#L74-L83
67272c4a7d6238d17f8ada59613e9c0f8a93cdd1
github
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_crypto_dto/src/main/ets/crypto/encryption/RSA.ets
arkts
generate2048RSAKey
生成2048位RSA的非对称密钥 @returns 2048位RSA密钥{publicKey:2048位公钥,privateKey:2048位私钥}
static async generate2048RSAKey(): Promise<OutDTO<CryptoKey>> { return CryptoUtil.generateCryptoKey('RSA2048'); }
AST#method_declaration#Left static async generate2048RSAKey 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 OutDTO AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left CryptoKey AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CryptoUtil AST#expression#Right . generateCryptoKey AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'RSA2048' 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 generate2048RSAKey(): Promise<OutDTO<CryptoKey>> { return CryptoUtil.generateCryptoKey('RSA2048'); }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto_dto/src/main/ets/crypto/encryption/RSA.ets#L42-L44
6ef688aff3436f03913c5031b7079cdc7ba575a1
gitee
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_crypto_dto/src/main/ets/crypto/encryption/sm2/SM2Convert.ets
arkts
readC3
读取C3部分 @param sm2_sequence sm2序列工具 @param data 待读取的数据 @returns C3部分
private readC3(sm2_sequence: SM2Sequence, data: string): string { if (data.startsWith("0420")) { sm2_sequence.C3 = data.slice(4, 68); data = data.slice(68, data.length); } else { Logger.debug('读取SM2字符串中的C3出错~'); } return data; }
AST#method_declaration#Left private readC3 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#builder_function_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 data AST#expression#Right . startsWith AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "0420" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left sm2_sequence AST#expression#Right . C3 AST#member_expression#Right = 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 4 AST#expression#Right , AST#expression#Left 68 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#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 68 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 } else { 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字符串中的C3出错~' 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#expression_statement#Left AST#expression#Left return AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left data AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
private readC3(sm2_sequence: SM2Sequence, data: string): string { if (data.startsWith("0420")) { sm2_sequence.C3 = data.slice(4, 68); data = data.slice(68, data.length); } else { Logger.debug('读取SM2字符串中的C3出错~'); } return data; }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto_dto/src/main/ets/crypto/encryption/sm2/SM2Convert.ets#L253-L261
977547253c0de7c2e38434d39d108cd77369c5f6
gitee
openharmony-tpc-incubate/photo-deal-demo
01382ce30b1785f8fc8bc14f6b94f0a670a5b50b
library/src/main/ets/components/textInput/TextEditNodeController.ets
arkts
onFuncTypeChanged
功能菜单切换通知 用于处理画板、马赛克、文本叠加处理后切到文本时露出文本供用户操作,从文本切走后恢复用户操作时的叠加状态 @param isText 是否为文本功能
onFuncTypeChanged(isText: boolean): void { if (this.rootNode) { let textNodes = Array.from(this.textRecords).filter((record: OperateRecord) => { return record.type === ImageEditFunctionType.TEXT; }); if (!textNodes || textNodes.length === 0) { return; } if (!isText) { // 切出场景删除空的文本节点 this.removeEmptyTextNode(textNodes); } else { // 切入场景把最近一个文本节点切换到编辑态 this.setTextNodeActivated(textNodes[textNodes.length - 1], true); } textNodes.forEach((record: OperateRecord) => { if (!isText) { // 切出场景文本框节点全部切换到非编辑态 this.setTextNodeActivated(record, false); } }); } }
AST#method_declaration#Left onFuncTypeChanged AST#parameter_list#Left ( AST#parameter#Left isText : 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#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rootNode AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left textNodes = 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 Array AST#expression#Right . from 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 . textRecords AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . filter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left record : AST#type_annotation#Left AST#primary_type#Left OperateRecord AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left record AST#expression#Right . type AST#member_expression#Right AST#expression#Right === AST#expression#Left ImageEditFunctionType AST#expression#Right AST#binary_expression#Right AST#expression#Right . TEXT AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left textNodes AST#expression#Right AST#unary_expression#Right AST#expression#Right || AST#expression#Left textNodes AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left isText 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 this AST#expression#Right . removeEmptyTextNode AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left textNodes 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 this AST#expression#Right . setTextNodeActivated AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left textNodes AST#expression#Right [ AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left textNodes AST#expression#Right . length AST#member_expression#Right AST#expression#Right - AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right , AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#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 textNodes 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 record : AST#type_annotation#Left AST#primary_type#Left OperateRecord 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 isText 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 this AST#expression#Right . setTextNodeActivated AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left record 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#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#method_declaration#Right
onFuncTypeChanged(isText: boolean): void { if (this.rootNode) { let textNodes = Array.from(this.textRecords).filter((record: OperateRecord) => { return record.type === ImageEditFunctionType.TEXT; }); if (!textNodes || textNodes.length === 0) { return; } if (!isText) { this.removeEmptyTextNode(textNodes); } else { this.setTextNodeActivated(textNodes[textNodes.length - 1], true); } textNodes.forEach((record: OperateRecord) => { if (!isText) { this.setTextNodeActivated(record, false); } }); } }
https://github.com/openharmony-tpc-incubate/photo-deal-demo/blob/01382ce30b1785f8fc8bc14f6b94f0a670a5b50b/library/src/main/ets/components/textInput/TextEditNodeController.ets#L124-L148
c9300eb5bcec7e2acc71020b7f0ceb016d1f4f14
gitee
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
ArkUI/UI_Component_Performance_Optimization/entry/src/main/ets/segment/segment2.ets
arkts
VideoCard
[Start Case1]
@Component export struct VideoCard { @State isVideoInit: boolean = false; // [StartExclude Case1] @Prop item: VideoItem = { id: '' }; private createComplexVideoPlayer(): void { } // [EndExclude Case1] build() { Column() { // Video Playback Component } .onAreaChange((old, newValue) => { if (!this.isVideoInit) { let positionY: number = newValue.position.y as number if (positionY < screenHeight / 3) { this.createComplexVideoPlayer(); this.isVideoInit = true; } } }) } // ... }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct VideoCard AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right isVideoInit : 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 // [StartExclude Case1] AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right item : AST#type_annotation#Left AST#primary_type#Left VideoItem AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left id AST#property_name#Right : AST#expression#Left '' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#method_declaration#Left private createComplexVideoPlayer AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { } AST#builder_function_body#Right AST#method_declaration#Right // [EndExclude Case1] 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 { // Video Playback Component } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . onAreaChange ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left old AST#parameter#Right , AST#parameter#Left newValue AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . isVideoInit AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left positionY : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left newValue AST#expression#Right . position AST#member_expression#Right AST#expression#Right . y AST#member_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#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 positionY AST#expression#Right < AST#expression#Left AST#binary_expression#Left AST#expression#Left screenHeight AST#expression#Right / AST#expression#Left 3 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 this AST#expression#Right . createComplexVideoPlayer AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isVideoInit AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right // ... } AST#component_body#Right AST#decorated_export_declaration#Right
@Component export struct VideoCard { @State isVideoInit: boolean = false; @Prop item: VideoItem = { id: '' }; private createComplexVideoPlayer(): void { } build() { Column() { } .onAreaChange((old, newValue) => { if (!this.isVideoInit) { let positionY: number = newValue.position.y as number if (positionY < screenHeight / 3) { this.createComplexVideoPlayer(); this.isVideoInit = true; } } }) } }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/ArkUI/UI_Component_Performance_Optimization/entry/src/main/ets/segment/segment2.ets#L27-L52
f82f072c73c8123d1c76ada0acc1cfdb6b4ff2ce
gitee
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/models/datas/cigen/CigenWordDbAccess.ets
arkts
CigenWordTables.ts
export namespace CigenTable { // ============================================================ // Cgcz 表 // ============================================================ export namespace Cgcz { export const table = 'Cgcz';
AST#export_declaration#Left export AST#ERROR#Left namespace CigenTable { // ============================================================ // Cgcz 表 // ============================================================ export namespace Cgcz { export AST#ERROR#Right AST#variable_declaration#Left const AST#variable_declarator#Left table = AST#expression#Left 'Cgcz' AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#export_declaration#Right
export namespace CigenTable { export namespace Cgcz { export const table = 'Cgcz';
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/datas/cigen/CigenWordDbAccess.ets#L13-L19
7d447a2806d6968e2272379eae64cacef98b9adf
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/models/networks/Http.ets
arkts
_request
私有方法:执行实际HTTP请求
private static _request( url: string, method: HttpUtils.Method, params: HttpUtils.HttpParams, callback: (responseData: string | null) => void ): void { const httpRequest = http.createHttp(); let finalUrl = url; let requestParams: string | null = null; // GET请求处理查询参数 if (method === HttpUtils.Method.GET && params) { finalUrl = `${url}?${Http._buildQueryString(params)}`; } else if (params) { requestParams = JSON.stringify(params); } DebugLog.d(`[HTTP] ${finalUrl} [${method}]`); Http._createHeaders().then((headers) => { // 发送HTTP请求 httpRequest.request( finalUrl, { method: HttpUtils.Functions.toRequestMethod(method), extraData: requestParams, expectDataType: http.HttpDataType.STRING, // 确保返回字符串 header: headers , connectTimeout: 10000, // 10秒连接超时 readTimeout: 10000 // 10秒读取超时 }, (err: BusinessError, data: http.HttpResponse) => { // 销毁请求对象释放资源 httpRequest.destroy(); if (err) { DebugLog.e(`[HTTP] 请求失败: ${JSON.stringify(err)}`); callback(null); } else { // 处理响应数据 if (data.resultType === http.HttpDataType.STRING) { callback(data.result as string); } else { DebugLog.e('[HTTP] 响应类型不是字符串'); callback(null); } } } ); }) .catch((err: Error)=>{ DebugLog.e(`[HTTP] create header error: ${err.message}`); callback(null); }) }
AST#method_declaration#Left private static _request AST#parameter_list#Left ( AST#parameter#Left url : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left method : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left HttpUtils . Method AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left params : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left HttpUtils . HttpParams AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left callback : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left responseData : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left httpRequest = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left http AST#expression#Right . createHttp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left finalUrl = AST#expression#Left url 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 requestParams : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // GET请求处理查询参数 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left method AST#expression#Right === AST#expression#Left HttpUtils AST#expression#Right AST#binary_expression#Right AST#expression#Right . Method AST#member_expression#Right AST#expression#Right . GET AST#member_expression#Right AST#expression#Right && AST#expression#Left params 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 finalUrl = AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left url AST#expression#Right } AST#template_substitution#Right ? AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Http AST#expression#Right . _buildQueryString 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#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left params AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left requestParams = 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 params 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#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DebugLog AST#expression#Right . d AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` [HTTP] AST#template_substitution#Left $ { AST#expression#Left finalUrl AST#expression#Right } AST#template_substitution#Right [ AST#template_substitution#Left $ { AST#expression#Left method 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 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 Http AST#expression#Right . _createHeaders AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left headers AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { // 发送HTTP请求 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left httpRequest AST#expression#Right . request AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left finalUrl AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left method AST#property_name#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 HttpUtils AST#expression#Right . Functions AST#member_expression#Right AST#expression#Right . toRequestMethod AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left method 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 extraData AST#property_name#Right : AST#expression#Left requestParams AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left expectDataType AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left http AST#expression#Right . HttpDataType AST#member_expression#Right AST#expression#Right . STRING AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , // 确保返回字符串 AST#property_assignment#Left AST#property_name#Left header AST#property_name#Right : AST#expression#Left headers AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left connectTimeout AST#property_name#Right : AST#expression#Left 10000 AST#expression#Right AST#property_assignment#Right , // 10秒连接超时 AST#property_assignment#Left AST#property_name#Left readTimeout AST#property_name#Right : AST#expression#Left 10000 AST#expression#Right AST#property_assignment#Right // 10秒读取超时 } AST#object_literal#Right AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err : AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left httpRequest AST#expression#Right . destroy AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#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 DebugLog AST#expression#Right . e AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` [HTTP] 请求失败: AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` 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 callback 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#block_statement#Right else AST#block_statement#Left { // 处理响应数据 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . resultType AST#member_expression#Right AST#expression#Right === AST#expression#Left http AST#expression#Right AST#binary_expression#Right AST#expression#Right . HttpDataType AST#member_expression#Right AST#expression#Right . STRING 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 callback AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . result AST#member_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; 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 DebugLog AST#expression#Right . e AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '[HTTP] 响应类型不是字符串' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left callback AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#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 err : AST#type_annotation#Left AST#primary_type#Left Error AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DebugLog AST#expression#Right . e AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` [HTTP] create header error: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left callback 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#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private static _request( url: string, method: HttpUtils.Method, params: HttpUtils.HttpParams, callback: (responseData: string | null) => void ): void { const httpRequest = http.createHttp(); let finalUrl = url; let requestParams: string | null = null; if (method === HttpUtils.Method.GET && params) { finalUrl = `${url}?${Http._buildQueryString(params)}`; } else if (params) { requestParams = JSON.stringify(params); } DebugLog.d(`[HTTP] ${finalUrl} [${method}]`); Http._createHeaders().then((headers) => { httpRequest.request( finalUrl, { method: HttpUtils.Functions.toRequestMethod(method), extraData: requestParams, expectDataType: http.HttpDataType.STRING, header: headers , connectTimeout: 10000, readTimeout: 10000 }, (err: BusinessError, data: http.HttpResponse) => { httpRequest.destroy(); if (err) { DebugLog.e(`[HTTP] 请求失败: ${JSON.stringify(err)}`); callback(null); } else { if (data.resultType === http.HttpDataType.STRING) { callback(data.result as string); } else { DebugLog.e('[HTTP] 响应类型不是字符串'); callback(null); } } } ); }) .catch((err: Error)=>{ DebugLog.e(`[HTTP] create header error: ${err.message}`); callback(null); }) }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/networks/Http.ets#L103-L159
0dac4cc6fc6ca3f026a450cd77127723fedbf7c2
github
Joker-x-dev/HarmonyKit.git
f97197ce157df7f303244fba42e34918306dfb08
core/data/src/main/ets/repository/DemoRepository.ets
arkts
createDemo
创建 Demo 记录 @param {string} title - 标题 @param {string} description - 描述 @returns {Promise<number>} 新建记录主键
async createDemo(title: string, description: string = ""): Promise<number> { return this.demoLocalDataSource.createItem(title, description); }
AST#method_declaration#Left async createDemo 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 description : 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#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . demoLocalDataSource AST#member_expression#Right AST#expression#Right . createItem AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left title AST#expression#Right , AST#expression#Left description AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async createDemo(title: string, description: string = ""): Promise<number> { return this.demoLocalDataSource.createItem(title, description); }
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/data/src/main/ets/repository/DemoRepository.ets#L27-L29
0f608178c6258dcfc8720e6b63fc7518c6215d87
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/voicerecordynamiceffect/src/main/ets/models/AudioRecorder.ets
arkts
音频录制
export class AudioRecorder { private avRecorder: media.AVRecorder | undefined = undefined; public maxAmplitude: number = 0; public time: number = 0; private avProfile: media.AVRecorderProfile = { audioBitrate: Const.AUDIO_BITRATE, // 音频比特率 audioChannels: Const.AUDIO_CHANNELS, // 音频声道数 audioCodec: media.CodecMimeType.AUDIO_AAC, // 音频编码格式,当前只支持aac audioSampleRate: Const.AUDIO_SAMPLE_RATE, // 音频采样率 fileFormat: media.ContainerFormatType.CFT_MPEG_4A, // 封装格式,当前只支持m4a }; private avConfig: media.AVRecorderConfig = { audioSourceType: media.AudioSourceType.AUDIO_SOURCE_TYPE_MIC, // 音频输入源,这里设置为麦克风 profile: this.avProfile, url: 'fd://35', // 参考应用文件访问与管理开发示例新建并读写一个文件 }; // 注册audioRecorder回调函数 setAudioRecorderCallback(): void { if (this.avRecorder !== undefined) { // 状态机变化回调函数 this.avRecorder.on('stateChange', (state: media.AVRecorderState, _: media.StateChangeReason) => { console.log(`AudioRecorder current state is ${state}`); }) // 错误上报回调函数 this.avRecorder.on('error', (err: BusinessError) => { console.error(`AudioRecorder failed, code is ${err.code}, message is ${err.message}`); }) } } // 开始录制对应的流程 async startRecordingProcess(): Promise<void> { if (this.avRecorder !== undefined) { await this.avRecorder.release(); this.avRecorder = undefined; } // 1.创建录制实例 this.avRecorder = await media.createAVRecorder(); this.setAudioRecorderCallback(); // 2.获取录制文件fd赋予avConfig里的url;参考FilePicker文档 const context = getContext(this); const path = context.filesDir; const filepath = path + '/01.mp3'; const file = fs.openSync(filepath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); const fdNumber = file.fd; this.avConfig.url = 'fd://' + fdNumber; // 3.配置录制参数完成准备工作 await this.avRecorder.prepare(this.avConfig); // 4.开始录制 await this.avRecorder.start(); // TODO:知识点:通过getAudioCapturerMaxAmplitude接口获取声音振幅大小。 this.time = setInterval(() => { this.avRecorder!.getAudioCapturerMaxAmplitude((_: BusinessError, amplitude: number) => { this.maxAmplitude = amplitude; }); }, Const.COLUMN_HEIGHT); } // 暂停录制对应的流程 async pauseRecordingProcess(): Promise<void> { if (this.avRecorder !== undefined && this.avRecorder.state === 'started') { // 仅在started状态下调用pause为合理状态切换 await this.avRecorder.pause(); } } // 恢复录制对应的流程 async resumeRecordingProcess(): Promise<void> { if (this.avRecorder !== undefined && this.avRecorder.state === 'paused') { // 仅在paused状态下调用resume为合理状态切换 await this.avRecorder.resume(); } } // 停止录制对应的流程 async stopRecordingProcess(): Promise<void> { if (this.avRecorder !== undefined) { // 1. 停止录制 if (this.avRecorder.state === 'started' || this.avRecorder.state === 'paused') { // 仅在started或者paused状态下调用stop为合理状态切换 await this.avRecorder.stop(); clearInterval(this.time); } // 2.重置 await this.avRecorder.reset(); // 3.释放录制实例 await this.avRecorder.release(); this.avRecorder = undefined; } } }
AST#export_declaration#Left export AST#class_declaration#Left class AudioRecorder AST#class_body#Left { AST#property_declaration#Left private avRecorder : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#qualified_type#Left media . AVRecorder AST#qualified_type#Right AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left undefined AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left public maxAmplitude : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left public time : 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 avProfile : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left media . AVRecorderProfile 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 audioBitrate AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . AUDIO_BITRATE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , // 音频比特率 AST#property_assignment#Left AST#property_name#Left audioChannels AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . AUDIO_CHANNELS AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , // 音频声道数 AST#property_assignment#Left AST#property_name#Left audioCodec AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left media AST#expression#Right . CodecMimeType AST#member_expression#Right AST#expression#Right . AUDIO_AAC AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , // 音频编码格式,当前只支持aac AST#property_assignment#Left AST#property_name#Left audioSampleRate AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . AUDIO_SAMPLE_RATE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , // 音频采样率 AST#property_assignment#Left AST#property_name#Left fileFormat AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left media AST#expression#Right . ContainerFormatType AST#member_expression#Right AST#expression#Right . CFT_MPEG_4A AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , // 封装格式,当前只支持m4a } AST#object_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private avConfig : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left media . AVRecorderConfig 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 audioSourceType AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left media AST#expression#Right . AudioSourceType AST#member_expression#Right AST#expression#Right . AUDIO_SOURCE_TYPE_MIC AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , // 音频输入源,这里设置为麦克风 AST#property_assignment#Left AST#property_name#Left profile AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . avProfile AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left url AST#property_name#Right : AST#expression#Left 'fd://35' AST#expression#Right AST#property_assignment#Right , // 参考应用文件访问与管理开发示例新建并读写一个文件 } AST#object_literal#Right AST#expression#Right ; AST#property_declaration#Right // 注册audioRecorder回调函数 AST#method_declaration#Left setAudioRecorderCallback AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . avRecorder AST#member_expression#Right AST#expression#Right !== AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { // 状态机变化回调函数 AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . avRecorder AST#member_expression#Right AST#expression#Right . on AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'stateChange' AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left state : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left media . AVRecorderState AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left _ : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left media . StateChangeReason 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 console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` AudioRecorder current state is AST#template_substitution#Left $ { AST#expression#Left state AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right // 错误上报回调函数 AST#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 . avRecorder 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` AudioRecorder failed, code is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , message is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right // 开始录制对应的流程 AST#method_declaration#Left async startRecordingProcess 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#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . avRecorder AST#member_expression#Right AST#expression#Right !== AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#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 . avRecorder AST#member_expression#Right AST#expression#Right . release AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . avRecorder AST#member_expression#Right = AST#expression#Left undefined AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right // 1.创建录制实例 AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . avRecorder 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 media AST#expression#Right AST#await_expression#Right AST#expression#Right . createAVRecorder 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 this AST#expression#Right . setAudioRecorderCallback 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 // 2.获取录制文件fd赋予avConfig里的url;参考FilePicker文档 AST#expression_statement#Left AST#expression#Left const AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left 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#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left const AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left path = AST#expression#Left AST#member_expression#Left AST#expression#Left context AST#expression#Right . filesDir AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left const AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left filepath = AST#expression#Left AST#binary_expression#Left AST#expression#Left path AST#expression#Right + AST#expression#Left '/01.mp3' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left const AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left file = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fs AST#expression#Right . openSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left filepath AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fs AST#expression#Right . OpenMode AST#member_expression#Right AST#expression#Right . READ_WRITE AST#member_expression#Right AST#expression#Right | AST#expression#Left fs AST#expression#Right AST#binary_expression#Right AST#expression#Right . OpenMode AST#member_expression#Right AST#expression#Right . CREATE 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#expression_statement#Left AST#expression#Left const AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left fdNumber = AST#expression#Left AST#member_expression#Left AST#expression#Left file AST#expression#Right . fd AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . avConfig AST#member_expression#Right AST#expression#Right . url AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left 'fd://' AST#expression#Right + AST#expression#Left fdNumber AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right // 3.配置录制参数完成准备工作 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 . avRecorder AST#member_expression#Right AST#expression#Right . prepare 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 . avConfig AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right // 4.开始录制 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 . avRecorder AST#member_expression#Right AST#expression#Right . start AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right // TODO:知识点:通过getAudioCapturerMaxAmplitude接口获取声音振幅大小。 AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . time AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left setInterval AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#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 . avRecorder AST#member_expression#Right AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right . getAudioCapturerMaxAmplitude AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left _ : AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left amplitude : 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 . maxAmplitude AST#member_expression#Right = AST#expression#Left amplitude 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#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . COLUMN_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#builder_function_body#Right AST#method_declaration#Right // 暂停录制对应的流程 AST#method_declaration#Left async pauseRecordingProcess 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#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . avRecorder AST#member_expression#Right AST#expression#Right !== AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . avRecorder AST#member_expression#Right AST#expression#Right . state AST#member_expression#Right AST#expression#Right === AST#expression#Left 'started' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { // 仅在started状态下调用pause为合理状态切换 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 . avRecorder AST#member_expression#Right AST#expression#Right . pause AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right // 恢复录制对应的流程 AST#method_declaration#Left async resumeRecordingProcess 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#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . avRecorder AST#member_expression#Right AST#expression#Right !== AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . avRecorder AST#member_expression#Right AST#expression#Right . state AST#member_expression#Right AST#expression#Right === AST#expression#Left 'paused' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { // 仅在paused状态下调用resume为合理状态切换 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 . avRecorder AST#member_expression#Right AST#expression#Right . resume AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right // 停止录制对应的流程 AST#method_declaration#Left async stopRecordingProcess 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 this AST#expression#Right . avRecorder AST#member_expression#Right AST#expression#Right !== AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { // 1. 停止录制 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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#member_expression#Left AST#expression#Left this AST#expression#Right . avRecorder AST#member_expression#Right AST#expression#Right . state AST#member_expression#Right AST#expression#Right === AST#expression#Left 'started' AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . avRecorder AST#member_expression#Right AST#expression#Right . state AST#member_expression#Right AST#expression#Right === AST#expression#Left 'paused' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { // 仅在started或者paused状态下调用stop为合理状态切换 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 . avRecorder AST#member_expression#Right AST#expression#Right . stop AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left clearInterval AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . time 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 // 2.重置 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 . avRecorder AST#member_expression#Right AST#expression#Right . reset AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 3.释放录制实例 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 . avRecorder AST#member_expression#Right AST#expression#Right . release AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . avRecorder AST#member_expression#Right = AST#expression#Left undefined AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class AudioRecorder { private avRecorder: media.AVRecorder | undefined = undefined; public maxAmplitude: number = 0; public time: number = 0; private avProfile: media.AVRecorderProfile = { audioBitrate: Const.AUDIO_BITRATE, audioChannels: Const.AUDIO_CHANNELS, audioCodec: media.CodecMimeType.AUDIO_AAC, audioSampleRate: Const.AUDIO_SAMPLE_RATE, fileFormat: media.ContainerFormatType.CFT_MPEG_4A, }; private avConfig: media.AVRecorderConfig = { audioSourceType: media.AudioSourceType.AUDIO_SOURCE_TYPE_MIC, profile: this.avProfile, url: 'fd://35', }; setAudioRecorderCallback(): void { if (this.avRecorder !== undefined) { this.avRecorder.on('stateChange', (state: media.AVRecorderState, _: media.StateChangeReason) => { console.log(`AudioRecorder current state is ${state}`); }) this.avRecorder.on('error', (err: BusinessError) => { console.error(`AudioRecorder failed, code is ${err.code}, message is ${err.message}`); }) } } async startRecordingProcess(): Promise<void> { if (this.avRecorder !== undefined) { await this.avRecorder.release(); this.avRecorder = undefined; } this.avRecorder = await media.createAVRecorder(); this.setAudioRecorderCallback(); const context = getContext(this); const path = context.filesDir; const filepath = path + '/01.mp3'; const file = fs.openSync(filepath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); const fdNumber = file.fd; this.avConfig.url = 'fd://' + fdNumber; await this.avRecorder.prepare(this.avConfig); await this.avRecorder.start(); this.time = setInterval(() => { this.avRecorder!.getAudioCapturerMaxAmplitude((_: BusinessError, amplitude: number) => { this.maxAmplitude = amplitude; }); }, Const.COLUMN_HEIGHT); } async pauseRecordingProcess(): Promise<void> { if (this.avRecorder !== undefined && this.avRecorder.state === 'started') { await this.avRecorder.pause(); } } async resumeRecordingProcess(): Promise<void> { if (this.avRecorder !== undefined && this.avRecorder.state === 'paused') { await this.avRecorder.resume(); } } async stopRecordingProcess(): Promise<void> { if (this.avRecorder !== undefined) { if (this.avRecorder.state === 'started' || this.avRecorder.state === 'paused') { await this.avRecorder.stop(); clearInterval(this.time); } await this.avRecorder.reset(); await this.avRecorder.release(); this.avRecorder = undefined; } } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/voicerecordynamiceffect/src/main/ets/models/AudioRecorder.ets#L22-L113
6513214d2717511a3255e03b75303bed8d0608fa
gitee
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
FramedRendering/entry/src/main/ets/view/DateItemView.ets
arkts
aboutToAppear
[EndExclude Case2]
aboutToAppear(): void { hiTraceMeter.startTrace('appear_', 1); this.displaySync = displaySync.create(); const range: ExpectedFrameRateRange = { expected: 120, min: 60, max: 120 }; this.displaySync.setExpectedFrameRateRange(range); this.displaySync.on('frame', () => { // [StartExclude Case2] // [Start Case3] if (this.temp.length > 0) { if (this.step === 0) { // Step 1: Add the monthly data and calculate the maximum number of frames required to complete the data operation. hiTraceMeter.startTrace('reuse_' + this.step, 1); this.month = this.temp[0].month; this.monthNumber = this.temp[0].num; this.maxStep = this.maxStep + Math.ceil(this.temp[0].days.length / this.MAX_EVERY_FRAME); hiTraceMeter.finishTrace('reuse_' + this.step, 1); this.step += 1; } else if (this.step === this.maxStep - 1) { // Final step: Initialize partial count data. this.temp = []; this.step = 0; this.maxStep = 2; } else { hiTraceMeter.startTrace('reuse_' + this.step, 1); const start: number = this.MAX_EVERY_FRAME * (this.step - 1); const end: number = (this.MAX_EVERY_FRAME * this.step) > this.temp[0].days.length ? this.temp[0].days.length : this.MAX_EVERY_FRAME * this.step; for (let i = start; i < end; i++) { this.days[i] = this.temp[0].days[i]; this.lunarDays[i] = this.temp[0].lunarDays[i]; } hiTraceMeter.finishTrace('reuse_' + this.step, 1); this.step += 1; } } // [End Case3] // [EndExclude Case2] }); this.displaySync.start(); allDisplaySyncArray.push(this.displaySync); this.temp.push(this.monthItem); hiTraceMeter.finishTrace('appear_', 1); }
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#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 'appear_' 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . displaySync AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left displaySync AST#expression#Right . create AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left range : AST#type_annotation#Left AST#primary_type#Left ExpectedFrameRateRange AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left expected AST#property_name#Right : AST#expression#Left 120 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left min AST#property_name#Right : AST#expression#Left 60 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left max AST#property_name#Right : AST#expression#Left 120 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . displaySync AST#member_expression#Right AST#expression#Right . setExpectedFrameRateRange AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left range 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 . displaySync AST#member_expression#Right AST#expression#Right . on AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'frame' AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { // [StartExclude Case2] // [Start Case3] 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 . temp 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#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 . step 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 { // Step 1: Add the monthly data and calculate the maximum number of frames required to complete the data operation. 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 AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'reuse_' AST#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . step AST#member_expression#Right 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . month AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . temp AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . month AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . monthNumber AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . temp AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . num AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . maxStep AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . maxStep AST#member_expression#Right AST#expression#Right + AST#expression#Left Math AST#expression#Right AST#binary_expression#Right AST#expression#Right . ceil AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 . temp AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . days AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right / AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . MAX_EVERY_FRAME 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 hiTraceMeter AST#expression#Right . finishTrace 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 'reuse_' AST#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . step AST#member_expression#Right 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . step AST#member_expression#Right += AST#expression#Left 1 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#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 this AST#expression#Right . step AST#member_expression#Right AST#expression#Right === AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . maxStep AST#member_expression#Right AST#expression#Right - AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { // Final step: Initialize partial count data. 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 . temp AST#member_expression#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . step AST#member_expression#Right = AST#expression#Left 0 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . maxStep AST#member_expression#Right = AST#expression#Left 2 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 hiTraceMeter AST#expression#Right . startTrace 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 'reuse_' AST#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . step AST#member_expression#Right AST#expression#Right , AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left start : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . MAX_EVERY_FRAME 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#member_expression#Left AST#expression#Left this AST#expression#Right . step AST#member_expression#Right AST#expression#Right - AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left end : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . MAX_EVERY_FRAME AST#member_expression#Right AST#expression#Right * AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . step AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right > AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . temp AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . days 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 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 . temp AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . days AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right : AST#expression#Left this AST#expression#Right AST#conditional_expression#Right AST#expression#Right . MAX_EVERY_FRAME AST#member_expression#Right AST#expression#Right * AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . step AST#member_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 start AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left end AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . days AST#member_expression#Right AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#ERROR#Left = this AST#ERROR#Right . temp AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . days AST#member_expression#Right AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . lunarDays AST#member_expression#Right AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#ERROR#Left = this AST#ERROR#Right . temp AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . lunarDays AST#member_expression#Right AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#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 . finishTrace 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 'reuse_' AST#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . step AST#member_expression#Right 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . step AST#member_expression#Right += AST#expression#Left 1 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // [End Case3] // [EndExclude Case2] } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . displaySync AST#member_expression#Right AST#expression#Right . start AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left allDisplaySyncArray AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . displaySync 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#member_expression#Left AST#expression#Left this AST#expression#Right . temp AST#member_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 this AST#expression#Right . monthItem 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 hiTraceMeter AST#expression#Right . finishTrace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'appear_' 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#method_declaration#Right
aboutToAppear(): void { hiTraceMeter.startTrace('appear_', 1); this.displaySync = displaySync.create(); const range: ExpectedFrameRateRange = { expected: 120, min: 60, max: 120 }; this.displaySync.setExpectedFrameRateRange(range); this.displaySync.on('frame', () => { if (this.temp.length > 0) { if (this.step === 0) { hiTraceMeter.startTrace('reuse_' + this.step, 1); this.month = this.temp[0].month; this.monthNumber = this.temp[0].num; this.maxStep = this.maxStep + Math.ceil(this.temp[0].days.length / this.MAX_EVERY_FRAME); hiTraceMeter.finishTrace('reuse_' + this.step, 1); this.step += 1; } else if (this.step === this.maxStep - 1) { this.temp = []; this.step = 0; this.maxStep = 2; } else { hiTraceMeter.startTrace('reuse_' + this.step, 1); const start: number = this.MAX_EVERY_FRAME * (this.step - 1); const end: number = (this.MAX_EVERY_FRAME * this.step) > this.temp[0].days.length ? this.temp[0].days.length : this.MAX_EVERY_FRAME * this.step; for (let i = start; i < end; i++) { this.days[i] = this.temp[0].days[i]; this.lunarDays[i] = this.temp[0].lunarDays[i]; } hiTraceMeter.finishTrace('reuse_' + this.step, 1); this.step += 1; } } }); this.displaySync.start(); allDisplaySyncArray.push(this.displaySync); this.temp.push(this.monthItem); hiTraceMeter.finishTrace('appear_', 1); }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/FramedRendering/entry/src/main/ets/view/DateItemView.ets#L67-L113
6339e7123f0a539b5a72fa67b78c0babc5454704
gitee
bigbear20240612/planner_build-.git
89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1
entry/src/main/ets/viewmodel/StatsManager.ets
arkts
exportStats
导出统计数据
async exportStats(): Promise<string> { const exportData = { exportTime: new Date().toISOString(), version: '1.0', stats: this.stats }; return JSON.stringify(exportData, null, 2); }
AST#method_declaration#Left async exportStats AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left exportData = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left exportTime AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . toISOString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left version AST#property_name#Right : AST#expression#Left '1.0' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left stats AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . stats AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left 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 exportData AST#expression#Right , AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right , AST#expression#Left 2 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async exportStats(): Promise<string> { const exportData = { exportTime: new Date().toISOString(), version: '1.0', stats: this.stats }; return JSON.stringify(exportData, null, 2); }
https://github.com/bigbear20240612/planner_build-.git/blob/89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1/entry/src/main/ets/viewmodel/StatsManager.ets#L366-L373
284deae64b3fba35a1df6654a7144635a5a26f83
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/models/managers/userdata/CosDownloaderUserData.ets
arkts
MARK: - 构造函数
private constructor() { // 初始化腾讯云服务 CosService.shared; }
AST#constructor_declaration#Left private constructor AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { // 初始化腾讯云服务 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CosService AST#expression#Right . shared AST#member_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right
private constructor() { CosService.shared; }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/managers/userdata/CosDownloaderUserData.ets#L20-L23
6442f62dcb2fc245fe09df2b30bbc2f07bf410fd
github
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/PasteboardUtil.ets
arkts
getDataPixelMap
读取系统剪贴板PixelMap内容,使用Promise异步回调。 @returns
static async getDataPixelMap(): Promise<image.PixelMap> { const pasteData: pasteboard.PasteData = await PasteboardUtil.getData(); return pasteData.getPrimaryPixelMap(); }
AST#method_declaration#Left static async getDataPixelMap 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 image . PixelMap AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left pasteData : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left pasteboard . PasteData 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 PasteboardUtil AST#expression#Right AST#await_expression#Right AST#expression#Right . getData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left pasteData AST#expression#Right . getPrimaryPixelMap AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static async getDataPixelMap(): Promise<image.PixelMap> { const pasteData: pasteboard.PasteData = await PasteboardUtil.getData(); return pasteData.getPrimaryPixelMap(); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/PasteboardUtil.ets#L276-L279
a550046158609e3d70b7d55fa20e4a63c15264d9
gitee
sithvothykiv/dialog_hub.git
b676c102ef2d05f8994d170abe48dcc40cd39005
custom_dialog/src/main/ets/core/proxy/DatePickerBuilderProxy.ets
arkts
dateType
时间类型 @param dateType 枚举:YmdHms-年月日时分秒; YmdHm-年月日时分; YmdH-年月日时; Ymd-年月日; Ym-年月; Y-年; Hms-时分秒; Hm-时分; Ms-分秒 @returns
dateType(dateType: DateType) { this.builderOptions.dateType = dateType return this }
AST#method_declaration#Left dateType AST#parameter_list#Left ( AST#parameter#Left dateType : AST#type_annotation#Left AST#primary_type#Left DateType AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . builderOptions AST#member_expression#Right AST#expression#Right . dateType AST#member_expression#Right = AST#expression#Left dateType AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left this AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
dateType(dateType: DateType) { this.builderOptions.dateType = dateType return this }
https://github.com/sithvothykiv/dialog_hub.git/blob/b676c102ef2d05f8994d170abe48dcc40cd39005/custom_dialog/src/main/ets/core/proxy/DatePickerBuilderProxy.ets#L16-L19
cc93d9be582934a6ca31128ff423e81bdeef4097
github
851432669/Smart-Home-ArkTs-Hi3861.git
0451f85f072ed3281cc23d9cdc2843d79f60f975
entry/src/main/ets/common/utils/MQTTUtil.ets
arkts
publishMessage
发布消息到指定主题 @param topic 主题 @param message 消息内容 @returns 发布是否成功
async publishMessage(topic: string, message: string): Promise<boolean> { // 检查连接状态,如果未连接则尝试重连 if (!this.isClientConnected()) { console.warn('MQTT客户端未连接,尝试重新连接...'); try { // 使用保存的回调进行重连 if (this.messageCallback) { await this.connect(this.messageCallback); } else { // 使用默认回调进行重连 await this.connect((err, data) => { if (!err) { console.info(`重连后收到消息: ${data.topic}, ${data.payload}`); } }); } // 等待短暂时间确保连接完成 await new Promise<void>((resolve) => setTimeout(resolve, 500)); // 如果重连后仍然未连接,则返回失败 if (!this.isClientConnected()) { console.error('MQTT重连失败,无法发送消息'); return false; } } catch (error) { console.error(`MQTT重连异常: ${JSON.stringify(error)}`); return false; } } // 再次确认客户端不为null if (!this.mqttAsyncClient) { console.error('MQTT客户端为null,无法发送消息'); return false; } try { console.info(`准备发送MQTT消息: topic=${topic}, message=${message}`); // 发布消息 const response = await this.mqttAsyncClient.publish({ topic: topic, payload: message, qos: 1, retained: false }); // 检查response是否有效 if (!response) { console.error('MQTT消息发布失败: 收到无效的响应'); this.isConnected = false; // 标记连接状态为断开,下次将尝试重连 return false; } console.info(`MQTT消息发布成功: topic=${topic}`); return true; } catch (error) { console.error(`MQTT消息发布异常: ${JSON.stringify(error)}`); this.isConnected = false; // 标记连接状态为断开 // 发生错误时安排重连 this.scheduleReconnect(); return false; } }
AST#method_declaration#Left async publishMessage AST#parameter_list#Left ( AST#parameter#Left topic : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left message : 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 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#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . isClientConnected AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . warn AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'MQTT客户端未连接,尝试重新连接...' 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 . messageCallback 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 . connect 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 . messageCallback AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { // 使用默认回调进行重连 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . connect 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#parameter#Right , AST#parameter#Left data 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` 重连后收到消息: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . topic 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 data AST#expression#Right . payload AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 等待短暂时间确保连接完成 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left AST#new_expression#Left new AST#expression#Left Promise AST#expression#Right AST#new_expression#Right AST#expression#Right AST#await_expression#Right AST#expression#Right 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#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left resolve AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left setTimeout AST#expression#Right AST#argument_list#Left ( AST#expression#Left resolve AST#expression#Right , AST#expression#Left 500 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 如果重连后仍然未连接,则返回失败 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . isClientConnected AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'MQTT重连失败,无法发送消息' 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#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` MQTT重连异常: 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#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 再次确认客户端不为null 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 . mqttAsyncClient 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 . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'MQTT客户端为null,无法发送消息' 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#if_statement#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` 准备发送MQTT消息: topic= AST#template_substitution#Left $ { AST#expression#Left topic AST#expression#Right } AST#template_substitution#Right , message= AST#template_substitution#Left $ { AST#expression#Left message AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 发布消息 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left response = 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 . mqttAsyncClient AST#member_expression#Right AST#expression#Right . publish 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 topic AST#property_name#Right : AST#expression#Left topic AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left payload AST#property_name#Right : AST#expression#Left message AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left qos AST#property_name#Right : AST#expression#Left 1 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left retained AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 检查response是否有效 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left response 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 console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'MQTT消息发布失败: 收到无效的响应' 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 . isConnected AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 标记连接状态为断开,下次将尝试重连 AST#statement#Left AST#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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` MQTT消息发布成功: topic= AST#template_substitution#Left $ { AST#expression#Left topic AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` MQTT消息发布异常: 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isConnected AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 标记连接状态为断开 // 发生错误时安排重连 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scheduleReconnect 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 false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async publishMessage(topic: string, message: string): Promise<boolean> { if (!this.isClientConnected()) { console.warn('MQTT客户端未连接,尝试重新连接...'); try { if (this.messageCallback) { await this.connect(this.messageCallback); } else { await this.connect((err, data) => { if (!err) { console.info(`重连后收到消息: ${data.topic}, ${data.payload}`); } }); } await new Promise<void>((resolve) => setTimeout(resolve, 500)); if (!this.isClientConnected()) { console.error('MQTT重连失败,无法发送消息'); return false; } } catch (error) { console.error(`MQTT重连异常: ${JSON.stringify(error)}`); return false; } } if (!this.mqttAsyncClient) { console.error('MQTT客户端为null,无法发送消息'); return false; } try { console.info(`准备发送MQTT消息: topic=${topic}, message=${message}`); const response = await this.mqttAsyncClient.publish({ topic: topic, payload: message, qos: 1, retained: false }); if (!response) { console.error('MQTT消息发布失败: 收到无效的响应'); this.isConnected = false; return false; } console.info(`MQTT消息发布成功: topic=${topic}`); return true; } catch (error) { console.error(`MQTT消息发布异常: ${JSON.stringify(error)}`); this.isConnected = false; this.scheduleReconnect(); return false; } }
https://github.com/851432669/Smart-Home-ArkTs-Hi3861.git/blob/0451f85f072ed3281cc23d9cdc2843d79f60f975/entry/src/main/ets/common/utils/MQTTUtil.ets#L191-L255
86a22e15c0eb765aa5dbbaa0eac8b2f0d0c61a08
github
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
core/database/src/main/ets/datasource/footprint/FootprintLocalDataSourceImpl.ets
arkts
构造函数,初始化 ORM 并确保足迹表已迁移 @returns {FootprintLocalDataSourceImpl} 实例
constructor() { this.ensureMigrated(); }
AST#constructor_declaration#Left constructor AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . ensureMigrated 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#constructor_declaration#Right
constructor() { this.ensureMigrated(); }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/database/src/main/ets/datasource/footprint/FootprintLocalDataSourceImpl.ets#L24-L26
a3370fc52ac990a5301e55909eb2f5a280244d32
github
kaina404/HarmonyStock.git
99233a46fb0dfb21e02294c730fd80e2fb404f9b
entry/src/main/ets/pages/component/MinuteLineComponent.ets
arkts
_drawMinuteLine
绘制分钟线
_drawMinuteLine() { this.drawBackgroundLine() this.drawMinuteLine() this.drawAveragePriceLine() this.context.font = '40px' this.context.textAlign = 'center' this.context.textBaseline = 'middle' //绘制左侧最高价格 if (this.stockData.lineHighest != null) { this.context.fillStyle = '#e2233e' let txtH = this.stockApi.roundUpToTwoDecimalPlaces(this.stockData.lineHighest) this.context.fillText(txtH, this.minuteRect.startX + this.maxPriceTxtWidth / 2, this.minuteRect.startY + this.singleTxtHeight) } //绘制昨收价格 if (this.stockData.prev_close != null) { this.context.fillStyle = '#6c6c6c' let txtH = this.stockApi.roundUpToTwoDecimalPlaces(this.stockData.prev_close) this.context.fillText(txtH, this.minuteRect.startX + this.maxPriceTxtWidth / 2, this.minuteRect.height / 2 + this.singleTxtHeight) } //绘制左侧最低价格 if (this.stockData.lineLowest != null) { this.context.fillStyle = '#228B22' let txtH = this.stockApi.roundUpToTwoDecimalPlaces(this.stockData.lineLowest) this.context.fillText(txtH, this.minuteRect.startX + this.maxPriceTxtWidth / 2, this.minuteRect.getEndY() - this.singleTxtHeight / 2) } }
AST#method_declaration#Left _drawMinuteLine 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 . drawBackgroundLine 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 . drawMinuteLine 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 . drawAveragePriceLine AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . context AST#member_expression#Right AST#expression#Right . font AST#member_expression#Right = AST#expression#Left '40px' AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . context AST#member_expression#Right AST#expression#Right . textAlign AST#member_expression#Right = AST#expression#Left 'center' AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . context AST#member_expression#Right AST#expression#Right . textBaseline AST#member_expression#Right = AST#expression#Left 'middle' 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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . stockData AST#member_expression#Right AST#expression#Right . lineHighest AST#member_expression#Right AST#expression#Right != AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . context AST#member_expression#Right AST#expression#Right . fillStyle AST#member_expression#Right = AST#expression#Left '#e2233e' AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left let AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left txtH = 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 . stockApi AST#member_expression#Right AST#expression#Right . roundUpToTwoDecimalPlaces 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 . stockData AST#member_expression#Right AST#expression#Right . lineHighest 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#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 . context AST#member_expression#Right AST#expression#Right . fillText AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left txtH AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . minuteRect AST#member_expression#Right AST#expression#Right . startX AST#member_expression#Right AST#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . maxPriceTxtWidth AST#member_expression#Right AST#expression#Right / AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . minuteRect AST#member_expression#Right AST#expression#Right . startY AST#member_expression#Right AST#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . singleTxtHeight AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right //绘制昨收价格 AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . stockData AST#member_expression#Right AST#expression#Right . prev_close AST#member_expression#Right AST#expression#Right != AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . context AST#member_expression#Right AST#expression#Right . fillStyle AST#member_expression#Right = AST#expression#Left '#6c6c6c' AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left let AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left txtH = 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 . stockApi AST#member_expression#Right AST#expression#Right . roundUpToTwoDecimalPlaces 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 . stockData AST#member_expression#Right AST#expression#Right . prev_close 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#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 . context AST#member_expression#Right AST#expression#Right . fillText AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left txtH AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . minuteRect AST#member_expression#Right AST#expression#Right . startX AST#member_expression#Right AST#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . maxPriceTxtWidth AST#member_expression#Right AST#expression#Right / AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . minuteRect AST#member_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right / AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . singleTxtHeight AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right //绘制左侧最低价格 AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . stockData AST#member_expression#Right AST#expression#Right . lineLowest AST#member_expression#Right AST#expression#Right != AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . context AST#member_expression#Right AST#expression#Right . fillStyle AST#member_expression#Right = AST#expression#Left '#228B22' AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left let AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left txtH = 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 . stockApi AST#member_expression#Right AST#expression#Right . roundUpToTwoDecimalPlaces 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 . stockData AST#member_expression#Right AST#expression#Right . lineLowest 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#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 . context AST#member_expression#Right AST#expression#Right . fillText AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left txtH AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . minuteRect AST#member_expression#Right AST#expression#Right . startX AST#member_expression#Right AST#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . maxPriceTxtWidth AST#member_expression#Right 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 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 this AST#expression#Right . minuteRect AST#member_expression#Right AST#expression#Right . getEndY AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . singleTxtHeight AST#member_expression#Right AST#expression#Right / AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
_drawMinuteLine() { this.drawBackgroundLine() this.drawMinuteLine() this.drawAveragePriceLine() this.context.font = '40px' this.context.textAlign = 'center' this.context.textBaseline = 'middle' if (this.stockData.lineHighest != null) { this.context.fillStyle = '#e2233e' let txtH = this.stockApi.roundUpToTwoDecimalPlaces(this.stockData.lineHighest) this.context.fillText(txtH, this.minuteRect.startX + this.maxPriceTxtWidth / 2, this.minuteRect.startY + this.singleTxtHeight) } if (this.stockData.prev_close != null) { this.context.fillStyle = '#6c6c6c' let txtH = this.stockApi.roundUpToTwoDecimalPlaces(this.stockData.prev_close) this.context.fillText(txtH, this.minuteRect.startX + this.maxPriceTxtWidth / 2, this.minuteRect.height / 2 + this.singleTxtHeight) } if (this.stockData.lineLowest != null) { this.context.fillStyle = '#228B22' let txtH = this.stockApi.roundUpToTwoDecimalPlaces(this.stockData.lineLowest) this.context.fillText(txtH, this.minuteRect.startX + this.maxPriceTxtWidth / 2, this.minuteRect.getEndY() - this.singleTxtHeight / 2) } }
https://github.com/kaina404/HarmonyStock.git/blob/99233a46fb0dfb21e02294c730fd80e2fb404f9b/entry/src/main/ets/pages/component/MinuteLineComponent.ets#L255-L280
ad40e48600a16593fb53eac531fa3f986318efd1
github
EL233/WeChat-HarmonyOS.git
b5fa65556eb5f5698a92ec289ffd9ebe4cc5bb3e
entry/src/main/ets/view/component/Dialog.ets
arkts
openDialog
打开自定义对话框
openDialog() { if (this.contentNode !== null && this.contentNode !== undefined) { this.ctx?.getPromptAction() .openCustomDialog(this.contentNode, this.options) .then(() => { hilog.info(0xFF00, 'PersonalInformation', '%{public}s', 'OpenCustomDialog complete'); // 记录日志,对话框打开完成 }) .catch((error: BusinessError) => { let message = (error as BusinessError).message; // 获取错误消息 let code = (error as BusinessError).code; // 获取错误代码 hilog.error(0xFF00, 'PersonalInformation', '%{public}s', `OpenCustomDialog args error code is ${code}, message is ${message}`); // 记录错误日志 }); } }
AST#method_declaration#Left openDialog AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . contentNode AST#member_expression#Right AST#expression#Right !== AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . contentNode AST#member_expression#Right AST#expression#Right !== AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . ctx AST#member_expression#Right AST#expression#Right ?. getPromptAction AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . openCustomDialog AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . contentNode AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0xFF00 AST#expression#Right , AST#expression#Left 'PersonalInformation' AST#expression#Right , AST#expression#Left '%{public}s' AST#expression#Right , AST#expression#Left 'OpenCustomDialog complete' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 记录日志,对话框打开完成 } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . catch AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left error : AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left message = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . message AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 获取错误消息 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left code = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . code AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 获取错误代码 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0xFF00 AST#expression#Right , AST#expression#Left 'PersonalInformation' AST#expression#Right , AST#expression#Left '%{public}s' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` OpenCustomDialog args error code is AST#template_substitution#Left $ { AST#expression#Left code AST#expression#Right } AST#template_substitution#Right , message is AST#template_substitution#Left $ { AST#expression#Left message AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 记录错误日志 } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
openDialog() { if (this.contentNode !== null && this.contentNode !== undefined) { this.ctx?.getPromptAction() .openCustomDialog(this.contentNode, this.options) .then(() => { hilog.info(0xFF00, 'PersonalInformation', '%{public}s', 'OpenCustomDialog complete'); }) .catch((error: BusinessError) => { let message = (error as BusinessError).message; let code = (error as BusinessError).code; hilog.error(0xFF00, 'PersonalInformation', '%{public}s', `OpenCustomDialog args error code is ${code}, message is ${message}`); }); } }
https://github.com/EL233/WeChat-HarmonyOS.git/blob/b5fa65556eb5f5698a92ec289ffd9ebe4cc5bb3e/entry/src/main/ets/view/component/Dialog.ets#L31-L45
edfb3c15079a4fa59c317003d4a96eec8acb52aa
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/BasicFeature/Connectivity/StageSocket/entry/src/main/ets/controller/LoginController.ets
arkts
sendData
TCP 和 TLS发送消息 @param data
public sendData(data: string): void { this.mSocket?.sendData(data); }
AST#method_declaration#Left public sendData AST#parameter_list#Left ( 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 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 . mSocket AST#member_expression#Right AST#expression#Right ?. sendData 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#builder_function_body#Right AST#method_declaration#Right
public sendData(data: string): void { this.mSocket?.sendData(data); }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/BasicFeature/Connectivity/StageSocket/entry/src/main/ets/controller/LoginController.ets#L96-L98
b488d19801a2502c906a46bda56814b080975936
gitee
wangjinyuan/JS-TS-ArkTS-database.git
a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26
npm/@pornhub_alerts/94.0.1/package/app.ets
arkts
应用约束60: 使用ES模块的export语法代替CommonJS的exports
export function printMsg(): void {}
AST#export_declaration#Left export AST#function_declaration#Left function printMsg 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#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export function printMsg(): void {}
https://github.com/wangjinyuan/JS-TS-ArkTS-database.git/blob/a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26/npm/@pornhub_alerts/94.0.1/package/app.ets#L2-L2
d0205959e4186b4ad2f3d842b9da8504793a3826
github