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
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/danmakuplayer/src/main/ets/common/Constants.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 Constants { static readonly HUNDRED_PERCENT: number = 100; // 百分比最大值 static readonly MAX_BRIGHTNESS: number = 255; // 最大亮度 static readonly DEFAULT_BRIGHTNESS: number = 10; // 默认亮度 static readonly DANMU_RESIZE_TIME: number = 300; // 默认亮度 static readonly COUNT_DOWN_TIME: number = 3; // UI自动隐藏倒计时时间 static readonly MS_IN_SECOND: number = 1000; // 1s对应毫秒数 static readonly SECOND_IN_MINUTE: number = 60; // 1min对应秒数 static readonly MINUTE_IN_HOUR: number = 60; // 1h对应分钟数 static readonly SECOND_IN_HOUR: number = 3600; // 1h对应秒数 static readonly MAX_DANMAKU_LINES: number = 5; // 滚动弹幕最大显示行数 static readonly DANMAKU_STYLE: number = 3; // 滚动弹幕最大显示行数 static readonly DANMAKU_SCROLL_SPEED: number = 1.2; // 弹幕滚动速率 static readonly DANMAKU_SCALE_TEXT_SIZE: number = 1.2; // 缩放字体大小 static readonly DANMAKU_MARGIN: number = 40; // 弹幕显示外边距 }
AST#export_declaration#Left export AST#class_declaration#Left class Constants AST#class_body#Left { AST#property_declaration#Left static readonly HUNDRED_PERCENT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 100 AST#expression#Right ; AST#property_declaration#Right // 百分比最大值 AST#property_declaration#Left static readonly MAX_BRIGHTNESS : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 255 AST#expression#Right ; AST#property_declaration#Right // 最大亮度 AST#property_declaration#Left static readonly DEFAULT_BRIGHTNESS : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 10 AST#expression#Right ; AST#property_declaration#Right // 默认亮度 AST#property_declaration#Left static readonly DANMU_RESIZE_TIME : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 300 AST#expression#Right ; AST#property_declaration#Right // 默认亮度 AST#property_declaration#Left static readonly COUNT_DOWN_TIME : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 3 AST#expression#Right ; AST#property_declaration#Right // UI自动隐藏倒计时时间 AST#property_declaration#Left static readonly MS_IN_SECOND : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 1000 AST#expression#Right ; AST#property_declaration#Right // 1s对应毫秒数 AST#property_declaration#Left static readonly SECOND_IN_MINUTE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 60 AST#expression#Right ; AST#property_declaration#Right // 1min对应秒数 AST#property_declaration#Left static readonly MINUTE_IN_HOUR : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 60 AST#expression#Right ; AST#property_declaration#Right // 1h对应分钟数 AST#property_declaration#Left static readonly SECOND_IN_HOUR : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 3600 AST#expression#Right ; AST#property_declaration#Right // 1h对应秒数 AST#property_declaration#Left static readonly MAX_DANMAKU_LINES : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 5 AST#expression#Right ; AST#property_declaration#Right // 滚动弹幕最大显示行数 AST#property_declaration#Left static readonly DANMAKU_STYLE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 3 AST#expression#Right ; AST#property_declaration#Right // 滚动弹幕最大显示行数 AST#property_declaration#Left static readonly DANMAKU_SCROLL_SPEED : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 1.2 AST#expression#Right ; AST#property_declaration#Right // 弹幕滚动速率 AST#property_declaration#Left static readonly DANMAKU_SCALE_TEXT_SIZE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 1.2 AST#expression#Right ; AST#property_declaration#Right // 缩放字体大小 AST#property_declaration#Left static readonly DANMAKU_MARGIN : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 40 AST#expression#Right ; AST#property_declaration#Right // 弹幕显示外边距 } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class Constants { static readonly HUNDRED_PERCENT: number = 100; static readonly MAX_BRIGHTNESS: number = 255; static readonly DEFAULT_BRIGHTNESS: number = 10; static readonly DANMU_RESIZE_TIME: number = 300; static readonly COUNT_DOWN_TIME: number = 3; static readonly MS_IN_SECOND: number = 1000; static readonly SECOND_IN_MINUTE: number = 60; static readonly MINUTE_IN_HOUR: number = 60; static readonly SECOND_IN_HOUR: number = 3600; static readonly MAX_DANMAKU_LINES: number = 5; static readonly DANMAKU_STYLE: number = 3; static readonly DANMAKU_SCROLL_SPEED: number = 1.2; static readonly DANMAKU_SCALE_TEXT_SIZE: number = 1.2; static readonly DANMAKU_MARGIN: number = 40; }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/danmakuplayer/src/main/ets/common/Constants.ets#L16-L31
59596071cd1a7a69e88d987d48ef94c4bd616757
gitee
bigbear20240612/planner_build-.git
89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1
entry/src/main/ets/viewmodel/TaskViewModel.ets
arkts
addListener
添加任务变更监听器
addListener(listener: TaskChangeListener) { this.listeners.push(listener); }
AST#method_declaration#Left addListener AST#parameter_list#Left ( AST#parameter#Left listener : AST#type_annotation#Left AST#primary_type#Left TaskChangeListener AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . listeners AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left listener AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
addListener(listener: TaskChangeListener) { this.listeners.push(listener); }
https://github.com/bigbear20240612/planner_build-.git/blob/89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1/entry/src/main/ets/viewmodel/TaskViewModel.ets#L32-L34
93d9f24162a36922e8338e93b6234e7a8f75ae2d
github
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_axios/src/main/ets/axios/EfClientApi.ets
arkts
appendBaseURL
拼接url @param baseurl @returns
private static appendBaseURL(baseurl?: string): string { let url: string = ''; if (baseurl) { url = baseurl; } return url; }
AST#method_declaration#Left private static appendBaseURL AST#parameter_list#Left ( AST#parameter#Left baseurl ? : 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 url : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '' AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left baseurl AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left url = AST#expression#Left baseurl 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 url AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private static appendBaseURL(baseurl?: string): string { let url: string = ''; if (baseurl) { url = baseurl; } return url; }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_axios/src/main/ets/axios/EfClientApi.ets#L63-L69
3efe5d6baabd48369a3d33923d329b7051fe40ab
gitee
harmonyos/samples
f5d967efaa7666550ee3252d118c3c73a77686f5
HarmonyOS_NEXT/Notification/CustomNotificationBadge/notification/src/main/ets/notification/NotificationContentUtil.ets
arkts
initNotificationPictureContent
init picture notification content @param basicContent @param notificationBriefText @param notificationExpandedTitle @param notificationPicture @return return the created NotificationContent
initNotificationPictureContent(basicContent: notification.NotificationBasicContent, notificationBriefText: string, notificationExpandedTitle: string, notificationPicture: image.PixelMap) { let result: NotificationContentUtilResultType = { contentType: notification.ContentType.NOTIFICATION_CONTENT_PICTURE, // 通知内容类型 picture: { title: basicContent.title, // 通知标题 text: basicContent.text, // 通知内容 additionalText: basicContent.additionalText ? basicContent.additionalText : '', // 通知次要内容,是对通知内容的补充 briefText: notificationBriefText, // 通知概要内容,是对通知内容的总结 expandedTitle: notificationExpandedTitle, // 通知展开时的标题 picture: notificationPicture // 通知的图片 } }; return result; }
AST#method_declaration#Left initNotificationPictureContent AST#parameter_list#Left ( AST#parameter#Left basicContent : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left notification . NotificationBasicContent AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left notificationBriefText : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left notificationExpandedTitle : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left notificationPicture : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left image . PixelMap AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left result : AST#type_annotation#Left AST#primary_type#Left NotificationContentUtilResultType AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left contentType AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left notification AST#expression#Right . ContentType AST#member_expression#Right AST#expression#Right . NOTIFICATION_CONTENT_PICTURE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , // 通知内容类型 AST#property_assignment#Left AST#property_name#Left picture AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left title AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left basicContent AST#expression#Right . title AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , // 通知标题 AST#property_assignment#Left AST#property_name#Left text AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left basicContent AST#expression#Right . text AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , // 通知内容 AST#property_assignment#Left AST#property_name#Left additionalText AST#property_name#Right : AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left basicContent AST#expression#Right . additionalText AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left basicContent AST#expression#Right . additionalText AST#member_expression#Right AST#expression#Right : AST#expression#Left '' AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#property_assignment#Right , // 通知次要内容,是对通知内容的补充 AST#property_assignment#Left AST#property_name#Left briefText AST#property_name#Right : AST#expression#Left notificationBriefText AST#expression#Right AST#property_assignment#Right , // 通知概要内容,是对通知内容的总结 AST#property_assignment#Left AST#property_name#Left expandedTitle AST#property_name#Right : AST#expression#Left notificationExpandedTitle AST#expression#Right AST#property_assignment#Right , // 通知展开时的标题 AST#property_assignment#Left AST#property_name#Left picture AST#property_name#Right : AST#expression#Left notificationPicture AST#expression#Right AST#property_assignment#Right // 通知的图片 } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#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
initNotificationPictureContent(basicContent: notification.NotificationBasicContent, notificationBriefText: string, notificationExpandedTitle: string, notificationPicture: image.PixelMap) { let result: NotificationContentUtilResultType = { contentType: notification.ContentType.NOTIFICATION_CONTENT_PICTURE, picture: { title: basicContent.title, text: basicContent.text, additionalText: basicContent.additionalText ? basicContent.additionalText : '', briefText: notificationBriefText, expandedTitle: notificationExpandedTitle, picture: notificationPicture } }; return result; }
https://github.com/harmonyos/samples/blob/f5d967efaa7666550ee3252d118c3c73a77686f5/HarmonyOS_NEXT/Notification/CustomNotificationBadge/notification/src/main/ets/notification/NotificationContentUtil.ets#L96-L109
41a92caeeeaeb7574ec47fdd14c243adbc894ba5
gitee
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_core/src/main/ets/core/util/RegUtil.ets
arkts
isMatch
给定内容是否匹配正则 @param regex 正则 @param content 内容
static isMatch(pattern: string, content: string): OutDTO<string> { if (content == null || content == '') { // 提供 null 的字符串为不匹配 return OutDTO.Error("验证字符串不能为空"); } if (new RegExp(pattern).test(content)) { return OutDTO.OK("验证字符串格式正确") } else { return OutDTO.Error("验证字符串格式不正确,请检查") } }
AST#method_declaration#Left static isMatch AST#parameter_list#Left ( AST#parameter#Left pattern : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#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 AST#generic_type#Left OutDTO AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left content AST#expression#Right == AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left AST#binary_expression#Left AST#expression#Left content AST#expression#Right == AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { // 提供 null 的字符串为不匹配 AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left OutDTO AST#expression#Right . Error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "验证字符串不能为空" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left RegExp AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left pattern AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . test AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left content AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left OutDTO AST#expression#Right . OK 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#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left OutDTO AST#expression#Right . Error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "验证字符串格式不正确,请检查" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#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
static isMatch(pattern: string, content: string): OutDTO<string> { if (content == null || content == '') { return OutDTO.Error("验证字符串不能为空"); } if (new RegExp(pattern).test(content)) { return OutDTO.OK("验证字符串格式正确") } else { return OutDTO.Error("验证字符串格式不正确,请检查") } }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_core/src/main/ets/core/util/RegUtil.ets#L33-L43
d970645afdd8735a3ff933e9eb80cf7402c756aa
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_dialog/src/main/ets/utils/DateHelper.ets
arkts
isSameHour
是否是同一时
static isSameHour(selectDate: Date, date: Date): boolean { return DateHelper.isSameDay(selectDate, date) && selectDate.getHours() == date.getHours(); }
AST#method_declaration#Left static isSameHour AST#parameter_list#Left ( AST#parameter#Left selectDate : AST#type_annotation#Left AST#primary_type#Left Date AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left date : AST#type_annotation#Left AST#primary_type#Left Date AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DateHelper AST#expression#Right . isSameDay AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left selectDate AST#expression#Right , AST#expression#Left date AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right && AST#expression#Left selectDate AST#expression#Right AST#binary_expression#Right AST#expression#Right . getHours AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right == AST#expression#Left date AST#expression#Right AST#binary_expression#Right AST#expression#Right . getHours AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static isSameHour(selectDate: Date, date: Date): boolean { return DateHelper.isSameDay(selectDate, date) && selectDate.getHours() == date.getHours(); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_dialog/src/main/ets/utils/DateHelper.ets#L137-L139
821b642f52bbd5515a0aa5e390b532b33d442929
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/WindowUtil.ets
arkts
TODO 窗口工具 author: 桃花镇童长老ᥫ᭡ since: 2024/05/01
export class WindowUtil { /** * 设置窗口的显示方向属性,使用Promise异步回调。 * Orientation 窗口显示方向类型枚举: * UNSPECIFIED 0 表示未定义方向模式,由系统判定。 * PORTRAIT 1 表示竖屏显示模式。 * LANDSCAPE 2 表示横屏显示模式。 * PORTRAIT_INVERTED 3 表示反向竖屏显示模式。 * LANDSCAPE_INVERTED 4 表示反向横屏显示模式。 * AUTO_ROTATION 5 表示传感器自动旋转模式。 * AUTO_ROTATION_PORTRAIT 6 表示传感器自动竖向旋转模式。 * AUTO_ROTATION_LANDSCAPE 7 表示传感器自动横向旋转模式。 * AUTO_ROTATION_RESTRICTED 8 表示受开关控制的自动旋转模式。 * AUTO_ROTATION_PORTRAIT_RESTRICTED 9 表示受开关控制的自动竖向旋转模式。 * AUTO_ROTATION_LANDSCAPE_RESTRICTED 10 表示受开关控制的自动横向旋转模式。 * LOCKED 11 表示锁定模式。 * @param windowClass 不传该值,默认主窗口。 */ static async setPreferredOrientation(orientation: window.Orientation, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.setPreferredOrientation(orientation); } /** * 获取窗口的显示方向属性,主窗口调用。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static getPreferredOrientation(windowClass: window.Window = AppUtil.getMainWindow()): window.Orientation { return windowClass.getPreferredOrientation(); } /** * 设置窗口是否为隐私模式。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。 * @param isPrivacyMode 窗口是否为隐私模式。true表示模式开启;false表示模式关闭。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static async setWindowPrivacyMode(isPrivacyMode: boolean, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.setWindowPrivacyMode(isPrivacyMode); } /** * 窗口是否隐私模式,默认为false。true表示模式开启;false表示模式关闭。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static isPrivacyMode(windowClass: window.Window = AppUtil.getMainWindow()): boolean { return WindowUtil.getWindowProperties(windowClass).isPrivacyMode; } /** * 设置窗口的布局是否为沉浸式布局(该沉浸式布局状态栏、导航栏仍然显示)。 * @param isLayoutFullScreen true表示沉浸式布局;false表示非沉浸式布局。 * @param windowClass 不传该值,默认主窗口。 */ static async setWindowLayoutFullScreen(isLayoutFullScreen: boolean, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.setWindowLayoutFullScreen(isLayoutFullScreen); } /** * 判断窗口是否为沉浸式,默认为false。true表示沉浸式;false表示非沉浸式。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static isLayoutFullScreen(windowClass: window.Window = AppUtil.getMainWindow()): boolean { return WindowUtil.getWindowProperties(windowClass).isLayoutFullScreen; } /** * 设置主窗口三键导航栏、状态栏的属性,使用Promise异步回调。 * @param systemBarProperties 状态栏、导航栏的属性: * statusBarColor 状态栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如#00FF00或#FF00FF00。默认值:#0x66000000。 * statusBarContentColor 状态栏文字颜色。当设置此属性后, isStatusBarLightIcon属性设置无效。默认值:#0xE5FFFFFF。 * isStatusBarLightIcon 状态栏图标是否为高亮状态。true表示高亮;false表示不高亮。默认值:false。 * navigationBarColor 导航栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如#00FF00或#FF00FF00。默认值:#0x66000000。 * navigationBarContentColor 导航栏文字颜色。当设置此属性后, isNavigationBarLightIcon属性设置无效。默认值:#0xE5FFFFFF。 * isNavigationBarLightIcon 导航栏图标是否为高亮状态。true表示高亮;false表示不高亮。默认值:false。 * enableStatusBarAnimation 是否使能状态栏属性变化时动画效果。true表示变化时使能动画效果;false表示没有使能动画效果。默认值:false。 * enableNavigationBarAnimation 是否使能导航栏属性变化时动画效果。true表示变化时使能动画效果;false表示没有使能动画效果。默认值:false。 * @param windowClass 不传该值,默认主窗口。 */ static async setWindowSystemBarProperties(systemBarProperties: window.SystemBarProperties, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.setWindowSystemBarProperties(systemBarProperties); } /** * 获取主窗口三键导航栏、状态栏的属性。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static getWindowSystemBarProperties(windowClass: window.Window = AppUtil.getMainWindow()): window.SystemBarProperties { return windowClass.getWindowSystemBarProperties(); } /** * 设置当前窗口是否开启沉浸式布局,该调用不会改变窗口模式和窗口大小。 * @param enabled 是否开启沉浸式布局。true表示开启,false表示关闭。 * @param windowClass 不传该值,默认主窗口。 */ static setImmersiveModeEnabledState(enabled: boolean, windowClass: window.Window = AppUtil.getMainWindow()) { windowClass.setImmersiveModeEnabledState(enabled); } /** * 查询当前窗口是否已经开启沉浸式布局。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static getImmersiveModeEnabledState(windowClass: window.Window = AppUtil.getMainWindow()): boolean { return windowClass.getImmersiveModeEnabledState(); } /** * 设置窗口灰阶,使用Promise异步回调。该接口需要在调用loadContent()或setUIContent()使窗口加载页面内容后调用。 * @param grayScale 窗口灰阶。该参数为浮点数,取值范围为[0.0, 1.0]。0.0表示窗口图像无变化,1.0表示窗口图像完全转为灰度图像,0.0至1.0之间时效果呈线性变化。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static async setWindowGrayScale(grayScale: number, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.setWindowGrayScale(grayScale); } /** * 设置窗口的背景色。Stage模型下,该接口需要在loadContent()或setUIContent()调用生效后使用。 * @param color 需要设置的背景色,为十六进制RGB或ARGB颜色,不区分大小写,例如#00FF00或#FF00FF00。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static setWindowBackgroundColor(color: string | ColorMetrics, windowClass: window.Window = AppUtil.getMainWindow()) { try { windowClass.setWindowBackgroundColor(color); } catch (err) { LogUtil.error(err); } } /** * 设置主窗口三键导航栏、状态栏、底部导航条的可见模式,状态栏与底部导航条通过status控制、三键导航栏通过navigation控制,使用Promise异步回调。 * @param names 设置窗口全屏模式时状态栏、三键导航栏和底部导航条是否显示。例如,需全部显示,该参数设置为['status', 'navigation'];不设置,则默认不显示。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static async setWindowSystemBarEnable(names: Array<'status' | 'navigation'>, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.setWindowSystemBarEnable(names); } /** * 设置主窗口三键导航栏、状态栏、底部导航条的显示和隐藏,使用Promise异步回调。 * @param name 设置窗口全屏模式时,显示或隐藏的系统栏类型。 * @param enable 设置窗口全屏模式时,显示或隐藏的系统栏类型。 * @param enableAnimation 设置状态栏、三键导航栏或底部导航条显示状态变化时是否使用动画,true表示使用, false表示不使用,默认值为false。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static async setSpecificSystemBarEnabled(name: window.SpecificSystemBar, enable: boolean, enableAnimation: boolean = false, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.setSpecificSystemBarEnabled(name, enable, enableAnimation); } /** * 设置屏幕是否为常亮状态,使用Promise异步回调。 * @param isKeepScreenOn true表示常亮;false表示不常亮。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static async setWindowKeepScreenOn(isKeepScreenOn: boolean, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.setWindowKeepScreenOn(isKeepScreenOn); } /** * 屏幕是否常亮,默认为false。true表示常亮;false表示不常亮。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static isKeepScreenOn(windowClass: window.Window = AppUtil.getMainWindow()): boolean { return WindowUtil.getWindowProperties(windowClass).isKeepScreenOn; } /** * 设置屏幕亮度值,使用Promise异步回调。 * @param brightness 屏幕亮度值。该参数为浮点数,取值范围为[0.0, 1.0]或-1.0。1.0表示最亮,-1.0表示默认亮度。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static async setWindowBrightness(brightness: number, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.setWindowBrightness(brightness); } /** * 获取屏幕亮度。该参数为浮点数,可设置的亮度范围为[0.0, 1.0],其取1.0时表示最大亮度值。如果窗口没有设置亮度值,表示亮度跟随系统,此时获取到的亮度值为-1。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static getBrightness(windowClass: window.Window = AppUtil.getMainWindow()): number { return WindowUtil.getWindowProperties(windowClass).brightness; } /** * 设置使用点击或其他方式使该窗口获焦的场景时,该窗口是否支持窗口焦点从点击前的获焦窗口切换到该窗口,使用Promise异步回调。 * @param isFocusable 点击时是否支持切换焦点窗口。true表示支持;false表示不支持。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static async setWindowFocusable(isFocusable: boolean, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.setWindowFocusable(isFocusable); } /** * 窗口是否可聚焦,默认为true。true表示可聚焦;false表示不可聚焦。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static isFocusable(windowClass: window.Window = AppUtil.getMainWindow()): boolean { return WindowUtil.getWindowProperties(windowClass).focusable; } /** * 设置窗口是否为可触状态,使用Promise异步回调。 * @param isTouchable 窗口是否为可触状态。true表示可触;false表示不可触。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static async setWindowTouchable(isTouchable: boolean, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.setWindowTouchable(isTouchable); } /** * 窗口是否可触摸,默认为true。true表示可触摸;false表示不可触摸。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static isTouchable(windowClass: window.Window = AppUtil.getMainWindow()): boolean { return WindowUtil.getWindowProperties(windowClass).touchable; } /** * 获取当前窗口的属性 * @param windowClass 不传该值,获取主窗口的属性 * @returns */ static getWindowProperties(windowClass: window.Window = AppUtil.getMainWindow()): window.WindowProperties { return windowClass.getWindowProperties(); } /** * 获取当前应用窗口内容规避的区域。如系统栏区域、刘海屏区域、手势区域、软键盘区域等与窗口内容重叠时,需要窗口内容避让的区域。 * @param type 表示规避区类型。 * @returns */ static getWindowAvoidArea(type: window.AvoidAreaType, windowClass: window.Window = AppUtil.getMainWindow()): window.AvoidArea { return windowClass.getWindowAvoidArea(type); } /** * 获取窗口类型。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static getWindowType(windowClass: window.Window = AppUtil.getMainWindow()): window.WindowType { return WindowUtil.getWindowProperties(windowClass).type; } /** * 获取当前应用窗口的模式。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static getWindowStatus(windowClass: window.Window = AppUtil.getMainWindow()): window.WindowStatusType { return windowClass.getWindowStatus(); } /** * 判断窗口是否全屏,默认为false。true表示全屏;false表示非全屏。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static isFullScreen(windowClass: window.Window = AppUtil.getMainWindow()): boolean { return WindowUtil.getWindowProperties(windowClass).isFullScreen; } /** * 判断当前窗口是否已获焦。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static isFocused(windowClass: window.Window = AppUtil.getMainWindow()): boolean { return windowClass.isFocused(); } /** * 窗口是否透明。默认为false。true表示透明;false表示不透明。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static isTransparent(windowClass: window.Window = AppUtil.getMainWindow()): boolean { return WindowUtil.getWindowProperties(windowClass).isTransparent; } /** * 判断当前窗口是否已显示。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static isWindowShowing(windowClass: window.Window = AppUtil.getMainWindow()): boolean { return windowClass.isWindowShowing(); } /** * 判断当前窗口是否支持广色域模式,使用Promise异步回调。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static async isWindowSupportWideGamut(windowClass: window.Window = AppUtil.getMainWindow()): Promise<boolean> { return windowClass.isWindowSupportWideGamut(); } /** * 设置模态窗口是否响应手势返回事件,非模态窗口调用返回错误码。 * @param enabled 是否响应手势返回事件。true表示响应手势返回事件,触发onBackPress回调;false表示不响应手势返回事件,不触发onBackPress回调。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static async setDialogBackGestureEnabled(enabled: boolean, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.setDialogBackGestureEnabled(enabled); } /** * 设置当前窗口是否禁用返回手势功能,仅主窗全屏模式下生效,2in1设备下不生效。<API13+> * @param enabled true时开启返回手势功能,false时禁用返回手势功能。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static async setGestureBackEnabled(enabled: boolean, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { if (AppUtil.isApiSupported(13)) { return windowClass.setGestureBackEnabled(enabled); } } /** * 获取当前窗口是否禁用返回手势功能,仅主窗全屏模式下生效,2in1设备不生效。<API13+> * @param windowClass 不传该值,默认主窗口。 * @returns 是否已经禁用返回手势。true表示未禁用返回手势功能,false表示已禁用返回手势功能。 */ static isGestureBackEnabled(windowClass: window.Window = AppUtil.getMainWindow()): boolean { if (AppUtil.isApiSupported(13)) { return windowClass.isGestureBackEnabled(); } return false; } /** * 移动窗口位置,使用Promise异步回调。调用成功即返回,但返回后无法立即获取最终生效结果。如需立即获取,请使用moveWindowToAsync()。 * @param x 窗口在x轴方向移动到的坐标位置,单位为px,值为正表示位置在x轴右侧;值为负表示位置在x轴左侧;值为0表示位置在x轴坐标原点。该参数仅支持整数输入,浮点数输入将向下取整。 * @param y 窗口在y轴方向移动到的坐标位置,单位为px,值为正表示位置在y轴下侧;值为负表示位置在y轴上侧;值为0表示位置在y轴坐标原点。该参数仅支持整数输入,浮点数输入将向下取整。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static async moveWindowTo(x: number, y: number, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.moveWindowTo(x, y); } /** * 移动窗口位置,使用Promise异步回调。调用生效后返回,回调中可使用getWindowProperties()(见示例)立即获取最终生效结果。 * @param x 窗口在x轴方向移动到的坐标位置,单位为px,值为正表示位置在x轴右侧;值为负表示位置在x轴左侧;值为0表示位置在x轴坐标原点。该参数仅支持整数输入,浮点数输入将向下取整。 * @param y 窗口在y轴方向移动到的坐标位置,单位为px,值为正表示位置在y轴下侧;值为负表示位置在y轴上侧;值为0表示位置在y轴坐标原点。该参数仅支持整数输入,浮点数输入将向下取整。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static async moveWindowToAsync(x: number, y: number, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.moveWindowToAsync(x, y); } /** * 改变当前窗口大小,使用Promise异步回调。调用成功即返回,该接口返回后无法立即获取最终生效结果,如需立即获取,建议使用接口resizeAsync()。 * @param width 目标窗口的宽度,单位为px,该参数仅支持整数输入,浮点数输入将向下取整,负值为非法参数。 * @param height 目标窗口的高度,单位为px,该参数仅支持整数输入,浮点数输入将向下取整,负值为非法参数。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static async resize(width: number, height: number, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.resize(width, height); } /** * 改变当前窗口大小,使用Promise异步回调。调用生效后返回,回调中可使用getWindowProperties()(见示例)立即获取最终生效结果。 * @param width 目标窗口的宽度,单位为px,该参数仅支持整数输入,浮点数输入将向下取整,负值为非法参数。 * @param height 目标窗口的高度,单位为px,该参数仅支持整数输入,浮点数输入将向下取整,负值为非法参数。 * @param windowClass 不传该值,默认主窗口。 * @returns */ static async resizeAsync(width: number, height: number, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.resizeAsync(width, height); } /** * 创建子窗口 * @param options 窗口参数 * @param windowStage WindowStage * @returns */ static async createSubWindow(options: WindowOptions, windowStage: window.WindowStage = AppUtil.getWindowStage()): Promise<window.Window> { let windowClass = await windowStage.createSubWindow(options.name); await windowClass.resize(options.width, options.height); await windowClass.moveWindowTo(options.x ?? 0, options.y ?? 0); await windowClass.setUIContent(options.path); WindowUtil.setWindowBackgroundColor(options.backgroundColor ?? '#00000000', windowClass); return windowClass; } /** * 销毁窗口 * @param name 窗口名字,即Configuration中的name。 * @returns */ static async destroyWindow(name: string): Promise<boolean> { const subWindow = WindowUtil.findWindow(name); if (subWindow) { await subWindow.destroyWindow(); return true; } return false; } /** * 创建子窗口或者系统窗口,使用Promise异步回调。 * @param config 创建窗口时的参数。 * 需要权限: 当创建窗口类型为window.WindowType.TYPE_FLOAT时,需要ohos.permission.SYSTEM_FLOAT_WINDOW权限 * @returns */ static async createWindow(config: window.Configuration): Promise<window.Window> { return window.createWindow(config); } /** * 查找name所对应的窗口。 * @param name 窗口名字,即Configuration中的name。 * @returns */ static findWindow(name: string): window.Window | undefined { try { return window.findWindow(name); } catch (e) { const err = e as BusinessError; LogUtil.error(`findWindow - code:${err.code},message:${err.message}`); } return undefined; } /** * 获取当前应用内最上层的子窗口,若无应用子窗口,则返回应用主窗口,使用Promise异步回调。 * @param ctx 当前应用上下文信息。 * @returns */ static async getLastWindow(ctx: common.BaseContext = AppUtil.getContext()): Promise<window.Window> { return window.getLastWindow(ctx); } /** * 在同应用内将窗口焦点从源窗口转移到目标窗口,仅支持应用主窗和子窗的焦点转移。 * @param sourceWindowId 源窗口id,必须是获焦状态。 * @param targetWindowId 目标窗口id。 * @returns */ static async shiftAppWindowFocus(sourceWindowId: number, targetWindowId: number): Promise<void> { return window.shiftAppWindowFocus(sourceWindowId, targetWindowId); } }
AST#export_declaration#Left export AST#class_declaration#Left class WindowUtil AST#class_body#Left { /** * 设置窗口的显示方向属性,使用Promise异步回调。 * Orientation 窗口显示方向类型枚举: * UNSPECIFIED 0 表示未定义方向模式,由系统判定。 * PORTRAIT 1 表示竖屏显示模式。 * LANDSCAPE 2 表示横屏显示模式。 * PORTRAIT_INVERTED 3 表示反向竖屏显示模式。 * LANDSCAPE_INVERTED 4 表示反向横屏显示模式。 * AUTO_ROTATION 5 表示传感器自动旋转模式。 * AUTO_ROTATION_PORTRAIT 6 表示传感器自动竖向旋转模式。 * AUTO_ROTATION_LANDSCAPE 7 表示传感器自动横向旋转模式。 * AUTO_ROTATION_RESTRICTED 8 表示受开关控制的自动旋转模式。 * AUTO_ROTATION_PORTRAIT_RESTRICTED 9 表示受开关控制的自动竖向旋转模式。 * AUTO_ROTATION_LANDSCAPE_RESTRICTED 10 表示受开关控制的自动横向旋转模式。 * LOCKED 11 表示锁定模式。 * @param windowClass 不传该值,默认主窗口。 */ AST#method_declaration#Left static async setPreferredOrientation AST#parameter_list#Left ( AST#parameter#Left orientation : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Orientation AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . setPreferredOrientation AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left orientation 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 windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static getPreferredOrientation AST#parameter_list#Left ( AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Orientation AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . getPreferredOrientation 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 /** * 设置窗口是否为隐私模式。设置为隐私模式的窗口,窗口内容将无法被截屏或录屏。 * @param isPrivacyMode 窗口是否为隐私模式。true表示模式开启;false表示模式关闭。 * @param windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static async setWindowPrivacyMode AST#parameter_list#Left ( AST#parameter#Left isPrivacyMode : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . setWindowPrivacyMode AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left isPrivacyMode AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 窗口是否隐私模式,默认为false。true表示模式开启;false表示模式关闭。 * @param windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static isPrivacyMode AST#parameter_list#Left ( AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left WindowUtil AST#expression#Right . getWindowProperties AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left windowClass AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . isPrivacyMode AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 设置窗口的布局是否为沉浸式布局(该沉浸式布局状态栏、导航栏仍然显示)。 * @param isLayoutFullScreen true表示沉浸式布局;false表示非沉浸式布局。 * @param windowClass 不传该值,默认主窗口。 */ AST#method_declaration#Left static async setWindowLayoutFullScreen AST#parameter_list#Left ( AST#parameter#Left isLayoutFullScreen : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . setWindowLayoutFullScreen AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left isLayoutFullScreen 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 /** * 判断窗口是否为沉浸式,默认为false。true表示沉浸式;false表示非沉浸式。 * @param windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static isLayoutFullScreen AST#parameter_list#Left ( AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left WindowUtil AST#expression#Right . getWindowProperties AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left windowClass AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . isLayoutFullScreen AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 设置主窗口三键导航栏、状态栏的属性,使用Promise异步回调。 * @param systemBarProperties 状态栏、导航栏的属性: * statusBarColor 状态栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如#00FF00或#FF00FF00。默认值:#0x66000000。 * statusBarContentColor 状态栏文字颜色。当设置此属性后, isStatusBarLightIcon属性设置无效。默认值:#0xE5FFFFFF。 * isStatusBarLightIcon 状态栏图标是否为高亮状态。true表示高亮;false表示不高亮。默认值:false。 * navigationBarColor 导航栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如#00FF00或#FF00FF00。默认值:#0x66000000。 * navigationBarContentColor 导航栏文字颜色。当设置此属性后, isNavigationBarLightIcon属性设置无效。默认值:#0xE5FFFFFF。 * isNavigationBarLightIcon 导航栏图标是否为高亮状态。true表示高亮;false表示不高亮。默认值:false。 * enableStatusBarAnimation 是否使能状态栏属性变化时动画效果。true表示变化时使能动画效果;false表示没有使能动画效果。默认值:false。 * enableNavigationBarAnimation 是否使能导航栏属性变化时动画效果。true表示变化时使能动画效果;false表示没有使能动画效果。默认值:false。 * @param windowClass 不传该值,默认主窗口。 */ AST#method_declaration#Left static async setWindowSystemBarProperties AST#parameter_list#Left ( AST#parameter#Left systemBarProperties : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . SystemBarProperties AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . setWindowSystemBarProperties AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left systemBarProperties 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 windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static getWindowSystemBarProperties AST#parameter_list#Left ( AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . SystemBarProperties AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . getWindowSystemBarProperties 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 /** * 设置当前窗口是否开启沉浸式布局,该调用不会改变窗口模式和窗口大小。 * @param enabled 是否开启沉浸式布局。true表示开启,false表示关闭。 * @param windowClass 不传该值,默认主窗口。 */ AST#method_declaration#Left static setImmersiveModeEnabledState AST#parameter_list#Left ( AST#parameter#Left enabled : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right AST#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 windowClass AST#expression#Right . setImmersiveModeEnabledState AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left enabled 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 /** * 查询当前窗口是否已经开启沉浸式布局。 * @param windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static getImmersiveModeEnabledState AST#parameter_list#Left ( AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . getImmersiveModeEnabledState 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 /** * 设置窗口灰阶,使用Promise异步回调。该接口需要在调用loadContent()或setUIContent()使窗口加载页面内容后调用。 * @param grayScale 窗口灰阶。该参数为浮点数,取值范围为[0.0, 1.0]。0.0表示窗口图像无变化,1.0表示窗口图像完全转为灰度图像,0.0至1.0之间时效果呈线性变化。 * @param windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static async setWindowGrayScale AST#parameter_list#Left ( AST#parameter#Left grayScale : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . setWindowGrayScale AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left grayScale 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 /** * 设置窗口的背景色。Stage模型下,该接口需要在loadContent()或setUIContent()调用生效后使用。 * @param color 需要设置的背景色,为十六进制RGB或ARGB颜色,不区分大小写,例如#00FF00或#FF00FF00。 * @param windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static setWindowBackgroundColor AST#parameter_list#Left ( AST#parameter#Left color : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left ColorMetrics AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right AST#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 windowClass AST#expression#Right . setWindowBackgroundColor 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#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 LogUtil AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 设置主窗口三键导航栏、状态栏、底部导航条的可见模式,状态栏与底部导航条通过status控制、三键导航栏通过navigation控制,使用Promise异步回调。 * @param names 设置窗口全屏模式时状态栏、三键导航栏和底部导航条是否显示。例如,需全部显示,该参数设置为['status', 'navigation'];不设置,则默认不显示。 * @param windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static async setWindowSystemBarEnable AST#parameter_list#Left ( AST#parameter#Left names : AST#type_annotation#Left AST#primary_type#Left Array AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right AST#ERROR#Left < 'status' | 'navigation' > AST#ERROR#Right , AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . setWindowSystemBarEnable AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left names 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 /** * 设置主窗口三键导航栏、状态栏、底部导航条的显示和隐藏,使用Promise异步回调。 * @param name 设置窗口全屏模式时,显示或隐藏的系统栏类型。 * @param enable 设置窗口全屏模式时,显示或隐藏的系统栏类型。 * @param enableAnimation 设置状态栏、三键导航栏或底部导航条显示状态变化时是否使用动画,true表示使用, false表示不使用,默认值为false。 * @param windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static async setSpecificSystemBarEnabled AST#parameter_list#Left ( AST#parameter#Left name : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . SpecificSystemBar AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left enable : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left enableAnimation : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#parameter#Right , AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . setSpecificSystemBarEnabled AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left name AST#expression#Right , AST#expression#Left enable AST#expression#Right , AST#expression#Left enableAnimation 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 /** * 设置屏幕是否为常亮状态,使用Promise异步回调。 * @param isKeepScreenOn true表示常亮;false表示不常亮。 * @param windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static async setWindowKeepScreenOn AST#parameter_list#Left ( AST#parameter#Left isKeepScreenOn : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . setWindowKeepScreenOn AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left isKeepScreenOn 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 /** * 屏幕是否常亮,默认为false。true表示常亮;false表示不常亮。 * @param windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static isKeepScreenOn AST#parameter_list#Left ( AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left WindowUtil AST#expression#Right . getWindowProperties AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left windowClass AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . isKeepScreenOn AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 设置屏幕亮度值,使用Promise异步回调。 * @param brightness 屏幕亮度值。该参数为浮点数,取值范围为[0.0, 1.0]或-1.0。1.0表示最亮,-1.0表示默认亮度。 * @param windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static async setWindowBrightness AST#parameter_list#Left ( AST#parameter#Left brightness : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . setWindowBrightness AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left brightness 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 /** * 获取屏幕亮度。该参数为浮点数,可设置的亮度范围为[0.0, 1.0],其取1.0时表示最大亮度值。如果窗口没有设置亮度值,表示亮度跟随系统,此时获取到的亮度值为-1。 * @param windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static getBrightness AST#parameter_list#Left ( AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left WindowUtil AST#expression#Right . getWindowProperties AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left windowClass AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . brightness AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 设置使用点击或其他方式使该窗口获焦的场景时,该窗口是否支持窗口焦点从点击前的获焦窗口切换到该窗口,使用Promise异步回调。 * @param isFocusable 点击时是否支持切换焦点窗口。true表示支持;false表示不支持。 * @param windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static async setWindowFocusable AST#parameter_list#Left ( AST#parameter#Left isFocusable : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . setWindowFocusable AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left isFocusable 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 /** * 窗口是否可聚焦,默认为true。true表示可聚焦;false表示不可聚焦。 * @param windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static isFocusable AST#parameter_list#Left ( AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left WindowUtil AST#expression#Right . getWindowProperties AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left windowClass AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . focusable AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 设置窗口是否为可触状态,使用Promise异步回调。 * @param isTouchable 窗口是否为可触状态。true表示可触;false表示不可触。 * @param windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static async setWindowTouchable AST#parameter_list#Left ( AST#parameter#Left isTouchable : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . setWindowTouchable AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left isTouchable 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 /** * 窗口是否可触摸,默认为true。true表示可触摸;false表示不可触摸。 * @param windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static isTouchable AST#parameter_list#Left ( AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left WindowUtil AST#expression#Right . getWindowProperties AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left windowClass AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . touchable AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 获取当前窗口的属性 * @param windowClass 不传该值,获取主窗口的属性 * @returns */ AST#method_declaration#Left static getWindowProperties AST#parameter_list#Left ( AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . WindowProperties AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . getWindowProperties AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 获取当前应用窗口内容规避的区域。如系统栏区域、刘海屏区域、手势区域、软键盘区域等与窗口内容重叠时,需要窗口内容避让的区域。 * @param type 表示规避区类型。 * @returns */ AST#method_declaration#Left static getWindowAvoidArea AST#parameter_list#Left ( AST#parameter#Left type : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . AvoidAreaType AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . AvoidArea AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . getWindowAvoidArea AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left type AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 获取窗口类型。 * @param windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static getWindowType AST#parameter_list#Left ( AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . WindowType AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left WindowUtil AST#expression#Right . getWindowProperties AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left windowClass AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . type AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 获取当前应用窗口的模式。 * @param windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static getWindowStatus AST#parameter_list#Left ( AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . WindowStatusType AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . getWindowStatus 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 /** * 判断窗口是否全屏,默认为false。true表示全屏;false表示非全屏。 * @param windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static isFullScreen AST#parameter_list#Left ( AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left WindowUtil AST#expression#Right . getWindowProperties AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left windowClass AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . isFullScreen AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 判断当前窗口是否已获焦。 * @param windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static isFocused AST#parameter_list#Left ( AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . isFocused AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 窗口是否透明。默认为false。true表示透明;false表示不透明。 * @param windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static isTransparent AST#parameter_list#Left ( AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left WindowUtil AST#expression#Right . getWindowProperties AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left windowClass AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . isTransparent AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 判断当前窗口是否已显示。 * @param windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static isWindowShowing AST#parameter_list#Left ( AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . isWindowShowing 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 /** * 判断当前窗口是否支持广色域模式,使用Promise异步回调。 * @param windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static async isWindowSupportWideGamut AST#parameter_list#Left ( AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . isWindowSupportWideGamut 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 /** * 设置模态窗口是否响应手势返回事件,非模态窗口调用返回错误码。 * @param enabled 是否响应手势返回事件。true表示响应手势返回事件,触发onBackPress回调;false表示不响应手势返回事件,不触发onBackPress回调。 * @param windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static async setDialogBackGestureEnabled AST#parameter_list#Left ( AST#parameter#Left enabled : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . setDialogBackGestureEnabled AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left enabled 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 /** * 设置当前窗口是否禁用返回手势功能,仅主窗全屏模式下生效,2in1设备下不生效。<API13+> * @param enabled true时开启返回手势功能,false时禁用返回手势功能。 * @param windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static async setGestureBackEnabled AST#parameter_list#Left ( AST#parameter#Left enabled : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . isApiSupported AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 13 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . setGestureBackEnabled AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left enabled AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 获取当前窗口是否禁用返回手势功能,仅主窗全屏模式下生效,2in1设备不生效。<API13+> * @param windowClass 不传该值,默认主窗口。 * @returns 是否已经禁用返回手势。true表示未禁用返回手势功能,false表示已禁用返回手势功能。 */ AST#method_declaration#Left static isGestureBackEnabled AST#parameter_list#Left ( AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . isApiSupported AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 13 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . isGestureBackEnabled 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#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 移动窗口位置,使用Promise异步回调。调用成功即返回,但返回后无法立即获取最终生效结果。如需立即获取,请使用moveWindowToAsync()。 * @param x 窗口在x轴方向移动到的坐标位置,单位为px,值为正表示位置在x轴右侧;值为负表示位置在x轴左侧;值为0表示位置在x轴坐标原点。该参数仅支持整数输入,浮点数输入将向下取整。 * @param y 窗口在y轴方向移动到的坐标位置,单位为px,值为正表示位置在y轴下侧;值为负表示位置在y轴上侧;值为0表示位置在y轴坐标原点。该参数仅支持整数输入,浮点数输入将向下取整。 * @param windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static async moveWindowTo AST#parameter_list#Left ( AST#parameter#Left x : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left y : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . moveWindowTo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left x AST#expression#Right , AST#expression#Left y AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 移动窗口位置,使用Promise异步回调。调用生效后返回,回调中可使用getWindowProperties()(见示例)立即获取最终生效结果。 * @param x 窗口在x轴方向移动到的坐标位置,单位为px,值为正表示位置在x轴右侧;值为负表示位置在x轴左侧;值为0表示位置在x轴坐标原点。该参数仅支持整数输入,浮点数输入将向下取整。 * @param y 窗口在y轴方向移动到的坐标位置,单位为px,值为正表示位置在y轴下侧;值为负表示位置在y轴上侧;值为0表示位置在y轴坐标原点。该参数仅支持整数输入,浮点数输入将向下取整。 * @param windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static async moveWindowToAsync AST#parameter_list#Left ( AST#parameter#Left x : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left y : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . moveWindowToAsync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left x AST#expression#Right , AST#expression#Left y AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 改变当前窗口大小,使用Promise异步回调。调用成功即返回,该接口返回后无法立即获取最终生效结果,如需立即获取,建议使用接口resizeAsync()。 * @param width 目标窗口的宽度,单位为px,该参数仅支持整数输入,浮点数输入将向下取整,负值为非法参数。 * @param height 目标窗口的高度,单位为px,该参数仅支持整数输入,浮点数输入将向下取整,负值为非法参数。 * @param windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static async resize AST#parameter_list#Left ( AST#parameter#Left width : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left height : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . resize AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left width AST#expression#Right , AST#expression#Left height 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 /** * 改变当前窗口大小,使用Promise异步回调。调用生效后返回,回调中可使用getWindowProperties()(见示例)立即获取最终生效结果。 * @param width 目标窗口的宽度,单位为px,该参数仅支持整数输入,浮点数输入将向下取整,负值为非法参数。 * @param height 目标窗口的高度,单位为px,该参数仅支持整数输入,浮点数输入将向下取整,负值为非法参数。 * @param windowClass 不传该值,默认主窗口。 * @returns */ AST#method_declaration#Left static async resizeAsync AST#parameter_list#Left ( AST#parameter#Left width : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left height : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left windowClass AST#expression#Right . resizeAsync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left width AST#expression#Right , AST#expression#Left height AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 创建子窗口 * @param options 窗口参数 * @param windowStage WindowStage * @returns */ AST#method_declaration#Left static async createSubWindow AST#parameter_list#Left ( AST#parameter#Left options : AST#type_annotation#Left AST#primary_type#Left WindowOptions AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left windowStage : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . WindowStage AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getWindowStage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left windowClass = 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 windowStage AST#expression#Right AST#await_expression#Right AST#expression#Right . createSubWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . name AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left windowClass AST#expression#Right AST#await_expression#Right AST#expression#Right . resize AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . width AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . height 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#await_expression#Left await AST#expression#Left windowClass AST#expression#Right AST#await_expression#Right AST#expression#Right . moveWindowTo 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 options AST#expression#Right . x AST#member_expression#Right AST#expression#Right ?? AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . y AST#member_expression#Right AST#expression#Right ?? AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left windowClass AST#expression#Right AST#await_expression#Right AST#expression#Right . setUIContent AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . path 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 WindowUtil AST#expression#Right . setWindowBackgroundColor 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 options AST#expression#Right . backgroundColor AST#member_expression#Right AST#expression#Right ?? AST#expression#Left '#00000000' AST#expression#Right AST#binary_expression#Right AST#expression#Right , AST#expression#Left windowClass AST#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 windowClass AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 销毁窗口 * @param name 窗口名字,即Configuration中的name。 * @returns */ AST#method_declaration#Left static async destroyWindow AST#parameter_list#Left ( AST#parameter#Left name : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left subWindow = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left WindowUtil AST#expression#Right . findWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left name 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 subWindow 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 subWindow AST#expression#Right AST#await_expression#Right AST#expression#Right . destroyWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 创建子窗口或者系统窗口,使用Promise异步回调。 * @param config 创建窗口时的参数。 * 需要权限: 当创建窗口类型为window.WindowType.TYPE_FLOAT时,需要ohos.permission.SYSTEM_FLOAT_WINDOW权限 * @returns */ AST#method_declaration#Left static async createWindow AST#parameter_list#Left ( AST#parameter#Left config : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Configuration AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . createWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left config 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 /** * 查找name所对应的窗口。 * @param name 窗口名字,即Configuration中的name。 * @returns */ AST#method_declaration#Left static findWindow AST#parameter_list#Left ( AST#parameter#Left name : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . findWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left name 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 ( e ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left err = AST#expression#Left AST#as_expression#Left AST#expression#Left e AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LogUtil AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` findWindow - code: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ,message: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left undefined AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 获取当前应用内最上层的子窗口,若无应用子窗口,则返回应用主窗口,使用Promise异步回调。 * @param ctx 当前应用上下文信息。 * @returns */ AST#method_declaration#Left static async getLastWindow AST#parameter_list#Left ( AST#parameter#Left ctx : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . BaseContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getContext AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . getLastWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left ctx 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 sourceWindowId 源窗口id,必须是获焦状态。 * @param targetWindowId 目标窗口id。 * @returns */ AST#method_declaration#Left static async shiftAppWindowFocus AST#parameter_list#Left ( AST#parameter#Left sourceWindowId : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left targetWindowId : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left window AST#expression#Right . shiftAppWindowFocus AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sourceWindowId AST#expression#Right , AST#expression#Left targetWindowId 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 WindowUtil { static async setPreferredOrientation(orientation: window.Orientation, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.setPreferredOrientation(orientation); } static getPreferredOrientation(windowClass: window.Window = AppUtil.getMainWindow()): window.Orientation { return windowClass.getPreferredOrientation(); } static async setWindowPrivacyMode(isPrivacyMode: boolean, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.setWindowPrivacyMode(isPrivacyMode); } static isPrivacyMode(windowClass: window.Window = AppUtil.getMainWindow()): boolean { return WindowUtil.getWindowProperties(windowClass).isPrivacyMode; } static async setWindowLayoutFullScreen(isLayoutFullScreen: boolean, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.setWindowLayoutFullScreen(isLayoutFullScreen); } static isLayoutFullScreen(windowClass: window.Window = AppUtil.getMainWindow()): boolean { return WindowUtil.getWindowProperties(windowClass).isLayoutFullScreen; } static async setWindowSystemBarProperties(systemBarProperties: window.SystemBarProperties, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.setWindowSystemBarProperties(systemBarProperties); } static getWindowSystemBarProperties(windowClass: window.Window = AppUtil.getMainWindow()): window.SystemBarProperties { return windowClass.getWindowSystemBarProperties(); } static setImmersiveModeEnabledState(enabled: boolean, windowClass: window.Window = AppUtil.getMainWindow()) { windowClass.setImmersiveModeEnabledState(enabled); } static getImmersiveModeEnabledState(windowClass: window.Window = AppUtil.getMainWindow()): boolean { return windowClass.getImmersiveModeEnabledState(); } static async setWindowGrayScale(grayScale: number, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.setWindowGrayScale(grayScale); } static setWindowBackgroundColor(color: string | ColorMetrics, windowClass: window.Window = AppUtil.getMainWindow()) { try { windowClass.setWindowBackgroundColor(color); } catch (err) { LogUtil.error(err); } } static async setWindowSystemBarEnable(names: Array<'status' | 'navigation'>, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.setWindowSystemBarEnable(names); } static async setSpecificSystemBarEnabled(name: window.SpecificSystemBar, enable: boolean, enableAnimation: boolean = false, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.setSpecificSystemBarEnabled(name, enable, enableAnimation); } static async setWindowKeepScreenOn(isKeepScreenOn: boolean, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.setWindowKeepScreenOn(isKeepScreenOn); } static isKeepScreenOn(windowClass: window.Window = AppUtil.getMainWindow()): boolean { return WindowUtil.getWindowProperties(windowClass).isKeepScreenOn; } static async setWindowBrightness(brightness: number, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.setWindowBrightness(brightness); } static getBrightness(windowClass: window.Window = AppUtil.getMainWindow()): number { return WindowUtil.getWindowProperties(windowClass).brightness; } static async setWindowFocusable(isFocusable: boolean, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.setWindowFocusable(isFocusable); } static isFocusable(windowClass: window.Window = AppUtil.getMainWindow()): boolean { return WindowUtil.getWindowProperties(windowClass).focusable; } static async setWindowTouchable(isTouchable: boolean, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.setWindowTouchable(isTouchable); } static isTouchable(windowClass: window.Window = AppUtil.getMainWindow()): boolean { return WindowUtil.getWindowProperties(windowClass).touchable; } static getWindowProperties(windowClass: window.Window = AppUtil.getMainWindow()): window.WindowProperties { return windowClass.getWindowProperties(); } static getWindowAvoidArea(type: window.AvoidAreaType, windowClass: window.Window = AppUtil.getMainWindow()): window.AvoidArea { return windowClass.getWindowAvoidArea(type); } static getWindowType(windowClass: window.Window = AppUtil.getMainWindow()): window.WindowType { return WindowUtil.getWindowProperties(windowClass).type; } static getWindowStatus(windowClass: window.Window = AppUtil.getMainWindow()): window.WindowStatusType { return windowClass.getWindowStatus(); } static isFullScreen(windowClass: window.Window = AppUtil.getMainWindow()): boolean { return WindowUtil.getWindowProperties(windowClass).isFullScreen; } static isFocused(windowClass: window.Window = AppUtil.getMainWindow()): boolean { return windowClass.isFocused(); } static isTransparent(windowClass: window.Window = AppUtil.getMainWindow()): boolean { return WindowUtil.getWindowProperties(windowClass).isTransparent; } static isWindowShowing(windowClass: window.Window = AppUtil.getMainWindow()): boolean { return windowClass.isWindowShowing(); } static async isWindowSupportWideGamut(windowClass: window.Window = AppUtil.getMainWindow()): Promise<boolean> { return windowClass.isWindowSupportWideGamut(); } static async setDialogBackGestureEnabled(enabled: boolean, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.setDialogBackGestureEnabled(enabled); } static async setGestureBackEnabled(enabled: boolean, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { if (AppUtil.isApiSupported(13)) { return windowClass.setGestureBackEnabled(enabled); } } static isGestureBackEnabled(windowClass: window.Window = AppUtil.getMainWindow()): boolean { if (AppUtil.isApiSupported(13)) { return windowClass.isGestureBackEnabled(); } return false; } static async moveWindowTo(x: number, y: number, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.moveWindowTo(x, y); } static async moveWindowToAsync(x: number, y: number, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.moveWindowToAsync(x, y); } static async resize(width: number, height: number, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.resize(width, height); } static async resizeAsync(width: number, height: number, windowClass: window.Window = AppUtil.getMainWindow()): Promise<void> { return windowClass.resizeAsync(width, height); } static async createSubWindow(options: WindowOptions, windowStage: window.WindowStage = AppUtil.getWindowStage()): Promise<window.Window> { let windowClass = await windowStage.createSubWindow(options.name); await windowClass.resize(options.width, options.height); await windowClass.moveWindowTo(options.x ?? 0, options.y ?? 0); await windowClass.setUIContent(options.path); WindowUtil.setWindowBackgroundColor(options.backgroundColor ?? '#00000000', windowClass); return windowClass; } static async destroyWindow(name: string): Promise<boolean> { const subWindow = WindowUtil.findWindow(name); if (subWindow) { await subWindow.destroyWindow(); return true; } return false; } static async createWindow(config: window.Configuration): Promise<window.Window> { return window.createWindow(config); } static findWindow(name: string): window.Window | undefined { try { return window.findWindow(name); } catch (e) { const err = e as BusinessError; LogUtil.error(`findWindow - code:${err.code},message:${err.message}`); } return undefined; } static async getLastWindow(ctx: common.BaseContext = AppUtil.getContext()): Promise<window.Window> { return window.getLastWindow(ctx); } static async shiftAppWindowFocus(sourceWindowId: number, targetWindowId: number): Promise<void> { return window.shiftAppWindowFocus(sourceWindowId, targetWindowId); } }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/WindowUtil.ets#L28-L547
25075db42537a56170f608c31c238b30e77d438d
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/common/types/ContactTypes.ets
arkts
扩展联系人信息接口
export interface ExtendedContactInfo { interests?: string[]; // 兴趣爱好 dislikes?: string[]; // 讨厌的事 favoriteFoods?: string[]; // 想吃的美食 taboos?: string[]; // 禁忌的事 occupation?: string; // 职业 company?: string; // 公司 department?: string; // 部门 position?: string; // 职位 address?: string; // 地址 socialMedia?: Map<string, string>; // 社交媒体账号 customAttributes?: CustomAttribute[]; // 自定义属性 }
AST#export_declaration#Left export AST#interface_declaration#Left interface ExtendedContactInfo AST#object_type#Left { AST#type_member#Left interests ? : 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_member#Right ; // 兴趣爱好 AST#type_member#Left dislikes ? : 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_member#Right ; // 讨厌的事 AST#type_member#Left favoriteFoods ? : 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_member#Right ; // 想吃的美食 AST#type_member#Left taboos ? : 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_member#Right ; // 禁忌的事 AST#type_member#Left occupation ? : 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 company ? : 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 department ? : 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 position ? : 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 address ? : 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 socialMedia ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Map AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left 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_member#Right ; // 社交媒体账号 AST#type_member#Left customAttributes ? : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left CustomAttribute [ ] AST#array_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 ExtendedContactInfo { interests?: string[]; dislikes?: string[]; favoriteFoods?: string[]; taboos?: string[]; occupation?: string; company?: string; department?: string; position?: string; address?: string; socialMedia?: Map<string, string>; customAttributes?: CustomAttribute[]; }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/types/ContactTypes.ets#L140-L152
9a01d29d7cafba34a32b0a57374c245fe19e5ea8
github
Neptune-EX/OS_System_Design.git
c728a82d48079ae0c52d50c4a2e2586b69f4ce55
entry/src/main/ets/view/PublicFilesTab.ets
arkts
loadFileListWithInfo
加载文件列表(包含详细信息)
async loadFileListWithInfo() { console.log('加载文件列表(带详细信息)...'); if (this.fileManager) { try { const files = await this.fileManager.getAllFilesWithInfo(); console.log('获取到的文件数量:', files.length); this.fileList = files; if (files.length > 0) { console.log('示例文件信息:', { filename: files[0].filename, size: files[0].sizeReadable, ctime: files[0].ctimeFormatted }); } } catch (error) { console.error('加载文件列表失败:', error); this.fileList = []; } } }
AST#method_declaration#Left async loadFileListWithInfo AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '加载文件列表(带详细信息)...' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . fileManager AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left files = 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 . fileManager AST#member_expression#Right AST#expression#Right . getAllFilesWithInfo 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 console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '获取到的文件数量:' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left files AST#expression#Right . length AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . fileList AST#member_expression#Right = AST#expression#Left files AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left files AST#expression#Right . length AST#member_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '示例文件信息:' AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left filename AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left files AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . filename AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left size AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left files AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . sizeReadable AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left ctime AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left files AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . ctimeFormatted AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '加载文件列表失败:' AST#expression#Right , AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . fileList 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#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 } AST#block_statement#Right AST#method_declaration#Right
async loadFileListWithInfo() { console.log('加载文件列表(带详细信息)...'); if (this.fileManager) { try { const files = await this.fileManager.getAllFilesWithInfo(); console.log('获取到的文件数量:', files.length); this.fileList = files; if (files.length > 0) { console.log('示例文件信息:', { filename: files[0].filename, size: files[0].sizeReadable, ctime: files[0].ctimeFormatted }); } } catch (error) { console.error('加载文件列表失败:', error); this.fileList = []; } } }
https://github.com/Neptune-EX/OS_System_Design.git/blob/c728a82d48079ae0c52d50c4a2e2586b69f4ce55/entry/src/main/ets/view/PublicFilesTab.ets#L211-L232
8f83246e3ab9d990c6f0001e5b355e4d5ee24dfa
github
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
Ability/StageAbilityDemo/entry/src/main/ets/common/constants/Constants.ets
arkts
The percentage of 100.
export const PERCENTAGE_100 = '100%';
AST#export_declaration#Left export AST#variable_declaration#Left const AST#variable_declarator#Left PERCENTAGE_100 = AST#expression#Left '100%' AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#export_declaration#Right
export const PERCENTAGE_100 = '100%';
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Ability/StageAbilityDemo/entry/src/main/ets/common/constants/Constants.ets#L40-L40
a764f9dd910c0bf29792d136212d4b8085daf5f2
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/KeyboardUtil.ets
arkts
onKeyboardListener
订阅输入法软键盘显示或隐藏事件 @param callBack: show boolen,true-键盘显示、false-键盘隐藏; height 键盘高度。
static onKeyboardListener(callback: KeyboardCallBack): void { if (ArrayUtil.contain(KeyboardUtil.callBacks, callback)) { LogUtil.error(`KeyboardUtil-onKeyboardListener: 监听事件已存在!`); } else { KeyboardUtil.callBacks.push(callback); } if (KeyboardUtil.keyboardCallBack === undefined) { KeyboardUtil.keyboardCallBack = (height: number) => { //全局的键盘监听回调 KeyboardUtil.callBacks.forEach((callback) => callback?.(height > 0, height)); } AppUtil.getMainWindow().on("keyboardHeightChange", KeyboardUtil.keyboardCallBack); } }
AST#method_declaration#Left static onKeyboardListener AST#parameter_list#Left ( AST#parameter#Left callback : AST#type_annotation#Left AST#primary_type#Left KeyboardCallBack 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ArrayUtil AST#expression#Right . contain AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left KeyboardUtil AST#expression#Right . callBacks AST#member_expression#Right AST#expression#Right , AST#expression#Left callback AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LogUtil AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` KeyboardUtil-onKeyboardListener: 监听事件已存在! ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } else { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left KeyboardUtil AST#expression#Right . callBacks AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left callback 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 KeyboardUtil AST#expression#Right . keyboardCallBack AST#member_expression#Right AST#expression#Right === AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left KeyboardUtil AST#expression#Right . keyboardCallBack AST#member_expression#Right = AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left height : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { //全局的键盘监听回调 AST#statement#Left AST#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 KeyboardUtil AST#expression#Right . callBacks AST#member_expression#Right AST#expression#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left callback AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left callback AST#expression#Right ?. AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left height AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right , AST#expression#Left height 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#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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . on AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "keyboardHeightChange" AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left KeyboardUtil AST#expression#Right . keyboardCallBack 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#builder_function_body#Right AST#method_declaration#Right
static onKeyboardListener(callback: KeyboardCallBack): void { if (ArrayUtil.contain(KeyboardUtil.callBacks, callback)) { LogUtil.error(`KeyboardUtil-onKeyboardListener: 监听事件已存在!`); } else { KeyboardUtil.callBacks.push(callback); } if (KeyboardUtil.keyboardCallBack === undefined) { KeyboardUtil.keyboardCallBack = (height: number) => { KeyboardUtil.callBacks.forEach((callback) => callback?.(height > 0, height)); } AppUtil.getMainWindow().on("keyboardHeightChange", KeyboardUtil.keyboardCallBack); } }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/KeyboardUtil.ets#L56-L68
bcd9bd66705e470503b73a54662fe47ba5688eee
gitee
bigbear20240612/planner_build-.git
89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1
entry/src/main/ets/viewmodel/TaskViewModel.ets
arkts
addTask
添加新任务
async addTask(taskData: TaskData): Promise<TaskItem> { const now = new Date(); // 初始化状态历史记录 const statusHistory: TaskStatusHistory[] = [{ status: taskData.status, timestamp: now, note: '任务创建' }]; // 初始化时间记录 const timeRecord: TaskTimeRecord = { totalTimeSpent: 0, focusTime: 0, breakTime: 0, pomodoroCount: 0 }; const newTask: TaskItem = { id: this.generateId(), title: taskData.title, description: taskData.description, priority: taskData.priority, status: taskData.status, completed: taskData.completed, completedAt: taskData.completedAt, dueDate: taskData.dueDate, scheduledDate: taskData.scheduledDate, estimatedPomodoros: taskData.estimatedPomodoros, actualPomodoros: taskData.actualPomodoros, tags: taskData.tags, category: taskData.category, // 新增时间记录字段 timeRecord: timeRecord, statusHistory: statusHistory, createdAt: now, updatedAt: now }; this.tasks.unshift(newTask); await this.saveTasks(); this.notifyListeners(); // 记录离线操作 await this.offlineManager.recordOfflineOperation('create', 'task', newTask.id); // 设置任务到期提醒 if (newTask.dueDate) { this.notificationManager.sendTaskDueReminder(newTask).catch((error: Error) => { hilog.error(0x0000, 'TaskViewModel', 'Failed to set task reminder: %{public}s', error.message); }); } return newTask; }
AST#method_declaration#Left async addTask AST#parameter_list#Left ( AST#parameter#Left taskData : AST#type_annotation#Left AST#primary_type#Left TaskData 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 TaskItem 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 now = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 初始化状态历史记录 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left statusHistory : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left TaskStatusHistory [ ] 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 status AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left taskData AST#expression#Right . status AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left timestamp AST#property_name#Right : AST#expression#Left now AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left note AST#property_name#Right : AST#expression#Left '任务创建' AST#expression#Right AST#property_assignment#Right } AST#object_literal#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#variable_declaration#Left const AST#variable_declarator#Left timeRecord : AST#type_annotation#Left AST#primary_type#Left TaskTimeRecord AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left totalTimeSpent AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left focusTime AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left breakTime AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left pomodoroCount AST#property_name#Right : AST#expression#Left 0 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 newTask : AST#type_annotation#Left AST#primary_type#Left TaskItem 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . generateId 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 title AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left taskData AST#expression#Right . title AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left description AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left taskData AST#expression#Right . description AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left priority AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left taskData AST#expression#Right . priority AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left status AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left taskData AST#expression#Right . status AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left completed AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left taskData AST#expression#Right . completed AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left completedAt AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left taskData AST#expression#Right . completedAt AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left dueDate AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left taskData AST#expression#Right . dueDate AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left scheduledDate AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left taskData AST#expression#Right . scheduledDate AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left estimatedPomodoros AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left taskData AST#expression#Right . estimatedPomodoros AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left actualPomodoros AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left taskData AST#expression#Right . actualPomodoros AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left tags AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left taskData AST#expression#Right . tags AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left category AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left taskData AST#expression#Right . category AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , // 新增时间记录字段 AST#property_assignment#Left AST#property_name#Left timeRecord AST#property_name#Right : AST#expression#Left timeRecord AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left statusHistory AST#property_name#Right : AST#expression#Left statusHistory AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left createdAt AST#property_name#Right : AST#expression#Left now AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left updatedAt AST#property_name#Right : AST#expression#Left now 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 . tasks AST#member_expression#Right AST#expression#Right . unshift AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left newTask AST#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 . saveTasks 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 this AST#expression#Right . notifyListeners AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 记录离线操作 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . offlineManager AST#member_expression#Right AST#expression#Right . recordOfflineOperation AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'create' AST#expression#Right , AST#expression#Left 'task' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left newTask AST#expression#Right . id AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 设置任务到期提醒 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left newTask AST#expression#Right . dueDate 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . notificationManager AST#member_expression#Right AST#expression#Right . sendTaskDueReminder AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left newTask 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 hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left 'TaskViewModel' AST#expression#Right , AST#expression#Left 'Failed to set task reminder: %{public}s' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . message AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left newTask AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async addTask(taskData: TaskData): Promise<TaskItem> { const now = new Date(); const statusHistory: TaskStatusHistory[] = [{ status: taskData.status, timestamp: now, note: '任务创建' }]; const timeRecord: TaskTimeRecord = { totalTimeSpent: 0, focusTime: 0, breakTime: 0, pomodoroCount: 0 }; const newTask: TaskItem = { id: this.generateId(), title: taskData.title, description: taskData.description, priority: taskData.priority, status: taskData.status, completed: taskData.completed, completedAt: taskData.completedAt, dueDate: taskData.dueDate, scheduledDate: taskData.scheduledDate, estimatedPomodoros: taskData.estimatedPomodoros, actualPomodoros: taskData.actualPomodoros, tags: taskData.tags, category: taskData.category, timeRecord: timeRecord, statusHistory: statusHistory, createdAt: now, updatedAt: now }; this.tasks.unshift(newTask); await this.saveTasks(); this.notifyListeners(); await this.offlineManager.recordOfflineOperation('create', 'task', newTask.id); if (newTask.dueDate) { this.notificationManager.sendTaskDueReminder(newTask).catch((error: Error) => { hilog.error(0x0000, 'TaskViewModel', 'Failed to set task reminder: %{public}s', error.message); }); } return newTask; }
https://github.com/bigbear20240612/planner_build-.git/blob/89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1/entry/src/main/ets/viewmodel/TaskViewModel.ets#L95-L149
4481fc5f3900bb04f8e37f567c3eb94d8aabbe42
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
harmonyos/src/main/ets/components/common/LoadingView.ets
arkts
ListLoadingMore
列表加载更多组件
@Component export struct ListLoadingMore { @Prop loading: boolean = false; @Prop hasMore: boolean = true; @Prop loadingText: string = '加载更多...'; @Prop noMoreText: string = '没有更多数据'; build() { Row({ space: 12 }) { if (this.loading && this.hasMore) { LoadingProgress() .width(16) .height(16) .color('#007AFF') Text(this.loadingText) .fontSize(14) .fontColor('#666666') } else if (!this.hasMore) { Text(this.noMoreText) .fontSize(14) .fontColor('#999999') } } .width('100%') .height(48) .justifyContent(FlexAlign.Center) .alignItems(VerticalAlign.Center) } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct ListLoadingMore AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right loading : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right hasMore : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right loadingText : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '加载更多...' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right noMoreText : 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#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 12 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . loading AST#member_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . hasMore AST#member_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left LoadingProgress ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . color ( AST#expression#Left '#007AFF' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . loadingText 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 . fontColor ( AST#expression#Left '#666666' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } else AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . hasMore AST#member_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . noMoreText 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 . fontColor ( AST#expression#Left '#999999' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_if_statement#Right AST#ui_if_statement#Right AST#ui_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 48 AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left VerticalAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#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 ListLoadingMore { @Prop loading: boolean = false; @Prop hasMore: boolean = true; @Prop loadingText: string = '加载更多...'; @Prop noMoreText: string = '没有更多数据'; build() { Row({ space: 12 }) { if (this.loading && this.hasMore) { LoadingProgress() .width(16) .height(16) .color('#007AFF') Text(this.loadingText) .fontSize(14) .fontColor('#666666') } else if (!this.hasMore) { Text(this.noMoreText) .fontSize(14) .fontColor('#999999') } } .width('100%') .height(48) .justifyContent(FlexAlign.Center) .alignItems(VerticalAlign.Center) } }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/harmonyos/src/main/ets/components/common/LoadingView.ets#L60-L89
7df6228b8cd27963380267277247eb0fefc4bfb8
github
Piagari/arkts_example.git
a63b868eaa2a50dc480d487b84c4650cc6a40fc8
hmos_app-main/hmos_app-main/legado-Harmony-master/entry/src/main/ets/view/CustomDialogComponent.ets
arkts
CustomDialogComponent
Custom pop-up window.
@CustomDialog export default struct CustomDialogComponent { controller: CustomDialogController = new CustomDialogController({'builder': ''}); cancel: Function = () => {}; confirm: Function = () => {}; build() { Column() { Text($r('app.string.dialog_text_title')) .width(CommonConstants.DIALOG_COMPONENT_WIDTH_PERCENT) .fontColor($r('app.color.dialog_text_color')) .fontSize($r('app.float.dialog_text_privacy_size')) .textAlign(TextAlign.Center) .fontWeight(CommonConstants.DIALOG_TITLE_FONT_WEIGHT) .margin({ top: $r('app.float.dialog_text_privacy_top'), bottom: $r('app.float.dialog_text_privacy_bottom') }) Text($r('app.string.dialog_text_privacy_content')) .fontSize($r('app.float.dialog_common_text_size')) .width(CommonConstants.DIALOG_COMPONENT_WIDTH_PERCENT) Text($r('app.string.dialog_text_privacy_statement')) .width(CommonConstants.DIALOG_COMPONENT_WIDTH_PERCENT) .fontColor($r('app.color.dialog_text_statement_color')) .fontSize($r('app.float.dialog_common_text_size')) .onClick(() => { // globalThis.isJumpPrivacy = true; GlobalContext.getContext().setObject('isJumpPrivacy', true); router.pushUrl({ url: CommonConstants.PRIVACY_PAGE_URL }).catch((error: Error) => { Logger.error(CommonConstants.CUSTOM_DIALOG_TAG, 'CustomDialog pushUrl error ' + JSON.stringify(error)); }); }) Text($r('app.string.dialog_text_declaration_prompt')) .width(CommonConstants.DIALOG_COMPONENT_WIDTH_PERCENT) .fontColor($r('app.color.dialog_text_color')) .fontSize($r('app.float.dialog_common_text_size')) .opacity($r('app.float.dialog_text_opacity')) .margin({ bottom: $r('app.float.dialog_text_declaration_bottom') }) Row() { Text($r('app.string.dialog_button_disagree')) .fancy() .onClick(() => { this.controller.close(); this.cancel(); }) Blank() .backgroundColor($r('app.color.dialog_blank_background_color')) .width($r('app.float.dialog_blank_width')) .height($r('app.float.dialog_blank_height')) Text($r('app.string.dialog_button_agree')) .fancy() .onClick(() => { this.controller.close(); this.confirm(); }) } .margin({ bottom: CommonConstants.DIALOG_ROW_MARGIN_BOTTOM }) } .width(CommonConstants.DIALOG_WIDTH_PERCENT) .borderRadius(CommonConstants.DIALOG_BORDER_RADIUS) .backgroundColor(Color.White) } }
AST#decorated_export_declaration#Left AST#decorator#Left @ CustomDialog AST#decorator#Right export default struct CustomDialogComponent AST#component_body#Left { AST#property_declaration#Left controller : AST#type_annotation#Left AST#primary_type#Left CustomDialogController 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 CustomDialogController AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left 'builder' AST#property_name#Right : AST#expression#Left '' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left cancel : AST#type_annotation#Left AST#primary_type#Left Function AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#expression#Left AST#object_literal#Left { } AST#object_literal#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left confirm : AST#type_annotation#Left AST#primary_type#Left Function AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#expression#Left AST#object_literal#Left { } AST#object_literal#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ; AST#property_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.dialog_text_title' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . DIALOG_COMPONENT_WIDTH_PERCENT 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.dialog_text_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.dialog_text_privacy_size' 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 . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . DIALOG_TITLE_FONT_WEIGHT AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.dialog_text_privacy_top' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.dialog_text_privacy_bottom' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.dialog_text_privacy_content' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.dialog_common_text_size' 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 CommonConstants AST#expression#Right . DIALOG_COMPONENT_WIDTH_PERCENT AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.dialog_text_privacy_statement' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . DIALOG_COMPONENT_WIDTH_PERCENT 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.dialog_text_statement_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.dialog_common_text_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { // globalThis.isJumpPrivacy = true; 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 GlobalContext AST#expression#Right . getContext AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . setObject AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'isJumpPrivacy' 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#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 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 AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . PRIVACY_PAGE_URL 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 . 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 . CUSTOM_DIALOG_TAG 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 'CustomDialog pushUrl error ' AST#expression#Right + AST#expression#Left JSON AST#expression#Right AST#binary_expression#Right AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.dialog_text_declaration_prompt' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . DIALOG_COMPONENT_WIDTH_PERCENT 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.dialog_text_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.dialog_common_text_size' 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.dialog_text_opacity' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.dialog_text_declaration_bottom' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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#resource_expression#Left $r ( AST#expression#Left 'app.string.dialog_button_disagree' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fancy ( ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . controller AST#member_expression#Right AST#expression#Right . close AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cancel AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Blank ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.dialog_blank_background_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.dialog_blank_width' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.float.dialog_blank_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.dialog_button_agree' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fancy ( ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . controller AST#member_expression#Right AST#expression#Right . close AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . confirm AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . DIALOG_ROW_MARGIN_BOTTOM AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . DIALOG_WIDTH_PERCENT AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . DIALOG_BORDER_RADIUS AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . White AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#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
@CustomDialog export default struct CustomDialogComponent { controller: CustomDialogController = new CustomDialogController({'builder': ''}); cancel: Function = () => {}; confirm: Function = () => {}; build() { Column() { Text($r('app.string.dialog_text_title')) .width(CommonConstants.DIALOG_COMPONENT_WIDTH_PERCENT) .fontColor($r('app.color.dialog_text_color')) .fontSize($r('app.float.dialog_text_privacy_size')) .textAlign(TextAlign.Center) .fontWeight(CommonConstants.DIALOG_TITLE_FONT_WEIGHT) .margin({ top: $r('app.float.dialog_text_privacy_top'), bottom: $r('app.float.dialog_text_privacy_bottom') }) Text($r('app.string.dialog_text_privacy_content')) .fontSize($r('app.float.dialog_common_text_size')) .width(CommonConstants.DIALOG_COMPONENT_WIDTH_PERCENT) Text($r('app.string.dialog_text_privacy_statement')) .width(CommonConstants.DIALOG_COMPONENT_WIDTH_PERCENT) .fontColor($r('app.color.dialog_text_statement_color')) .fontSize($r('app.float.dialog_common_text_size')) .onClick(() => { GlobalContext.getContext().setObject('isJumpPrivacy', true); router.pushUrl({ url: CommonConstants.PRIVACY_PAGE_URL }).catch((error: Error) => { Logger.error(CommonConstants.CUSTOM_DIALOG_TAG, 'CustomDialog pushUrl error ' + JSON.stringify(error)); }); }) Text($r('app.string.dialog_text_declaration_prompt')) .width(CommonConstants.DIALOG_COMPONENT_WIDTH_PERCENT) .fontColor($r('app.color.dialog_text_color')) .fontSize($r('app.float.dialog_common_text_size')) .opacity($r('app.float.dialog_text_opacity')) .margin({ bottom: $r('app.float.dialog_text_declaration_bottom') }) Row() { Text($r('app.string.dialog_button_disagree')) .fancy() .onClick(() => { this.controller.close(); this.cancel(); }) Blank() .backgroundColor($r('app.color.dialog_blank_background_color')) .width($r('app.float.dialog_blank_width')) .height($r('app.float.dialog_blank_height')) Text($r('app.string.dialog_button_agree')) .fancy() .onClick(() => { this.controller.close(); this.confirm(); }) } .margin({ bottom: CommonConstants.DIALOG_ROW_MARGIN_BOTTOM }) } .width(CommonConstants.DIALOG_WIDTH_PERCENT) .borderRadius(CommonConstants.DIALOG_BORDER_RADIUS) .backgroundColor(Color.White) } }
https://github.com/Piagari/arkts_example.git/blob/a63b868eaa2a50dc480d487b84c4650cc6a40fc8/hmos_app-main/hmos_app-main/legado-Harmony-master/entry/src/main/ets/view/CustomDialogComponent.ets#L24-L88
1f944ddb917b29cf4feec47d4052e85f3bba70be
github
vhall/VHLive_SDK_Harmony
29c820e5301e17ae01bc6bdcc393a4437b518e7c
watchKit/src/main/ets/components/player/VHBarrageView.ets
arkts
VHBarrageViews
弹幕
@Preview @Component export struct VHBarrageViews { private barrageController: BarrageController = new BarrageController; @State comHeight: number = 0; @State enable:boolean=true; aboutToAppear(): void { EmitterUtil.subscribe(VHRoomEventType.IM_TEXT, (msgData: EmitterMsgData) => { console.log(`收到文本消息,类型:${VHRoomEventType.IM_TEXT}`); let messageModel: VHIMMessageModel = msgData as VHIMMessageModel; if (messageModel.data!) { // if (typeof messageModel.data === 'string') { // const parsedMessage: VHIMMessageModel = JSON.parse(messageModel.data) as VHIMMessageModel; // this.handleTextMessage(parsedMessage); // } else { // // } this.handleTextMessage(messageModel.data); } }); EmitterUtil.subscribe("1001", (msgData: EmitterMsgData) => { this.enable = msgData.enable!; if(!this.enable ){ this.barrageController.clearInScreen(); } }); } private handleTextMessage(messageModel?: VHIMMessageModel){ if(messageModel && this.enable){ let imMsg:VHMsgData= messageModel.data as VHMsgData; // imMsg.nickname= messageModel.nick_name; // imMsg.data = messageModel.data as VHMsgData; const barrageItem = new BarrageItem(); barrageItem.id = "123"; barrageItem.text = EmojiTool.convertEmojiTags(imMsg.text_content) barrageItem.isSelf = false; barrageItem.speed = 1; barrageItem.textSize = 14; this.barrageController.addBarrage(barrageItem); } } aboutToDisappear(): void { } build() { Column({space:10}) { //用户测可通过this.playerConfig?.marquee 具体进行配置。 // 组件库参考https://gitee.com/wuhan-yihai-cloud-peak/barrage-component-library/tree/master/BarrageMaster BarrageView({ barrageController: this.barrageController, option: { maxLine: 5, trackLine: 5, textAlpha:1, isShowFPS: false }, onCanvasReady: () => { this.barrageController.start(); }, onTouchBarrage: (item: BarrageItem) => { console.log('BarrageMaster', 'click barrage :' + JSON.stringify(item)) } }) .width('100%') .height('100%') .onAreaChange((oldValue: Area, newValue: Area) => { this.comHeight = newValue.height as number; }) } .width('100%') .height('100%') } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Preview AST#decorator#Right AST#decorator#Left @ Component AST#decorator#Right export struct VHBarrageViews AST#component_body#Left { AST#property_declaration#Left private barrageController : AST#type_annotation#Left AST#primary_type#Left BarrageController AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#new_expression#Left new AST#expression#Left BarrageController AST#expression#Right AST#new_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right comHeight : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right enable : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#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 EmitterUtil AST#expression#Right . subscribe AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left VHRoomEventType AST#expression#Right . IM_TEXT AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left msgData : AST#type_annotation#Left AST#primary_type#Left EmitterMsgData AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` 收到文本消息,类型: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left VHRoomEventType AST#expression#Right . IM_TEXT 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#variable_declaration#Left let AST#variable_declarator#Left messageModel : AST#type_annotation#Left AST#primary_type#Left VHIMMessageModel AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#as_expression#Left AST#expression#Left msgData AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left VHIMMessageModel 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#non_null_assertion_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left messageModel AST#expression#Right . data AST#member_expression#Right AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right ) AST#block_statement#Left { // if (typeof messageModel.data === 'string') { // const parsedMessage: VHIMMessageModel = JSON.parse(messageModel.data) as VHIMMessageModel; // this.handleTextMessage(parsedMessage); // } else { // // } 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 . handleTextMessage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left messageModel AST#expression#Right . data AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left EmitterUtil AST#expression#Right . subscribe AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "1001" AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left msgData : AST#type_annotation#Left AST#primary_type#Left EmitterMsgData 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 . enable AST#member_expression#Right = AST#expression#Left AST#non_null_assertion_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left msgData AST#expression#Right . enable AST#member_expression#Right AST#expression#Right ! AST#non_null_assertion_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 AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . enable 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 . barrageController AST#member_expression#Right AST#expression#Right . clearInScreen AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left private handleTextMessage AST#parameter_list#Left ( AST#parameter#Left messageModel ? : AST#type_annotation#Left AST#primary_type#Left VHIMMessageModel 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 messageModel AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . enable AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left imMsg : AST#type_annotation#Left AST#primary_type#Left VHMsgData 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 messageModel AST#expression#Right . data AST#member_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left VHMsgData 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 // imMsg.nickname= messageModel.nick_name; // imMsg.data = messageModel.data as VHMsgData; AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left barrageItem = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left BarrageItem 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 barrageItem AST#expression#Right . id AST#member_expression#Right = AST#expression#Left "123" 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 barrageItem AST#expression#Right . text AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left EmojiTool AST#expression#Right . convertEmojiTags AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left imMsg AST#expression#Right . text_content AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left barrageItem AST#expression#Right . isSelf 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left barrageItem AST#expression#Right . speed AST#member_expression#Right = AST#expression#Left 1 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left barrageItem AST#expression#Right . textSize AST#member_expression#Right = AST#expression#Left 14 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . barrageController AST#member_expression#Right AST#expression#Right . addBarrage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left barrageItem AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left aboutToDisappear AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { } AST#builder_function_body#Right AST#method_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 10 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { //用户测可通过this.playerConfig?.marquee 具体进行配置。 // 组件库参考https://gitee.com/wuhan-yihai-cloud-peak/barrage-component-library/tree/master/BarrageMaster AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left BarrageView ( AST#component_parameters#Left { AST#component_parameter#Left barrageController : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . barrageController AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left option : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left maxLine AST#property_name#Right : AST#expression#Left 5 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left trackLine AST#property_name#Right : AST#expression#Left 5 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left textAlpha AST#property_name#Right : AST#expression#Left 1 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left isShowFPS 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#component_parameter#Right , AST#component_parameter#Left onCanvasReady : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . barrageController 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#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left onTouchBarrage : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left BarrageItem 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 'BarrageMaster' 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 'click barrage :' 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 item 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#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . onAreaChange ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left oldValue : AST#type_annotation#Left AST#primary_type#Left Area AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left newValue : AST#type_annotation#Left AST#primary_type#Left Area 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 . comHeight AST#member_expression#Right = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left newValue AST#expression#Right . height 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#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#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#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Preview @Component export struct VHBarrageViews { private barrageController: BarrageController = new BarrageController; @State comHeight: number = 0; @State enable:boolean=true; aboutToAppear(): void { EmitterUtil.subscribe(VHRoomEventType.IM_TEXT, (msgData: EmitterMsgData) => { console.log(`收到文本消息,类型:${VHRoomEventType.IM_TEXT}`); let messageModel: VHIMMessageModel = msgData as VHIMMessageModel; if (messageModel.data!) { } this.handleTextMessage(messageModel.data); } }); EmitterUtil.subscribe("1001", (msgData: EmitterMsgData) => { this.enable = msgData.enable!; if(!this.enable ){ this.barrageController.clearInScreen(); } }); } private handleTextMessage(messageModel?: VHIMMessageModel){ if(messageModel && this.enable){ let imMsg:VHMsgData= messageModel.data as VHMsgData; imMsg.nickname= messageModel.nick_name; imMsg.data = messageModel.data as VHMsgData; const barrageItem = new BarrageItem(); barrageItem.id = "123"; barrageItem.text = EmojiTool.convertEmojiTags(imMsg.text_content) barrageItem.isSelf = false; barrageItem.speed = 1; barrageItem.textSize = 14; this.barrageController.addBarrage(barrageItem); } } aboutToDisappear(): void { } build() { Column({space:10}) { 用户测可通过this.playerConfig?.marquee 具体进行配置。 组件库参考https:gitee.com/wuhan-yihai-cloud-peak/barrage-component-library/tree/master/BarrageMaster BarrageView({ barrageController: this.barrageController, option: { maxLine: 5, trackLine: 5, textAlpha:1, isShowFPS: false }, onCanvasReady: () => { this.barrageController.start(); }, onTouchBarrage: (item: BarrageItem) => { console.log('BarrageMaster', 'click barrage :' + JSON.stringify(item)) } }) .width('100%') .height('100%') .onAreaChange((oldValue: Area, newValue: Area) => { this.comHeight = newValue.height as number; }) } .width('100%') .height('100%') } }
https://github.com/vhall/VHLive_SDK_Harmony/blob/29c820e5301e17ae01bc6bdcc393a4437b518e7c/watchKit/src/main/ets/components/player/VHBarrageView.ets#L7-L84
2a22daea1e13c5f4bb14a7f1ae638f399ebba1f5
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/listslidetohistory/src/main/ets/constants/ListConstants.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 ListConstants { static readonly LAYOUT_WEIGHT: number = 1; // 自动分配剩余空间 static readonly LIST_SPACE: number = 8; // 列表默认间隔 }
AST#export_declaration#Left export AST#class_declaration#Left class ListConstants AST#class_body#Left { AST#property_declaration#Left static readonly LAYOUT_WEIGHT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 1 AST#expression#Right ; AST#property_declaration#Right // 自动分配剩余空间 AST#property_declaration#Left static readonly LIST_SPACE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 8 AST#expression#Right ; AST#property_declaration#Right // 列表默认间隔 } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class ListConstants { static readonly LAYOUT_WEIGHT: number = 1; static readonly LIST_SPACE: number = 8; }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/listslidetohistory/src/main/ets/constants/ListConstants.ets#L16-L19
3998e977f2a03df79014d1c6c0bc9549148a1b61
gitee
openharmony/interface_sdk-js
c349adc73e2ec1f61f6fca489b5af059e3ed6999
api/@ohos.arkui.advanced.SegmentButton.d.ets
arkts
capsule
The function used to create a SegmentButtonOptions of capsule type. @param { CapsuleSegmentButtonConstructionOptions } options - The options of SegmentButton. @returns { SegmentButtonOptions } Returns the a new SegmentButtonOptions object of capsule type. @static @syscap SystemCapability.ArkUI.ArkUI.Full @crossplatform @since 11 The function used to create a SegmentButtonOptions of capsule type. @param { CapsuleSegmentButtonConstructionOptions } options - The options of SegmentButton. @returns { SegmentButtonOptions } Returns the a new SegmentButtonOptions object of capsule type. @static @syscap SystemCapability.ArkUI.ArkUI.Full @crossplatform @atomicservice @since 12
static capsule(options: CapsuleSegmentButtonConstructionOptions): SegmentButtonOptions;
AST#method_declaration#Left static capsule AST#parameter_list#Left ( AST#parameter#Left options : AST#type_annotation#Left AST#primary_type#Left CapsuleSegmentButtonConstructionOptions AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left SegmentButtonOptions AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right
static capsule(options: CapsuleSegmentButtonConstructionOptions): SegmentButtonOptions;
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.arkui.advanced.SegmentButton.d.ets#L1748-L1748
7fa5a6cc5c825ff3e1c0950e3e4298956161c039
gitee
fengmingdev/protobuf-arkts-generator.git
75888d404fd6ce52a046cba2a94807ecf1350147
runtime/arkpb/index.ets
arkts
MessageUtils
消息工具函数 提供批量操作、过滤、分组等实用功能
export { MessageUtils } from './MessageUtils'
AST#export_declaration#Left export { MessageUtils } from './MessageUtils' AST#export_declaration#Right
export { MessageUtils } from './MessageUtils'
https://github.com/fengmingdev/protobuf-arkts-generator.git/blob/75888d404fd6ce52a046cba2a94807ecf1350147/runtime/arkpb/index.ets#L76-L76
71730cce6804f16b0365b2b67de20eab083729f6
github
ThePivotPoint/ArkTS-LSP-Server-Plugin.git
6231773905435f000d00d94b26504433082ba40b
packages/declarations/ets/api/@ohos.arkui.advanced.ChipGroup.d.ets
arkts
ChipGroup
Defines chipGroup. @struct ChipGroup @syscap SystemCapability.ArkUI.ArkUI.Full @crossplatform @atomicservice @since 12
@Component export declare struct ChipGroup { /** * Chip item. * * @type { ChipGroupItemOptions[] } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ @Require @Prop items: ChipGroupItemOptions[]; /** * Chip item style. * * @type { ?ChipItemStyle } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ @Prop itemStyle?: ChipItemStyle; /** * Default selected chip item indexes. * * @type { ?Array<number> } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ @Prop selectedIndexes?: Array<number>; /** * Support multiple chip item selection. * * @type { ?boolean } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ @Prop multiple?: boolean; /** * Chip group space. * * @type { ?ChipGroupSpaceOptions } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ @Prop chipGroupSpace?: ChipGroupSpaceOptions; /** * Chip group padding (only support top and bottom). * * @type { ?ChipGroupPaddingOptions } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ @Prop chipGroupPadding?: ChipGroupPaddingOptions; /** * Chip group callback. when chip status is changed, this onChange is called. * * @type { ?Callback<Array<number>> } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ onChange?: Callback<Array<number>>; /** * The builder function which will be rendered in the suffix of ChipGroup. * * @type { ?Callback<void> } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ @BuilderParam suffix?: Callback<void>; }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export AST#ERROR#Left declare AST#ERROR#Right struct ChipGroup AST#component_body#Left { /** * Chip item. * * @type { ChipGroupItemOptions[] } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ AST#property_declaration#Left AST#decorator#Left @ Require AST#decorator#Right AST#decorator#Left @ Prop AST#decorator#Right items : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left ChipGroupItemOptions [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Chip item style. * * @type { ?ChipItemStyle } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right itemStyle ? : AST#type_annotation#Left AST#primary_type#Left ChipItemStyle AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Default selected chip item indexes. * * @type { ?Array<number> } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right selectedIndexes ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Support multiple chip item selection. * * @type { ?boolean } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right multiple ? : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Chip group space. * * @type { ?ChipGroupSpaceOptions } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right chipGroupSpace ? : AST#type_annotation#Left AST#primary_type#Left ChipGroupSpaceOptions AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Chip group padding (only support top and bottom). * * @type { ?ChipGroupPaddingOptions } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right chipGroupPadding ? : AST#type_annotation#Left AST#primary_type#Left ChipGroupPaddingOptions AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Chip group callback. when chip status is changed, this onChange is called. * * @type { ?Callback<Array<number>> } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ AST#property_declaration#Left onChange ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Callback AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * The builder function which will be rendered in the suffix of ChipGroup. * * @type { ?Callback<void> } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 12 */ AST#property_declaration#Left AST#decorator#Left @ BuilderParam AST#decorator#Right suffix ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Callback AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Component export declare struct ChipGroup { @Require @Prop items: ChipGroupItemOptions[]; @Prop itemStyle?: ChipItemStyle; @Prop selectedIndexes?: Array<number>; @Prop multiple?: boolean; @Prop chipGroupSpace?: ChipGroupSpaceOptions; @Prop chipGroupPadding?: ChipGroupPaddingOptions; onChange?: Callback<Array<number>>; @BuilderParam suffix?: Callback<void>; }
https://github.com/ThePivotPoint/ArkTS-LSP-Server-Plugin.git/blob/6231773905435f000d00d94b26504433082ba40b/packages/declarations/ets/api/@ohos.arkui.advanced.ChipGroup.d.ets#L341-L431
f81d853b4868c865a05c33f5446a0cc810d42d10
github
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
core/model/src/main/ets/request/ReceiveCouponRequest.ets
arkts
@file 领取优惠券请求参数 @author Joker.X
export class ReceiveCouponRequest { /** * 优惠券ID */ couponId: number; /** * @param {ReceiveCouponRequest} init - 初始化数据 */ constructor(init: ReceiveCouponRequest) { this.couponId = init.couponId; } }
AST#export_declaration#Left export AST#class_declaration#Left class ReceiveCouponRequest AST#class_body#Left { /** * 优惠券ID */ AST#property_declaration#Left couponId : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * @param {ReceiveCouponRequest} init - 初始化数据 */ AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left init : AST#type_annotation#Left AST#primary_type#Left ReceiveCouponRequest 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 . couponId AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left init AST#expression#Right . couponId AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class ReceiveCouponRequest { couponId: number; constructor(init: ReceiveCouponRequest) { this.couponId = init.couponId; } }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/model/src/main/ets/request/ReceiveCouponRequest.ets#L5-L17
401e1947eb651c8d34d6d71d1f59f2c12a2108b5
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/bluetooth/src/main/ets/viewmodel/BluetoothClientModel.ets
arkts
getDevice
获取设备信息
private getDevice(deviceId: string, deviceName: string): BluetoothDevice { Log.showInfo(TAG, `getDevice: deviceId = ${deviceId}, deviceName = ${deviceName}`); let device = new BluetoothDevice(); device.deviceId = deviceId; device.deviceName = deviceName; Log.showInfo(TAG, `getDevice: device = ${JSON.stringify(device)}`); return device; }
AST#method_declaration#Left private getDevice AST#parameter_list#Left ( AST#parameter#Left deviceId : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left deviceName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left BluetoothDevice 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 Log AST#expression#Right . showInfo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` getDevice: deviceId = AST#template_substitution#Left $ { AST#expression#Left deviceId AST#expression#Right } AST#template_substitution#Right , deviceName = AST#template_substitution#Left $ { AST#expression#Left deviceName AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left device = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left BluetoothDevice 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 device AST#expression#Right . deviceId AST#member_expression#Right = AST#expression#Left deviceId AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left device AST#expression#Right . deviceName AST#member_expression#Right = AST#expression#Left deviceName AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Log AST#expression#Right . showInfo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` getDevice: device = 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 device 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 device AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private getDevice(deviceId: string, deviceName: string): BluetoothDevice { Log.showInfo(TAG, `getDevice: deviceId = ${deviceId}, deviceName = ${deviceName}`); let device = new BluetoothDevice(); device.deviceId = deviceId; device.deviceName = deviceName; Log.showInfo(TAG, `getDevice: device = ${JSON.stringify(device)}`); return device; }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/bluetooth/src/main/ets/viewmodel/BluetoothClientModel.ets#L471-L478
f0db2318c6c8a41ea8873bbb493af017e1a28787
gitee
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_crypto_dto/src/main/ets/crypto/keyAgree/ECDH.ets
arkts
ecdh
ecdh动态协商密钥,要求密钥长度为256位的非对称密钥 @param pubKey 符合256位的非对称密钥的公钥字符串或Uint8Array字节流 【一般为外部传入】 @param priKey 符合256位的非对称密钥的私钥字符串或Uint8Array字节流 【一般为本项目】 @returns ECC256共享密钥
static async ecdh(pubKey: string | Uint8Array, priKey: string | Uint8Array): Promise<OutDTO<string>> { return DynamicUtil.dynamicKey(pubKey, priKey, 'ECC256', 256); }
AST#method_declaration#Left static async ecdh AST#parameter_list#Left ( AST#parameter#Left pubKey : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left Uint8Array AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left priKey : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left Uint8Array AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left OutDTO AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DynamicUtil AST#expression#Right . dynamicKey AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left pubKey AST#expression#Right , AST#expression#Left priKey AST#expression#Right , AST#expression#Left 'ECC256' AST#expression#Right , AST#expression#Left 256 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 ecdh(pubKey: string | Uint8Array, priKey: string | Uint8Array): Promise<OutDTO<string>> { return DynamicUtil.dynamicKey(pubKey, priKey, 'ECC256', 256); }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto_dto/src/main/ets/crypto/keyAgree/ECDH.ets#L32-L34
13f2d50ed2238aa3c14c2c8102cc5108bb1b42af
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/statusbaranimation/src/main/ets/view/StatusBarAnimation.ets
arkts
topUpBuilder
展开后的蓝色回顶部图标
@Builder topUpBuilder() { Column() { Image($r("app.media.status_bar_animation_top_up")) .width($r('app.integer.status_bar_animation_top_up_width')) .aspectRatio(Constants.ASPECT_RATIO_ONE) Text($r('app.string.status_bar_animation_top_up_text')) .textAlign(TextAlign.Center) .fontSize($r('app.integer.status_bar_animation_top_up_text_font')) .fontColor($r("app.color.status_bar_animation_text_black")) .width($r('app.integer.status_bar_animation_top_up_text_width')) .height($r('app.integer.status_bar_animation_top_up_text_height')) } .onClick(() => { this.isTop = true; // 点击回顶部按钮列表回滚到顶部 setTimeout(()=> { this.scroller.scrollTo({ xOffset: Constants.MAIN_SCROLLER_OFFSET_X, yOffset: Constants.MAIN_SCROLLER_OFFSET_Y, animation: { duration: Constants.ANIMATION_DURATION1, curve: Curve.FastOutLinearIn } }) },Constants.ANIMATION_DURATION) }) .padding({ left: $r('app.integer.status_bar_animation_top_up_padding_left') }) .zIndex(Constants.Z_INDEX_ONE) }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right topUpBuilder AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.media.status_bar_animation_top_up" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.status_bar_animation_top_up_width' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . aspectRatio ( AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . ASPECT_RATIO_ONE AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.status_bar_animation_top_up_text' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.status_bar_animation_top_up_text_font' 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.status_bar_animation_text_black" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.status_bar_animation_top_up_text_width' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.status_bar_animation_top_up_text_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isTop AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 点击回顶部按钮列表回滚到顶部 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left setTimeout AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . scroller AST#member_expression#Right AST#expression#Right . scrollTo 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 xOffset AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . MAIN_SCROLLER_OFFSET_X AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left yOffset AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . MAIN_SCROLLER_OFFSET_Y 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#object_literal#Left { AST#property_assignment#Left AST#property_name#Left duration AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . ANIMATION_DURATION1 AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left curve AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Curve AST#expression#Right . FastOutLinearIn AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . ANIMATION_DURATION AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.status_bar_animation_top_up_padding_left' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . zIndex ( AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . Z_INDEX_ONE 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#builder_function_body#Right AST#method_declaration#Right
@Builder topUpBuilder() { Column() { Image($r("app.media.status_bar_animation_top_up")) .width($r('app.integer.status_bar_animation_top_up_width')) .aspectRatio(Constants.ASPECT_RATIO_ONE) Text($r('app.string.status_bar_animation_top_up_text')) .textAlign(TextAlign.Center) .fontSize($r('app.integer.status_bar_animation_top_up_text_font')) .fontColor($r("app.color.status_bar_animation_text_black")) .width($r('app.integer.status_bar_animation_top_up_text_width')) .height($r('app.integer.status_bar_animation_top_up_text_height')) } .onClick(() => { this.isTop = true; setTimeout(()=> { this.scroller.scrollTo({ xOffset: Constants.MAIN_SCROLLER_OFFSET_X, yOffset: Constants.MAIN_SCROLLER_OFFSET_Y, animation: { duration: Constants.ANIMATION_DURATION1, curve: Curve.FastOutLinearIn } }) },Constants.ANIMATION_DURATION) }) .padding({ left: $r('app.integer.status_bar_animation_top_up_padding_left') }) .zIndex(Constants.Z_INDEX_ONE) }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/statusbaranimation/src/main/ets/view/StatusBarAnimation.ets#L139-L173
d15c74295ad8568c5142491ca8f41dc4f9da2b81
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/StrUtil.ets
arkts
replace
替换字符串中匹配的正则为给定的字符串 @param str 待替换的字符串 @param pattern 要匹配的内容正则或字符串 @param replaceValue 替换的内容 @returns
static replace(str: string, pattern: RegExp | string, replaceValue: string = ''): string { return str.replace(pattern, replaceValue); }
AST#method_declaration#Left static replace 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 pattern : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left RegExp AST#primary_type#Right | AST#primary_type#Left string AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left replaceValue : 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 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 str AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left pattern AST#expression#Right , AST#expression#Left replaceValue 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 replace(str: string, pattern: RegExp | string, replaceValue: string = ''): string { return str.replace(pattern, replaceValue); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/StrUtil.ets#L131-L133
50f9fec1bb405195fe6a32743610f445f57f43d2
gitee
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_crypto/src/main/ets/crypto/keyAgree/X25519.ets
arkts
@Author csx @DateTime 2024/3/20 21:29 @TODO X25519 @Use 详细使用方法以及文档详见ohpm官网,地址https://ohpm.openharmony.cn/#/cn/detail/@yunkss%2Fef_crypto
export class X25519 { /** * X25519动态协商密钥,要求密钥长度为256位的非对称密钥 * @param pubKey 符合非对称密钥的公钥字符串或Uint8Array字节流 【一般为外部传入】 * @param priKey 符合非对称密钥的私钥字符串或Uint8Array字节流 【一般为本项目】 * @returns 256位共享密钥字符串 */ static async x25519(pubKey: string | Uint8Array, priKey: string | Uint8Array): Promise<string> { return DynamicUtil.dynamicKey(pubKey, priKey, 'X25519', 256); } }
AST#export_declaration#Left export AST#class_declaration#Left class X25519 AST#class_body#Left { /** * X25519动态协商密钥,要求密钥长度为256位的非对称密钥 * @param pubKey 符合非对称密钥的公钥字符串或Uint8Array字节流 【一般为外部传入】 * @param priKey 符合非对称密钥的私钥字符串或Uint8Array字节流 【一般为本项目】 * @returns 256位共享密钥字符串 */ AST#method_declaration#Left static async x25519 AST#parameter_list#Left ( AST#parameter#Left pubKey : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left Uint8Array AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left priKey : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left Uint8Array AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DynamicUtil AST#expression#Right . dynamicKey AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left pubKey AST#expression#Right , AST#expression#Left priKey AST#expression#Right , AST#expression#Left 'X25519' AST#expression#Right , AST#expression#Left 256 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 X25519 { static async x25519(pubKey: string | Uint8Array, priKey: string | Uint8Array): Promise<string> { return DynamicUtil.dynamicKey(pubKey, priKey, 'X25519', 256); } }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto/src/main/ets/crypto/keyAgree/X25519.ets#L26-L36
4fd576361daf08c968b963cb2d06fe944e6352fe
gitee
mayuanwei/harmonyOS_bilibili
8a36b68b1ddf4433e2e17ee10fee4993cce2a6c5
AtomicService/XiaoXunAI/entry/src/main/ets/model/ChatController.ets
arkts
submitUserInput
提交用户输入内容函数 @param userIputText
public submitUserInput(userIputText: string) { if (this.chatCtrl) { this.chatCtrl.submitUserInput(userIputText); } }
AST#method_declaration#Left public submitUserInput AST#parameter_list#Left ( AST#parameter#Left userIputText : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . chatCtrl AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . chatCtrl AST#member_expression#Right AST#expression#Right . submitUserInput AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left userIputText AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
public submitUserInput(userIputText: string) { if (this.chatCtrl) { this.chatCtrl.submitUserInput(userIputText); } }
https://github.com/mayuanwei/harmonyOS_bilibili/blob/8a36b68b1ddf4433e2e17ee10fee4993cce2a6c5/AtomicService/XiaoXunAI/entry/src/main/ets/model/ChatController.ets#L22-L26
0ed8080a9cb9a992fee401ef3203485bd4b45b45
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/customscan/src/main/ets/viewmodel/CustomScanViewModel.ets
arkts
reCustomScan
重新触发一次扫码(仅能使用在customScan.start的异步回调中) @returns {void}
reCustomScan(): void { try { customScan.rescan(); } catch (error) { logger.error('reCustomScan failed error: ' + JSON.stringify(error)); } }
AST#method_declaration#Left reCustomScan AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left customScan AST#expression#Right . rescan AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 'reCustomScan failed error: ' AST#expression#Right + AST#expression#Left JSON AST#expression#Right AST#binary_expression#Right AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
reCustomScan(): void { try { customScan.rescan(); } catch (error) { logger.error('reCustomScan failed error: ' + JSON.stringify(error)); } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/customscan/src/main/ets/viewmodel/CustomScanViewModel.ets#L329-L335
86411c0b831e9f25e71809061422e155233b0126
gitee
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
LoadPerformanceInWeb/entry/src/main/ets/pages/common.ets
arkts
makeNode
The method that must be overridden is used to build the number of nodes and return the nodes to be mounted in the corresponding NodeContainer. //Called when the corresponding NodeContainer is created, or refreshed by calling the rebuild method.
makeNode(uiContext: UIContext): FrameNode | null { console.info(' uicontext is undefined : ' + (uiContext === undefined)); try { if (this.rootNode != null) { const parent: FrameNode = this.rootNode.getFrameNode()?.getParent() as FrameNode; if (parent) { console.info(JSON.stringify(parent.getInspectorInfo())); parent.removeChild(this.rootNode.getFrameNode()); this.root = null; } this.root = new FrameNode(uiContext); this.root.appendChild(this.rootNode.getFrameNode()); // Returns the FrameNode node return this.root; } // Returns a null node that controls the dynamic component to be unbound. return null; } catch (error) { return null; } }
AST#method_declaration#Left makeNode AST#parameter_list#Left ( AST#parameter#Left uiContext : AST#type_annotation#Left AST#primary_type#Left UIContext AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left FrameNode AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left ' uicontext is undefined : ' AST#expression#Right + AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left uiContext AST#expression#Right === AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#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#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rootNode AST#member_expression#Right AST#expression#Right != AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left parent : AST#type_annotation#Left AST#primary_type#Left FrameNode AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rootNode AST#member_expression#Right AST#expression#Right . getFrameNode AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ?. getParent 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 FrameNode 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 parent 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left parent AST#expression#Right . getInspectorInfo 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#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 parent AST#expression#Right . removeChild AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rootNode AST#member_expression#Right AST#expression#Right . getFrameNode 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . root AST#member_expression#Right = AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . root AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left FrameNode AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left uiContext AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . root AST#member_expression#Right AST#expression#Right . appendChild AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rootNode AST#member_expression#Right AST#expression#Right . getFrameNode 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 // Returns the FrameNode node AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . root 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 // Returns a null node that controls the dynamic component to be unbound. AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
makeNode(uiContext: UIContext): FrameNode | null { console.info(' uicontext is undefined : ' + (uiContext === undefined)); try { if (this.rootNode != null) { const parent: FrameNode = this.rootNode.getFrameNode()?.getParent() as FrameNode; if (parent) { console.info(JSON.stringify(parent.getInspectorInfo())); parent.removeChild(this.rootNode.getFrameNode()); this.root = null; } this.root = new FrameNode(uiContext); this.root.appendChild(this.rootNode.getFrameNode()); return this.root; } return null; } catch (error) { return null; } }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/LoadPerformanceInWeb/entry/src/main/ets/pages/common.ets#L41-L61
e933b4047a0bda4f90ebab414ac7e1d1583cc680
gitee
Autumnker/ArkTS_FreeKnowledgeChat.git
cfbe354ba6ac3bc03f23484aa102dfc41c8b64e7
entry/src/main/ets/commonViews/exit.ets
arkts
exit
跳转按钮 点击右侧箭头返回登录页面
@Entry @Component export struct exit{ @Prop indexPage:string="pages/Index" build() { Column(){ Row({space:0}) { Row() { Image($r('app.media.left_arrow')) .width(36) .height(36) .margin({ left: 12 }) .onClick(() => { router.back() }) } .layoutWeight(1) Row(){} } .height("5%") .width("100%") Row() { Row(){}.layoutWeight(1) Row() { Text("退出") .fontSize(36) .fontColor(Color.White) } Row(){}.layoutWeight(1) } .backgroundColor(Color.Black) .height("8%") .width("98%") .borderRadius(15) .onClick(()=> { router.pushUrl({ url: this.indexPage })}) } .width("100%") .height("100%") } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Entry AST#decorator#Right AST#decorator#Left @ Component AST#decorator#Right export struct exit AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right indexPage : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "pages/Index" AST#expression#Right AST#property_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 0 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.left_arrow' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 36 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 36 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 12 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left router AST#expression#Right . back AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#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 . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . height ( AST#expression#Left "5%" AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left "100%" AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#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 36 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . White AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#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#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Black AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left "8%" AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left "98%" AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 15 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 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . indexPage AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left "100%" AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left "100%" AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Entry @Component export struct exit{ @Prop indexPage:string="pages/Index" build() { Column(){ Row({space:0}) { Row() { Image($r('app.media.left_arrow')) .width(36) .height(36) .margin({ left: 12 }) .onClick(() => { router.back() }) } .layoutWeight(1) Row(){} } .height("5%") .width("100%") Row() { Row(){}.layoutWeight(1) Row() { Text("退出") .fontSize(36) .fontColor(Color.White) } Row(){}.layoutWeight(1) } .backgroundColor(Color.Black) .height("8%") .width("98%") .borderRadius(15) .onClick(()=> { router.pushUrl({ url: this.indexPage })}) } .width("100%") .height("100%") } }
https://github.com/Autumnker/ArkTS_FreeKnowledgeChat.git/blob/cfbe354ba6ac3bc03f23484aa102dfc41c8b64e7/entry/src/main/ets/commonViews/exit.ets#L5-L50
76fecf40a5a9b6f33060ede2373d5e48e8a26c8f
github
WinWang/HarmoneyOpenEye.git
57f0542795336009aa0d46fd9fa5b07facc2ae87
entry/src/main/ets/http/AxiosHttp.ets
arkts
定义接口响应包装类
export interface BaseResponse { //wanAndroid-API响应体 errorCode: number errorMsg: string //拓展xxx-API响应体 }
AST#export_declaration#Left export AST#interface_declaration#Left interface BaseResponse AST#object_type#Left { //wanAndroid-API响应体 AST#type_member#Left errorCode : 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 errorMsg : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right //拓展xxx-API响应体 } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
export interface BaseResponse { errorCode: number errorMsg: string }
https://github.com/WinWang/HarmoneyOpenEye.git/blob/57f0542795336009aa0d46fd9fa5b07facc2ae87/entry/src/main/ets/http/AxiosHttp.ets#L15-L20
2a55bfd552ea6edb894849102a966977b2efe312
github
mayuanwei/harmonyOS_bilibili
8a36b68b1ddf4433e2e17ee10fee4993cce2a6c5
NEXT/XiaoXunAI/entry/src/main/ets/utils/TongYiHttpUtils.ets
arkts
request
消息请求函数 @param msg @param callback
request(msg: string,callback: Function) { //创建请求 let httpRequest = http.createHttp(); //发起请求 httpRequest.request( //请求地址url "https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation", //请求可选设置options { //请求方式 method: http.RequestMethod.POST, //请求头 header: { "Content-Type": "application/json", //API-KEY "Authorization": this.API_KEY }, //请求体 extraData: { "model": "qwen-plus", //模型名称(必选):指定用于对话的通义千问模型名 "input": { "messages": [//消息列表(必选):用户发送给模型的消息 { 'role': 'system',//系统消息的角色,固定为system 'content': '我是小讯百问智能助理!' }, { "role": "user",//用户消息的角色,固定为user "content": msg //用户消息的内容(文本、图片、音频) } ] } } }, (err, data: http.HttpResponse) => { if (err) { console.log(`dxin => ${JSON.stringify(err) ?? ''} `) httpRequest.destroy(); callback('抱歉,小讯百问正在成长中'); } else { console.log(`dxin => ${JSON.stringify(data.result)} `) let resp: TongYiResponse = JSON.parse(data.result.toString()); console.log(`dxin => ${JSON.stringify(resp?.output?.text)} `) httpRequest.destroy(); callback(resp?.output?.text); } }) }
AST#method_declaration#Left request AST#parameter_list#Left ( AST#parameter#Left msg : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#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 let AST#variable_declarator#Left httpRequest = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left http AST#expression#Right . createHttp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right //发起请求 AST#statement#Left AST#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 ( //请求地址url AST#expression#Left "https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation" AST#expression#Right , //请求可选设置options AST#expression#Left AST#object_literal#Left { //请求方式 AST#property_assignment#Left AST#property_name#Left method 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 . RequestMethod AST#member_expression#Right AST#expression#Right . POST 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 AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left "Content-Type" AST#property_name#Right : AST#expression#Left "application/json" AST#expression#Right AST#property_assignment#Right , //API-KEY AST#property_assignment#Left AST#property_name#Left "Authorization" AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . API_KEY AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right , //请求体 AST#property_assignment#Left AST#property_name#Left extraData AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left "model" AST#property_name#Right : AST#expression#Left "qwen-plus" AST#expression#Right AST#property_assignment#Right , //模型名称(必选):指定用于对话的通义千问模型名 AST#property_assignment#Left AST#property_name#Left "input" AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left "messages" 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 'role' AST#property_name#Right : AST#expression#Left 'system' AST#expression#Right AST#property_assignment#Right , //系统消息的角色,固定为system AST#property_assignment#Left AST#property_name#Left 'content' AST#property_name#Right : AST#expression#Left '我是小讯百问智能助理!' 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 "role" AST#property_name#Right : AST#expression#Left "user" AST#expression#Right AST#property_assignment#Right , //用户消息的角色,固定为user AST#property_assignment#Left AST#property_name#Left "content" AST#property_name#Right : AST#expression#Left msg 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#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err AST#parameter#Right , AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left http . HttpResponse AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left err AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` dxin => AST#template_substitution#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 JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ?? AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right } AST#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 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#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#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` dxin => 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 AST#member_expression#Left AST#expression#Left data AST#expression#Right . result AST#member_expression#Right 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#variable_declaration#Left let AST#variable_declarator#Left resp : AST#type_annotation#Left AST#primary_type#Left TongYiResponse AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . parse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . result 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#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` dxin => 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 AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resp AST#expression#Right ?. output AST#member_expression#Right AST#expression#Right ?. text AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#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 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#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#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resp AST#expression#Right ?. output AST#member_expression#Right AST#expression#Right ?. text AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
request(msg: string,callback: Function) { let httpRequest = http.createHttp(); httpRequest.request( "https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation", { method: http.RequestMethod.POST, header: { "Content-Type": "application/json", "Authorization": this.API_KEY }, extraData: { "model": "qwen-plus", "input": { "messages": [ { 'role': 'system', 'content': '我是小讯百问智能助理!' }, { "role": "user", "content": msg } ] } } }, (err, data: http.HttpResponse) => { if (err) { console.log(`dxin => ${JSON.stringify(err) ?? ''} `) httpRequest.destroy(); callback('抱歉,小讯百问正在成长中'); } else { console.log(`dxin => ${JSON.stringify(data.result)} `) let resp: TongYiResponse = JSON.parse(data.result.toString()); console.log(`dxin => ${JSON.stringify(resp?.output?.text)} `) httpRequest.destroy(); callback(resp?.output?.text); } }) }
https://github.com/mayuanwei/harmonyOS_bilibili/blob/8a36b68b1ddf4433e2e17ee10fee4993cce2a6c5/NEXT/XiaoXunAI/entry/src/main/ets/utils/TongYiHttpUtils.ets#L22-L70
ff904575c5476ad042e6e916a811bdcaf758fae0
gitee
charon2pluto/MoodDiary-HarmonyOS.git
0ec7ee6861e150bc9b4571062dbf302d1b106b8c
entry/src/main/ets/pages/MoodDetail.ets
arkts
getScoreColor
获取分数颜色
getScoreColor(score: number): string { if (score >= 8) return '#FF9800'; // 橙 if (score >= 5) return '#2196F3'; // 蓝 return '#9E9E9E'; // 灰 }
AST#method_declaration#Left getScoreColor AST#parameter_list#Left ( AST#parameter#Left score : 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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left score AST#expression#Right >= AST#expression#Left 8 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return AST#expression#Left '#FF9800' AST#expression#Right ; AST#return_statement#Right AST#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 score AST#expression#Right >= AST#expression#Left 5 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return AST#expression#Left '#2196F3' AST#expression#Right ; AST#return_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right // 蓝 AST#statement#Left AST#return_statement#Left return AST#expression#Left '#9E9E9E' AST#expression#Right ; AST#return_statement#Right AST#statement#Right // 灰 } AST#block_statement#Right AST#method_declaration#Right
getScoreColor(score: number): string { if (score >= 8) return '#FF9800'; if (score >= 5) return '#2196F3'; return '#9E9E9E'; }
https://github.com/charon2pluto/MoodDiary-HarmonyOS.git/blob/0ec7ee6861e150bc9b4571062dbf302d1b106b8c/entry/src/main/ets/pages/MoodDetail.ets#L36-L40
594135f5b30b1e8dfd438678a78d433dcb4752d8
github
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_crypto/src/main/ets/crypto/encryption/sm2/SM2Sync.ets
arkts
generateSM2Key
生成SM2的非对称密钥 @param resultCoding 返回结果编码方式(hex/base64)-默认不传为base64格式 @returns SM2密钥{publicKey:公钥,privateKey:私钥}
static generateSM2Key(resultCoding: buffer.BufferEncoding = 'base64'): CryptoKey { return CryptoSyncUtil.generateCryptoKey('SM2_256', resultCoding); }
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
static generateSM2Key(resultCoding: buffer.BufferEncoding = 'base64'): CryptoKey { return CryptoSyncUtil.generateCryptoKey('SM2_256', resultCoding); }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto/src/main/ets/crypto/encryption/sm2/SM2Sync.ets#L34-L36
aefebc80a3b7fb010ccfbf092223e24e088c6d6d
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
entry/src/main/ets/model/DescribeBean.ets
arkts
url地址
constructor(name: string, desc: string, type: number = 0) { this.name = name; this.desc = desc; this.type = type; }
AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left name : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left desc : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left type : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . name AST#member_expression#Right = AST#expression#Left name AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . desc AST#member_expression#Right = AST#expression#Left desc 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 . type AST#member_expression#Right = AST#expression#Left type 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(name: string, desc: string, type: number = 0) { this.name = name; this.desc = desc; this.type = type; }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/entry/src/main/ets/model/DescribeBean.ets#L10-L14
9472866437ed472bb5e77790ee16b72bf00c16fb
gitee
Joker-x-dev/HarmonyKit.git
f97197ce157df7f303244fba42e34918306dfb08
core/model/src/main/ets/entity/Auth.ets
arkts
shouldRefresh
检查令牌是否需要刷新(过期前15分钟) @returns {boolean} 是否需要刷新
shouldRefresh(): boolean { const currentTime: number = Date.now(); const refreshTime: number = this.createdAt + this.expire * 1000 - 15 * 60 * 1000; return currentTime >= refreshTime && !this.isRefreshTokenExpired(); }
AST#method_declaration#Left shouldRefresh AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left currentTime : 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 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 refreshTime : 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#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 . createdAt AST#member_expression#Right AST#expression#Right + AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . expire AST#member_expression#Right AST#expression#Right * AST#expression#Left 1000 AST#expression#Right AST#binary_expression#Right AST#expression#Right - AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 15 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#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left currentTime AST#expression#Right >= AST#expression#Left refreshTime AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . isRefreshTokenExpired 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
shouldRefresh(): boolean { const currentTime: number = Date.now(); const refreshTime: number = this.createdAt + this.expire * 1000 - 15 * 60 * 1000; return currentTime >= refreshTime && !this.isRefreshTokenExpired(); }
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/model/src/main/ets/entity/Auth.ets#L76-L80
a2d7aad78e3e470c727e3b2d8dd9cbb27b410c13
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/SystemFeature/DeviceManagement/DeviceManagementCollection/feature/capabilities/src/main/ets/util/InputDeviceUtil.ets
arkts
removeDuplicate
列表对象去重 @param arr 列表
private removeDuplicate(arr: InputDeviceInfo[]): InputDeviceInfo[] { const newArr: InputDeviceInfo[] = []; for (const item of arr) { // 检查缓存中是否已经存在 if (newArr.find((cur: InputDeviceInfo) => cur.id === item.id && cur.name === item.name && cur.connect === item.connect) ) { // 已经存在说明以前记录过,现在这个就是多余的,直接忽略 continue; } // 不存在就说明以前没遇到过,把它记录下来 newArr.push(item) } // 记录结果就是过滤后的结果 return newArr }
AST#method_declaration#Left private removeDuplicate AST#parameter_list#Left ( AST#parameter#Left arr : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left InputDeviceInfo [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left InputDeviceInfo [ ] 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 newArr : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left InputDeviceInfo [ ] 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 item of AST#expression#Left arr AST#expression#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 newArr AST#expression#Right . find 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 cur : AST#type_annotation#Left AST#primary_type#Left InputDeviceInfo 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 AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cur AST#expression#Right . id 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 cur AST#expression#Right AST#binary_expression#Right AST#expression#Right . name AST#member_expression#Right AST#expression#Right === AST#expression#Left item AST#expression#Right AST#binary_expression#Right AST#expression#Right . name AST#member_expression#Right AST#expression#Right && AST#expression#Left cur AST#expression#Right AST#binary_expression#Right AST#expression#Right . connect AST#member_expression#Right AST#expression#Right === AST#expression#Left item AST#expression#Right AST#binary_expression#Right AST#expression#Right . connect 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#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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left newArr AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left item AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right // 记录结果就是过滤后的结果 AST#statement#Left AST#return_statement#Left return AST#expression#Left newArr AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private removeDuplicate(arr: InputDeviceInfo[]): InputDeviceInfo[] { const newArr: InputDeviceInfo[] = []; for (const item of arr) { if (newArr.find((cur: InputDeviceInfo) => cur.id === item.id && cur.name === item.name && cur.connect === item.connect) ) { continue; } newArr.push(item) } return newArr }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/SystemFeature/DeviceManagement/DeviceManagementCollection/feature/capabilities/src/main/ets/util/InputDeviceUtil.ets#L194-L211
c65e12f5804f4f8f36d77d3a900bd402d543e86c
gitee
Application-Security-Automation/Arktan.git
3ad9cb05235e38b00cd5828476aa59a345afa1c0
dataset/completeness/interface_class/simple_class/simple_class_006_F.ets
arkts
Introduction 函数内部类
export function simple_class_006_F(taint_src : string) { class A { data: string; clean: string; constructor() { this.data = taint_src; this.clean = "_"; }
AST#export_declaration#Left export AST#function_declaration#Left function simple_class_006_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 class AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left A AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left data AST#property_name#Right : AST#expression#Left string AST#expression#Right AST#property_assignment#Right AST#object_literal#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left clean AST#expression#Right AST#ERROR#Left : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left constructor 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 AST#object_literal#Left { AST#property_assignment#Left this AST#property_assignment#Right AST#object_literal#Right AST#expression#Right . data AST#member_expression#Right = AST#expression#Left taint_src 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 . clean AST#member_expression#Right = AST#expression#Left "_" AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export function simple_class_006_F(taint_src : string) { class A { data: string; clean: string; constructor() { this.data = taint_src; this.clean = "_"; }
https://github.com/Application-Security-Automation/Arktan.git/blob/3ad9cb05235e38b00cd5828476aa59a345afa1c0/dataset/completeness/interface_class/simple_class/simple_class_006_F.ets#L6-L13
f78a53decc853d0864aba9d482cfef3003e8bf51
github
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
feature/user/src/main/ets/viewmodel/ProfileViewModel.ets
arkts
getPhoneText
获取手机号展示文本 @returns {ResourceStr} 手机号文本
getPhoneText(): ResourceStr { const phone: string = this.getUserInfo().phone ?? ""; return phone ? phone : $r("app.string.not_bound"); } /** * 获取账号展示文本 * @returns {ResourceStr} 账号文本 */ getAccountText(): ResourceStr { const id: number | null = this.getUserInfo().id ?? null; return id ? `${id}` : $r("app.string.not_set"); }
AST#method_declaration#Left getPhoneText AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left phone : AST#type_annotation#Left AST#primary_type#Left string 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this 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 . phone AST#member_expression#Right AST#expression#Right ?? AST#expression#Left "" AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#ERROR#Left return AST#expression#Left phone AST#expression#Right ? phone AST#ERROR#Left : AST#ERROR#Left $r ( "app.string.not_bound" ) ; } /** * 获取账号展示文本 * @returns {ResourceStr} 账号文本 */ getAccount Text AST#ERROR#Right AST#parameter_list#Left ( ) AST#parameter_list#Right AST#ERROR#Right : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right { AST#ERROR#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left id : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left number AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this 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 . id 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#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 id AST#expression#Right ? AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left id AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.not_set" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
getPhoneText(): ResourceStr { const phone: string = this.getUserInfo().phone ?? ""; return phone ? phone : $r("app.string.not_bound"); } getAccountText(): ResourceStr { const id: number | null = this.getUserInfo().id ?? null; return id ? `${id}` : $r("app.string.not_set"); }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/user/src/main/ets/viewmodel/ProfileViewModel.ets#L100-L112
a77650d27a39d1527d090dd339e2b60b32b5da7b
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/ets/entry2ability/Entry2Ability.ets
arkts
onWindowStageDestroy
[End soft_keyboard_entryability]
onWindowStageDestroy(): void { // Main window is destroyed, release UI related resources hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); }
AST#method_declaration#Left onWindowStageDestroy AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { // Main window is destroyed, release UI related resources AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left 'testTag' AST#expression#Right , AST#expression#Left '%{public}s' AST#expression#Right , AST#expression#Left 'Ability onWindowStageDestroy' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
onWindowStageDestroy(): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/ArkWeb/ManageWebPageInteracts/entry2/src/main/ets/entry2ability/Entry2Ability.ets#L47-L50
d8b28178fa47e80c1ef62ea03f3c7bed2516475d
gitee
open9527/OpenHarmony
fdea69ed722d426bf04e817ec05bff4002e81a4e
libs/core/src/main/ets/utils/CharUtils.ets
arkts
isAscii
检查字符是否位于ASCII范围内(0~127) @param ch 被检查的字符 @returns `true`表示为ASCII字符,否则为`false`
static isAscii(ch: string): boolean { // 确保输入的是单个字符 if (ch.length !== 1) throw new Error("Input must be a single character"); return ch.charCodeAt(0) < 128; }
AST#method_declaration#Left static isAscii AST#parameter_list#Left ( AST#parameter#Left ch : 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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ch 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#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 "Input must be a single character" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#throw_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ch AST#expression#Right . charCodeAt 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#Left 128 AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static isAscii(ch: string): boolean { if (ch.length !== 1) throw new Error("Input must be a single character"); return ch.charCodeAt(0) < 128; }
https://github.com/open9527/OpenHarmony/blob/fdea69ed722d426bf04e817ec05bff4002e81a4e/libs/core/src/main/ets/utils/CharUtils.ets#L26-L30
70e5e6102c52ce9e85edf91dc0d837c0eafd8b93
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/customcalendarpickerdialog/src/main/ets/components/MonthDataSource.ets
arkts
unregisterDataChangeListener
为对应的LazyForEach组件在数据源处去除listener监听。 @param {DataChangeListener} listener - 监听对象。
unregisterDataChangeListener(listener: DataChangeListener): void { const pos = this.listeners.indexOf(listener); if (pos >= 0) { console.info('remove listener'); this.listeners.splice(pos, 1); } }
AST#method_declaration#Left unregisterDataChangeListener AST#parameter_list#Left ( AST#parameter#Left listener : AST#type_annotation#Left AST#primary_type#Left DataChangeListener AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left pos = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . listeners AST#member_expression#Right AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left listener AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left pos AST#expression#Right >= AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'remove listener' AST#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 . listeners AST#member_expression#Right AST#expression#Right . splice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left pos AST#expression#Right , AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
unregisterDataChangeListener(listener: DataChangeListener): void { const pos = this.listeners.indexOf(listener); if (pos >= 0) { console.info('remove listener'); this.listeners.splice(pos, 1); } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/customcalendarpickerdialog/src/main/ets/components/MonthDataSource.ets#L64-L70
605c48423c90ddfd910df58f86e9c581af858a76
gitee
openharmony/update_update_app
0157b7917e2f48e914b5585991e8b2f4bc25108a
feature/ota/src/main/ets/dialog/DialogHelper.ets
arkts
logInfo
info级别日志打印 @param message 日志内容
function logInfo(message: string): void { LogUtils.info('DialogHelper', message); }
AST#function_declaration#Left function logInfo AST#parameter_list#Left ( 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 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 LogUtils AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'DialogHelper' AST#expression#Right , AST#expression#Left message AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right
function logInfo(message: string): void { LogUtils.info('DialogHelper', message); }
https://github.com/openharmony/update_update_app/blob/0157b7917e2f48e914b5585991e8b2f4bc25108a/feature/ota/src/main/ets/dialog/DialogHelper.ets#L203-L205
ddc3ee38840deb4b32eaeae1632f7b2bc1e77500
gitee
openharmony/interface_sdk-js
c349adc73e2ec1f61f6fca489b5af059e3ed6999
api/@ohos.util.d.ets
arkts
isSetIterator
Check whether the entered value is the iterator type of set. @param { Object } value - A Set iterator value @returns { boolean } Returns true if the value is an iterator returned for a built-in Set instance. @syscap SystemCapability.Utils.Lang @crossplatform @atomicservice @since 20
isSetIterator(value: Object): boolean;
AST#method_declaration#Left isSetIterator AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right
isSetIterator(value: Object): boolean;
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.util.d.ets#L1334-L1334
58b496f9b0fa584239b10a2d5f236f86f0e8a05b
gitee
openharmony/xts_acts
5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686
arkui/ace_ets_module_ui/ace_ets_module_commonAttrsEvents/ace_ets_module_commonAttrsEvents_api13/entry/src/main/ets/MainAbility/common/Log.ets
arkts
showDebug
print debug level log @param {string} tag - Page or class tag @param {string} log - Log needs to be printed
static showDebug(tag: string, log: string) { console.debug(`${TAG} tag: ${tag} --> ${log}`); }
AST#method_declaration#Left static showDebug AST#parameter_list#Left ( AST#parameter#Left tag : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left log : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . debug AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left TAG AST#expression#Right } AST#template_substitution#Right tag: AST#template_substitution#Left $ { AST#expression#Left tag AST#expression#Right } AST#template_substitution#Right --> AST#template_substitution#Left $ { AST#expression#Left log AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
static showDebug(tag: string, log: string) { console.debug(`${TAG} tag: ${tag} --> ${log}`); }
https://github.com/openharmony/xts_acts/blob/5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686/arkui/ace_ets_module_ui/ace_ets_module_commonAttrsEvents/ace_ets_module_commonAttrsEvents_api13/entry/src/main/ets/MainAbility/common/Log.ets#L38-L40
2a0bc984213bac4dcc7d69262edb38727407e723
gitee
queyun123/weatherApp-ArkTS.git
6beee6640db32ae70c342866b24fc643a9c512bf
entry/src/main/ets/model/WeatherData.ets
arkts
天气数据接口
export interface WeatherNow { temp: string; // 温度 text: string; // 天气描述 humidity: string; // 湿度 windDir: string; // 风向 windScale: string; // 风力等级 icon: string; // 天气图标代码 }
AST#export_declaration#Left export AST#interface_declaration#Left interface WeatherNow AST#object_type#Left { AST#type_member#Left temp : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; // 温度 AST#type_member#Left text : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; // 天气描述 AST#type_member#Left humidity : 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 windDir : 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 windScale : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; // 风力等级 AST#type_member#Left icon : AST#type_annotation#Left AST#primary_type#Left 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 WeatherNow { temp: string; text: string; humidity: string; windDir: string; windScale: string; icon: string; }
https://github.com/queyun123/weatherApp-ArkTS.git/blob/6beee6640db32ae70c342866b24fc643a9c512bf/entry/src/main/ets/model/WeatherData.ets#L2-L9
b1b2b0df3d05281ceb8efdabffaab22d0ab7da42
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/videocreategif/src/main/ets/components/RangeSeekBarView.ets
arkts
touchInLeftThumb
是否触摸在左边的条状物 @param event @returns
touchInLeftThumb(event?: GestureEvent): boolean { let pointX:number = this.clearUndefined(event?.fingerList[0].localX); let pointY:number = this.clearUndefined(event?.fingerList[0].localY); return this.pointInArea(pointX, pointY, this.leftThumbRect); }
AST#method_declaration#Left touchInLeftThumb 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#variable_declaration#Left let AST#variable_declarator#Left pointY : 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 . localY AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . pointInArea AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left pointX AST#expression#Right , AST#expression#Left pointY AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . leftThumbRect 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
touchInLeftThumb(event?: GestureEvent): boolean { let pointX:number = this.clearUndefined(event?.fingerList[0].localX); let pointY:number = this.clearUndefined(event?.fingerList[0].localY); return this.pointInArea(pointX, pointY, this.leftThumbRect); }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/videocreategif/src/main/ets/components/RangeSeekBarView.ets#L353-L358
2b4818e0b4c4bd580a54fc265b859eb73ec6bb65
gitee
openharmony/developtools_profiler
73d26bb5acfcafb2b1f4f94ead5640241d1e5f73
host/smartperf/client/client_ui/entry/src/main/ets/common/entity/UserEntity.ets
arkts
Copyright (C) 2022 Huawei Device Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
export class User { public token: String; public expiresIn: String; //过期时间 public refreshToken: String; //刷新token public expiresAt: String; //时间 public tokenType: String; //token类型 constructor(token?: String, expiresIn?: String, refreshToken?: String, expiresAt?: String, tokenType?: String) { this.token = token; this.expiresIn = expiresIn; this.refreshToken = refreshToken; this.expiresAt = expiresAt; this.tokenType = tokenType; } }
AST#export_declaration#Left export AST#class_declaration#Left class User AST#class_body#Left { AST#property_declaration#Left public token : AST#type_annotation#Left AST#primary_type#Left String AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left public expiresIn : AST#type_annotation#Left AST#primary_type#Left String AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right //过期时间 AST#property_declaration#Left public refreshToken : AST#type_annotation#Left AST#primary_type#Left String AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right //刷新token AST#property_declaration#Left public expiresAt : AST#type_annotation#Left AST#primary_type#Left String AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right //时间 AST#property_declaration#Left public tokenType : AST#type_annotation#Left AST#primary_type#Left String AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right //token类型 AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left token ? : AST#type_annotation#Left AST#primary_type#Left String AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left expiresIn ? : AST#type_annotation#Left AST#primary_type#Left String AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left refreshToken ? : AST#type_annotation#Left AST#primary_type#Left String AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left expiresAt ? : AST#type_annotation#Left AST#primary_type#Left String AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left tokenType ? : AST#type_annotation#Left AST#primary_type#Left String AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . token AST#member_expression#Right = AST#expression#Left token 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 . expiresIn AST#member_expression#Right = AST#expression#Left expiresIn 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 . refreshToken AST#member_expression#Right = AST#expression#Left refreshToken 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 . expiresAt AST#member_expression#Right = AST#expression#Left expiresAt 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 . tokenType AST#member_expression#Right = AST#expression#Left tokenType AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class User { public token: String; public expiresIn: String; public refreshToken: String; public expiresAt: String; public tokenType: String; constructor(token?: String, expiresIn?: String, refreshToken?: String, expiresAt?: String, tokenType?: String) { this.token = token; this.expiresIn = expiresIn; this.refreshToken = refreshToken; this.expiresAt = expiresAt; this.tokenType = tokenType; } }
https://github.com/openharmony/developtools_profiler/blob/73d26bb5acfcafb2b1f4f94ead5640241d1e5f73/host/smartperf/client/client_ui/entry/src/main/ets/common/entity/UserEntity.ets#L16-L30
6cb9db6c0c8922226ef8759fc779a1e22be1aae5
gitee
cljhwt/Gemini3_to_ArkTS.git
11507c45be72ecccef2f757eaf024c2b8617ad34
ArtTs-Demo/ImageGetAndSave-master/entry/src/main/ets/pages/Index.ets
arkts
alphaTypeToString
Alpha 类型转换为字符串
function alphaTypeToString(alpha: number): string { // 不同API版本枚举名可能为 AlphaType 或 PixelMapAlphaType,按你的SDK调整 switch (alpha) { case 0: return 'ALPHA_TYPE_UNKNOWN'; case 1: return 'ALPHA_TYPE_OPAQUE'; case 2: return 'ALPHA_TYPE_PREMUL'; case 3: return 'ALPHA_TYPE_UNPREMUL'; default: return `ALPHA_TYPE_UNKNOWN(${alpha})`; }
AST#function_declaration#Left function alphaTypeToString AST#parameter_list#Left ( AST#parameter#Left alpha : 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 { // 不同API版本枚举名可能为 AlphaType 或 PixelMapAlphaType,按你的SDK调整 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 alpha AST#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#object_literal#Left { AST#property_assignment#Left AST#property_name#Left case AST#property_name#Right AST#ERROR#Left 0 AST#ERROR#Right : AST#expression#Left return AST#expression#Right AST#property_assignment#Right AST#object_literal#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left 'ALPHA_TYPE_UNKNOWN' 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 1 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 'ALPHA_TYPE_OPAQUE' AST#expression#Right ; AST#return_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 2 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 'ALPHA_TYPE_PREMUL' AST#expression#Right ; AST#return_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 3 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 'ALPHA_TYPE_UNPREMUL' 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 AST#ERROR#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#template_literal#Left ` ALPHA_TYPE_UNKNOWN( AST#template_substitution#Left $ { AST#expression#Left alpha AST#expression#Right } AST#template_substitution#Right ) ` AST#template_literal#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right
function alphaTypeToString(alpha: number): string { switch (alpha) { case 0: return 'ALPHA_TYPE_UNKNOWN'; case 1: return 'ALPHA_TYPE_OPAQUE'; case 2: return 'ALPHA_TYPE_PREMUL'; case 3: return 'ALPHA_TYPE_UNPREMUL'; default: return `ALPHA_TYPE_UNKNOWN(${alpha})`; }
https://github.com/cljhwt/Gemini3_to_ArkTS.git/blob/11507c45be72ecccef2f757eaf024c2b8617ad34/ArtTs-Demo/ImageGetAndSave-master/entry/src/main/ets/pages/Index.ets#L69-L82
291e0ecd5971c290cb7ff18d2fdfa9d36ce2e252
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/listslidetohistory/src/main/ets/view/ListSlideToHistory.ets
arkts
ListSlideToHistoryComponent
公共常亮存放LazyForEach数据实体 功能描述: 在长列表场景时,当用户在浏览过程中打断时,列表会从第一项开始重新加载,此时我们使用scrollToIndex跳转到某个列表项时,当开启smooth动效时,会对经过的所有item进行加载和布局计算,当大量加载item时会导致性能问题,影响用户体验。因此我们使用currentOffset方法获取并记录偏移量,然后使用scrollTo方法跳转到上次浏览记录功能,可以流畅滑动到上次列表的位置。 推荐场景: 长列表滑动到指定列表项动效 核心组件: 1. ListSlideToHistory 实现步骤: 1.使用LazyForEach+cacheCount+@Reusable实现懒加载列表。 2.创建ListScroller对象,将ListScroller对象绑定到List组件内。 3.在需要记录当前位置时通过currentOffset方法存储当前偏移量historyOffset,在需要跳转时用scrollTo方法跳转。
@Component export struct ListSlideToHistoryComponent { @State cachedCountNumber: number = 3; // 懒加载缓存数 @State firstIndex: number = 0; // 当前显示在屏幕上的子组件索引值,用来控制下方按钮跳转 listScroller: ListScroller = new ListScroller(); // scroller控制器 historyOffset: number = 0; // 上次浏览到列表距离顶端的偏移量offset readonly DEFAULT_OFFSET: number = 1000; // 默认跳转位置,用于第一次进入页面的跳转位置 readonly ANIMATION_DURATION: number = 500; // 动画持续时间 readonly SWITCH_BUTTON: number = 3; // 当前显示在屏幕上的子组件Index到达该阈值时,将跳转到历史记录按钮切换成跳转到顶部 private timer: number = 0; // 存储防抖计时器 aboutToAppear(): void { // 一个函数加载10个,为保证初始页面跳转,因此加载20个列表。 getFriendMomentFromRawfile(); getFriendMomentFromRawfile(); } build() { Column() { Row() { Text($r('app.string.list_slide_to_history_near_message')) .fontSize($r('app.integer.list_slide_to_history_title_fontSize')) .fontColor($r('app.color.list_slide_to_history_title_font_color')) .fontWeight(FontWeight.Bold) .margin({ left: $r('app.integer.list_slide_to_history_title_margin_left') }) .fontFamily($r('app.string.list_slide_to_history_harmony_hei_ti')) .lineHeight($r('app.integer.list_slide_to_history_title_line_height')) .layoutWeight(ListConstants.LAYOUT_WEIGHT) } .alignItems(VerticalAlign.Center) .height($r('app.integer.list_slide_to_history_title_height')) .width($r('app.string.list_slide_to_history_layout_100')) .padding({ left: $r('app.integer.list_slide_to_history_title_padding_left'), right: $r('app.integer.list_slide_to_history_title_padding_right'), top: $r('app.integer.list_slide_to_history_title_padding_top'), bottom: $r('app.integer.list_slide_to_history_title_padding_bottom') }) List({ space: ListConstants.LIST_SPACE, scroller: this.listScroller }) { // TODO:高性能知识点:列表数据较多,不需要全部渲染上屏,采用LazyForEach。 LazyForEach(momentData, (moment: FriendMoment) => { ListItem() { OneMoment({ moment: moment }) } }, (moment: FriendMoment) => moment.id) } .id("slide_to_history_list") // TODO:高性能知识点:为保证滑动流畅,采用cachedCount缓存前后节点。 .cachedCount(this.cachedCountNumber) .width($r('app.string.list_slide_to_history_layout_100')) .height($r('app.string.list_slide_to_history_layout_100')) .listDirection(Axis.Vertical) .divider({ strokeWidth: $r('app.integer.list_slide_to_history_divider_width'), color: $r('app.color.list_slide_to_history_divider_color'), startMargin: $r('app.integer.list_slide_to_history_list_divider_margin'), endMargin: $r('app.integer.list_slide_to_history_list_divider_margin') }) .onScrollIndex((first: number) => { this.firstIndex = first; }) Button({ type: ButtonType.Normal, stateEffect: true }){ Image(this.firstIndex < this.SWITCH_BUTTON ?$r("app.media.list_slide_to_history_location"):$r('app.media.list_slide_to_top')) } .id("slide_to_history_button") .fontColor($r('app.color.list_slide_to_history_jump_button_font_color')) .height($r('app.integer.list_slide_to_history_jump_button_height')) .borderRadius($r('app.integer.list_slide_to_history_jump_button_radius')) .backgroundColor($r('app.color.list_slide_to_history_jump_button_bgc')) .opacity($r('app.float.list_slide_to_history_jump_button_opacity')) .width($r('app.integer.list_slide_to_history_jump_button_width')) .position({ x: $r('app.string.list_slide_to_history_jump_position_x'), y: $r('app.string.list_slide_to_history_jump_position_y') }) .markAnchor({ x: $r('app.string.list_slide_to_history_jump_markAnchor_x') }) .onClick(() => { // 如果没有计时器,则执行 if (this.timer === 0) { // 当前显示的index值小于设定的SWITCH_BUTTON时,按钮为跳转到上次浏览记录,否则为跳转到顶部 if (this.firstIndex < this.SWITCH_BUTTON) { this.listScroller.scrollTo({ xOffset: 0, yOffset: this.historyOffset === 0 ? this.DEFAULT_OFFSET : this.historyOffset, animation: { duration: this.ANIMATION_DURATION, curve: Curve.LinearOutSlowIn } }); } else { this.historyOffset = this.listScroller.currentOffset().yOffset; this.listScroller.scrollTo({ xOffset: 0, yOffset: 0, animation: { duration: this.ANIMATION_DURATION, curve: Curve.LinearOutSlowIn } }); } // 设置防抖延迟,时间为动画时长 this.timer = setTimeout(() => { this.timer = 0 }, this.ANIMATION_DURATION); } }) } .height($r('app.string.list_slide_to_history_layout_100')) .width($r('app.string.list_slide_to_history_layout_100')) } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct ListSlideToHistoryComponent AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right cachedCountNumber : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 3 AST#expression#Right ; AST#property_declaration#Right // 懒加载缓存数 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right firstIndex : 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 listScroller : AST#type_annotation#Left AST#primary_type#Left ListScroller 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 ListScroller AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right // scroller控制器 AST#property_declaration#Left historyOffset : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right // 上次浏览到列表距离顶端的偏移量offset AST#property_declaration#Left readonly DEFAULT_OFFSET : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 1000 AST#expression#Right ; AST#property_declaration#Right // 默认跳转位置,用于第一次进入页面的跳转位置 AST#property_declaration#Left readonly ANIMATION_DURATION : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 500 AST#expression#Right ; AST#property_declaration#Right // 动画持续时间 AST#property_declaration#Left readonly SWITCH_BUTTON : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 3 AST#expression#Right ; AST#property_declaration#Right // 当前显示在屏幕上的子组件Index到达该阈值时,将跳转到历史记录按钮切换成跳转到顶部 AST#property_declaration#Left private timer : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right // 存储防抖计时器 AST#method_declaration#Left aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { // 一个函数加载10个,为保证初始页面跳转,因此加载20个列表。 AST#ui_custom_component_statement#Left getFriendMomentFromRawfile ( ) ; AST#ui_custom_component_statement#Right AST#ui_custom_component_statement#Left getFriendMomentFromRawfile ( ) ; AST#ui_custom_component_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.list_slide_to_history_near_message' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.list_slide_to_history_title_fontSize' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.list_slide_to_history_title_font_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Bold AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.list_slide_to_history_title_margin_left' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontFamily ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.list_slide_to_history_harmony_hei_ti' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . lineHeight ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.list_slide_to_history_title_line_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left ListConstants AST#expression#Right . LAYOUT_WEIGHT AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left VerticalAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.list_slide_to_history_title_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.list_slide_to_history_layout_100' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.list_slide_to_history_title_padding_left' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.list_slide_to_history_title_padding_right' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.list_slide_to_history_title_padding_top' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.list_slide_to_history_title_padding_bottom' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left List ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left AST#member_expression#Left AST#expression#Left ListConstants AST#expression#Right . LIST_SPACE AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left scroller : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . listScroller AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { // TODO:高性能知识点:列表数据较多,不需要全部渲染上屏,采用LazyForEach。 AST#ui_control_flow#Left AST#lazy_for_each_statement#Left LazyForEach ( AST#expression#Left momentData AST#expression#Right , AST#ui_builder_arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left moment : AST#type_annotation#Left AST#primary_type#Left FriendMoment AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#ui_arrow_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left ListItem ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left OneMoment ( AST#component_parameters#Left { AST#component_parameter#Left moment : AST#expression#Left moment AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#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 moment : AST#type_annotation#Left AST#primary_type#Left FriendMoment 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 moment AST#expression#Right . id AST#member_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#lazy_for_each_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . id ( AST#expression#Left "slide_to_history_list" AST#expression#Right ) // TODO:高性能知识点:为保证滑动流畅,采用cachedCount缓存前后节点。 AST#modifier_chain_expression#Left . cachedCount ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cachedCountNumber AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.list_slide_to_history_layout_100' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.list_slide_to_history_layout_100' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . listDirection ( AST#expression#Left AST#member_expression#Left AST#expression#Left Axis AST#expression#Right . Vertical AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . divider ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left strokeWidth AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.list_slide_to_history_divider_width' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.list_slide_to_history_divider_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left startMargin AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.list_slide_to_history_list_divider_margin' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left endMargin AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.list_slide_to_history_list_divider_margin' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onScrollIndex ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left first : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#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 . firstIndex AST#member_expression#Right = AST#expression#Left first AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#component_parameters#Left { AST#component_parameter#Left type : AST#expression#Left AST#member_expression#Left AST#expression#Left ButtonType AST#expression#Right . Normal AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left stateEffect : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#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#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 . firstIndex AST#member_expression#Right AST#expression#Right < AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . SWITCH_BUTTON AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.media.list_slide_to_history_location" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.list_slide_to_top' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . id ( AST#expression#Left "slide_to_history_button" AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.list_slide_to_history_jump_button_font_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.list_slide_to_history_jump_button_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.list_slide_to_history_jump_button_radius' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.list_slide_to_history_jump_button_bgc' 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.list_slide_to_history_jump_button_opacity' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.list_slide_to_history_jump_button_width' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . position ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.list_slide_to_history_jump_position_x' AST#expression#Right ) AST#resource_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#resource_expression#Left $r ( AST#expression#Left 'app.string.list_slide_to_history_jump_position_y' 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 . markAnchor ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.list_slide_to_history_jump_markAnchor_x' 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 . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { // 如果没有计时器,则执行 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . timer AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { // 当前显示的index值小于设定的SWITCH_BUTTON时,按钮为跳转到上次浏览记录,否则为跳转到顶部 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 . firstIndex AST#member_expression#Right AST#expression#Right < AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . SWITCH_BUTTON 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 . listScroller AST#member_expression#Right AST#expression#Right . scrollTo 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 xOffset AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left yOffset AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . historyOffset AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . DEFAULT_OFFSET AST#member_expression#Right AST#expression#Right : AST#expression#Left this AST#expression#Right AST#conditional_expression#Right AST#expression#Right . historyOffset 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#object_literal#Left { AST#property_assignment#Left AST#property_name#Left duration AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . ANIMATION_DURATION AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left curve AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Curve AST#expression#Right . LinearOutSlowIn AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . historyOffset AST#member_expression#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 . listScroller 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 . yOffset AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . listScroller AST#member_expression#Right AST#expression#Right . scrollTo 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 xOffset AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left yOffset AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left animation AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left duration AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . ANIMATION_DURATION AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left curve AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Curve AST#expression#Right . LinearOutSlowIn AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 设置防抖延迟,时间为动画时长 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . timer AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left setTimeout AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . timer AST#member_expression#Right = AST#expression#Left 0 AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . ANIMATION_DURATION 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#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#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.list_slide_to_history_layout_100' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.list_slide_to_history_layout_100' 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#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Component export struct ListSlideToHistoryComponent { @State cachedCountNumber: number = 3; @State firstIndex: number = 0; listScroller: ListScroller = new ListScroller(); historyOffset: number = 0; readonly DEFAULT_OFFSET: number = 1000; readonly ANIMATION_DURATION: number = 500; readonly SWITCH_BUTTON: number = 3; private timer: number = 0; aboutToAppear(): void { getFriendMomentFromRawfile(); getFriendMomentFromRawfile(); } build() { Column() { Row() { Text($r('app.string.list_slide_to_history_near_message')) .fontSize($r('app.integer.list_slide_to_history_title_fontSize')) .fontColor($r('app.color.list_slide_to_history_title_font_color')) .fontWeight(FontWeight.Bold) .margin({ left: $r('app.integer.list_slide_to_history_title_margin_left') }) .fontFamily($r('app.string.list_slide_to_history_harmony_hei_ti')) .lineHeight($r('app.integer.list_slide_to_history_title_line_height')) .layoutWeight(ListConstants.LAYOUT_WEIGHT) } .alignItems(VerticalAlign.Center) .height($r('app.integer.list_slide_to_history_title_height')) .width($r('app.string.list_slide_to_history_layout_100')) .padding({ left: $r('app.integer.list_slide_to_history_title_padding_left'), right: $r('app.integer.list_slide_to_history_title_padding_right'), top: $r('app.integer.list_slide_to_history_title_padding_top'), bottom: $r('app.integer.list_slide_to_history_title_padding_bottom') }) List({ space: ListConstants.LIST_SPACE, scroller: this.listScroller }) { LazyForEach(momentData, (moment: FriendMoment) => { ListItem() { OneMoment({ moment: moment }) } }, (moment: FriendMoment) => moment.id) } .id("slide_to_history_list") .cachedCount(this.cachedCountNumber) .width($r('app.string.list_slide_to_history_layout_100')) .height($r('app.string.list_slide_to_history_layout_100')) .listDirection(Axis.Vertical) .divider({ strokeWidth: $r('app.integer.list_slide_to_history_divider_width'), color: $r('app.color.list_slide_to_history_divider_color'), startMargin: $r('app.integer.list_slide_to_history_list_divider_margin'), endMargin: $r('app.integer.list_slide_to_history_list_divider_margin') }) .onScrollIndex((first: number) => { this.firstIndex = first; }) Button({ type: ButtonType.Normal, stateEffect: true }){ Image(this.firstIndex < this.SWITCH_BUTTON ?$r("app.media.list_slide_to_history_location"):$r('app.media.list_slide_to_top')) } .id("slide_to_history_button") .fontColor($r('app.color.list_slide_to_history_jump_button_font_color')) .height($r('app.integer.list_slide_to_history_jump_button_height')) .borderRadius($r('app.integer.list_slide_to_history_jump_button_radius')) .backgroundColor($r('app.color.list_slide_to_history_jump_button_bgc')) .opacity($r('app.float.list_slide_to_history_jump_button_opacity')) .width($r('app.integer.list_slide_to_history_jump_button_width')) .position({ x: $r('app.string.list_slide_to_history_jump_position_x'), y: $r('app.string.list_slide_to_history_jump_position_y') }) .markAnchor({ x: $r('app.string.list_slide_to_history_jump_markAnchor_x') }) .onClick(() => { if (this.timer === 0) { if (this.firstIndex < this.SWITCH_BUTTON) { this.listScroller.scrollTo({ xOffset: 0, yOffset: this.historyOffset === 0 ? this.DEFAULT_OFFSET : this.historyOffset, animation: { duration: this.ANIMATION_DURATION, curve: Curve.LinearOutSlowIn } }); } else { this.historyOffset = this.listScroller.currentOffset().yOffset; this.listScroller.scrollTo({ xOffset: 0, yOffset: 0, animation: { duration: this.ANIMATION_DURATION, curve: Curve.LinearOutSlowIn } }); } this.timer = setTimeout(() => { this.timer = 0 }, this.ANIMATION_DURATION); } }) } .height($r('app.string.list_slide_to_history_layout_100')) .width($r('app.string.list_slide_to_history_layout_100')) } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/listslidetohistory/src/main/ets/view/ListSlideToHistory.ets#L67-L175
6a59d57b8c0ae6b3da9fec24a6d1e00fe1dd78b8
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/FileUtil.ets
arkts
fsyncSync
同步文件数据,以同步方法。 @param fd number 已打开的文件描述符。
static fsyncSync(fd: number) { fs.fsyncSync(fd); }
AST#method_declaration#Left static fsyncSync AST#parameter_list#Left ( AST#parameter#Left fd : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fs AST#expression#Right . fsyncSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left fd AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
static fsyncSync(fd: number) { fs.fsyncSync(fd); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/FileUtil.ets#L744-L746
2b298149bb213b969edc772be7c31ce52f073178
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/analytics/AdvancedAnalyticsService.ets
arkts
initialize
初始化分析服务
async initialize(context: Context): Promise<void> { try { this.context = context; this.preferences = await preferences.getPreferences(context, 'analytics_prefs'); // 加载存储的数据 await this.loadStoredData(); // 初始化预定义的用户细分 this.initializeDefaultSegments(); // 初始化预测模型 this.initializePredictionModels(); hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, 'AdvancedAnalyticsService initialized'); } catch (error) { hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to initialize AdvancedAnalyticsService: ${error}`); throw error; } }
AST#method_declaration#Left async initialize AST#parameter_list#Left ( AST#parameter#Left context : AST#type_annotation#Left AST#primary_type#Left Context AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . context AST#member_expression#Right = AST#expression#Left context 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 . preferences AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left preferences AST#expression#Right AST#await_expression#Right AST#expression#Right . getPreferences AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right , AST#expression#Left 'analytics_prefs' 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 AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . loadStoredData 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 this AST#expression#Right . initializeDefaultSegments 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 this AST#expression#Right . initializePredictionModels 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 'AdvancedAnalyticsService initialized' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Failed to initialize AdvancedAnalyticsService: 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 initialize(context: Context): Promise<void> { try { this.context = context; this.preferences = await preferences.getPreferences(context, 'analytics_prefs'); await this.loadStoredData(); this.initializeDefaultSegments(); this.initializePredictionModels(); hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, 'AdvancedAnalyticsService initialized'); } catch (error) { hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to initialize AdvancedAnalyticsService: ${error}`); throw error; } }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/analytics/AdvancedAnalyticsService.ets#L309-L329
3e5a55dde1875d0effc09576e51d5963aa6efa0b
github
2763981847/Accounting-app.git
cf8302a42588ecce1561b82e8533798157157257
entry/src/main/ets/viewmodel/PanelColors.ets
arkts
面板颜色数组 此数组包含用于显示数据面板的预定义颜色。
export const panelColors: Array<string> = [ 'rgb(248,178,9)', 'rgb(243,70,14)', 'rgb(232,87,150)', 'rgb(161,53,246)', 'rgb(79,76,247)', 'rgb(5,126,254)', 'rgb(81,181,227)', 'rgb(108,209,76)', 'rgb(143,143,143)' ]
AST#export_declaration#Left export AST#variable_declaration#Left const AST#variable_declarator#Left panelColors : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left 'rgb(248,178,9)' AST#expression#Right , AST#expression#Left 'rgb(243,70,14)' AST#expression#Right , AST#expression#Left 'rgb(232,87,150)' AST#expression#Right , AST#expression#Left 'rgb(161,53,246)' AST#expression#Right , AST#expression#Left 'rgb(79,76,247)' AST#expression#Right , AST#expression#Left 'rgb(5,126,254)' AST#expression#Right , AST#expression#Left 'rgb(81,181,227)' AST#expression#Right , AST#expression#Left 'rgb(108,209,76)' AST#expression#Right , AST#expression#Left 'rgb(143,143,143)' AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#export_declaration#Right
export const panelColors: Array<string> = [ 'rgb(248,178,9)', 'rgb(243,70,14)', 'rgb(232,87,150)', 'rgb(161,53,246)', 'rgb(79,76,247)', 'rgb(5,126,254)', 'rgb(81,181,227)', 'rgb(108,209,76)', 'rgb(143,143,143)' ]
https://github.com/2763981847/Accounting-app.git/blob/cf8302a42588ecce1561b82e8533798157157257/entry/src/main/ets/viewmodel/PanelColors.ets#L6-L16
dd347de18824bff4779370461e5ea3ee1737f5fb
github
anhao0226/harmony-music-player.git
4bc1d8f9f5fdb573af387d3ba9ad333c9beb8073
entry/src/main/ets/view_models/ArtistDetailModel.ets
arkts
@param artistId @returns
export function fetchArtistData(artistId: number): Promise<ArtistDetailData> { let queryParams = { 'id': artistId }; return new Promise(async (resolve, reject) => { try { const result = await httpRequestGet('/artists', { queryParams }); if (result['code'] === 200) { let artist = new ArtistDetailModel().formJson(result['artist']); let hotSongs: SongModel[] = []; const hotSongsJson = result['hotSongs']; if (hotSongsJson && Array.isArray(hotSongsJson)) { hotSongsJson.forEach((item) => { hotSongs.push(new SongModel().formJson(item)); }) } resolve({ artist, hotSongs }); } else { reject(new Error(`State code error ${result['code']}`)); } } catch (err) { reject(err); } }) }
AST#export_declaration#Left export AST#function_declaration#Left function fetchArtistData AST#parameter_list#Left ( AST#parameter#Left artistId : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left ArtistDetailData 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 queryParams = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left 'id' AST#property_name#Right : AST#expression#Left artistId 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#new_expression#Left new AST#expression#Left Promise AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left async AST#parameter_list#Left ( AST#parameter#Left resolve AST#parameter#Right , AST#parameter#Left reject AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left result = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left httpRequestGet AST#expression#Right AST#await_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '/artists' AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left queryParams AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left result AST#expression#Right [ AST#expression#Left 'code' AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right === AST#expression#Left 200 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left artist = 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 ArtistDetailModel 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 . formJson AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left result AST#expression#Right [ AST#expression#Left 'artist' AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left hotSongs : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left SongModel [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left hotSongsJson = AST#expression#Left AST#subscript_expression#Left AST#expression#Left result AST#expression#Right [ AST#expression#Left 'hotSongs' AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left hotSongsJson AST#expression#Right && AST#expression#Left Array AST#expression#Right AST#binary_expression#Right AST#expression#Right . isArray AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left hotSongsJson AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hotSongsJson AST#expression#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hotSongs AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left SongModel 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 . formJson 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#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left resolve AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left artist AST#property_assignment#Right , AST#property_assignment#Left hotSongs 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 reject AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Error AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` State code error AST#template_substitution#Left $ { AST#expression#Left AST#subscript_expression#Left AST#expression#Left result AST#expression#Right [ AST#expression#Left 'code' AST#expression#Right ] AST#subscript_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#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left reject AST#expression#Right AST#argument_list#Left ( AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export function fetchArtistData(artistId: number): Promise<ArtistDetailData> { let queryParams = { 'id': artistId }; return new Promise(async (resolve, reject) => { try { const result = await httpRequestGet('/artists', { queryParams }); if (result['code'] === 200) { let artist = new ArtistDetailModel().formJson(result['artist']); let hotSongs: SongModel[] = []; const hotSongsJson = result['hotSongs']; if (hotSongsJson && Array.isArray(hotSongsJson)) { hotSongsJson.forEach((item) => { hotSongs.push(new SongModel().formJson(item)); }) } resolve({ artist, hotSongs }); } else { reject(new Error(`State code error ${result['code']}`)); } } catch (err) { reject(err); } }) }
https://github.com/anhao0226/harmony-music-player.git/blob/4bc1d8f9f5fdb573af387d3ba9ad333c9beb8073/entry/src/main/ets/view_models/ArtistDetailModel.ets#L84-L106
2ad6ef04f36ddae91c567765ea4241608171d110
github
Joker-x-dev/HarmonyKit.git
f97197ce157df7f303244fba42e34918306dfb08
core/util/src/main/ets/storage/PreferencesUtil.ets
arkts
get
读取键值,若不存在返回默认值 @param {string} key 键 @param {preferences.ValueType} defaultValue 默认值 @returns {Promise<preferences.ValueType>} 读取到的值
async get(key: string, defaultValue: preferences.ValueType): Promise<preferences.ValueType> { try { const prefs: preferences.Preferences = await this.getPrefs(); return prefs.get(key, defaultValue); } catch (error) { throw this.wrapError(error, `读取键 ${key} 失败`); } }
AST#method_declaration#Left async get AST#parameter_list#Left ( AST#parameter#Left key : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left defaultValue : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left preferences . ValueType AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left preferences . ValueType 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#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left prefs : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left preferences . Preferences 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 this AST#expression#Right AST#await_expression#Right AST#expression#Right . getPrefs AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left prefs AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right , AST#expression#Left defaultValue AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; 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#throw_statement#Left throw AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . wrapError AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right , AST#expression#Left AST#template_literal#Left ` 读取键 AST#template_substitution#Left $ { AST#expression#Left key AST#expression#Right } AST#template_substitution#Right 失败 ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#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 get(key: string, defaultValue: preferences.ValueType): Promise<preferences.ValueType> { try { const prefs: preferences.Preferences = await this.getPrefs(); return prefs.get(key, defaultValue); } catch (error) { throw this.wrapError(error, `读取键 ${key} 失败`); } }
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/util/src/main/ets/storage/PreferencesUtil.ets#L61-L68
517826ad7c29b67309252f65dd5b30f0ea9a8414
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/models/managers/plan/plancurve/DayOf.ets
arkts
lessThan
判断是否小于另一个DayOf对象 @param other - 另一个DayOf对象
lessThan(other: DayOf): boolean { return this.compareTo(other) < 0; }
AST#method_declaration#Left lessThan AST#parameter_list#Left ( AST#parameter#Left other : AST#type_annotation#Left AST#primary_type#Left DayOf AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . compareTo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left other AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right < AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
lessThan(other: DayOf): boolean { return this.compareTo(other) < 0; }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/managers/plan/plancurve/DayOf.ets#L114-L116
5365724832b9e7626b1717e7218b3da46447f266
github
openharmony/applications_settings
aac607310ec30e30d1d54db2e04d055655f72730
product/phone/src/main/ets/pages/system/languageSettings/languageAndRegion/selectRegion.ets
arkts
getData
从数据源获取指定索引值的数据项 @param index 数据源索引值 @return 对应索引值的数据项
public getData(index: number): string { return this.regionArray[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 . regionArray 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.regionArray[index]; }
https://github.com/openharmony/applications_settings/blob/aac607310ec30e30d1d54db2e04d055655f72730/product/phone/src/main/ets/pages/system/languageSettings/languageAndRegion/selectRegion.ets#L210-L212
309608688771901789e70ece937a9c89276c05d3
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/ets/utils/Calc.ets
arkts
[Start function_add_har1]
export function addHar1(a: number, b: number): number { let c = a + b; console.info('DynamicImport I am har1, %d + %d = %d', a, b, c); let harName = 'har2'; import(harName).then((ns: ESObject) => { console.info('DynamicImport addHar2 4 + 5 = ' + ns.addHar2(4, 5)); }); return c; }
AST#export_declaration#Left export AST#function_declaration#Left function addHar1 AST#parameter_list#Left ( AST#parameter#Left a : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left b : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left c = AST#expression#Left AST#binary_expression#Left AST#expression#Left a AST#expression#Right + AST#expression#Left b AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'DynamicImport I am har1, %d + %d = %d' AST#expression#Right , AST#expression#Left a AST#expression#Right , AST#expression#Left b AST#expression#Right , AST#expression#Left c AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left harName = AST#expression#Left 'har2' 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#import_expression#Left import ( AST#expression#Left harName AST#expression#Right ) AST#import_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 ns : AST#type_annotation#Left AST#primary_type#Left ESObject AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'DynamicImport addHar2 4 + 5 = ' AST#expression#Right + AST#expression#Left ns AST#expression#Right AST#binary_expression#Right AST#expression#Right . addHar2 AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 4 AST#expression#Right , AST#expression#Left 5 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 c AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export function addHar1(a: number, b: number): number { let c = a + b; console.info('DynamicImport I am har1, %d + %d = %d', a, b, c); let harName = 'har2'; import(harName).then((ns: ESObject) => { console.info('DynamicImport addHar2 4 + 5 = ' + ns.addHar2(4, 5)); }); return c; }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/ArkTS/ArkTSRuntime/ArkTSModule/DynamicImport/har1/src/main/ets/utils/Calc.ets#L17-L26
1ec6ce334bbf4c82b2557b538754a73a23e263fd
gitee
L1rics06/arkTS-.git
991fd131bfdb11e2933152133c97453d86092ac0
entry/src/main/ets/pages/NetworkUtil.ets
arkts
getFriendList
获取好友列表
static getFriendList(myId: string): Promise<ResponseDao<FriendItem[]>> { // 获取当前token const token = NetworkUtil.getAuthToken(); // 确保token存在 if (!token) { console.error("未找到认证token,请先登录"); return Promise.reject("未找到认证token,请先登录"); } const params: FriendListParams = { myId }; return new Promise((resolve, reject) => { axios({ method: "POST", url: `${BASE_URL}/ddchat/friend/getList`, data: params, headers: { token: token } }) .then((res: AxiosResponse<ResponseDao<FriendItem[]>>) => { console.log('获取好友列表响应:', JSON.stringify(res)); const responseData = res.data; if (responseData.code === "S1") { console.log("成功获取好友列表"); resolve(responseData); } else { console.error("获取好友列表失败:", responseData.message); reject(responseData.message || "未知错误"); } }) .catch((error: Error) => { let errorMessage = "未知错误"; if (error instanceof Error) { errorMessage = error.message; } console.error("获取好友列表错误:", errorMessage); reject(`网络请求失败: ${errorMessage}`); }); }); }
AST#method_declaration#Left static getFriendList AST#parameter_list#Left ( AST#parameter#Left myId : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left ResponseDao AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left FriendItem [ ] 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#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { // 获取当前token AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left token = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left NetworkUtil AST#expression#Right . getAuthToken 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 // 确保token存在 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left token 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 "未找到认证token,请先登录" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Promise AST#expression#Right . reject AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "未找到认证token,请先登录" 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#variable_declaration#Left const AST#variable_declarator#Left params : AST#type_annotation#Left AST#primary_type#Left FriendListParams AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left myId AST#property_assignment#Right } AST#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#new_expression#Left new AST#expression#Left Promise AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left resolve AST#parameter#Right , AST#parameter#Left reject AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#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 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/friend/getList ` 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 params 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 token AST#property_name#Right : AST#expression#Left token 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 . 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 AST#array_type#Left FriendItem [ ] 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#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#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 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 responseData = 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 responseData 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#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left resolve AST#expression#Right AST#argument_list#Left ( AST#expression#Left responseData AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "获取好友列表失败:" AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left responseData AST#expression#Right . message AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left reject AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left responseData AST#expression#Right . message AST#member_expression#Right AST#expression#Right || AST#expression#Left "未知错误" AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . 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#variable_declaration#Left let AST#variable_declarator#Left errorMessage = AST#expression#Left "未知错误" AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left error AST#expression#Right instanceof AST#expression#Left Error 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 errorMessage = AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . message AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "获取好友列表错误:" AST#expression#Right , AST#expression#Left errorMessage AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left reject AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` 网络请求失败: AST#template_substitution#Left $ { AST#expression#Left errorMessage AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static getFriendList(myId: string): Promise<ResponseDao<FriendItem[]>> { const token = NetworkUtil.getAuthToken(); if (!token) { console.error("未找到认证token,请先登录"); return Promise.reject("未找到认证token,请先登录"); } const params: FriendListParams = { myId }; return new Promise((resolve, reject) => { axios({ method: "POST", url: `${BASE_URL}/ddchat/friend/getList`, data: params, headers: { token: token } }) .then((res: AxiosResponse<ResponseDao<FriendItem[]>>) => { console.log('获取好友列表响应:', JSON.stringify(res)); const responseData = res.data; if (responseData.code === "S1") { console.log("成功获取好友列表"); resolve(responseData); } else { console.error("获取好友列表失败:", responseData.message); reject(responseData.message || "未知错误"); } }) .catch((error: Error) => { let errorMessage = "未知错误"; if (error instanceof Error) { errorMessage = error.message; } console.error("获取好友列表错误:", errorMessage); reject(`网络请求失败: ${errorMessage}`); }); }); }
https://github.com/L1rics06/arkTS-.git/blob/991fd131bfdb11e2933152133c97453d86092ac0/entry/src/main/ets/pages/NetworkUtil.ets#L408-L453
de8e6501da72b4c5fd1f47f26ec86f0225ff04e5
github
openharmony-tpc/ohos_mpchart
4fb43a7137320ef2fee2634598f53d93975dfb4a
library/src/main/ets/components/data/DataSet.ets
arkts
setEntries
Sets the array of entries that this DataSet represents, and calls notifyDataSetChanged() @return
public setEntries(entries: JArrayList<T>): void { this.mEntries = entries; this.notifyDataSetChanged(); }
AST#method_declaration#Left public setEntries AST#parameter_list#Left ( AST#parameter#Left entries : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left JArrayList AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mEntries AST#member_expression#Right = AST#expression#Left entries 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 . notifyDataSetChanged AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
public setEntries(entries: JArrayList<T>): void { this.mEntries = entries; this.notifyDataSetChanged(); }
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/data/DataSet.ets#L168-L171
f2369aaa4b37f93aaaf27e05773e027f43c23d93
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/BasicFeature/Media/CustomScan/customscan/Index.ets
arkts
CustomScanPage
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 { CustomScanPage } from './src/main/ets/pages/CustomScanPage';
AST#export_declaration#Left export { CustomScanPage } from './src/main/ets/pages/CustomScanPage' ; AST#export_declaration#Right
export { CustomScanPage } from './src/main/ets/pages/CustomScanPage';
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/BasicFeature/Media/CustomScan/customscan/Index.ets#L16-L16
118370398bcae6dc2fbf8df76873f5dd821deb44
gitee
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
feature/feedback/src/main/ets/navigation/FeedbackSubmitNav.ets
arkts
FeedbackSubmitNav
@file 提交反馈页面导航入口 @returns {void} 无返回值 @author Joker.X
@Builder export function FeedbackSubmitNav(): void { FeedbackSubmitPage(); }
AST#decorated_export_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right export function FeedbackSubmitNav AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#ui_custom_component_statement#Left FeedbackSubmitPage ( ) ; AST#ui_custom_component_statement#Right } AST#builder_function_body#Right AST#decorated_export_declaration#Right
@Builder export function FeedbackSubmitNav(): void { FeedbackSubmitPage(); }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/feedback/src/main/ets/navigation/FeedbackSubmitNav.ets#L8-L11
0d65afcf68d803b1731e8c392e04536f1526899b
github
openharmony-tpc/ImageKnife
bc55de9e2edd79ed4646ce37177ad94b432874f7
library/src/main/ets/model/ImageKnifeOption.ets
arkts
请求回调
export interface OnLoadCallBack { // 请求开始 onLoadStart?: (request?: ImageKnifeRequest) => void; // 请求成功 onLoadSuccess?: (data: string | PixelMap | undefined, imageKnifeData: ImageKnifeData, request?: ImageKnifeRequest) => void; // 请求结束 onLoadFailed?: (err: string, request?: ImageKnifeRequest) => void; // 请求取消 onLoadCancel?: (reason: string, request?: ImageKnifeRequest) => void; }
AST#export_declaration#Left export AST#interface_declaration#Left interface OnLoadCallBack AST#object_type#Left { // 请求开始 AST#type_member#Left onLoadStart ? : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left request ? : AST#type_annotation#Left AST#primary_type#Left ImageKnifeRequest 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#type_member#Right ; // 请求成功 AST#type_member#Left onLoadSuccess ? : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left PixelMap 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#Left imageKnifeData : AST#type_annotation#Left AST#primary_type#Left ImageKnifeData AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left request ? : AST#type_annotation#Left AST#primary_type#Left ImageKnifeRequest 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#type_member#Right ; // 请求结束 AST#type_member#Left onLoadFailed ? : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left err : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left request ? : AST#type_annotation#Left AST#primary_type#Left ImageKnifeRequest 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#type_member#Right ; // 请求取消 AST#type_member#Left onLoadCancel ? : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left reason : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left request ? : AST#type_annotation#Left AST#primary_type#Left ImageKnifeRequest 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#type_member#Right ; } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
export interface OnLoadCallBack { onLoadStart?: (request?: ImageKnifeRequest) => void; onLoadSuccess?: (data: string | PixelMap | undefined, imageKnifeData: ImageKnifeData, request?: ImageKnifeRequest) => void; onLoadFailed?: (err: string, request?: ImageKnifeRequest) => void; onLoadCancel?: (reason: string, request?: ImageKnifeRequest) => void; }
https://github.com/openharmony-tpc/ImageKnife/blob/bc55de9e2edd79ed4646ce37177ad94b432874f7/library/src/main/ets/model/ImageKnifeOption.ets#L94-L105
b88d81cd18b1da2cbd347625f57854c8194c9aa5
gitee
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
feature/main/src/main/ets/viewmodel/MainViewModel.ets
arkts
getRawFileAnimationData
从 rawfile 资源文件夹中获取 json 动画对象 @param path 资源文件路径
getRawFileAnimationData(path: string): Object { const context: Context = ContextUtil.getUIAbilityCtx(); const data: Uint8Array = context.resourceManager.getRawFileContentSync(path) const decoder = util.TextDecoder.create('utf-8', { ignoreBOM: true }) return JSON.parse(decoder.decodeToString(data)) }
AST#method_declaration#Left getRawFileAnimationData AST#parameter_list#Left ( AST#parameter#Left path : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left context : AST#type_annotation#Left AST#primary_type#Left Context 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 ContextUtil AST#expression#Right . getUIAbilityCtx 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 data : AST#type_annotation#Left AST#primary_type#Left Uint8Array AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#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 . getRawFileContentSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left path AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left decoder = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left util AST#expression#Right . TextDecoder AST#member_expression#Right AST#expression#Right . create AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'utf-8' AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left ignoreBOM AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#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 . parse 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 decoder AST#expression#Right . decodeToString 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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
getRawFileAnimationData(path: string): Object { const context: Context = ContextUtil.getUIAbilityCtx(); const data: Uint8Array = context.resourceManager.getRawFileContentSync(path) const decoder = util.TextDecoder.create('utf-8', { ignoreBOM: true }) return JSON.parse(decoder.decodeToString(data)) }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/main/src/main/ets/viewmodel/MainViewModel.ets#L36-L41
533f699002b7a0c8a34ae32e2df9d56fc79a5311
github
liuchao0739/arkTS_universal_starter.git
0ca845f5ae0e78db439dc09f712d100c0dd46ed3
entry/src/main/ets/services/CartService.ets
arkts
removeFromCart
从购物车移除
async removeFromCart(productId: string): Promise<void> { this.cartItems = this.cartItems.filter(item => item.productId !== productId); await this.saveCart(); }
AST#method_declaration#Left async removeFromCart AST#parameter_list#Left ( AST#parameter#Left productId : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#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 . cartItems 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 . cartItems 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 item => AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . productId AST#member_expression#Right AST#expression#Right !== AST#expression#Left productId AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right 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 . saveCart 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 removeFromCart(productId: string): Promise<void> { this.cartItems = this.cartItems.filter(item => item.productId !== productId); await this.saveCart(); }
https://github.com/liuchao0739/arkTS_universal_starter.git/blob/0ca845f5ae0e78db439dc09f712d100c0dd46ed3/entry/src/main/ets/services/CartService.ets#L92-L95
a35e0fd64dd22596dd5da31051b0e505beeabe12
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/pages/AnonymousKeyProof.ets
arkts
anonAttestKeyItem
4.证明密钥
function anonAttestKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { return new Promise<huks.HuksReturnResult>((resolve, reject) => { try { huks.anonAttestKeyItem(keyAlias, huksOptions, (error, data) => { if (error) { reject(error); } else { resolve(data); } }); } catch (error) { throwObject.isThrow = true; throw (error as Error); } }); }
AST#function_declaration#Left function anonAttestKeyItem AST#parameter_list#Left ( AST#parameter#Left keyAlias : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left huksOptions : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left huks . HuksOptions AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left throwObject : AST#type_annotation#Left AST#primary_type#Left ThrowObject AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Promise AST#expression#Right AST#new_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left huks . HuksReturnResult AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left resolve AST#parameter#Right , AST#parameter#Left reject AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left huks AST#expression#Right . anonAttestKeyItem AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left keyAlias AST#expression#Right , AST#expression#Left huksOptions AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left error 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 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 reject AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left resolve AST#expression#Right AST#argument_list#Left ( AST#expression#Left data AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left throwObject AST#expression#Right . isThrow AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#throw_statement#Left throw 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 Error AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ; AST#throw_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right
function anonAttestKeyItem(keyAlias: string, huksOptions: huks.HuksOptions, throwObject: ThrowObject) { return new Promise<huks.HuksReturnResult>((resolve, reject) => { try { huks.anonAttestKeyItem(keyAlias, huksOptions, (error, data) => { if (error) { reject(error); } else { resolve(data); } }); } catch (error) { throwObject.isThrow = true; throw (error as Error); } }); }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/Security/UniversalKeystoreKit/KeyProving/DevelopmentGuidelines/AnonymousKeyProof/entry/src/main/ets/pages/AnonymousKeyProof.ets#L139-L154
abc3f400fa7632be8bdea69b3810086b4ce1306c
gitee
851432669/Smart-Home-ArkTs-Hi3861.git
0451f85f072ed3281cc23d9cdc2843d79f60f975
entry/src/main/ets/pages/RegisterPage.ets
arkts
httpRequest
释放HTTP客户端资源
httpRequest.destroy();
AST#method_declaration#Left httpRequest AST#ERROR#Left . destroy AST#ERROR#Right AST#parameter_list#Left ( ) AST#parameter_list#Right ; AST#method_declaration#Right
httpRequest.destroy();
https://github.com/851432669/Smart-Home-ArkTs-Hi3861.git/blob/0451f85f072ed3281cc23d9cdc2843d79f60f975/entry/src/main/ets/pages/RegisterPage.ets#L192-L192
9e1be007e1100fb398c4495a3a8c4ac8752cfdae
github
openharmony/interface_sdk-js
c349adc73e2ec1f61f6fca489b5af059e3ed6999
api/@ohos.file.PhotoPickerComponent.d.ets
arkts
PickerOptions Object @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core @atomicservice @since 12
export declare class PickerOptions extends photoAccessHelper.BaseSelectOptions { /** * Support set checkBox color * * @type { ?string } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 12 */ checkBoxColor?: string; /** * Support set backgroundColor * * @type { ?string } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 12 */ backgroundColor?: string; /** * Support set gridMargin * * @type { ?Margin } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 14 */ gridMargin?: Margin; /** * Support set photoBrowserMargin * * @type { ?Margin } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 14 */ photoBrowserMargin?: Margin; /** * Support to set offset between first grid item and the top of the grid * * @type { ?number } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 20 */ gridStartOffset?: number; /** * Support to set offset between last grid item and the bottom of the grid * * @type { ?number } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 20 */ gridEndOffset?: number; /** * Support repeat select * * @type { ?boolean } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 12 */ isRepeatSelectSupported?: boolean; /** * Support to set checkbox text color * * @type { ?string } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 12 */ checkboxTextColor?: string; /** * Support to set photo browser background color mode * * @type { ?PickerColorMode } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 12 */ photoBrowserBackgroundColorMode?: PickerColorMode; /** * Support to set max select number remind mode. * * @type { ?ReminderMode } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 12 */ maxSelectedReminderMode?: ReminderMode; /** * Support to set display orientation * * @type { ?PickerOrientation } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 12 */ orientation?: PickerOrientation; /** * Support to set select mode * * @type { ?SelectMode } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 12 */ selectMode?: SelectMode; /** * Support to set max photo select number * * @type { ?number } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 12 */ maxPhotoSelectNumber?: number; /** * Support to set max video select number * * @type { ?number } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 12 */ maxVideoSelectNumber?: number; /** * Support to set sliding selection * * @type { ?boolean } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 13 */ isSlidingSelectionSupported?: boolean; /** * Support to set photo browser checkbox position * * @type { ?[number, number] } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 13 */ photoBrowserCheckboxPosition?: [number, number]; /** * Single-line display mode for the PhotoPickerComponent. * * @type { ?SingleLineConfig } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 20 */ singleLineConfig?: SingleLineConfig; /** * Support to set UIComponent color mode. * * @type { ?PickerColorMode } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 20 */ uiComponentColorMode?: PickerColorMode; /** * Support to set a serial number to distinguish different picker components. Default value is -1. * * @type { ?number } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 21 */ pickerIndex?: number; /** * Support automatically selecting the user-selected image/video on the PhotoPickerComponent * at the specified picker index. * * @type { ?Array<PreselectedInfo> } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 21 */ preselectedInfos?: Array<PreselectedInfo>; /** * * Support to config special badge display. * The picker component supports only one type of badge * * @type { ?BadgeConfig } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 21 */ badgeConfig?: BadgeConfig; }
AST#export_declaration#Left export AST#ERROR#Left declare AST#ERROR#Right AST#class_declaration#Left class PickerOptions extends AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left photoAccessHelper . BaseSelectOptions AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#class_body#Left { /** * Support set checkBox color * * @type { ?string } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 12 */ AST#property_declaration#Left checkBoxColor ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Support set backgroundColor * * @type { ?string } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 12 */ AST#property_declaration#Left backgroundColor ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Support set gridMargin * * @type { ?Margin } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 14 */ AST#property_declaration#Left gridMargin ? : AST#type_annotation#Left AST#primary_type#Left Margin AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Support set photoBrowserMargin * * @type { ?Margin } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 14 */ AST#property_declaration#Left photoBrowserMargin ? : AST#type_annotation#Left AST#primary_type#Left Margin AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Support to set offset between first grid item and the top of the grid * * @type { ?number } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 20 */ AST#property_declaration#Left gridStartOffset ? : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Support to set offset between last grid item and the bottom of the grid * * @type { ?number } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 20 */ AST#property_declaration#Left gridEndOffset ? : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Support repeat select * * @type { ?boolean } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 12 */ AST#property_declaration#Left isRepeatSelectSupported ? : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Support to set checkbox text color * * @type { ?string } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 12 */ AST#property_declaration#Left checkboxTextColor ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Support to set photo browser background color mode * * @type { ?PickerColorMode } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 12 */ AST#property_declaration#Left photoBrowserBackgroundColorMode ? : AST#type_annotation#Left AST#primary_type#Left PickerColorMode AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Support to set max select number remind mode. * * @type { ?ReminderMode } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 12 */ AST#property_declaration#Left maxSelectedReminderMode ? : AST#type_annotation#Left AST#primary_type#Left ReminderMode AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Support to set display orientation * * @type { ?PickerOrientation } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 12 */ AST#property_declaration#Left orientation ? : AST#type_annotation#Left AST#primary_type#Left PickerOrientation AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Support to set select mode * * @type { ?SelectMode } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 12 */ AST#property_declaration#Left selectMode ? : AST#type_annotation#Left AST#primary_type#Left SelectMode AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Support to set max photo select number * * @type { ?number } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 12 */ AST#property_declaration#Left maxPhotoSelectNumber ? : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Support to set max video select number * * @type { ?number } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 12 */ AST#property_declaration#Left maxVideoSelectNumber ? : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Support to set sliding selection * * @type { ?boolean } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 13 */ AST#property_declaration#Left isSlidingSelectionSupported ? : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Support to set photo browser checkbox position * * @type { ?[number, number] } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 13 */ AST#property_declaration#Left photoBrowserCheckboxPosition ? : AST#type_annotation#Left AST#primary_type#Left AST#tuple_type#Left [ AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ] AST#tuple_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Single-line display mode for the PhotoPickerComponent. * * @type { ?SingleLineConfig } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 20 */ AST#property_declaration#Left singleLineConfig ? : AST#type_annotation#Left AST#primary_type#Left SingleLineConfig AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Support to set UIComponent color mode. * * @type { ?PickerColorMode } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 20 */ AST#property_declaration#Left uiComponentColorMode ? : AST#type_annotation#Left AST#primary_type#Left PickerColorMode AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Support to set a serial number to distinguish different picker components. Default value is -1. * * @type { ?number } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 21 */ AST#property_declaration#Left pickerIndex ? : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Support automatically selecting the user-selected image/video on the PhotoPickerComponent * at the specified picker index. * * @type { ?Array<PreselectedInfo> } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 21 */ AST#property_declaration#Left preselectedInfos ? : 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 PreselectedInfo 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 /** * * Support to config special badge display. * The picker component supports only one type of badge * * @type { ?BadgeConfig } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice * @since 21 */ AST#property_declaration#Left badgeConfig ? : AST#type_annotation#Left AST#primary_type#Left BadgeConfig AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export declare class PickerOptions extends photoAccessHelper.BaseSelectOptions { checkBoxColor?: string; backgroundColor?: string; gridMargin?: Margin; photoBrowserMargin?: Margin; gridStartOffset?: number; gridEndOffset?: number; isRepeatSelectSupported?: boolean; checkboxTextColor?: string; photoBrowserBackgroundColorMode?: PickerColorMode; maxSelectedReminderMode?: ReminderMode; orientation?: PickerOrientation; selectMode?: SelectMode; maxPhotoSelectNumber?: number; maxVideoSelectNumber?: number; isSlidingSelectionSupported?: boolean; photoBrowserCheckboxPosition?: [number, number]; singleLineConfig?: SingleLineConfig; uiComponentColorMode?: PickerColorMode; pickerIndex?: number; preselectedInfos?: Array<PreselectedInfo>; badgeConfig?: BadgeConfig; }
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.file.PhotoPickerComponent.d.ets#L335-L548
8ca2726474d9c6acb9c45e7c3fb84d88aa933272
gitee
openharmony/interface_sdk-js
c349adc73e2ec1f61f6fca489b5af059e3ed6999
api/@ohos.arkui.advanced.TreeView.d.ets
arkts
modifyNode
Modify the node name. Register an ON_ITEM_MODIFY callback to obtain the ID, parent node ID, and node name of the modified node. @syscap SystemCapability.ArkUI.ArkUI.Full @since 10 Modify the node name. Register an ON_ITEM_MODIFY callback to obtain the ID, parent node ID, and node name of the modified node. @syscap SystemCapability.ArkUI.ArkUI.Full @atomicservice @since 11
modifyNode(): void;
AST#method_declaration#Left modifyNode AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right
modifyNode(): void;
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.arkui.advanced.TreeView.d.ets#L528-L528
8c8936e1cefccbf463e4061430bb468215f6c523
gitee
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
WaterFlowSample/entry/src/main/ets/pages/DataUpdateAndAnimationPage.ets
arkts
headerRefresh
[EndExclude quick_start] 1、Refresh Loading Animation Component.
@Builder headerRefresh(): void { Column() { LoadingProgress() .color(Color.Black) .opacity(0.6) .width(36) .height(36) } .justifyContent(FlexAlign.Center) }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right headerRefresh AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left LoadingProgress ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . color ( 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 . opacity ( AST#expression#Left 0.6 AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left 36 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 36 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 . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
@Builder headerRefresh(): void { Column() { LoadingProgress() .color(Color.Black) .opacity(0.6) .width(36) .height(36) } .justifyContent(FlexAlign.Center) }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/WaterFlowSample/entry/src/main/ets/pages/DataUpdateAndAnimationPage.ets#L130-L140
4a6d80e19f2d30af2552f239264ae597dc0e0ed1
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/storage/PreferencesService.ets
arkts
getArray
获取数组值(从JSON字符串解析) @param key 键 @param defaultValue 默认值 @returns 数组值
async getArray<T>(key: string, defaultValue: T[] = []): Promise<T[]> { try { const jsonString = await this.getString(key, ''); if (!jsonString) { return defaultValue; } return JSON.parse(jsonString) as T[]; } catch (error) { hilog.error(0x0001, 'BirthdayReminder', `Failed to get array: ${error}`); return defaultValue; } }
AST#method_declaration#Left async getArray AST#type_parameters#Left < AST#type_parameter#Left T AST#type_parameter#Right > AST#type_parameters#Right AST#parameter_list#Left ( AST#parameter#Left key : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left defaultValue : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left T [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#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 T [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left jsonString = 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 . getString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right , AST#expression#Left '' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#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 jsonString AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left defaultValue AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left 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 jsonString AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left T [ ] AST#array_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 hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0001 AST#expression#Right , AST#expression#Left 'BirthdayReminder' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Failed to get array: 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 defaultValue AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async getArray<T>(key: string, defaultValue: T[] = []): Promise<T[]> { try { const jsonString = await this.getString(key, ''); if (!jsonString) { return defaultValue; } return JSON.parse(jsonString) as T[]; } catch (error) { hilog.error(0x0001, 'BirthdayReminder', `Failed to get array: ${error}`); return defaultValue; } }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/storage/PreferencesService.ets#L183-L194
7df66a09d8ad104519390bceb2f6d3c7419359d7
github
common-apps/ZRouter
5adc9c4bcca6ba7d9b323451ed464e1e9b47eee6
RouterApi/src/main/ets/api/Router.ets
arkts
redirect
@deprecated @see {ZRouter.getInstance().redirect} @param name
public static redirect(name: string) { ZRouter.getRouterMgr().redirect<ObjectOrNull>(name) }
AST#method_declaration#Left public static redirect AST#parameter_list#Left ( AST#parameter#Left name : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ZRouter AST#expression#Right . getRouterMgr AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . redirect AST#member_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left ObjectOrNull AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left name AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
public static redirect(name: string) { ZRouter.getRouterMgr().redirect<ObjectOrNull>(name) }
https://github.com/common-apps/ZRouter/blob/5adc9c4bcca6ba7d9b323451ed464e1e9b47eee6/RouterApi/src/main/ets/api/Router.ets#L427-L429
0986fd50b042b5488dc2b2a91fafd204cc60d68f
gitee
jxdiaodeyi/YX_Sports.git
af5346bd3d5003c33c306ff77b4b5e9184219893
YX_Sports/oh_modules/.ohpm/@pura+harmony-utils@1.3.6/oh_modules/@pura/harmony-utils/src/main/ets/crypto/CryptoUtil.ets
arkts
sign
对数据进行签名,异步 @param dataBlob 待签名数据 @param priKey 私钥 @param algName 指定签名算法(RSA1024|PKCS1|SHA256、RSA2048|PKCS1|SHA256、ECC256|SHA256、SM2_256|SM3、、等)。 @returns
static async sign(dataBlob: cryptoFramework.DataBlob, priKey: cryptoFramework.PriKey, algName: string): Promise<cryptoFramework.DataBlob> { let signer = cryptoFramework.createSign(algName); await signer.init(priKey); let signData = await signer.sign(dataBlob); return signData; }
AST#method_declaration#Left static async sign AST#parameter_list#Left ( AST#parameter#Left dataBlob : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . DataBlob AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left priKey : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . PriKey AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left algName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . DataBlob AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left signer = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . createSign AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left algName AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left signer AST#expression#Right AST#await_expression#Right AST#expression#Right . init AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left priKey AST#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 signData = 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 signer AST#expression#Right AST#await_expression#Right AST#expression#Right . sign AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left dataBlob 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 signData AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static async sign(dataBlob: cryptoFramework.DataBlob, priKey: cryptoFramework.PriKey, algName: string): Promise<cryptoFramework.DataBlob> { let signer = cryptoFramework.createSign(algName); await signer.init(priKey); let signData = await signer.sign(dataBlob); return signData; }
https://github.com/jxdiaodeyi/YX_Sports.git/blob/af5346bd3d5003c33c306ff77b4b5e9184219893/YX_Sports/oh_modules/.ohpm/@pura+harmony-utils@1.3.6/oh_modules/@pura/harmony-utils/src/main/ets/crypto/CryptoUtil.ets#L290-L295
ff77b7888ee30e133fed7963a7869ca60bc9e092
github
Joker-x-dev/HarmonyKit.git
f97197ce157df7f303244fba42e34918306dfb08
core/state/src/main/ets/WindowSafeAreaState.ets
arkts
获取全局窗口安全区状态实例;若不存在则创建 @returns {WindowSafeAreaState} 全局窗口安全区状态 @example const state = getWindowSafeAreaState();
export function getWindowSafeAreaState(): WindowSafeAreaState { return AppStorageV2.connect<WindowSafeAreaState>( WindowSafeAreaState, WINDOW_SAFE_AREA_STATE_KEY, () => new WindowSafeAreaState() )!; }
AST#export_declaration#Left export AST#function_declaration#Left function getWindowSafeAreaState AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left WindowSafeAreaState AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#non_null_assertion_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorageV2 AST#expression#Right . connect AST#member_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left WindowSafeAreaState AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left WindowSafeAreaState AST#expression#Right , AST#expression#Left WINDOW_SAFE_AREA_STATE_KEY AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left WindowSafeAreaState AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export function getWindowSafeAreaState(): WindowSafeAreaState { return AppStorageV2.connect<WindowSafeAreaState>( WindowSafeAreaState, WINDOW_SAFE_AREA_STATE_KEY, () => new WindowSafeAreaState() )!; }
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/state/src/main/ets/WindowSafeAreaState.ets#L75-L81
e03df3ed2d3f678e5a940a3ef12d6aaacfe74f50
github
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
Ability/StageAbilityDemo/entry/src/main/ets/viewmodel/GoodsData.ets
arkts
GoodsData is used to initialize the GoodsComponent.
export default class GoodsData { goodsName: Resource = $r('app.string.goods_list_item_1'); price: string = ''; originalPrice: string = ''; discounts: Resource = $r('app.string.goods_list_item_1_save'); label: Resource = $r('app.string.goods_list_activity_new'); goodsImg: Resource = $rawfile('index/good1.png'); goodsDescription: Resource = $r('app.string.goods_list_item_1_desc'); }
AST#export_declaration#Left export default AST#class_declaration#Left class GoodsData AST#class_body#Left { AST#property_declaration#Left goodsName : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.goods_list_item_1' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left price : 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 originalPrice : 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 discounts : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.goods_list_item_1_save' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left label : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.goods_list_activity_new' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left goodsImg : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left $rawfile AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'index/good1.png' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left goodsDescription : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.goods_list_item_1_desc' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export default class GoodsData { goodsName: Resource = $r('app.string.goods_list_item_1'); price: string = ''; originalPrice: string = ''; discounts: Resource = $r('app.string.goods_list_item_1_save'); label: Resource = $r('app.string.goods_list_activity_new'); goodsImg: Resource = $rawfile('index/good1.png'); goodsDescription: Resource = $r('app.string.goods_list_item_1_desc'); }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Ability/StageAbilityDemo/entry/src/main/ets/viewmodel/GoodsData.ets#L19-L27
3793ca27c5295fc751668365553cc8e80f503e9e
gitee
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
core/util/src/main/ets/notification/NotificationUtil.ets
arkts
取消当前应用所有已发布的通知 @returns {Promise<void>} void
export async function cancelAll(): Promise<void> { return notificationManager.cancelAll(); }
AST#export_declaration#Left export AST#function_declaration#Left async function cancelAll 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#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left notificationManager AST#expression#Right . cancelAll AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export async function cancelAll(): Promise<void> { return notificationManager.cancelAll(); }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/util/src/main/ets/notification/NotificationUtil.ets#L324-L326
1668424c96420d68dca7dfbdda24acde31fd48b3
github
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
Distributed/DistributeDraw/entry/src/main/ets/pages/Index.ets
arkts
redraw
Redraw the track.
redraw(): void { this.canvasContext.clearRect(0, 0, this.canvasContext.width, this.canvasContext.height); this.positionList.forEach((position) => { Logger.info('Index', `redraw position=${JSON.stringify(position)}`); if (position.isFirstPosition) { this.canvasContext.beginPath(); this.canvasContext.lineWidth = CommonConstants.CANVAS_LINE_WIDTH; this.canvasContext.lineJoin = CommonConstants.CANVAS_LINE_JOIN; this.canvasContext.moveTo(position.positionX, position.positionY); } else { this.canvasContext.lineTo(position.positionX, position.positionY); if (position.isEndPosition) { this.canvasContext.stroke(); } } }); }
AST#method_declaration#Left redraw AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . canvasContext AST#member_expression#Right AST#expression#Right . clearRect AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left 0 AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . canvasContext AST#member_expression#Right AST#expression#Right . width AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . canvasContext AST#member_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#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 . positionList AST#member_expression#Right AST#expression#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left position 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 . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Index' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` redraw position= 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 position 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#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left position AST#expression#Right . isFirstPosition 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 . canvasContext AST#member_expression#Right AST#expression#Right . beginPath 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . canvasContext AST#member_expression#Right AST#expression#Right . lineWidth AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . CANVAS_LINE_WIDTH AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . canvasContext AST#member_expression#Right AST#expression#Right . lineJoin AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . CANVAS_LINE_JOIN AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . canvasContext AST#member_expression#Right AST#expression#Right . moveTo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left position AST#expression#Right . positionX AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left position AST#expression#Right . positionY 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#member_expression#Left AST#expression#Left this AST#expression#Right . canvasContext AST#member_expression#Right AST#expression#Right . lineTo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left position AST#expression#Right . positionX AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left position AST#expression#Right . positionY AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left position AST#expression#Right . isEndPosition 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 . canvasContext AST#member_expression#Right AST#expression#Right . stroke AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#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
redraw(): void { this.canvasContext.clearRect(0, 0, this.canvasContext.width, this.canvasContext.height); this.positionList.forEach((position) => { Logger.info('Index', `redraw position=${JSON.stringify(position)}`); if (position.isFirstPosition) { this.canvasContext.beginPath(); this.canvasContext.lineWidth = CommonConstants.CANVAS_LINE_WIDTH; this.canvasContext.lineJoin = CommonConstants.CANVAS_LINE_JOIN; this.canvasContext.moveTo(position.positionX, position.positionY); } else { this.canvasContext.lineTo(position.positionX, position.positionY); if (position.isEndPosition) { this.canvasContext.stroke(); } } }); }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Distributed/DistributeDraw/entry/src/main/ets/pages/Index.ets#L141-L157
830ce1e0c1f603f405598bad84a828606747d588
gitee
bigbear20240612/planner_build-.git
89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1
entry/src/main/ets/entryability/EntryAbility.ets
arkts
initializeNotifications
初始化通知系统
private async initializeNotifications(): Promise<void> { try { const notificationManager = SimpleNotificationManager.getInstance(); // 初始化通知权限 const permissionsGranted = await notificationManager.initializeNotifications(); if (permissionsGranted) { hilog.info(0x0000, 'EntryAbility', 'Notification permissions granted'); // 初始化所有提醒 await notificationManager.initializeAllReminders(); hilog.info(0x0000, 'EntryAbility', 'Notification system initialized successfully'); } else { hilog.warn(0x0000, 'EntryAbility', 'Notification permissions not granted'); } } catch (error) { hilog.error(0x0000, 'EntryAbility', 'Failed to initialize notification system: %{public}s', error.message); } }
AST#method_declaration#Left private async initializeNotifications AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left notificationManager = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left SimpleNotificationManager AST#expression#Right . getInstance AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 初始化通知权限 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left permissionsGranted = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left notificationManager AST#expression#Right AST#await_expression#Right AST#expression#Right . initializeNotifications AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left permissionsGranted AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left 'EntryAbility' AST#expression#Right , AST#expression#Left 'Notification permissions granted' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 初始化所有提醒 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left notificationManager AST#expression#Right AST#await_expression#Right AST#expression#Right . initializeAllReminders 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 0x0000 AST#expression#Right , AST#expression#Left 'EntryAbility' AST#expression#Right , AST#expression#Left 'Notification system initialized successfully' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right 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 hilog AST#expression#Right . warn AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left 'EntryAbility' AST#expression#Right , AST#expression#Left 'Notification permissions not granted' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left 'EntryAbility' AST#expression#Right , AST#expression#Left 'Failed to initialize notification system: %{public}s' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . message AST#member_expression#Right AST#expression#Right ) AST#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 initializeNotifications(): Promise<void> { try { const notificationManager = SimpleNotificationManager.getInstance(); const permissionsGranted = await notificationManager.initializeNotifications(); if (permissionsGranted) { hilog.info(0x0000, 'EntryAbility', 'Notification permissions granted'); await notificationManager.initializeAllReminders(); hilog.info(0x0000, 'EntryAbility', 'Notification system initialized successfully'); } else { hilog.warn(0x0000, 'EntryAbility', 'Notification permissions not granted'); } } catch (error) { hilog.error(0x0000, 'EntryAbility', 'Failed to initialize notification system: %{public}s', error.message); } }
https://github.com/bigbear20240612/planner_build-.git/blob/89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1/entry/src/main/ets/entryability/EntryAbility.ets#L33-L51
e65498f0c90b290cadbc45f2c2f0d40f9c6bbe0b
github
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
feature/order/src/main/ets/view/OrderListPage.ets
arkts
构建订单列表页面 @returns {void} 无返回值
build() { AppNavDestination({ title: $r("app.string.order_list"), viewModel: this.vm }) { BaseNetWorkListView({ uiState: this.vm.uiState, onRetry: (): void => this.vm.retryRequest(), content: (): void => this.OrderListContent() }); OrderGoodsModal({ visible: this.vm.rebuyModalVisible, title: $r("app.string.select_goods_to_buy"), buttonText: $r("app.string.rebuy"), cartList: this.vm.rebuyCartList, onDismiss: (): void => this.vm.hideRebuyModal(), onItemButtonClick: (goodsId: number): void => this.vm.toGoodsDetailForRebuy(goodsId) }); OrderGoodsModal({ visible: this.vm.commentModalVisible, title: $r("app.string.select_goods_to_comment"), buttonText: $r("app.string.go_to_comment"), cartList: this.vm.commentCartList, onDismiss: (): void => this.vm.hideCommentModal(), onItemButtonClick: (goodsId: number): void => this.vm.toOrderCommentForGoods(goodsId) }); } }
AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left AppNavDestination ( AST#component_parameters#Left { AST#component_parameter#Left title : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.order_list" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left viewModel : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . vm AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#ui_custom_component_statement#Left BaseNetWorkListView ( AST#component_parameters#Left { AST#component_parameter#Left uiState : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . vm AST#member_expression#Right AST#expression#Right . uiState AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left onRetry : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . vm AST#member_expression#Right AST#expression#Right . retryRequest AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left content : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . OrderListContent AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) ; AST#ui_custom_component_statement#Right AST#ui_custom_component_statement#Left OrderGoodsModal ( AST#component_parameters#Left { AST#component_parameter#Left visible : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . vm AST#member_expression#Right AST#expression#Right . rebuyModalVisible AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left title : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.select_goods_to_buy" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left buttonText : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.rebuy" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left cartList : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . vm AST#member_expression#Right AST#expression#Right . rebuyCartList AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left onDismiss : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . vm AST#member_expression#Right AST#expression#Right . hideRebuyModal AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left onItemButtonClick : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left goodsId : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . vm AST#member_expression#Right AST#expression#Right . toGoodsDetailForRebuy AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left goodsId AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) ; AST#ui_custom_component_statement#Right AST#ui_custom_component_statement#Left OrderGoodsModal ( AST#component_parameters#Left { AST#component_parameter#Left visible : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . vm AST#member_expression#Right AST#expression#Right . commentModalVisible AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left title : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.select_goods_to_comment" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left buttonText : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.go_to_comment" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left cartList : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . vm AST#member_expression#Right AST#expression#Right . commentCartList AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left onDismiss : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . vm AST#member_expression#Right AST#expression#Right . hideCommentModal AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left onItemButtonClick : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left goodsId : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . vm AST#member_expression#Right AST#expression#Right . toOrderCommentForGoods AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left goodsId AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) ; AST#ui_custom_component_statement#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right
build() { AppNavDestination({ title: $r("app.string.order_list"), viewModel: this.vm }) { BaseNetWorkListView({ uiState: this.vm.uiState, onRetry: (): void => this.vm.retryRequest(), content: (): void => this.OrderListContent() }); OrderGoodsModal({ visible: this.vm.rebuyModalVisible, title: $r("app.string.select_goods_to_buy"), buttonText: $r("app.string.rebuy"), cartList: this.vm.rebuyCartList, onDismiss: (): void => this.vm.hideRebuyModal(), onItemButtonClick: (goodsId: number): void => this.vm.toGoodsDetailForRebuy(goodsId) }); OrderGoodsModal({ visible: this.vm.commentModalVisible, title: $r("app.string.select_goods_to_comment"), buttonText: $r("app.string.go_to_comment"), cartList: this.vm.commentCartList, onDismiss: (): void => this.vm.hideCommentModal(), onItemButtonClick: (goodsId: number): void => this.vm.toOrderCommentForGoods(goodsId) }); } }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/order/src/main/ets/view/OrderListPage.ets#L28-L56
680bde14d4a55766f0ce64ce09fadc148732bb98
github
zqaini002/YaoYaoLingXian.git
5095b12cbeea524a87c42d0824b1702978843d39
YaoYaoLingXian/entry/src/main/ets/services/ApiService.ets
arkts
点赞动态 @param id 动态ID
export function likePost(id: number): Promise<void> { try { console.info(`点赞动态, id: ${id}`); // 获取当前用户会话 const userSession = UserSession.getInstance(); // 确保用户已登录 if (!userSession.isLoggedIn()) { console.error('用户未登录,无法点赞'); return Promise.reject(new Error('用户未登录,请先登录')); } // 获取用户ID const userId = userSession.getUserId(); if (!userId) { console.error('无法获取当前登录用户ID'); return Promise.reject(new Error('无法获取用户ID,请重新登录')); } // 添加userId作为查询参数 const params = {} as QueryParams; params.userId = userId; return request<void>(RequestMethod.POST, `/posts/${id}/like`, params); } catch (error) { const errorMsg = `点赞动态失败: ${error instanceof Error ? error.message : String(error)}`; console.error(errorMsg); throw new Error(errorMsg); } }
AST#export_declaration#Left export AST#function_declaration#Left function likePost AST#parameter_list#Left ( AST#parameter#Left id : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_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 console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` 点赞动态, id: AST#template_substitution#Left $ { AST#expression#Left id AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 获取当前用户会话 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left userSession = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left UserSession AST#expression#Right . getInstance AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 确保用户已登录 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left userSession AST#expression#Right AST#unary_expression#Right AST#expression#Right . isLoggedIn AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '用户未登录,无法点赞' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Promise AST#expression#Right . reject AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Error AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '用户未登录,请先登录' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 获取用户ID AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left userId = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left userSession AST#expression#Right . getUserId AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left userId 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 '无法获取当前登录用户ID' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Promise AST#expression#Right . reject AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Error AST#expression#Right AST#new_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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 添加userId作为查询参数 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left params = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#object_literal#Left { } AST#object_literal#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left QueryParams 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 params 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#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left request AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left RequestMethod AST#expression#Right . POST AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` /posts/ AST#template_substitution#Left $ { AST#expression#Left id AST#expression#Right } AST#template_substitution#Right /like ` AST#template_literal#Right AST#expression#Right , AST#expression#Left params AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left errorMsg = AST#expression#Left AST#template_literal#Left ` 点赞动态失败: AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left error AST#expression#Right instanceof AST#expression#Left Error AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . message AST#member_expression#Right AST#expression#Right : AST#expression#Left String AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left errorMsg AST#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 errorMsg AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#throw_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export function likePost(id: number): Promise<void> { try { console.info(`点赞动态, id: ${id}`); const userSession = UserSession.getInstance(); if (!userSession.isLoggedIn()) { console.error('用户未登录,无法点赞'); return Promise.reject(new Error('用户未登录,请先登录')); } const userId = userSession.getUserId(); if (!userId) { console.error('无法获取当前登录用户ID'); return Promise.reject(new Error('无法获取用户ID,请重新登录')); } const params = {} as QueryParams; params.userId = userId; return request<void>(RequestMethod.POST, `/posts/${id}/like`, params); } catch (error) { const errorMsg = `点赞动态失败: ${error instanceof Error ? error.message : String(error)}`; console.error(errorMsg); throw new Error(errorMsg); } }
https://github.com/zqaini002/YaoYaoLingXian.git/blob/5095b12cbeea524a87c42d0824b1702978843d39/YaoYaoLingXian/entry/src/main/ets/services/ApiService.ets#L829-L859
5f1a51ee4d2c40dd2851fa65272292143633f551
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
harmonyos/src/main/ets/pages/CalendarPage.ets
arkts
buildUpcomingBirthdays
构建即将到来的生日列表
@Builder buildUpcomingBirthdays() { Column({ space: 12 }) { Row() { Text(this.selectedDate ? `${this.selectedDate} 生日` : '即将到来的生日') .fontSize(18) .fontWeight(FontWeight.Medium) .fontColor('#333333') .layoutWeight(1) if (!this.selectedDate) { Text(`${this.upcomingBirthdays.length}人`) .fontSize(14) .fontColor('#666666') } } .width('100%') // 生日列表 if (this.selectedDate) { this.buildSelectedDayBirthdays() } else { this.buildUpcomingBirthdaysList() } } .width('100%') .padding(16) .backgroundColor('#ffffff') .margin({ top: 8 }) .layoutWeight(1) }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildUpcomingBirthdays AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 12 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left 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#member_expression#Left AST#expression#Left this AST#expression#Right . selectedDate 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 this AST#expression#Right . selectedDate AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right 生日 ` AST#template_literal#Right 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 18 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 '#333333' AST#expression#Right ) AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . selectedDate AST#member_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . upcomingBirthdays AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right 人 ` AST#template_literal#Right AST#expression#Right ) AST#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 '#666666' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . 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#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedDate AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . buildSelectedDayBirthdays AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } else { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . buildUpcomingBirthdaysList AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#ffffff' AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left 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#Left . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
@Builder buildUpcomingBirthdays() { Column({ space: 12 }) { Row() { Text(this.selectedDate ? `${this.selectedDate} 生日` : '即将到来的生日') .fontSize(18) .fontWeight(FontWeight.Medium) .fontColor('#333333') .layoutWeight(1) if (!this.selectedDate) { Text(`${this.upcomingBirthdays.length}人`) .fontSize(14) .fontColor('#666666') } } .width('100%') if (this.selectedDate) { this.buildSelectedDayBirthdays() } else { this.buildUpcomingBirthdaysList() } } .width('100%') .padding(16) .backgroundColor('#ffffff') .margin({ top: 8 }) .layoutWeight(1) }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/harmonyos/src/main/ets/pages/CalendarPage.ets#L379-L409
03a582fa899c2f8d212a3f59facc9127792902b9
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/common/components/Privacy/PrivacyManager.ets
arkts
get
单例模式实现
static get shared(): PrivacyManager { if (!PrivacyManager.instance) { PrivacyManager.instance = new PrivacyManager(); } return PrivacyManager.instance; }
AST#method_declaration#Left static get AST#ERROR#Left shared AST#ERROR#Right AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left PrivacyManager AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left PrivacyManager AST#expression#Right AST#unary_expression#Right AST#expression#Right . instance AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left PrivacyManager AST#expression#Right . instance AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left PrivacyManager AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#expression_statement#Left AST#expression#Left return AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left PrivacyManager AST#expression#Right . instance AST#member_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
static get shared(): PrivacyManager { if (!PrivacyManager.instance) { PrivacyManager.instance = new PrivacyManager(); } return PrivacyManager.instance; }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/components/Privacy/PrivacyManager.ets#L14-L19
d16e3b6c02904a468ad2fef9aaf11778b4a57aee
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/common/components/Sounds/Cloud/Download/CDownloadable/CosService.ets
arkts
initTencentCos
MARK: - 初始化腾讯云COS
private initTencentCos(): void { //////////////////////////////////////////////////////////// ///Cos配置鸿蒙版: https://cloud.tencent.com/document/product/436/112125 //////////////////////////////////////////////////////////// // 服务配置 let cosXmlServiceConfig = new CosXmlServiceConfig(StringEncoder.removedSalt(CosConfig.region)!!); // 初始化默认的 Service CosXmlBaseService.initDefaultService( getAppContext(), cosXmlServiceConfig // 可以不设置临时密钥回调 ) }
AST#method_declaration#Left private initTencentCos 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 { //////////////////////////////////////////////////////////// ///Cos配置鸿蒙版: https://cloud.tencent.com/document/product/436/112125 //////////////////////////////////////////////////////////// // 服务配置 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left cosXmlServiceConfig = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left CosXmlServiceConfig AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#non_null_assertion_expression#Left AST#expression#Left AST#non_null_assertion_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left StringEncoder AST#expression#Right . removedSalt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CosConfig AST#expression#Right . region AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right ! AST#non_null_assertion_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 // 初始化默认的 Service AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CosXmlBaseService AST#expression#Right . initDefaultService AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left getAppContext AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left cosXmlServiceConfig AST#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 initTencentCos(): void { let cosXmlServiceConfig = new CosXmlServiceConfig(StringEncoder.removedSalt(CosConfig.region)!!); CosXmlBaseService.initDefaultService( getAppContext(), cosXmlServiceConfig ) }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/components/Sounds/Cloud/Download/CDownloadable/CosService.ets#L42-L57
9b219ce9e054ab9ed7ed26167a58ce070fb064c5
github
Application-Security-Automation/Arktan.git
3ad9cb05235e38b00cd5828476aa59a345afa1c0
dataset/completeness/expression/basic_expression_operation/binary_expression_add_assignment_001_T.ets
arkts
Introduction 基础表达式运算-二元运算-加等
export function binary_expression_add_assignment_001_T(taint_src : string) { let t = "_"; t += taint_src; taint.Sink(t); }
AST#export_declaration#Left export AST#function_declaration#Left function binary_expression_add_assignment_001_T AST#parameter_list#Left ( AST#parameter#Left taint_src : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left t = AST#expression#Left "_" 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 t += AST#expression#Left taint_src 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 taint AST#expression#Right . Sink AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left t AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export function binary_expression_add_assignment_001_T(taint_src : string) { let t = "_"; t += taint_src; taint.Sink(t); }
https://github.com/Application-Security-Automation/Arktan.git/blob/3ad9cb05235e38b00cd5828476aa59a345afa1c0/dataset/completeness/expression/basic_expression_operation/binary_expression_add_assignment_001_T.ets#L6-L10
187897e43e52bd8debc2cae5a9306c7e1de9c338
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/multimodaltransion/Index.ets
arkts
HalfModalWindowComponent
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 { HalfModalWindowComponent } from './src/main/ets/view/HalfModalWindow';
AST#export_declaration#Left export { HalfModalWindowComponent } from './src/main/ets/view/HalfModalWindow' ; AST#export_declaration#Right
export { HalfModalWindowComponent } from './src/main/ets/view/HalfModalWindow';
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/multimodaltransion/Index.ets#L15-L15
f5c4110629a2226160fb05d8efc86495ff808d31
gitee
openharmony/developtools_profiler
73d26bb5acfcafb2b1f4f94ead5640241d1e5f73
host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/highlight/Highlight.ets
arkts
getXPx
returns the x-position of the highlight in pixels
public getXPx(): number { return this.mXPx; }
AST#method_declaration#Left public getXPx 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 . mXPx AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
public getXPx(): number { return this.mXPx; }
https://github.com/openharmony/developtools_profiler/blob/73d26bb5acfcafb2b1f4f94ead5640241d1e5f73/host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/highlight/Highlight.ets#L121-L123
71f27c2b40aab40f1eadf0ec8f97aa0980916fbd
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/settings/SettingsService.ets
arkts
getNotificationSettings
获取通知设置 @returns 通知设置
async getNotificationSettings(): Promise<NotificationSettings> { const settings = await this.getSettings(); return settings.notification; }
AST#method_declaration#Left async getNotificationSettings 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 NotificationSettings 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 settings = 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 . getSettings 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#member_expression#Left AST#expression#Left settings AST#expression#Right . notification AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async getNotificationSettings(): Promise<NotificationSettings> { const settings = await this.getSettings(); return settings.notification; }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/settings/SettingsService.ets#L191-L194
d5b1e4b75715b144ddcb75260c7d1ca76cd8c08f
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/slidetohideanddisplace/src/main/ets/view/SlideToHideAndDisplace.ets
arkts
iconAndDescription
自定义构建函数,将重复使用的UI元素抽象成一个方法。此处样式为:上方图标下方文字
@Builder iconAndDescription(icon: Resource, description: string | Resource, iconSize?: Size, radius?: number, handleClick?: () => void) { Column() { Image(icon) .size(iconSize === undefined ? { height: $r('app.integer.slidetohideanddisplace_icon_default_height'), width: $r('app.integer.slidetohideanddisplace_icon_default_height') } : iconSize) .borderRadius(radius) Text(description) .margin({ top: $r('app.integer.slidetohideanddisplace_margin_between_icon_and_description') }) } .onClick(() => { // 修改的主要目的是为了让开发者方便找到业务代码,然后修改成自己的业务 if (handleClick) { promptAction.showToast({ message: description }); } }) }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right iconAndDescription AST#parameter_list#Left ( AST#parameter#Left icon : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left description : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left Resource AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left iconSize ? : AST#type_annotation#Left AST#primary_type#Left Size AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left radius ? : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left handleClick ? : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left icon AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . size ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left iconSize AST#expression#Right === AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left height AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.slidetohideanddisplace_icon_default_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.slidetohideanddisplace_icon_default_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right : AST#expression#Left iconSize AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left radius 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 description AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.slidetohideanddisplace_margin_between_icon_and_description' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { // 修改的主要目的是为了让开发者方便找到业务代码,然后修改成自己的业务 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left handleClick 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 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 description 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#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
@Builder iconAndDescription(icon: Resource, description: string | Resource, iconSize?: Size, radius?: number, handleClick?: () => void) { Column() { Image(icon) .size(iconSize === undefined ? { height: $r('app.integer.slidetohideanddisplace_icon_default_height'), width: $r('app.integer.slidetohideanddisplace_icon_default_height') } : iconSize) .borderRadius(radius) Text(description) .margin({ top: $r('app.integer.slidetohideanddisplace_margin_between_icon_and_description') }) } .onClick(() => { if (handleClick) { promptAction.showToast({ message: description }); } }) }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/slidetohideanddisplace/src/main/ets/view/SlideToHideAndDisplace.ets#L92-L111
e04faef013e0489e193e124ea40939178769c468
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/pages/contacts/ContactImportPage.ets
arkts
parseCsvContent
解析CSV内容
private parseCsvContent() { if (!this.csvContent.trim()) { this.csvParseResult = null; return; } this.csvParseResult = CsvParser.parseCsvContent(this.csvContent); hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `CSV parsed: ${this.csvParseResult.validRows}/${this.csvParseResult.totalRows} valid`); }
AST#method_declaration#Left private parseCsvContent AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 . csvContent AST#member_expression#Right AST#expression#Right . trim AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#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 . csvParseResult AST#member_expression#Right = AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . csvParseResult AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CsvParser AST#expression#Right . parseCsvContent 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 . csvContent 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 hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` CSV parsed: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . csvParseResult AST#member_expression#Right AST#expression#Right . validRows 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . csvParseResult AST#member_expression#Right AST#expression#Right . totalRows AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right valid ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private parseCsvContent() { if (!this.csvContent.trim()) { this.csvParseResult = null; return; } this.csvParseResult = CsvParser.parseCsvContent(this.csvContent); hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `CSV parsed: ${this.csvParseResult.validRows}/${this.csvParseResult.totalRows} valid`); }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/contacts/ContactImportPage.ets#L801-L810
f6299b6d41d6c00eb5a3f116b890bd3bc3e9a8b5
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/styledtext/src/main/ets/components/TextAndSpanComponent.ets
arkts
videoLinkSpanBuilder
带有图标的视频链接Span组件
@Builder videoLinkSpanBuilder(item: MyCustomSpan) { ContainerSpan() { ImageSpan(this.videoLinkIcon) .height($r('app.integer.styled_text_video_link_icon_height')) .verticalAlign(ImageSpanAlignment.CENTER) .onClick(() => { setTimeout(() => { this.clickSpanId = ''; }, this.backgroundChangeDelay) this.clickSpanId = item.id; if(this.linkClickCallback){ this.linkClickCallback(item); } }) Span(item.content) .fontColor(this.linkColor) .fontSize(this.linkFontSize) .onClick(() => { setTimeout(() => { this.clickSpanId = ''; }, this.backgroundChangeDelay) this.clickSpanId = item.id; if(this.linkClickCallback){ this.linkClickCallback(item); } }) } .textBackgroundStyle({ color: this.clickSpanId === item.id ? $r('app.color.styled_text_link_clicked_background_color') : Color.Transparent }) }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right videoLinkSpanBuilder AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left MyCustomSpan 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 ContainerSpan ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left ImageSpan ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . videoLinkIcon AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.styled_text_video_link_icon_height' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . verticalAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left ImageSpanAlignment AST#expression#Right . CENTER AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left setTimeout AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . clickSpanId AST#member_expression#Right = AST#expression#Left '' AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . backgroundChangeDelay AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . clickSpanId 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#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . linkClickCallback AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . linkClickCallback 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#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#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 Span ( AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . content AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . linkColor AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . linkFontSize AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left setTimeout AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . clickSpanId AST#member_expression#Right = AST#expression#Left '' AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . backgroundChangeDelay AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . clickSpanId 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#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . linkClickCallback AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . linkClickCallback 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#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#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . textBackgroundStyle ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left 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 . clickSpanId 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.color.styled_text_link_clicked_background_color' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left Color AST#expression#Right AST#conditional_expression#Right AST#expression#Right . Transparent AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
@Builder videoLinkSpanBuilder(item: MyCustomSpan) { ContainerSpan() { ImageSpan(this.videoLinkIcon) .height($r('app.integer.styled_text_video_link_icon_height')) .verticalAlign(ImageSpanAlignment.CENTER) .onClick(() => { setTimeout(() => { this.clickSpanId = ''; }, this.backgroundChangeDelay) this.clickSpanId = item.id; if(this.linkClickCallback){ this.linkClickCallback(item); } }) Span(item.content) .fontColor(this.linkColor) .fontSize(this.linkFontSize) .onClick(() => { setTimeout(() => { this.clickSpanId = ''; }, this.backgroundChangeDelay) this.clickSpanId = item.id; if(this.linkClickCallback){ this.linkClickCallback(item); } }) } .textBackgroundStyle({ color: this.clickSpanId === item.id ? $r('app.color.styled_text_link_clicked_background_color') : Color.Transparent }) }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/styledtext/src/main/ets/components/TextAndSpanComponent.ets#L120-L152
ca4bb2aa11190aab96e32d44ebd246404e602160
gitee
TianQvQ/WeChat_ArkTs.git
077ddcdb8e8032f71f45540461fbd66f2d49c973
entry/src/main/ets/Toptag/StatusBarManager.ets
arkts
immerseColor
沉浸式状态栏颜色和状态栏icon 一般推荐这个方案,但这个目前仅是api先支持,部分系统还未跟进支持(目前大多数设备无效) 在Ability或Component中使用都可
static async immerseColor(color?: string, light?: boolean) { // 获取当前应用窗口 let windowClass: window.Window = await window.getLastWindow(getContext()) // 将状态栏和导航栏的背景色设置为跟应用窗口相同的颜色 await windowClass.setWindowSystemBarProperties({ navigationBarColor: color, statusBarColor: color, navigationBarContentColor: color, statusBarContentColor: color, isStatusBarLightIcon: light, isNavigationBarLightIcon: light }) }
AST#method_declaration#Left static async immerseColor 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 light ? : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { // 获取当前应用窗口 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left windowClass : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left window AST#expression#Right AST#await_expression#Right AST#expression#Right . getLastWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left getContext AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right // 将状态栏和导航栏的背景色设置为跟应用窗口相同的颜色 AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left windowClass AST#expression#Right AST#await_expression#Right AST#expression#Right . setWindowSystemBarProperties 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 navigationBarColor AST#property_name#Right : AST#expression#Left color AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left statusBarColor AST#property_name#Right : AST#expression#Left color AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left navigationBarContentColor AST#property_name#Right : AST#expression#Left color AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left statusBarContentColor AST#property_name#Right : AST#expression#Left color AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left isStatusBarLightIcon AST#property_name#Right : AST#expression#Left light AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left isNavigationBarLightIcon AST#property_name#Right : AST#expression#Left light 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#method_declaration#Right
static async immerseColor(color?: string, light?: boolean) { let windowClass: window.Window = await window.getLastWindow(getContext()) await windowClass.setWindowSystemBarProperties({ navigationBarColor: color, statusBarColor: color, navigationBarContentColor: color, statusBarContentColor: color, isStatusBarLightIcon: light, isNavigationBarLightIcon: light }) }
https://github.com/TianQvQ/WeChat_ArkTs.git/blob/077ddcdb8e8032f71f45540461fbd66f2d49c973/entry/src/main/ets/Toptag/StatusBarManager.ets#L14-L26
6f7f7569a74cff2c95547ee43660091299e9b21d
github
jjjjjjava/ffmpeg_tools.git
6c73f7540bc7ca3f0d5b3edd7a6c10cb84a26161
src/main/ets/ffmpeg/FFmpegFactory.ets
arkts
imagesToVideo
图片序列合成视频 @param inputPattern 输入图片路径模式,如 "/path/frame_%04d.jpg" @param output 输出视频路径 @param fps 视频帧率,默认 25
public static imagesToVideo(inputPattern: string, output: string, fps: number = 25): string[] { return [ 'ffmpeg', '-framerate', fps.toString(), '-i', inputPattern, '-c:v', FFmpegFactory.HW_CODEC, '-pix_fmt', 'yuv420p', '-y', output ]; }
AST#method_declaration#Left public static imagesToVideo AST#parameter_list#Left ( AST#parameter#Left inputPattern : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left output : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left fps : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 25 AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#array_literal#Left [ AST#expression#Left 'ffmpeg' AST#expression#Right , AST#expression#Left '-framerate' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fps 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 '-i' AST#expression#Right , AST#expression#Left inputPattern AST#expression#Right , AST#expression#Left '-c:v' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left FFmpegFactory AST#expression#Right . HW_CODEC AST#member_expression#Right AST#expression#Right , AST#expression#Left '-pix_fmt' AST#expression#Right , AST#expression#Left 'yuv420p' AST#expression#Right , AST#expression#Left '-y' AST#expression#Right , AST#expression#Left output AST#expression#Right ] AST#array_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
public static imagesToVideo(inputPattern: string, output: string, fps: number = 25): string[] { return [ 'ffmpeg', '-framerate', fps.toString(), '-i', inputPattern, '-c:v', FFmpegFactory.HW_CODEC, '-pix_fmt', 'yuv420p', '-y', output ]; }
https://github.com/jjjjjjava/ffmpeg_tools.git/blob/6c73f7540bc7ca3f0d5b3edd7a6c10cb84a26161/src/main/ets/ffmpeg/FFmpegFactory.ets#L277-L286
cc8e354abf269c752fc4f639a7a66136261f14b8
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/waterFlow/WaterFlowDataSource.ets
arkts
实现IDataSource接口的对象,用于瀑布流组件加载数据
export class WaterFlowDataSource implements IDataSource { private dataArray: number[] = []; private listeners: DataChangeListener[] = []; constructor(count: number) { for (let i = 0; i < count; i++) { this.dataArray.push(i); } } // 获取索引对应的数据 public getData(index: number): number { return this.dataArray[index]; } // 通知控制器数据重新加载 notifyDataReload(): void { this.listeners.forEach(listener => { listener.onDataReloaded(); }) } // 通知控制器数据增加 notifyDataAdd(index: number): void { this.listeners.forEach(listener => { listener.onDataAdd(index); }) } // 通知控制器数据变化 notifyDataChange(index: number): void { this.listeners.forEach(listener => { listener.onDataChange(index); }) } // 通知控制器数据删除 notifyDataDelete(index: number): void { this.listeners.forEach(listener => { listener.onDataDelete(index); }) } // 通知控制器数据位置变化 notifyDataMove(from: number, to: number): void { this.listeners.forEach(listener => { listener.onDataMove(from, to); }) } // 获取数据总数 public totalCount(): number { return this.dataArray.length; } // 注册改变数据的控制器 registerDataChangeListener(listener: DataChangeListener): void { if (this.listeners.indexOf(listener) < 0) { this.listeners.push(listener); } } // 注销改变数据的控制器 unregisterDataChangeListener(listener: DataChangeListener): void { const pos = this.listeners.indexOf(listener) if (pos >= 0) { this.listeners.splice(pos, 1); } } // 增加数据 public add1stItem(): void { this.dataArray.splice(0, 0, this.dataArray.length); this.notifyDataAdd(0); } // 在数据尾部增加一个元素 public addLastItem(): void { this.dataArray.splice(this.dataArray.length, 0, this.dataArray.length); this.notifyDataAdd(this.dataArray.length - 1); } public addNewItems(count: number): void { for (let i = 0; i < count; i++) { this.dataArray.push(this.dataArray.length); this.notifyDataAdd(this.dataArray.length - 1); } } // 在指定索引位置增加一个元素 public addItem(index: number): void { this.dataArray.splice(index, 0, this.dataArray.length); this.notifyDataAdd(index); } // 删除第一个元素 public delete1stItem(): void { this.dataArray.splice(0, 1); this.notifyDataDelete(0); } // 删除第二个元素 public delete2ndItem(): void { this.dataArray.splice(1, 1); this.notifyDataDelete(1); } // 删除最后一个元素 public deleteLastItem(): void { this.dataArray.splice(-1, 1); this.notifyDataDelete(this.dataArray.length); } // 在指定索引位置增加一个元素 public deleteItem(index: number): void { this.dataArray.splice(index, 1); this.notifyDataDelete(index); } // 重新加载数据 public reload(): void { this.dataArray.splice(1, 1); this.dataArray.splice(3, 2); this.notifyDataReload(); } }
AST#export_declaration#Left export AST#class_declaration#Left class WaterFlowDataSource AST#implements_clause#Left implements IDataSource AST#implements_clause#Right AST#class_body#Left { AST#property_declaration#Left private dataArray : 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 [ ] AST#array_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private listeners : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left DataChangeListener [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left count : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left count AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataArray AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left i AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right // 获取索引对应的数据 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 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#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataArray AST#member_expression#Right AST#expression#Right [ AST#expression#Left index AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right // 通知控制器数据重新加载 AST#method_declaration#Left notifyDataReload AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . listeners AST#member_expression#Right AST#expression#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left listener => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left listener AST#expression#Right . onDataReloaded AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right // 通知控制器数据增加 AST#method_declaration#Left notifyDataAdd AST#parameter_list#Left ( AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . listeners AST#member_expression#Right AST#expression#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left listener => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left listener AST#expression#Right . onDataAdd AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left index AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right // 通知控制器数据变化 AST#method_declaration#Left notifyDataChange AST#parameter_list#Left ( AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . listeners AST#member_expression#Right AST#expression#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left listener => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left listener AST#expression#Right . onDataChange AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left index AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right // 通知控制器数据删除 AST#method_declaration#Left notifyDataDelete AST#parameter_list#Left ( AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . listeners AST#member_expression#Right AST#expression#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left listener => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left listener AST#expression#Right . onDataDelete AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left index AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right // 通知控制器数据位置变化 AST#method_declaration#Left notifyDataMove AST#parameter_list#Left ( AST#parameter#Left from : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left to : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . listeners AST#member_expression#Right AST#expression#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left 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 . onDataMove AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left from AST#expression#Right , AST#expression#Left to AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right // 获取数据总数 AST#method_declaration#Left public totalCount AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataArray AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right // 注册改变数据的控制器 AST#method_declaration#Left registerDataChangeListener AST#parameter_list#Left ( AST#parameter#Left listener : AST#type_annotation#Left AST#primary_type#Left DataChangeListener AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . listeners AST#member_expression#Right AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left listener AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right < AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . listeners AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left listener AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right // 注销改变数据的控制器 AST#method_declaration#Left unregisterDataChangeListener AST#parameter_list#Left ( AST#parameter#Left listener : AST#type_annotation#Left AST#primary_type#Left DataChangeListener AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left pos = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . listeners AST#member_expression#Right AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left listener AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left pos AST#expression#Right >= AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . listeners AST#member_expression#Right AST#expression#Right . splice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left pos AST#expression#Right , AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right // 增加数据 AST#method_declaration#Left public add1stItem AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataArray AST#member_expression#Right AST#expression#Right . splice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left 0 AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataArray AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . notifyDataAdd AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right // 在数据尾部增加一个元素 AST#method_declaration#Left public addLastItem AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataArray AST#member_expression#Right AST#expression#Right . splice 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 . dataArray AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right , AST#expression#Left 0 AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataArray AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . notifyDataAdd AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataArray AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right - AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left public addNewItems AST#parameter_list#Left ( AST#parameter#Left count : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left count AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataArray 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataArray AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . notifyDataAdd AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataArray AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right - AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right // 在指定索引位置增加一个元素 AST#method_declaration#Left public addItem 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 . dataArray AST#member_expression#Right AST#expression#Right . splice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left index AST#expression#Right , AST#expression#Left 0 AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataArray AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . notifyDataAdd AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left index AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right // 删除第一个元素 AST#method_declaration#Left public delete1stItem AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataArray AST#member_expression#Right AST#expression#Right . splice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . notifyDataDelete AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right // 删除第二个元素 AST#method_declaration#Left public delete2ndItem AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataArray AST#member_expression#Right AST#expression#Right . splice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 1 AST#expression#Right , AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . notifyDataDelete AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right // 删除最后一个元素 AST#method_declaration#Left public deleteLastItem AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataArray AST#member_expression#Right AST#expression#Right . splice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right , AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . notifyDataDelete AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataArray AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right // 在指定索引位置增加一个元素 AST#method_declaration#Left public deleteItem 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 . dataArray AST#member_expression#Right AST#expression#Right . splice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left index AST#expression#Right , AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . notifyDataDelete AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left index AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right // 重新加载数据 AST#method_declaration#Left public reload AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataArray AST#member_expression#Right AST#expression#Right . splice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 1 AST#expression#Right , AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dataArray AST#member_expression#Right AST#expression#Right . splice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 3 AST#expression#Right , AST#expression#Left 2 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 . notifyDataReload AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class WaterFlowDataSource implements IDataSource { private dataArray: number[] = []; private listeners: DataChangeListener[] = []; constructor(count: number) { for (let i = 0; i < count; i++) { this.dataArray.push(i); } } public getData(index: number): number { return this.dataArray[index]; } notifyDataReload(): void { this.listeners.forEach(listener => { listener.onDataReloaded(); }) } notifyDataAdd(index: number): void { this.listeners.forEach(listener => { listener.onDataAdd(index); }) } notifyDataChange(index: number): void { this.listeners.forEach(listener => { listener.onDataChange(index); }) } notifyDataDelete(index: number): void { this.listeners.forEach(listener => { listener.onDataDelete(index); }) } notifyDataMove(from: number, to: number): void { this.listeners.forEach(listener => { listener.onDataMove(from, to); }) } public totalCount(): number { return this.dataArray.length; } registerDataChangeListener(listener: DataChangeListener): void { if (this.listeners.indexOf(listener) < 0) { this.listeners.push(listener); } } unregisterDataChangeListener(listener: DataChangeListener): void { const pos = this.listeners.indexOf(listener) if (pos >= 0) { this.listeners.splice(pos, 1); } } public add1stItem(): void { this.dataArray.splice(0, 0, this.dataArray.length); this.notifyDataAdd(0); } public addLastItem(): void { this.dataArray.splice(this.dataArray.length, 0, this.dataArray.length); this.notifyDataAdd(this.dataArray.length - 1); } public addNewItems(count: number): void { for (let i = 0; i < count; i++) { this.dataArray.push(this.dataArray.length); this.notifyDataAdd(this.dataArray.length - 1); } } public addItem(index: number): void { this.dataArray.splice(index, 0, this.dataArray.length); this.notifyDataAdd(index); } public delete1stItem(): void { this.dataArray.splice(0, 1); this.notifyDataDelete(0); } public delete2ndItem(): void { this.dataArray.splice(1, 1); this.notifyDataDelete(1); } public deleteLastItem(): void { this.dataArray.splice(-1, 1); this.notifyDataDelete(this.dataArray.length); } public deleteItem(index: number): void { this.dataArray.splice(index, 1); this.notifyDataDelete(index); } public reload(): void { this.dataArray.splice(1, 1); this.dataArray.splice(3, 2); this.notifyDataReload(); } }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/ArkUISample/ScrollableComponent/entry/src/main/ets/pages/waterFlow/WaterFlowDataSource.ets#L17-L142
e1e18901461a461f5db2b9b1b085fabf66c0d621
gitee
awa_Liny/LinysBrowser_NEXT
a5cd96a9aa8114cae4972937f94a8967e55d4a10
home/src/main/ets/processes/init_process.ets
arkts
history
Inits history. @param t0 Start time of the whole initialization process.
function history(storage: LocalStorage) { AppStorage.setOrCreate('bunch_of_history', new bunch_of_history()); // Initialize statuses AppStorage.setOrCreate('reindexing_history', undefined); AppStorage.setOrCreate('history_index_loading', undefined); AppStorage.setOrCreate('history_index_saving', undefined); AppStorage.setOrCreate('reindexing_history_progress', ''); AppStorage.setOrCreate('history_index_loading_progress', ''); AppStorage.setOrCreate('history_index_saving_progress', ''); // Timer console.log('[init] History OK. (' + run_time(storage) + ' ms)'); }
AST#function_declaration#Left function history 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . setOrCreate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'bunch_of_history' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left bunch_of_history AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // Initialize statuses AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . setOrCreate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'reindexing_history' AST#expression#Right , AST#expression#Left undefined AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . setOrCreate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'history_index_loading' AST#expression#Right , AST#expression#Left undefined AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . setOrCreate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'history_index_saving' AST#expression#Right , AST#expression#Left undefined AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . setOrCreate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'reindexing_history_progress' AST#expression#Right , AST#expression#Left '' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . setOrCreate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'history_index_loading_progress' AST#expression#Right , AST#expression#Left '' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . setOrCreate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'history_index_saving_progress' AST#expression#Right , AST#expression#Left '' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // Timer 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#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left '[init] History OK. (' AST#expression#Right + AST#expression#Left run_time AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left storage AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left ' ms)' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right
function history(storage: LocalStorage) { AppStorage.setOrCreate('bunch_of_history', new bunch_of_history()); AppStorage.setOrCreate('reindexing_history', undefined); AppStorage.setOrCreate('history_index_loading', undefined); AppStorage.setOrCreate('history_index_saving', undefined); AppStorage.setOrCreate('reindexing_history_progress', ''); AppStorage.setOrCreate('history_index_loading_progress', ''); AppStorage.setOrCreate('history_index_saving_progress', ''); console.log('[init] History OK. (' + run_time(storage) + ' ms)'); }
https://github.com/awa_Liny/LinysBrowser_NEXT/blob/a5cd96a9aa8114cae4972937f94a8967e55d4a10/home/src/main/ets/processes/init_process.ets#L544-L557
aeb3e0cf7faad42569497ce54ec17446994139a5
gitee
openharmony-tpc-incubate/photo-deal-demo
01382ce30b1785f8fc8bc14f6b94f0a670a5b50b
library/src/main/ets/components/PaletteComponent.ets
arkts
PaletteComponent
画板组件
@ComponentV2 export struct PaletteComponent { @Param @Require eventListener: PaletteEventListener; private currentScale: number = 1; private color: string = '#DB2904'; private brushSize: number = LINE_WIDTH; private canvasContext: CanvasRenderingContext2D = new CanvasRenderingContext2D(new RenderingContextSettings(true)); private path?: Path2D; private canvasSize: EditRect = { x: 0, y: 0, width: 0, height: 0 }; private controller: PaletteController = { refreshScale: (scale: number): void => { this.currentScale = scale; }, refreshColor: (color: string): void => { this.color = color; }, refreshBrushSize: (size: number): void => { this.brushSize = size; }, undo: (data: PaletteData): void => { this.undoPalette(data); } }; aboutToAppear(): void { } build() { Canvas(this.canvasContext).onReady(() => { this.canvasSize = { x: 0, y: 0, width: this.canvasContext.width, height: this.canvasContext.height }; this.canvasContext.lineCap = 'round'; this.eventListener?.onReady?.(this.controller); Logger.i(IMAGE_EDIT_MODULE, TAG, `onReady ${JSON.stringify(this.canvasSize)}`); }).width('100%') .height('100%').onTouch((event: TouchEvent) => { if (event?.touches && event.touches[0]) { // 获取手指触摸位置的坐标点 const positionX: number = (event.touches[0].x); const positionY: number = (event.touches[0].y); switch (event.type) { case TouchType.Down: { this.canvasContext.strokeStyle = this.color; let lineWidth = this.brushSize / this.currentScale; this.canvasContext.lineWidth = lineWidth; // 按压时创建节点 let path = new Path2D(); this.path = path; this.path.moveTo(positionX, positionY); this.eventListener?.onAdd?.(new PaletteData(path, this.color, lineWidth)); break; } case TouchType.Move: { if (this.path) { this.path.lineTo(positionX, positionY); this.canvasContext.stroke(this.path); } break; }
AST#decorated_export_declaration#Left AST#decorator#Left @ ComponentV2 AST#decorator#Right export struct PaletteComponent AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right AST#decorator#Left @ Require AST#decorator#Right eventListener : AST#type_annotation#Left AST#primary_type#Left PaletteEventListener AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left private currentScale : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 1 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private color : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '#DB2904' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private brushSize : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left LINE_WIDTH AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private canvasContext : AST#type_annotation#Left AST#primary_type#Left CanvasRenderingContext2D 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 CanvasRenderingContext2D AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left RenderingContextSettings AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private path ? : AST#type_annotation#Left AST#primary_type#Left Path2D AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left private canvasSize : AST#type_annotation#Left AST#primary_type#Left EditRect 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 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 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left height AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private controller : AST#type_annotation#Left AST#primary_type#Left PaletteController AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left refreshScale AST#property_name#Right : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left scale : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentScale AST#member_expression#Right = AST#expression#Left scale AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left refreshColor AST#property_name#Right : AST#expression#Left AST#arrow_function#Left 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_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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . color AST#member_expression#Right = AST#expression#Left color AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left refreshBrushSize AST#property_name#Right : AST#expression#Left AST#arrow_function#Left 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 void AST#primary_type#Right AST#type_annotation#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . brushSize AST#member_expression#Right = AST#expression#Left size AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left undo AST#property_name#Right : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left PaletteData AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . undoPalette AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left data AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#method_declaration#Left aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { } AST#builder_function_body#Right AST#method_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Canvas ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . canvasContext AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . onReady ( 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 . canvasSize AST#member_expression#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 AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . canvasContext AST#member_expression#Right AST#expression#Right . width AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left height AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . canvasContext AST#member_expression#Right AST#expression#Right . height AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . canvasContext AST#member_expression#Right AST#expression#Right . lineCap AST#member_expression#Right = AST#expression#Left 'round' AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . eventListener AST#member_expression#Right AST#expression#Right ?. onReady 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 . controller 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 Logger AST#expression#Right . i AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left IMAGE_EDIT_MODULE AST#expression#Right , AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` onReady 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . canvasSize AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#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 . onTouch ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left 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#ERROR#Left if ( AST#ERROR#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#member_expression#Left AST#expression#Left event AST#expression#Right ?. touches AST#member_expression#Right AST#expression#Right && AST#expression#Left event AST#expression#Right AST#binary_expression#Right AST#expression#Right . touches AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#ERROR#Left ) { // 获取手指触摸位置的坐标点 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left positionX : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#parenthesized_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 event AST#expression#Right . touches AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . x AST#member_expression#Right AST#expression#Right ) AST#parenthesized_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 positionY : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#parenthesized_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 event AST#expression#Right . touches AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . y AST#member_expression#Right AST#expression#Right ) AST#parenthesized_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 AST#member_expression#Left AST#expression#Left event AST#expression#Right . type AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right { AST#property_name#Left case AST#property_name#Right Touch Type AST#ERROR#Right . Down AST#member_expression#Right AST#expression#Right : AST#ERROR#Right AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left this AST#property_assignment#Right AST#object_literal#Right AST#expression#Right . canvasContext AST#member_expression#Right AST#expression#Right . strokeStyle AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . color AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#ERROR#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left lineWidth = 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 . brushSize AST#member_expression#Right AST#expression#Right / AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . currentScale AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . canvasContext AST#member_expression#Right AST#expression#Right . lineWidth AST#member_expression#Right = AST#expression#Left lineWidth 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 path = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Path2D 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 this AST#expression#Right . path AST#member_expression#Right = AST#expression#Left path AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#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 . path AST#member_expression#Right AST#expression#Right . moveTo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left positionX AST#expression#Right , AST#expression#Left positionY AST#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 . eventListener AST#member_expression#Right AST#expression#Right ?. onAdd AST#member_expression#Right AST#expression#Right ?. AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left PaletteData AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left path AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . color AST#member_expression#Right AST#expression#Right , AST#expression#Left lineWidth 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#break_statement#Left break ; AST#break_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#ERROR#Left case Touch Type AST#ERROR#Right . Move AST#member_expression#Right AST#expression#Right AST#ERROR#Left : { if AST#ERROR#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . path AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#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#object_literal#Left { AST#property_assignment#Left this AST#property_assignment#Right AST#object_literal#Right AST#expression#Right . path AST#member_expression#Right AST#expression#Right . lineTo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left positionX AST#expression#Right , AST#expression#Left positionY 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 . canvasContext AST#member_expression#Right AST#expression#Right . stroke 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 . path AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#build_body#Right AST#build_method#Right AST#property_declaration#Left break ; AST#property_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@ComponentV2 export struct PaletteComponent { @Param @Require eventListener: PaletteEventListener; private currentScale: number = 1; private color: string = '#DB2904'; private brushSize: number = LINE_WIDTH; private canvasContext: CanvasRenderingContext2D = new CanvasRenderingContext2D(new RenderingContextSettings(true)); private path?: Path2D; private canvasSize: EditRect = { x: 0, y: 0, width: 0, height: 0 }; private controller: PaletteController = { refreshScale: (scale: number): void => { this.currentScale = scale; }, refreshColor: (color: string): void => { this.color = color; }, refreshBrushSize: (size: number): void => { this.brushSize = size; }, undo: (data: PaletteData): void => { this.undoPalette(data); } }; aboutToAppear(): void { } build() { Canvas(this.canvasContext).onReady(() => { this.canvasSize = { x: 0, y: 0, width: this.canvasContext.width, height: this.canvasContext.height }; this.canvasContext.lineCap = 'round'; this.eventListener?.onReady?.(this.controller); Logger.i(IMAGE_EDIT_MODULE, TAG, `onReady ${JSON.stringify(this.canvasSize)}`); }).width('100%') .height('100%').onTouch((event: TouchEvent) => { if (event?.touches && event.touches[0]) { const positionX: number = (event.touches[0].x); const positionY: number = (event.touches[0].y); switch (event.type) { case TouchType.Down: { this.canvasContext.strokeStyle = this.color; let lineWidth = this.brushSize / this.currentScale; this.canvasContext.lineWidth = lineWidth; let path = new Path2D(); this.path = path; this.path.moveTo(positionX, positionY); this.eventListener?.onAdd?.(new PaletteData(path, this.color, lineWidth)); break; } case TouchType.Move: { if (this.path) { this.path.lineTo(positionX, positionY); this.canvasContext.stroke(this.path); } break; }
https://github.com/openharmony-tpc-incubate/photo-deal-demo/blob/01382ce30b1785f8fc8bc14f6b94f0a670a5b50b/library/src/main/ets/components/PaletteComponent.ets#L45-L112
0801fbdebf59990c75364e8621aaad98033a276a
gitee
zqaini002/YaoYaoLingXian.git
5095b12cbeea524a87c42d0824b1702978843d39
YaoYaoLingXian/entry/src/main/ets/pages/personal/MinePage.ets
arkts
fetchDreamStats
获取梦想统计数据
async fetchDreamStats(userId: number) { try { console.info(`开始获取梦想统计数据, userId: ${userId}`); // 使用ApiService中的方法获取梦想统计数据 const stats = await ApiService.getDreamStats(userId); if (stats) { this.dreamStats = stats; console.info(`成功获取梦想统计数据: ${JSON.stringify(stats)}`); } else { console.error('获取梦想统计数据失败: 返回数据为空'); } } catch (error) { console.error(`获取梦想统计数据错误: ${(error as Error).message}`); // 保持现有的默认值,不做修改 } finally { // 确保没有undefined的统计数据显示到UI if (!this.dreamStats) { console.info('恢复默认的梦想统计数据'); this.dreamStats = { userId: userId, totalDreams: 0, inProgressDreams: 0, completedDreams: 0, abandonedDreams: 0, dreamCompletionRate: 0, totalTasks: 0, completedTasks: 0, taskCompletionRate: 0 }; } } }
AST#method_declaration#Left async fetchDreamStats AST#parameter_list#Left ( AST#parameter#Left userId : 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#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 ` 开始获取梦想统计数据, userId: AST#template_substitution#Left $ { AST#expression#Left userId 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 // 使用ApiService中的方法获取梦想统计数据 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left stats = 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 ApiService AST#expression#Right AST#await_expression#Right AST#expression#Right . getDreamStats AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left userId 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 stats 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 . dreamStats AST#member_expression#Right = AST#expression#Left stats AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` 成功获取梦想统计数据: 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 stats AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '获取梦想统计数据失败: 返回数据为空' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#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 ` 获取梦想统计数据错误: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left Error AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 保持现有的默认值,不做修改 } AST#block_statement#Right AST#catch_clause#Right AST#finally_clause#Left finally AST#block_statement#Left { // 确保没有undefined的统计数据显示到UI 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 . dreamStats AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '恢复默认的梦想统计数据' AST#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 . dreamStats AST#member_expression#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left userId AST#property_name#Right : AST#expression#Left userId AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left totalDreams AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left inProgressDreams AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left completedDreams AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left abandonedDreams AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left dreamCompletionRate AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left totalTasks AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left completedTasks AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left taskCompletionRate AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#finally_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async fetchDreamStats(userId: number) { try { console.info(`开始获取梦想统计数据, userId: ${userId}`); const stats = await ApiService.getDreamStats(userId); if (stats) { this.dreamStats = stats; console.info(`成功获取梦想统计数据: ${JSON.stringify(stats)}`); } else { console.error('获取梦想统计数据失败: 返回数据为空'); } } catch (error) { console.error(`获取梦想统计数据错误: ${(error as Error).message}`); } finally { if (!this.dreamStats) { console.info('恢复默认的梦想统计数据'); this.dreamStats = { userId: userId, totalDreams: 0, inProgressDreams: 0, completedDreams: 0, abandonedDreams: 0, dreamCompletionRate: 0, totalTasks: 0, completedTasks: 0, taskCompletionRate: 0 }; } } }
https://github.com/zqaini002/YaoYaoLingXian.git/blob/5095b12cbeea524a87c42d0824b1702978843d39/YaoYaoLingXian/entry/src/main/ets/pages/personal/MinePage.ets#L76-L109
e49144d2b028d5362d4d8b02c3ffb849d70c9c83
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/pages/SimpleBirthdayApp.ets
arkts
aboutToDisappear
页面生命周期 - 页面即将消失
aboutToDisappear() { hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, 'SimpleBirthdayApp 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 'SimpleBirthdayApp 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, 'SimpleBirthdayApp page aboutToDisappear'); }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/SimpleBirthdayApp.ets#L78-L80
bfc6a7eab0c443f59714a052546533f03561db1c
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/pages/analytics/ReportsPage.ets
arkts
buildReportsList
构建报告列表
@Builder buildReportsList() { if (this.getFilteredReports().length === 0) { this.buildEmptyState(); return; } Scroll() { Column({ space: 8 }) { ForEach(this.getFilteredReports(), (report: AnalyticsReport) => { this.buildReportCard(report) }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildReportsList AST#parameter_list#Left ( ) AST#parameter_list#Right AST#ERROR#Left { AST#ERROR#Left AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getFilteredReports AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { 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 . buildEmptyState 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#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 Scroll 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#ERROR#Left { AST#property_name#Left Column AST#property_name#Right ( AST#ERROR#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left space AST#property_name#Right : AST#expression#Left 8 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left ) AST#ERROR#Right { AST#property_name#Left ForEach AST#property_name#Right ( this AST#ERROR#Right AST#modifier_chain_expression#Left . getFilteredReports ( ) AST#modifier_chain_expression#Right , ( report AST#ERROR#Right : AST#type_annotation#Left AST#primary_type#Left AnalyticsReport AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left ) => AST#ERROR#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . buildReportCard AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left report 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
@Builder buildReportsList() { if (this.getFilteredReports().length === 0) { this.buildEmptyState(); return; } Scroll() { Column({ space: 8 }) { ForEach(this.getFilteredReports(), (report: AnalyticsReport) => { this.buildReportCard(report) }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/analytics/ReportsPage.ets#L276-L287
964f940d734276b6c2742c5ea305df172771c664
github
zqaini002/YaoYaoLingXian.git
5095b12cbeea524a87c42d0824b1702978843d39
YaoYaoLingXian/entry/src/main/ets/services/ApiService.ets
arkts
空查询参数对象
export const EmptyParams: QueryParams = {};
AST#export_declaration#Left export AST#variable_declaration#Left const AST#variable_declarator#Left EmptyParams : AST#type_annotation#Left AST#primary_type#Left QueryParams 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#export_declaration#Right
export const EmptyParams: QueryParams = {};
https://github.com/zqaini002/YaoYaoLingXian.git/blob/5095b12cbeea524a87c42d0824b1702978843d39/YaoYaoLingXian/entry/src/main/ets/services/ApiService.ets#L215-L215
a68b7f73d09b65ff3713ae997011fd3a6ae526e0
github
wuyuanwuhui999/harmony-arkts-chat-app-ui.git
128861bc002adae9c34c6ce8fbf12686c26e51ec
entry/src/main/ets/utils/PreferenceModel.ets
arkts
ensurePreferenceInitialized
确保首选项已初始化
private async ensurePreferenceInitialized() { if (preference === null) { await this.getPreferencesFromStorage(); } }
AST#method_declaration#Left private async ensurePreferenceInitialized 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 preference AST#expression#Right === AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . getPreferencesFromStorage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
private async ensurePreferenceInitialized() { if (preference === null) { await this.getPreferencesFromStorage(); } }
https://github.com/wuyuanwuhui999/harmony-arkts-chat-app-ui.git/blob/128861bc002adae9c34c6ce8fbf12686c26e51ec/entry/src/main/ets/utils/PreferenceModel.ets#L8-L12
8b3419122c7ae19e74f53e36c76bcfc743349876
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/Solutions/Social/GrapeSquare/feature/authorizedControl/src/main/ets/view/TitleBar.ets
arkts
TitleBar
Copyright (c) 2023 Huawei Device Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
@Component export struct TitleBar { private title: Resource = $r('app.string.explore'); private image: Resource = $r('app.media.addfriend') build() { Column() { Row() { Stack() { Row() { Text(this.title) .fontFamily('HarmonyHeiTi-Bold') .fontSize($r('app.integer.layout_size_24')) .fontColor($r('app.color.font_color_182431')) .fontWeight(700) .margin({ left: $r('app.integer.layout_size_22') }) } .width('100%') Row() { Image(this.image) .width($r('app.integer.layout_size_24')) .width($r('app.integer.layout_size_24')) .margin({ right: $r('app.integer.layout_size_24') }) Image($r('app.media.search')) .width($r('app.integer.layout_size_24')) .width($r('app.integer.layout_size_24')) .margin({ right: $r('app.integer.layout_size_12') }) } .width('100%') .justifyContent(FlexAlign.End) } } .width('90%') .height($r('app.integer.layout_size_33')) .margin({ top: $r('app.integer.layout_size_12'), bottom: $r('app.integer.layout_size_11') }) } } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct TitleBar AST#component_body#Left { AST#property_declaration#Left private title : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.explore' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private image : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.addfriend' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#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 Stack ( ) 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 . fontFamily ( AST#expression#Left 'HarmonyHeiTi-Bold' AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.layout_size_24' 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 700 AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.layout_size_22' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . 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#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . image AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.layout_size_24' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.layout_size_24' 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.integer.layout_size_24' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.search' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.layout_size_24' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.layout_size_24' 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.integer.layout_size_12' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . End AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#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 . width ( AST#expression#Left '90%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.layout_size_33' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.layout_size_12' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.layout_size_11' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Component export struct TitleBar { private title: Resource = $r('app.string.explore'); private image: Resource = $r('app.media.addfriend') build() { Column() { Row() { Stack() { Row() { Text(this.title) .fontFamily('HarmonyHeiTi-Bold') .fontSize($r('app.integer.layout_size_24')) .fontColor($r('app.color.font_color_182431')) .fontWeight(700) .margin({ left: $r('app.integer.layout_size_22') }) } .width('100%') Row() { Image(this.image) .width($r('app.integer.layout_size_24')) .width($r('app.integer.layout_size_24')) .margin({ right: $r('app.integer.layout_size_24') }) Image($r('app.media.search')) .width($r('app.integer.layout_size_24')) .width($r('app.integer.layout_size_24')) .margin({ right: $r('app.integer.layout_size_12') }) } .width('100%') .justifyContent(FlexAlign.End) } } .width('90%') .height($r('app.integer.layout_size_33')) .margin({ top: $r('app.integer.layout_size_12'), bottom: $r('app.integer.layout_size_11') }) } } }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/Solutions/Social/GrapeSquare/feature/authorizedControl/src/main/ets/view/TitleBar.ets#L16-L55
c8f89648bbd350f28bc4f1644354cf35f48f0334
gitee