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/expandtitle/src/main/ets/utils/TitleExpansion.ets
arkts
getTitleScaleOptions
获取主标题缩放的Scale参数 @returns {ScaleOptions} 主标题缩放系数
getTitleScaleOptions(): ScaleOptions { let scaleRatio = 1 + (this.animationAttribute.titleScale - 1) * Math.min((this.heightValue - this.animationAttribute.normalTitleHeight + Math.max(-this.curOffset, 0)) / this.animationAttribute.continuePullThreshold, 1); return { x: scaleRatio, y: scaleRatio, centerX: Constants.INIT_COORDINATE, centerY: Constants.INIT_COORDINATE }; }
AST#method_declaration#Left getTitleScaleOptions AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left ScaleOptions AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left scaleRatio = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 1 AST#expression#Right + AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . animationAttribute AST#member_expression#Right AST#expression#Right . titleScale AST#member_expression#Right AST#expression#Right - AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right * AST#expression#Left Math AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . min AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . heightValue AST#member_expression#Right AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . animationAttribute AST#member_expression#Right AST#expression#Right . normalTitleHeight AST#member_expression#Right AST#expression#Right + AST#expression#Left Math AST#expression#Right AST#binary_expression#Right AST#expression#Right . max AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left - AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . curOffset AST#member_expression#Right AST#expression#Right , AST#expression#Left 0 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right / AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . animationAttribute AST#member_expression#Right AST#expression#Right . continuePullThreshold AST#member_expression#Right AST#expression#Right , AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left scaleRatio AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left scaleRatio AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left centerX AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . INIT_COORDINATE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left centerY AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . INIT_COORDINATE AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
getTitleScaleOptions(): ScaleOptions { let scaleRatio = 1 + (this.animationAttribute.titleScale - 1) * Math.min((this.heightValue - this.animationAttribute.normalTitleHeight + Math.max(-this.curOffset, 0)) / this.animationAttribute.continuePullThreshold, 1); return { x: scaleRatio, y: scaleRatio, centerX: Constants.INIT_COORDINATE, centerY: Constants.INIT_COORDINATE }; }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/expandtitle/src/main/ets/utils/TitleExpansion.ets#L211-L220
2e5fad3ee62e1d54a6453db448412f28c45098d5
gitee
ali5669/ArkTSShopping.git
7065d61468d80c143788532337c499eb9eaa5ffd
entry/src/main/ets/viewmodel/LocalDataManager.ets
arkts
queryItemListById
通过ID搜索物品
queryItemListById(id: string){ const result = ItemData.filter(item => item.id == id)[0]; return result }
AST#method_declaration#Left queryItemListById AST#parameter_list#Left ( AST#parameter#Left id : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left result = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ItemData 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 . id AST#member_expression#Right AST#expression#Right == AST#expression#Left id AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left result AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
queryItemListById(id: string){ const result = ItemData.filter(item => item.id == id)[0]; return result }
https://github.com/ali5669/ArkTSShopping.git/blob/7065d61468d80c143788532337c499eb9eaa5ffd/entry/src/main/ets/viewmodel/LocalDataManager.ets#L25-L28
b52de15ed4716ae0a1b8a07ea962fc05c3bf45f8
github
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_crypto_dto/src/main/ets/crypto/encryption/MD5.ets
arkts
hash
散列哈希算法 @param value 待处理字符 @param enCoding 编码格式hex/base64 @returns
static hash(value: string, enCoding?: string): OutDTO<string> { let md = new MD5(); if (enCoding && enCoding == 'base64') { let md5 = md.b64_md5(value); if (!md5.endsWith('==')) { md5 += '=='; } return OutDTO.OKByDataRow('MD5散列算法Base64成功~', md5); } return OutDTO.OKByDataRow('MD5散列算法成功~', md.hex_md5(value)); }
AST#method_declaration#Left static hash AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left enCoding ? : 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#variable_declaration#Left let AST#variable_declarator#Left md = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left MD5 AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left enCoding AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left enCoding AST#expression#Right == AST#expression#Left 'base64' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left md5 = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left md AST#expression#Right . b64_md5 AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left value AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#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 md5 AST#expression#Right AST#unary_expression#Right AST#expression#Right . endsWith 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#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left md5 += AST#expression#Left '==' AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left OutDTO AST#expression#Right . OKByDataRow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'MD5散列算法Base64成功~' AST#expression#Right , AST#expression#Left md5 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left OutDTO AST#expression#Right . OKByDataRow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'MD5散列算法成功~' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left md AST#expression#Right . hex_md5 AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left value AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static hash(value: string, enCoding?: string): OutDTO<string> { let md = new MD5(); if (enCoding && enCoding == 'base64') { let md5 = md.b64_md5(value); if (!md5.endsWith('==')) { md5 += '=='; } return OutDTO.OKByDataRow('MD5散列算法Base64成功~', md5); } return OutDTO.OKByDataRow('MD5散列算法成功~', md.hex_md5(value)); }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto_dto/src/main/ets/crypto/encryption/MD5.ets#L47-L57
e8e41bd72918e1a5b2f8793dfb493eda7a168e40
gitee
openharmony/interface_sdk-js
c349adc73e2ec1f61f6fca489b5af059e3ed6999
arkts/@arkts.collections.d.ets
arkts
getBitsByRange
Returns the bit values in a range of indices in a bit vector. @param { number } fromIndex - The starting position of the index, containing the value at that index position. @param { number } toIndex - The end of the index, excluding the value at that index. @returns { BitVector } The BitVector type, returns the bit values in a range of indices in a bit vector. @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. @throws { BusinessError } 10200001 - The value of fromIndex or toIndex is out of range. @throws { BusinessError } 10200011 - The getBitsByRange method cannot be bound. @throws { BusinessError } 10200201 - Concurrent modification error. @syscap SystemCapability.Utils.Lang @atomicservice @since 12 Returns the bit values in a range of indices in a bit vector. @param { number } fromIndex - The starting position of the index, containing the value at that index position. @param { number } toIndex - The end of the index, excluding the value at that index. @returns { BitVector } The BitVector type, returns the bit values in a range of indices in a bit vector. @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. @throws { BusinessError } 10200001 - The value of fromIndex or toIndex is out of range. @throws { BusinessError } 10200011 - The getBitsByRange method cannot be bound. @throws { BusinessError } 10200201 - Concurrent modification error. @syscap SystemCapability.Utils.Lang @crossplatform @atomicservice @since 18
getBitsByRange(fromIndex: number, toIndex: number): BitVector;
AST#method_declaration#Left getBitsByRange AST#parameter_list#Left ( AST#parameter#Left fromIndex : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left toIndex : 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 BitVector AST#primary_type#Right AST#type_annotation#Right ; AST#method_declaration#Right
getBitsByRange(fromIndex: number, toIndex: number): BitVector;
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/arkts/@arkts.collections.d.ets#L12290-L12290
5485c7c8c5785085ca2bac6d9aceadaa6bb70840
gitee
vhall/VHLive_SDK_Harmony
29c820e5301e17ae01bc6bdcc393a4437b518e7c
watchKit/src/main/ets/util/ChatTools.ets
arkts
聊天工具类。
export default class ChatTools { /** 聊天界面全面屏状态栏背景色 */ static readonly chat_page_title_background_color = '#ffffff';//'#fafafa';//#2e3746';//'#2e3746'; /** 聊天界面全面屏状态栏文本颜色 */ static readonly chat_page_title_color = '#000000';//#ffffff'; /** * 退出系统。 * * @param context UIAbilityContext上下文对象 */ static exitSystem(context: common.UIAbilityContext) { context.terminateSelf(); } /** * 设置全面屏状态栏颜色。 * * @param context 上下文对象 * @param statusBarContentColor 状态栏文本颜色 * @param statusBarColor 状态栏背景色 */ static setStatusBarColor(context: common.BaseContext, statusBarContentColor: string, statusBarColor: string) { try { let windowClass = AppStorage.get<window.Window>('window') windowClass?.setWindowSystemBarProperties({ statusBarContentColor: statusBarContentColor,//color, statusBarColor: statusBarColor, }); } catch (exception) { console.error(TAG+ 'Failed to set the system bar properties. Cause: ' + JSON.stringify(exception)); } // }); } /** * 收起软键盘。 * * @param context 上下文对象 */ static hideSoftInputMethod(context: UIContext) { context.getFocusController().clearFocus(); } /** * 设置输入法软键盘避让模式为RESIZE(表示当输入显示时,压缩窗体高度,而不是使用默认的OFFSET模式将窗体整体上推)。 * 详见官方资料:https://developer.huawei.com/consumer/cn/doc/best-practices-V5/bpta-keyboard-layout-adapt-V5#section08221814182316 * * @param toRESIZE true表示设置为KeyboardAvoidMode.RESIZE模式,否则还原为系统默认的 KeyboardAvoidMode.OFFSET模式 */ static setKeyboardAvoidModeToRESIZE(context: UIContext, toRESIZE: boolean) { context.setKeyboardAvoidMode(toRESIZE ? KeyboardAvoidMode.RESIZE : KeyboardAvoidMode.OFFSET); } /** * Check obj is empty * * @param {object} obj * @return {boolean} true(empty) */ static isEmpty(obj: object | string, trimString: boolean = false): boolean { return obj === undefined || obj === null || obj === '' || (trimString? ((typeof obj === 'string') ? (obj as string).trim() === '' : false) : false); } /** * 返回本地用户UID. * * @returns local uid */ static getLocalUserUid(): string | undefined { // return ClientCoreSDK.getInstance().currentLoginInfo?.loginUserId return ""; } /** * 显示奶油提示。 * * @param message 提示内容 * @param duration 持续时间(单位:毫秒),默认1500 */ static showToast(message: string | Resource, duration: number = 1500) { promptAction.showToast({ message: message, duration: duration, showMode: promptAction.ToastShowMode.TOP_MOST, }); } /** * 显示对话框. * * @param message 文本显示内容 * @param primaryButtonText 主按钮文本 * @param primaryButtonTextColor 主按钮文本颜色 * @param primaryAction 主按钮Action * @param secondaryButtonText 次按钮文本 * @param secondaryButtonTextColor 次按钮文本颜色 * @param secondaryAction 次按钮Action */ static showAlertDialog(message: ResourceStr , primaryButtonText: string, primaryButtonTextColor: ResourceColor | undefined, primaryAction: Callback<void> , secondaryButtonText: string, secondaryButtonTextColor: ResourceColor | undefined, secondaryAction: Callback<void>) { AlertDialog.show( { message: message, autoCancel: false, alignment: DialogAlignment.Center, offset:{ dx: 0, dy: 0 } , // gridCount: 4, primaryButton: primaryButtonText ? { value: primaryButtonText, action: primaryAction, fontColor: primaryButtonTextColor } : undefined, secondaryButton: secondaryButtonText ? { value: secondaryButtonText, action: secondaryAction, fontColor: secondaryButtonTextColor//$r('sys.color.ohos_id_color_badge_red') } : undefined }); } /** * 仿照微信中的消息时间显示逻辑,将时间戳(单位:毫秒)转换为友好的显示格式. * * 1)7天之内的日期显示逻辑是:今天、昨天(-1d)、前天(-2d)、星期?(只显示总计7天之内的星期数,即<=-4d); * 2)7天之外(即>7天)的逻辑:直接显示完整日期时间。 * @param timestamp 时间戳(单位:毫秒),形如:1550789954260 * @param mustIncludeTime true表示输出的格式里一定会包含“时间:分钟” * ,否则不包含(参考微信,不包含时分的情况,用于首页“消息”中显示时) * @param timeWithSegmentStr 本参数仅在mustIncludeTime=true时有生效,表示在时间字符串前带上“上午”、“下午”、“晚上”这样的描述 * * @return 输出格式形如:“刚刚”、“10:30”、“昨天 12:04”、“前天 20:51”、“星期二”、“2019/2/21 12:09”等形式 * @author Jack Jiang(http://www.52im.net/thread-2792-1-1.html) */ static getTimeStringAutoShort2(timestamp: number, mustIncludeTime: boolean, timeWithSegmentStr: boolean): string { // 当前时间 let currentDate: Date = new Date(); // 目标判断时间 let srcDate: Date = new Date(timestamp); let currentYear: number = currentDate.getFullYear(); let currentMonth: number = (currentDate.getMonth()+1); let currentDateD: number = currentDate.getDate(); let srcYear: number = srcDate.getFullYear(); let srcMonth: number = (srcDate.getMonth()+1); let srcDateD: number = srcDate.getDate(); let ret: string = ''; // 要额外显示的时间分钟 let timeExtraStr = ''; if(mustIncludeTime) { // let timeExtraStr = (mustIncludeTime ? " " + _formatDate(srcDate, "hh:mm") : ""); timeExtraStr = " "+ChatTools.getTimeHH24Human(srcDate, timeWithSegmentStr); } // 当年 if(currentYear === srcYear) { let currentTimestamp: number = currentDate.getTime(); let srcTimestamp: number = timestamp; // 相差时间(单位:毫秒) let deltaTime: number = (currentTimestamp-srcTimestamp); // 当天(月份和日期一致才是) if(currentMonth === srcMonth && currentDateD === srcDateD) { // // 时间相差60秒以内 // if(deltaTime < 60 * 1000) // ret = "刚刚"; // // 否则当天其它时间段的,直接显示“时:分”的形式 // else // ret = _formatDate(srcDate, "hh:mm"); // 当天只需要显示时间分钟,且必须显示“上午”、“下午”这样的时间段描述 ret = ChatTools.getTimeHH24Human(srcDate, true); } // 当年 && 当天之外的时间(即昨天及以前的时间) else { // 昨天(以“现在”的时候为基准-1天) let yesterdayDate:Date = new Date(); yesterdayDate.setDate(yesterdayDate.getDate()-1); // 前天(以“现在”的时候为基准-2天) let beforeYesterdayDate: Date = new Date(); beforeYesterdayDate.setDate(beforeYesterdayDate.getDate()-2); // 用目标日期的“月”和“天”跟上方计算出来的“昨天”进行比较,是最为准确的(如果用时间戳差值 // 的形式,是不准确的,比如:现在时刻是2019年02月22日1:00、而srcDate是2019年02月21日23:00, // 这两者间只相差2小时,直接用“deltaTime/(3600 * 1000)” > 24小时来判断是否昨天,就完全是扯蛋的逻辑了) if(srcMonth === (yesterdayDate.getMonth()+1) && srcDateD === yesterdayDate.getDate()) { ret = "昨天"+timeExtraStr;// -1d } // “前天”判断逻辑同上 else if(srcMonth === (beforeYesterdayDate.getMonth()+1) && srcDateD === beforeYesterdayDate.getDate()) { ret = "前天" + timeExtraStr; // -2d } else{ // 跟当前时间相差的小时数 let deltaHour: number = (deltaTime/(3600 * 1000)); // 如果小于或等 7*24小时就显示星期几 if (deltaHour <= 7*24){ let weekday = new Array<string>(7); weekday[0]="星期日"; weekday[1]="星期一"; weekday[2]="星期二"; weekday[3]="星期三"; weekday[4]="星期四"; weekday[5]="星期五"; weekday[6]="星期六"; // 取出当前是星期几 let weedayDesc: string = weekday[srcDate.getDay()]; ret = weedayDesc + timeExtraStr; } // 否则直接显示完整日期时间 else ret = ChatTools.formatDate(srcDate, "M月d日")+timeExtraStr; } } } // 往年 else{ ret = ChatTools.formatDate(srcDate, "yy年M月d日")+timeExtraStr; } return ret; } /** * 获取仅包含“时间:分钟”部分的字符串,24小时制,且可以显示“上午”、“下午”、“晚上”这样的描述。 * * @param srcDateObj 原始日期对象 * @param timeWithSegmentStr 表示在时间字符串前带上“上午”、“下午”、“晚上”这样的描述 * @return 如果成功则返回结果,否则返回空字符串""(不是null) */ static getTimeHH24Human(srcDateObj: Date, timeWithSegmentStr: boolean): string { let ret: string = ''; try { let timePattern: string = 'hh:mm'; // 原始的时间分钟字符串 let timeStr: string = ChatTools.formatDate(srcDateObj, timePattern); // 时间段描述(形如:“上午”、“下午”、“晚上”这样的描述),只在中文语言下生效 let timeSegmentStr: string = ''; if(timeWithSegmentStr) timeSegmentStr = ChatTools.getTimeSegmentStr(timeStr); // 组合成最终的人性化时间分钟字符串形式 ret = timeSegmentStr+timeStr; } catch (e) { console.error("【DEBUG-getTimeHH24Human】计算出错:"+ JSON.stringify(e) +" 【NO】"); } return ret; } /** * 将一个两位24小时时间的转换为上午、下午这样的描述。 * * @param hh24 两位的24小时制时间的小时部分 * @return 如果成功转换则返回形如:“凌晨”、“上午”等,否则返回空字符串(不是null) * @since 3.1 */ static getTimeSegmentStr(hh24: string): string { let ret: string = ''; if (hh24 && hh24.length >= 2) { try { // 取出“小时”部分 let a = parseInt(hh24.substring(0, 2)); if (a >= 0 && a <= 6) { ret = "凌晨"; } else if (a > 6 && a <= 12) { ret = "上午"; } else if (a > 12 && a <= 13) { ret = "中午"; } else if (a > 13 && a <= 18) { ret = "下午"; } else if (a > 18 && a <= 24) { ret = "晚上"; } } catch (e) { console.error("【DEBUG-getTimeSegmentStr】计算出错:" + JSON.stringify(e) + " 【NO】"); } } return ret; } /** * 对Date的扩展,将 Date 转化为指定格式的String。 * * 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符, * 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)。 * * 【示例】: * common.formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss.S') ==> 2006-07-02 08:09:04.423 * common.formatDate(new Date(), 'yyyy-M-d h:m:s.S') ==> 2006-7-2 8:9:4.18 * common.formatDate(new Date(), 'hh:mm:ss.S') ==> 08:09:04.423 * * @param date Date对象 * @param fmt 格式字符串 * @param 格式化的字符串 */ static formatDate(date: Date, fmt: string) { let map = new Map<String, Number>(); map.set("M+", date.getMonth() + 1); // 月份 map.set("d+", date.getDate()); // 日 map.set("h+", date.getHours()); // 小时 map.set("m+", date.getMinutes()); // 分 map.set("s+", date.getSeconds()); // 秒 map.set("q+", Math.floor((date.getMonth() + 3) / 3)); // 季度 map.set("S", date.getMilliseconds()); // 毫秒 let yearMatcher = /(y+)/.exec(fmt); if (yearMatcher && yearMatcher.length > 0) { let match = yearMatcher[0]; fmt = fmt.replace(match, (date.getFullYear() + "").substr(4 - match.length)); } map.forEach((value, key) => { let matcher = new RegExp(`(${key})`).exec(fmt!); if (matcher && matcher.length > 0) { let match = matcher[0]; let replaceValue = ''; if ((match.length == 1)) { replaceValue = `${value}`; } else { replaceValue = (("00" + value).substr(("" + value).length)) } fmt = fmt!.replace(match, replaceValue); } }); return fmt; } static getLimitString(source: string, length: number): string { if (source !== '' && source.length > length) { return source.substring(0, length) + "..."; } return source; } static changeRoleToRoleName(role: string): string { // 1 主持人,2 观众,3 助理,4 嘉宾 let roleName: string = ''; switch (role) { case "1": case "host": roleName = "主持人"; break; case "3": case "assistant": roleName = "助理"; break; case "4": case "guest": roleName = "嘉宾"; break; default: roleName = "观众"; break; }
AST#export_declaration#Left export default AST#class_declaration#Left class ChatTools AST#class_body#Left { /** 聊天界面全面屏状态栏背景色 */ AST#property_declaration#Left static readonly chat_page_title_background_color = AST#expression#Left '#ffffff' AST#expression#Right ; AST#property_declaration#Right //'#fafafa';//#2e3746';//'#2e3746'; /** 聊天界面全面屏状态栏文本颜色 */ AST#property_declaration#Left static readonly chat_page_title_color = AST#expression#Left '#000000' AST#expression#Right ; AST#property_declaration#Right //#ffffff'; /** * 退出系统。 * * @param context UIAbilityContext上下文对象 */ AST#method_declaration#Left static exitSystem AST#parameter_list#Left ( AST#parameter#Left context : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . UIAbilityContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#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 context AST#expression#Right . terminateSelf 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 /** * 设置全面屏状态栏颜色。 * * @param context 上下文对象 * @param statusBarContentColor 状态栏文本颜色 * @param statusBarColor 状态栏背景色 */ AST#method_declaration#Left static setStatusBarColor AST#parameter_list#Left ( AST#parameter#Left context : 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#parameter#Right , AST#parameter#Left statusBarContentColor : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left statusBarColor : 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#try_statement#Left try 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#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left window . Window AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left 'window' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left w AST#ERROR#Right in AST#expression#Left dowClass AST#expression#Right AST#binary_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 statusBarContentColor AST#property_name#Right : AST#expression#Left statusBarContentColor AST#expression#Right AST#property_assignment#Right , //color, AST#property_assignment#Left AST#property_name#Left statusBarColor AST#property_name#Right : AST#expression#Left statusBarColor 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#block_statement#Right AST#catch_clause#Left catch ( exception ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left TAG AST#expression#Right + AST#expression#Left 'Failed to set the system bar properties. Cause: ' AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left JSON AST#expression#Right AST#binary_expression#Right AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left exception 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 /** * 收起软键盘。 * * @param context 上下文对象 */ AST#method_declaration#Left static hideSoftInputMethod AST#parameter_list#Left ( AST#parameter#Left context : 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#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 context AST#expression#Right . getFocusController AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . clearFocus 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 /** * 设置输入法软键盘避让模式为RESIZE(表示当输入显示时,压缩窗体高度,而不是使用默认的OFFSET模式将窗体整体上推)。 * 详见官方资料:https://developer.huawei.com/consumer/cn/doc/best-practices-V5/bpta-keyboard-layout-adapt-V5#section08221814182316 * * @param toRESIZE true表示设置为KeyboardAvoidMode.RESIZE模式,否则还原为系统默认的 KeyboardAvoidMode.OFFSET模式 */ AST#method_declaration#Left static setKeyboardAvoidModeToRESIZE AST#parameter_list#Left ( AST#parameter#Left context : AST#type_annotation#Left AST#primary_type#Left UIContext AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left toRESIZE : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left context AST#expression#Right . setKeyboardAvoidMode AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left toRESIZE AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left KeyboardAvoidMode AST#expression#Right . RESIZE AST#member_expression#Right AST#expression#Right : AST#expression#Left KeyboardAvoidMode AST#expression#Right AST#conditional_expression#Right AST#expression#Right . OFFSET 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 /** * Check obj is empty * * @param {object} obj * @return {boolean} true(empty) */ AST#method_declaration#Left static isEmpty AST#parameter_list#Left ( AST#parameter#Left obj : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left object 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 trimString : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left obj AST#expression#Right === AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left AST#binary_expression#Left AST#expression#Left obj AST#expression#Right === AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left AST#binary_expression#Left AST#expression#Left obj AST#expression#Right === AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left trimString AST#expression#Right ? AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left obj AST#expression#Right AST#unary_expression#Right AST#expression#Right === AST#expression#Left 'string' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right ? AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left obj AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . trim AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right === AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 返回本地用户UID. * * @returns local uid */ AST#method_declaration#Left static getLocalUserUid AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_statement#Left { // return ClientCoreSDK.getInstance().currentLoginInfo?.loginUserId AST#statement#Left AST#return_statement#Left return AST#expression#Left "" AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 显示奶油提示。 * * @param message 提示内容 * @param duration 持续时间(单位:毫秒),默认1500 */ AST#method_declaration#Left static showToast AST#parameter_list#Left ( AST#parameter#Left message : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left Resource AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left duration : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 1500 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 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 message AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left duration AST#property_name#Right : AST#expression#Left duration AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left showMode AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left promptAction AST#expression#Right . ToastShowMode AST#member_expression#Right AST#expression#Right . TOP_MOST 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#builder_function_body#Right AST#method_declaration#Right /** * 显示对话框. * * @param message 文本显示内容 * @param primaryButtonText 主按钮文本 * @param primaryButtonTextColor 主按钮文本颜色 * @param primaryAction 主按钮Action * @param secondaryButtonText 次按钮文本 * @param secondaryButtonTextColor 次按钮文本颜色 * @param secondaryAction 次按钮Action */ AST#method_declaration#Left static showAlertDialog AST#parameter_list#Left ( AST#parameter#Left message : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left primaryButtonText : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left primaryButtonTextColor : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left ResourceColor 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 primaryAction : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Callback AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left secondaryButtonText : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left secondaryButtonTextColor : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left ResourceColor 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 secondaryAction : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Callback AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#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 AlertDialog AST#expression#Right . show 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 message AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left autoCancel AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left alignment AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left DialogAlignment AST#expression#Right . Center AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offset AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left dx AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left dy AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right , // gridCount: 4, AST#property_assignment#Left AST#property_name#Left primaryButton AST#property_name#Right : AST#expression#Left AST#conditional_expression#Left AST#expression#Left primaryButtonText AST#expression#Right ? AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left value AST#property_name#Right : AST#expression#Left primaryButtonText AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left action AST#property_name#Right : AST#expression#Left primaryAction AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left fontColor AST#property_name#Right : AST#expression#Left primaryButtonTextColor AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right : AST#expression#Left undefined AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left secondaryButton AST#property_name#Right : AST#expression#Left AST#conditional_expression#Left AST#expression#Left secondaryButtonText AST#expression#Right ? AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left value AST#property_name#Right : AST#expression#Left secondaryButtonText AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left action AST#property_name#Right : AST#expression#Left secondaryAction AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left fontColor AST#property_name#Right : AST#expression#Left secondaryButtonTextColor AST#expression#Right AST#property_assignment#Right //$r('sys.color.ohos_id_color_badge_red') } AST#object_literal#Right AST#expression#Right : AST#expression#Left undefined AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right /** * 仿照微信中的消息时间显示逻辑,将时间戳(单位:毫秒)转换为友好的显示格式. * * 1)7天之内的日期显示逻辑是:今天、昨天(-1d)、前天(-2d)、星期?(只显示总计7天之内的星期数,即<=-4d); * 2)7天之外(即>7天)的逻辑:直接显示完整日期时间。 * @param timestamp 时间戳(单位:毫秒),形如:1550789954260 * @param mustIncludeTime true表示输出的格式里一定会包含“时间:分钟” * ,否则不包含(参考微信,不包含时分的情况,用于首页“消息”中显示时) * @param timeWithSegmentStr 本参数仅在mustIncludeTime=true时有生效,表示在时间字符串前带上“上午”、“下午”、“晚上”这样的描述 * * @return 输出格式形如:“刚刚”、“10:30”、“昨天 12:04”、“前天 20:51”、“星期二”、“2019/2/21 12:09”等形式 * @author Jack Jiang(http://www.52im.net/thread-2792-1-1.html) */ AST#method_declaration#Left static getTimeStringAutoShort2 AST#parameter_list#Left ( AST#parameter#Left timestamp : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left mustIncludeTime : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left timeWithSegmentStr : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 currentDate : AST#type_annotation#Left AST#primary_type#Left Date 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 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 let AST#variable_declarator#Left srcDate : AST#type_annotation#Left AST#primary_type#Left Date 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 Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left timestamp 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 currentYear : 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 currentDate AST#expression#Right . getFullYear AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left currentMonth : 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#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left currentDate AST#expression#Right . getMonth AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_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 let AST#variable_declarator#Left currentDateD : 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 currentDate AST#expression#Right . getDate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left srcYear : 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 srcDate AST#expression#Right . getFullYear AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left srcMonth : 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#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left srcDate AST#expression#Right . getMonth AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_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 let AST#variable_declarator#Left srcDateD : 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 srcDate AST#expression#Right . getDate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left ret : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '' AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 要额外显示的时间分钟 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left timeExtraStr = 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 mustIncludeTime AST#expression#Right ) AST#block_statement#Left { // let timeExtraStr = (mustIncludeTime ? " " + _formatDate(srcDate, "hh:mm") : ""); AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left timeExtraStr = 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#expression#Right + AST#expression#Left ChatTools AST#expression#Right AST#binary_expression#Right AST#expression#Right . getTimeHH24Human AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left srcDate AST#expression#Right , AST#expression#Left timeWithSegmentStr AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 当年 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left currentYear AST#expression#Right === AST#expression#Left srcYear 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 currentTimestamp : 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 currentDate AST#expression#Right . getTime AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left srcTimestamp : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left timestamp 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 deltaTime : 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#binary_expression#Left AST#expression#Left currentTimestamp AST#expression#Right - AST#expression#Left srcTimestamp AST#expression#Right AST#binary_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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left currentMonth AST#expression#Right === AST#expression#Left srcMonth AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left currentDateD AST#expression#Right === AST#expression#Left srcDateD AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { // // 时间相差60秒以内 // if(deltaTime < 60 * 1000) // ret = "刚刚"; // // 否则当天其它时间段的,直接显示“时:分”的形式 // else // ret = _formatDate(srcDate, "hh:mm"); // 当天只需要显示时间分钟,且必须显示“上午”、“下午”这样的时间段描述 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left ret = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ChatTools AST#expression#Right . getTimeHH24Human AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left srcDate 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#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right // 当年 && 当天之外的时间(即昨天及以前的时间) else AST#block_statement#Left { // 昨天(以“现在”的时候为基准-1天) AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left yesterdayDate : AST#type_annotation#Left AST#primary_type#Left Date 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 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left yesterdayDate AST#expression#Right . setDate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left yesterdayDate AST#expression#Right . getDate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right - AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 前天(以“现在”的时候为基准-2天) AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left beforeYesterdayDate : AST#type_annotation#Left AST#primary_type#Left Date 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 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left beforeYesterdayDate AST#expression#Right . setDate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left beforeYesterdayDate AST#expression#Right . getDate 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 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 用目标日期的“月”和“天”跟上方计算出来的“昨天”进行比较,是最为准确的(如果用时间戳差值 // 的形式,是不准确的,比如:现在时刻是2019年02月22日1:00、而srcDate是2019年02月21日23:00, // 这两者间只相差2小时,直接用“deltaTime/(3600 * 1000)” > 24小时来判断是否昨天,就完全是扯蛋的逻辑了) 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 AST#binary_expression#Left AST#expression#Left srcMonth AST#expression#Right === AST#expression#Left AST#parenthesized_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 yesterdayDate AST#expression#Right . getMonth AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left srcDateD AST#expression#Right === AST#expression#Left yesterdayDate AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . getDate 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 ret = AST#expression#Left AST#binary_expression#Left AST#expression#Left "昨天" AST#expression#Right + AST#expression#Left timeExtraStr AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // -1d } AST#block_statement#Right // “前天”判断逻辑同上 else 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 AST#binary_expression#Left AST#expression#Left srcMonth AST#expression#Right === AST#expression#Left AST#parenthesized_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 beforeYesterdayDate AST#expression#Right . getMonth AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left srcDateD AST#expression#Right === AST#expression#Left beforeYesterdayDate AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . getDate 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 ret = AST#expression#Left AST#binary_expression#Left AST#expression#Left "前天" AST#expression#Right + AST#expression#Left timeExtraStr AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // -2d } AST#block_statement#Right else AST#block_statement#Left { // 跟当前时间相差的小时数 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left deltaHour : 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#binary_expression#Left AST#expression#Left deltaTime AST#expression#Right / AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left 3600 AST#expression#Right * AST#expression#Left 1000 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#parenthesized_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 如果小于或等 7*24小时就显示星期几 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left deltaHour AST#expression#Right <= AST#expression#Left AST#binary_expression#Left AST#expression#Left 7 AST#expression#Right * AST#expression#Left 24 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left weekday = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Array AST#expression#Right AST#new_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left 7 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#subscript_expression#Left AST#expression#Left weekday AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left = AST#ERROR#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left "星期日" AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left weekday AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left = AST#ERROR#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left "星期一" AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left weekday AST#expression#Right [ AST#expression#Left 2 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left = AST#ERROR#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left "星期二" AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left weekday AST#expression#Right [ AST#expression#Left 3 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left = AST#ERROR#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left "星期三" AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left weekday AST#expression#Right [ AST#expression#Left 4 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left = AST#ERROR#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left "星期四" AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left weekday AST#expression#Right [ AST#expression#Left 5 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left = AST#ERROR#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left "星期五" AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left weekday AST#expression#Right [ AST#expression#Left 6 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left = AST#ERROR#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left "星期六" AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 取出当前是星期几 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left weedayDesc : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#subscript_expression#Left AST#expression#Left weekday AST#expression#Right [ AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left srcDate AST#expression#Right . getDay AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left ret = AST#expression#Left AST#binary_expression#Left AST#expression#Left weedayDesc AST#expression#Right + AST#expression#Left timeExtraStr AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right // 否则直接显示完整日期时间 else AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left ret = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ChatTools AST#expression#Right . formatDate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left srcDate AST#expression#Right , AST#expression#Left "M月d日" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left timeExtraStr AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right // 往年 else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left ret = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ChatTools AST#expression#Right . formatDate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left srcDate AST#expression#Right , AST#expression#Left "yy年M月d日" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left timeExtraStr AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left ret AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 获取仅包含“时间:分钟”部分的字符串,24小时制,且可以显示“上午”、“下午”、“晚上”这样的描述。 * * @param srcDateObj 原始日期对象 * @param timeWithSegmentStr 表示在时间字符串前带上“上午”、“下午”、“晚上”这样的描述 * @return 如果成功则返回结果,否则返回空字符串""(不是null) */ AST#method_declaration#Left static getTimeHH24Human AST#parameter_list#Left ( AST#parameter#Left srcDateObj : AST#type_annotation#Left AST#primary_type#Left Date AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left timeWithSegmentStr : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 ret : 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#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left timePattern : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'hh:mm' 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 timeStr : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ChatTools AST#expression#Right . formatDate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left srcDateObj AST#expression#Right , AST#expression#Left timePattern 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 timeSegmentStr : 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 timeWithSegmentStr AST#expression#Right ) AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left timeSegmentStr = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ChatTools AST#expression#Right . getTimeSegmentStr AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left timeStr 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#if_statement#Right AST#statement#Right // 组合成最终的人性化时间分钟字符串形式 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left ret = AST#expression#Left AST#binary_expression#Left AST#expression#Left timeSegmentStr AST#expression#Right + AST#expression#Left timeStr AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( e ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left "【DEBUG-getTimeHH24Human】计算出错:" 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 e AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left " 【NO】" AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left ret AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 将一个两位24小时时间的转换为上午、下午这样的描述。 * * @param hh24 两位的24小时制时间的小时部分 * @return 如果成功转换则返回形如:“凌晨”、“上午”等,否则返回空字符串(不是null) * @since 3.1 */ AST#method_declaration#Left static getTimeSegmentStr AST#parameter_list#Left ( AST#parameter#Left hh24 : 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 ret : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '' AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left hh24 AST#expression#Right && AST#expression#Left hh24 AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right >= AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { // 取出“小时”部分 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left a = AST#expression#Left AST#call_expression#Left AST#expression#Left parseInt AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hh24 AST#expression#Right . substring AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left 2 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left a 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 a AST#expression#Right <= AST#expression#Left 6 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left ret = AST#expression#Left "凌晨" AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left a AST#expression#Right > AST#expression#Left 6 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left a AST#expression#Right <= AST#expression#Left 12 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left ret = AST#expression#Left "上午" AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left a AST#expression#Right > AST#expression#Left 12 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left a AST#expression#Right <= AST#expression#Left 13 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left ret = AST#expression#Left "中午" AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left a AST#expression#Right > AST#expression#Left 13 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left a AST#expression#Right <= AST#expression#Left 18 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left ret = AST#expression#Left "下午" AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left a AST#expression#Right > AST#expression#Left 18 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left a AST#expression#Right <= AST#expression#Left 24 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left ret = AST#expression#Left "晚上" AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( e ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left "【DEBUG-getTimeSegmentStr】计算出错:" 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 e AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left " 【NO】" AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left ret AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 对Date的扩展,将 Date 转化为指定格式的String。 * * 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符, * 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)。 * * 【示例】: * common.formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss.S') ==> 2006-07-02 08:09:04.423 * common.formatDate(new Date(), 'yyyy-M-d h:m:s.S') ==> 2006-7-2 8:9:4.18 * common.formatDate(new Date(), 'hh:mm:ss.S') ==> 08:09:04.423 * * @param date Date对象 * @param fmt 格式字符串 * @param 格式化的字符串 */ AST#method_declaration#Left static formatDate AST#parameter_list#Left ( AST#parameter#Left date : AST#type_annotation#Left AST#primary_type#Left Date AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left fmt : 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 map = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Map AST#expression#Right AST#new_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left String AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left Number AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#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 map AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "M+" AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date AST#expression#Right . getMonth AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#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#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left map AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "d+" AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date AST#expression#Right . getDate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 日 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left map AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "h+" AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date 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#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 map AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "m+" AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date AST#expression#Right . getMinutes AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 分 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left map AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "s+" AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date AST#expression#Right . getSeconds AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 秒 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left map AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "q+" AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . floor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date AST#expression#Right . getMonth 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 3 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right / AST#expression#Left 3 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_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 map AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "S" AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date AST#expression#Right . getMilliseconds 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#variable_declaration#Left let AST#variable_declarator#Left yearMatcher = AST#ERROR#Left / AST#ERROR#Right AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left y AST#expression#Right + AST#expression#Left AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right / AST#expression#Left AST#expression#Right AST#binary_expression#Right AST#expression#Right . exec AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left fmt AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left yearMatcher AST#expression#Right && AST#expression#Left yearMatcher AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left match = AST#expression#Left AST#subscript_expression#Left AST#expression#Left yearMatcher AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left fmt = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fmt AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left match AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date AST#expression#Right . getFullYear AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left "" AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . substr AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 4 AST#expression#Right - AST#expression#Left match AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left map 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 value AST#parameter#Right , AST#parameter#Left key AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left matcher = 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 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 . exec AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#non_null_assertion_expression#Left AST#expression#Left fmt 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 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left matcher AST#expression#Right && AST#expression#Left matcher AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left match = AST#expression#Left AST#subscript_expression#Left AST#expression#Left matcher AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left replaceValue = 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#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left match 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#parenthesized_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left replaceValue = AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left value AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left replaceValue = AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left "00" AST#expression#Right + AST#expression#Left value AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . substr AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left "" AST#expression#Right + AST#expression#Left value AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_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#parenthesized_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left fmt = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#non_null_assertion_expression#Left AST#expression#Left fmt AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left match AST#expression#Right , AST#expression#Left replaceValue 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#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 fmt AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left static getLimitString AST#parameter_list#Left ( AST#parameter#Left source : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left length : 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 AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left source AST#expression#Right !== AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left source AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right > AST#expression#Left length AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left source AST#expression#Right . substring AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left length 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#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 source AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left static changeRoleToRoleName AST#parameter_list#Left ( AST#parameter#Left role : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#ERROR#Left : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right { // 1 主持人,2 观众,3 助理,4 嘉宾 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left roleName : 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left switch AST#expression#Right AST#argument_list#Left ( AST#expression#Left role 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 "1" AST#ERROR#Right : AST#expression#Left AST#assignment_expression#Left case AST#ERROR#Left "host" : AST#type_annotation#Left AST#primary_type#Left roleName AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Right = AST#expression#Left "主持人" AST#expression#Right AST#assignment_expression#Right 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#break_statement#Left break ; AST#break_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left "3" AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Right : AST#type_annotation#Left AST#primary_type#Left case AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left "assistant" : roleName = "助理" AST#ERROR#Right ; AST#method_declaration#Right AST#property_declaration#Left break ; AST#property_declaration#Right AST#property_declaration#Left case AST#ERROR#Left "4" AST#ERROR#Right : AST#type_annotation#Left AST#primary_type#Left case AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left "guest" : roleName AST#ERROR#Right = AST#expression#Left "嘉宾" AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left break ; AST#property_declaration#Right AST#property_declaration#Left default : AST#type_annotation#Left AST#primary_type#Left roleName AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "观众" AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left break ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export default class ChatTools { static readonly chat_page_title_background_color = '#ffffff'; static readonly chat_page_title_color = '#000000'; static exitSystem(context: common.UIAbilityContext) { context.terminateSelf(); } static setStatusBarColor(context: common.BaseContext, statusBarContentColor: string, statusBarColor: string) { try { let windowClass = AppStorage.get<window.Window>('window') windowClass?.setWindowSystemBarProperties({ statusBarContentColor: statusBarContentColor, statusBarColor: statusBarColor, }); } catch (exception) { console.error(TAG+ 'Failed to set the system bar properties. Cause: ' + JSON.stringify(exception)); } } static hideSoftInputMethod(context: UIContext) { context.getFocusController().clearFocus(); } static setKeyboardAvoidModeToRESIZE(context: UIContext, toRESIZE: boolean) { context.setKeyboardAvoidMode(toRESIZE ? KeyboardAvoidMode.RESIZE : KeyboardAvoidMode.OFFSET); } static isEmpty(obj: object | string, trimString: boolean = false): boolean { return obj === undefined || obj === null || obj === '' || (trimString? ((typeof obj === 'string') ? (obj as string).trim() === '' : false) : false); } static getLocalUserUid(): string | undefined { return ""; } static showToast(message: string | Resource, duration: number = 1500) { promptAction.showToast({ message: message, duration: duration, showMode: promptAction.ToastShowMode.TOP_MOST, }); } static showAlertDialog(message: ResourceStr , primaryButtonText: string, primaryButtonTextColor: ResourceColor | undefined, primaryAction: Callback<void> , secondaryButtonText: string, secondaryButtonTextColor: ResourceColor | undefined, secondaryAction: Callback<void>) { AlertDialog.show( { message: message, autoCancel: false, alignment: DialogAlignment.Center, offset:{ dx: 0, dy: 0 } , primaryButton: primaryButtonText ? { value: primaryButtonText, action: primaryAction, fontColor: primaryButtonTextColor } : undefined, secondaryButton: secondaryButtonText ? { value: secondaryButtonText, action: secondaryAction, fontColor: secondaryButtonTextColor } : undefined }); } static getTimeStringAutoShort2(timestamp: number, mustIncludeTime: boolean, timeWithSegmentStr: boolean): string { let currentDate: Date = new Date(); let srcDate: Date = new Date(timestamp); let currentYear: number = currentDate.getFullYear(); let currentMonth: number = (currentDate.getMonth()+1); let currentDateD: number = currentDate.getDate(); let srcYear: number = srcDate.getFullYear(); let srcMonth: number = (srcDate.getMonth()+1); let srcDateD: number = srcDate.getDate(); let ret: string = ''; let timeExtraStr = ''; if(mustIncludeTime) { timeExtraStr = " "+ChatTools.getTimeHH24Human(srcDate, timeWithSegmentStr); } if(currentYear === srcYear) { let currentTimestamp: number = currentDate.getTime(); let srcTimestamp: number = timestamp; let deltaTime: number = (currentTimestamp-srcTimestamp); if(currentMonth === srcMonth && currentDateD === srcDateD) { ret = ChatTools.getTimeHH24Human(srcDate, true); } && 当天之外的时间(即昨天及以前的时间) else { let yesterdayDate:Date = new Date(); yesterdayDate.setDate(yesterdayDate.getDate()-1); let beforeYesterdayDate: Date = new Date(); beforeYesterdayDate.setDate(beforeYesterdayDate.getDate()-2); if(srcMonth === (yesterdayDate.getMonth()+1) && srcDateD === yesterdayDate.getDate()) { ret = "昨天"+timeExtraStr; } else if(srcMonth === (beforeYesterdayDate.getMonth()+1) && srcDateD === beforeYesterdayDate.getDate()) { ret = "前天" + timeExtraStr; } else{ let deltaHour: number = (deltaTime/(3600 * 1000)); if (deltaHour <= 7*24){ let weekday = new Array<string>(7); weekday[0]="星期日"; weekday[1]="星期一"; weekday[2]="星期二"; weekday[3]="星期三"; weekday[4]="星期四"; weekday[5]="星期五"; weekday[6]="星期六"; let weedayDesc: string = weekday[srcDate.getDay()]; ret = weedayDesc + timeExtraStr; } else ret = ChatTools.formatDate(srcDate, "M月d日")+timeExtraStr; } } } else{ ret = ChatTools.formatDate(srcDate, "yy年M月d日")+timeExtraStr; } return ret; } static getTimeHH24Human(srcDateObj: Date, timeWithSegmentStr: boolean): string { let ret: string = ''; try { let timePattern: string = 'hh:mm'; let timeStr: string = ChatTools.formatDate(srcDateObj, timePattern); let timeSegmentStr: string = ''; if(timeWithSegmentStr) timeSegmentStr = ChatTools.getTimeSegmentStr(timeStr); ret = timeSegmentStr+timeStr; } catch (e) { console.error("【DEBUG-getTimeHH24Human】计算出错:"+ JSON.stringify(e) +" 【NO】"); } return ret; } static getTimeSegmentStr(hh24: string): string { let ret: string = ''; if (hh24 && hh24.length >= 2) { try { let a = parseInt(hh24.substring(0, 2)); if (a >= 0 && a <= 6) { ret = "凌晨"; } else if (a > 6 && a <= 12) { ret = "上午"; } else if (a > 12 && a <= 13) { ret = "中午"; } else if (a > 13 && a <= 18) { ret = "下午"; } else if (a > 18 && a <= 24) { ret = "晚上"; } } catch (e) { console.error("【DEBUG-getTimeSegmentStr】计算出错:" + JSON.stringify(e) + " 【NO】"); } } return ret; } static formatDate(date: Date, fmt: string) { let map = new Map<String, Number>(); map.set("M+", date.getMonth() + 1); map.set("d+", date.getDate()); map.set("h+", date.getHours()); map.set("m+", date.getMinutes()); map.set("s+", date.getSeconds()); map.set("q+", Math.floor((date.getMonth() + 3) / 3)); map.set("S", date.getMilliseconds()); let yearMatcher = /(y+)/.exec(fmt); if (yearMatcher && yearMatcher.length > 0) { let match = yearMatcher[0]; fmt = fmt.replace(match, (date.getFullYear() + "").substr(4 - match.length)); } map.forEach((value, key) => { let matcher = new RegExp(`(${key})`).exec(fmt!); if (matcher && matcher.length > 0) { let match = matcher[0]; let replaceValue = ''; if ((match.length == 1)) { replaceValue = `${value}`; } else { replaceValue = (("00" + value).substr(("" + value).length)) } fmt = fmt!.replace(match, replaceValue); } }); return fmt; } static getLimitString(source: string, length: number): string { if (source !== '' && source.length > length) { return source.substring(0, length) + "..."; } return source; } static changeRoleToRoleName(role: string): string { let roleName: string = ''; switch (role) { case "1": case "host": roleName = "主持人"; break; case "3": case "assistant": roleName = "助理"; break; case "4": case "guest": roleName = "嘉宾"; break; default: roleName = "观众"; break; }
https://github.com/vhall/VHLive_SDK_Harmony/blob/29c820e5301e17ae01bc6bdcc393a4437b518e7c/watchKit/src/main/ets/util/ChatTools.ets#L12-L379
b821b0c16049b3d3c86ca80fb2299297fcd0404a
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/BasicFeature/Media/Camera/entry/src/main/ets/pages/Index.ets
arkts
requestPermissionsFn
Obtain permissions
async requestPermissionsFn() { Logger.info(TAG, `requestPermissionsFn entry`); try { this.atManager.requestPermissionsFromUser(this.appContext, [ 'ohos.permission.CAMERA', 'ohos.permission.MICROPHONE', 'ohos.permission.READ_MEDIA', 'ohos.permission.WRITE_MEDIA' ]).then(() => { Logger.info(TAG, `request Permissions success!`); this.onShow = true; }) } catch (err) { Logger.info(TAG, `requestPermissionsFromUser call Failed! error: ${err.code}`); } }
AST#method_declaration#Left async requestPermissionsFn AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` requestPermissionsFn entry ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#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 . atManager AST#member_expression#Right AST#expression#Right . requestPermissionsFromUser 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 . appContext AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left 'ohos.permission.CAMERA' AST#expression#Right , AST#expression#Left 'ohos.permission.MICROPHONE' AST#expression#Right , AST#expression#Left 'ohos.permission.READ_MEDIA' AST#expression#Right , AST#expression#Left 'ohos.permission.WRITE_MEDIA' AST#expression#Right ] AST#array_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_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 TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` request Permissions success! ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . onShow AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` requestPermissionsFromUser call Failed! error: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async requestPermissionsFn() { Logger.info(TAG, `requestPermissionsFn entry`); try { this.atManager.requestPermissionsFromUser(this.appContext, [ 'ohos.permission.CAMERA', 'ohos.permission.MICROPHONE', 'ohos.permission.READ_MEDIA', 'ohos.permission.WRITE_MEDIA' ]).then(() => { Logger.info(TAG, `request Permissions success!`); this.onShow = true; }) } catch (err) { Logger.info(TAG, `requestPermissionsFromUser call Failed! error: ${err.code}`); } }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/BasicFeature/Media/Camera/entry/src/main/ets/pages/Index.ets#L120-L135
5dc1fb353eb26ca0d3e93a99b683b30cc2db58ba
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/Solutions/IM/Chat/features/chatlist/src/main/ets/utils/ChatListJsonData.ets
arkts
Copyright (c) 2023 Huawei Device Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
export default class ChatListJsonData { public static readonly CHAT_LIST_JSON_DATA: Array<string> = [ 'mockChatOneModelData.json', 'mockChatTwoModelData.json' ] }
AST#export_declaration#Left export default AST#class_declaration#Left class ChatListJsonData AST#class_body#Left { AST#property_declaration#Left public static readonly CHAT_LIST_JSON_DATA : 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 'mockChatOneModelData.json' AST#expression#Right , AST#expression#Left 'mockChatTwoModelData.json' AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export default class ChatListJsonData { public static readonly CHAT_LIST_JSON_DATA: Array<string> = [ 'mockChatOneModelData.json', 'mockChatTwoModelData.json' ] }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/Solutions/IM/Chat/features/chatlist/src/main/ets/utils/ChatListJsonData.ets#L16-L21
07e6b02bc7a5e37a80bc1861bbdd84bd0373ac29
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/WantUtil.ets
arkts
toAppGalleryDetail
拉起应用市场对应的应用详情界面 @param bundleName 需要打开应用详情的应用的包名。 @returns
static async toAppGalleryDetail(bundleName: string): Promise<void> { const want: Want = { action: 'ohos.want.action.appdetail', uri: 'store://appgallery.huawei.com/app/detail?id=' + bundleName, }; return AppUtil.getContext().startAbility(want); }
AST#method_declaration#Left static async toAppGalleryDetail AST#parameter_list#Left ( AST#parameter#Left bundleName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left want : AST#type_annotation#Left AST#primary_type#Left Want AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left action AST#property_name#Right : AST#expression#Left 'ohos.want.action.appdetail' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left uri AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left 'store://appgallery.huawei.com/app/detail?id=' AST#expression#Right + AST#expression#Left bundleName AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right , } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 . startAbility AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left want AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static async toAppGalleryDetail(bundleName: string): Promise<void> { const want: Want = { action: 'ohos.want.action.appdetail', uri: 'store://appgallery.huawei.com/app/detail?id=' + bundleName, }; return AppUtil.getContext().startAbility(want); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/WantUtil.ets#L211-L217
88b14fceac463459625c8da15ed9098a66fbc2a0
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/smartfill/Index.ets
arkts
SmartFill
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 { SmartFill } from './src/main/ets/view/SmartFill';
AST#export_declaration#Left export { SmartFill } from './src/main/ets/view/SmartFill' ; AST#export_declaration#Right
export { SmartFill } from './src/main/ets/view/SmartFill';
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/smartfill/Index.ets#L30-L30
c69ac2b7a01e94db6aff159ed66c1c7fc287b22b
gitee
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
Media/SimpleVideo/entry/src/main/ets/common/constants/CommonConstants.ets
arkts
default opacity
export const DEFAULT_OPACITY: number = Number.parseFloat('0.2');
AST#export_declaration#Left export AST#variable_declaration#Left const AST#variable_declarator#Left DEFAULT_OPACITY : 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 Number AST#expression#Right . parseFloat AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '0.2' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#export_declaration#Right
export const DEFAULT_OPACITY: number = Number.parseFloat('0.2');
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Media/SimpleVideo/entry/src/main/ets/common/constants/CommonConstants.ets#L54-L54
0afd8ec5d4dc8d5d8358c5f0a02192980a9393f3
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
harmonyos/src/main/ets/common/types/GreetingTypes.ets
arkts
祝福语模板接口
export interface GreetingTemplate { id: string; name: string; content: string; style: GreetingStyle; occasion: GreetingOccasion; variables: GreetingVariable[]; isSystem: boolean; usage: number; rating: number; tags: string[]; }
AST#export_declaration#Left export AST#interface_declaration#Left interface GreetingTemplate AST#object_type#Left { AST#type_member#Left id : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left name : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left content : 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 style : AST#type_annotation#Left AST#primary_type#Left GreetingStyle AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left occasion : AST#type_annotation#Left AST#primary_type#Left GreetingOccasion AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left variables : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left GreetingVariable [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left isSystem : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left usage : 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 rating : 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 tags : 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#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
export interface GreetingTemplate { id: string; name: string; content: string; style: GreetingStyle; occasion: GreetingOccasion; variables: GreetingVariable[]; isSystem: boolean; usage: number; rating: number; tags: string[]; }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/harmonyos/src/main/ets/common/types/GreetingTypes.ets#L133-L144
4fdcdef372d2ef43a07833aa136e3640c346aff5
github
pangpang20/wavecast.git
d3da8a0009eb44a576a2b9d9d9fe6195a2577e32
entry/src/main/ets/common/UIUtils.ets
arkts
setUIContext
页面初始化时调用
static setUIContext(context: UIContext): void { UIUtils.uiContext = context; }
AST#method_declaration#Left static setUIContext AST#parameter_list#Left ( AST#parameter#Left context : AST#type_annotation#Left AST#primary_type#Left UIContext AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 UIUtils AST#expression#Right . uiContext AST#member_expression#Right = AST#expression#Left context AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
static setUIContext(context: UIContext): void { UIUtils.uiContext = context; }
https://github.com/pangpang20/wavecast.git/blob/d3da8a0009eb44a576a2b9d9d9fe6195a2577e32/entry/src/main/ets/common/UIUtils.ets#L60-L62
754c60a7bbac30da15f818dbbadcf31c9b944902
github
vhall/VHLive_SDK_Harmony
29c820e5301e17ae01bc6bdcc393a4437b518e7c
watchKit/src/main/ets/model/VHHistoryMessageDataSource.ets
arkts
registerDataChangeListener
该方法为框架侧调用,为LazyForEach组件向其数据源处添加listener监听
registerDataChangeListener(listener: DataChangeListener): void { if (this.listeners.indexOf(listener) < 0) { console.info('add listener'); this.listeners.push(listener); } }
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 console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'add listener' 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 . 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
registerDataChangeListener(listener: DataChangeListener): void { if (this.listeners.indexOf(listener) < 0) { console.info('add listener'); this.listeners.push(listener); } }
https://github.com/vhall/VHLive_SDK_Harmony/blob/29c820e5301e17ae01bc6bdcc393a4437b518e7c/watchKit/src/main/ets/model/VHHistoryMessageDataSource.ets#L18-L23
c11b47fe8f40c26fc53b72b2a4e2f5fc694bf616
gitee
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
Media/VideoPlayer/entry/src/main/ets/viewmodel/HomeVideoListModel.ets
arkts
getLocalVideo
Scan the local video. @return Local video list data
async getLocalVideo() { this.videoLocalList = []; await this.assemblingVideoBean(); GlobalContext.getContext().setObject('videoLocalList', this.videoLocalList); return this.videoLocalList; }
AST#method_declaration#Left async getLocalVideo AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . videoLocalList AST#member_expression#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . assemblingVideoBean AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#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 'videoLocalList' AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . videoLocalList AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left return AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . videoLocalList AST#member_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
async getLocalVideo() { this.videoLocalList = []; await this.assemblingVideoBean(); GlobalContext.getContext().setObject('videoLocalList', this.videoLocalList); return this.videoLocalList; }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Media/VideoPlayer/entry/src/main/ets/viewmodel/HomeVideoListModel.ets#L31-L36
b0d19f269de8bd0962e2763484778244f5b38740
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/SystemFeature/FileManagement/Photos/entry/src/main/ets/pages/MediaOperationPage.ets
arkts
onActive
Callback when the page is in the foreground
onActive(): void { if (!this.isActive) { Log.info(TAG, 'onActive'); this.isActive = true; } }
AST#method_declaration#Left onActive AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . isActive 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 Log AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left 'onActive' 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isActive 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#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
onActive(): void { if (!this.isActive) { Log.info(TAG, 'onActive'); this.isActive = true; } }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/SystemFeature/FileManagement/Photos/entry/src/main/ets/pages/MediaOperationPage.ets#L150-L155
2e6acce71316c409bb456c9ad380bb696abf5204
gitee
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
feature/order/src/main/ets/viewmodel/OrderLogisticsViewModel.ets
arkts
loadOrderLogistics
获取订单物流信息 @returns {void} 无返回值
loadOrderLogistics(): void { if (!this.orderId) { this.logisticsInfo = new Logistics(); return; } RequestHelper.repository<Logistics>(this.repository.getOrderLogistics(this.orderId)) .toast(false) .execute() .then((data: Logistics): void => { this.logisticsInfo = data; }); }
AST#method_declaration#Left loadOrderLogistics AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . orderId AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . logisticsInfo AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Logistics 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#statement#Right AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left RequestHelper AST#expression#Right . repository AST#member_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left Logistics AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#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 . repository AST#member_expression#Right AST#expression#Right . getOrderLogistics 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 . orderId AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . toast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . execute AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left Logistics 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 . logisticsInfo AST#member_expression#Right = AST#expression#Left data AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#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
loadOrderLogistics(): void { if (!this.orderId) { this.logisticsInfo = new Logistics(); return; } RequestHelper.repository<Logistics>(this.repository.getOrderLogistics(this.orderId)) .toast(false) .execute() .then((data: Logistics): void => { this.logisticsInfo = data; }); }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/order/src/main/ets/viewmodel/OrderLogisticsViewModel.ets#L53-L64
08e7baeb13f3fa1bb9dcbe26202877facdf99c7b
github
openharmony-tpc/ohos_mpchart
4fb43a7137320ef2fee2634598f53d93975dfb4a
library/src/main/ets/components/charts/RadarChartModel.ets
arkts
setDrawWeb
If set to true, drawing the web is enabled, if set to false, drawing the whole web is disabled. Default: true @param enabled
public setDrawWeb(enabled: boolean) { this.mDrawWeb = enabled; }
AST#method_declaration#Left public setDrawWeb 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_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mDrawWeb AST#member_expression#Right = AST#expression#Left enabled AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
public setDrawWeb(enabled: boolean) { this.mDrawWeb = enabled; }
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/charts/RadarChartModel.ets#L310-L312
5ae659cf1e554e4c40e4b20d25f4db8e78d05b21
gitee
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/models/datas/model/SearchManager.ets
arkts
changeFavoriteLevelForWord
更改单词的收藏等级
async changeFavoriteLevelForWord(word: WordUser, newLevel: number): Promise<void> { word.favoriteLevel = newLevel; await WordUserDbAccess.shared.saveWordUser(word); }
AST#method_declaration#Left async changeFavoriteLevelForWord AST#parameter_list#Left ( AST#parameter#Left word : AST#type_annotation#Left AST#primary_type#Left WordUser AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left newLevel : 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#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left word AST#expression#Right . favoriteLevel AST#member_expression#Right = AST#expression#Left newLevel AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left WordUserDbAccess AST#expression#Right AST#await_expression#Right AST#expression#Right . shared AST#member_expression#Right AST#expression#Right . saveWordUser AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left word AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
async changeFavoriteLevelForWord(word: WordUser, newLevel: number): Promise<void> { word.favoriteLevel = newLevel; await WordUserDbAccess.shared.saveWordUser(word); }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/datas/model/SearchManager.ets#L837-L840
860b1cfbc1de6cbdf2d92d3c69646109d2148340
github
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
feature/main/src/main/ets/viewmodel/CartViewModel.ets
arkts
@file 购物车页面 ViewModel @author Joker.X
@ObservedV2 export default class CartViewModel extends BaseViewModel { /** * 购物车仓库 */ private readonly cartRepository: CartRepository = new CartRepository(); /** * 订单缓存本地存储仓库 */ private readonly orderCacheStoreRepository: OrderCacheStoreRepository = new OrderCacheStoreRepository(); /** * 购物车列表 */ @Trace cartList: Cart[] = []; /** * 选中的规格ID集合 (key: goodsId_specId) */ @Trace selectedSpecIds: Set<string> = new Set(); /** * 是否正在加载 */ @Trace isLoading: boolean = false; /** * 是否处于编辑模式 */ @Trace isEditing: boolean = false; /** * 获取选中的商品总数量 * @returns {number} 选中商品数量 */ get selectedCount(): number { return this.selectedSpecIds.size; } /** * 获取选中商品的总价 * @returns {number} 总价(单位:分) */ get totalAmount(): number { let total = 0; for (const cart of this.cartList) { for (const spec of cart.spec) { const key = `${cart.goodsId}_${spec.id}`; if (this.selectedSpecIds.has(key)) { total += spec.price * spec.count; } } } return total; } /** * 是否全选 * @returns {boolean} 是否全选 */ get isAllSelected(): boolean { if (this.cartList.length === 0) { return false; } for (const cart of this.cartList) { for (const spec of cart.spec) { const key = `${cart.goodsId}_${spec.id}`; if (!this.selectedSpecIds.has(key)) { return false; } } } return true; } /** * 购物车是否为空 * @returns {boolean} 是否为空 */ get isEmpty(): boolean { return this.cartList.length === 0; } /** * 加载购物车数据 * @returns {Promise<void>} Promise<void> */ async loadCartData(): Promise<void> { this.isLoading = true; try { this.cartList = await this.cartRepository.getAllCarts(); } finally { this.isLoading = false; } } /** * 切换规格选中状态 * @param {number} goodsId 商品ID * @param {number} specId 规格ID * @returns {void} 无返回值 */ toggleSpecSelected(goodsId: number, specId: number): void { const key = `${goodsId}_${specId}`; const newSet = new Set(this.selectedSpecIds); if (newSet.has(key)) { newSet.delete(key); } else { newSet.add(key); } this.selectedSpecIds = newSet; } /** * 判断规格是否选中 * @param {number} goodsId 商品ID * @param {number} specId 规格ID * @returns {boolean} 是否选中 */ isSpecSelected(goodsId: number, specId: number): boolean { const key = `${goodsId}_${specId}`; return this.selectedSpecIds.has(key); } /** * 全选/取消全选 * @returns {void} 无返回值 */ toggleSelectAll(): void { if (this.isAllSelected) { this.selectedSpecIds = new Set(); } else { this.selectAll(); } } /** * 全选所有商品 * @returns {void} 无返回值 */ private selectAll(): void { const newSet = new Set<string>(); for (const cart of this.cartList) { for (const spec of cart.spec) { newSet.add(`${cart.goodsId}_${spec.id}`); } } this.selectedSpecIds = newSet; } /** * 更新商品规格数量 * @param {number} goodsId 商品ID * @param {number} specId 规格ID * @param {number} count 新数量 * @returns {Promise<void>} Promise<void> */ async updateSpecCount(goodsId: number, specId: number, count: number): Promise<void> { await this.cartRepository.updateCartSpecCount(goodsId, specId, count); // 更新本地数据 for (const cart of this.cartList) { if (cart.goodsId === goodsId) { for (const spec of cart.spec) { if (spec.id === specId) { spec.count = count; break; } } break; } } // 触发响应式更新 this.cartList = [...this.cartList]; } /** * 删除商品规格 * @param {number} goodsId 商品ID * @param {number} specId 规格ID * @returns {Promise<void>} Promise<void> */ async removeSpec(goodsId: number, specId: number): Promise<void> { await this.cartRepository.removeSpecFromCart(goodsId, specId); // 更新本地数据 for (let i = 0; i < this.cartList.length; i++) { const cart = this.cartList[i]; if (cart.goodsId === goodsId) { cart.spec = cart.spec.filter((s: CartGoodsSpec): boolean => s.id !== specId); if (cart.spec.length === 0) { this.cartList.splice(i, 1); } break; } } // 移除选中状态 const key = `${goodsId}_${specId}`; const newSet = new Set(this.selectedSpecIds); newSet.delete(key); this.selectedSpecIds = newSet; // 触发响应式更新 this.cartList = [...this.cartList]; } /** * 删除选中的商品 * @returns {Promise<void>} Promise<void> */ async deleteSelected(): Promise<void> { const selectedKeys = Array.from(this.selectedSpecIds); for (const key of selectedKeys) { const parts = key.split('_'); const goodsId = parseInt(parts[0]); const specId = parseInt(parts[1]); await this.cartRepository.removeSpecFromCart(goodsId, specId); // 更新本地数据 for (let i = 0; i < this.cartList.length; i++) { const cart = this.cartList[i]; if (cart.goodsId === goodsId) { cart.spec = cart.spec.filter((s: CartGoodsSpec): boolean => s.id !== specId); if (cart.spec.length === 0) { this.cartList.splice(i, 1); } break; } } } // 触发响应式更新 this.cartList = [...this.cartList]; // 清空选择状态 this.selectedSpecIds = new Set(); // 退出编辑模式 this.isEditing = false; } /** * 结算按钮点击 * @returns {Promise<void>} Promise<void> */ async onSettleClick(): Promise<void> { // 检查是否有选中的商品 if (this.selectedSpecIds.size === 0) { ToastUtils.showError($r("app.string.please_select_settlement_goods")); return; } // 1. 获取选中的购物车项 const selectedCarts = this.getSelectedCarts(); if (selectedCarts.length === 0) { ToastUtils.showError($r("app.string.get_selected_goods_failed")); return; } // 2. 缓存选中的购物车项 await this.orderCacheStoreRepository.saveCarts(selectedCarts); // 3. 将购物车项转换为 SelectedGoods const selectedGoodsList = this.convertCartsToSelectedGoods(selectedCarts); // 4. 缓存 SelectedGoods await this.orderCacheStoreRepository.saveSelectedGoodsList(selectedGoodsList); // 5. 导航到订单确认页面 OrderNavigator.toConfirm(); } /** * 获取选中的购物车项 * @returns {Cart[]} 选中的购物车列表 */ private getSelectedCarts(): Cart[] { const result: Cart[] = []; for (const cart of this.cartList) { // 获取该商品下选中的规格 const selectedSpecs: CartGoodsSpec[] = []; for (const spec of cart.spec) { const key = `${cart.goodsId}_${spec.id}`; if (this.selectedSpecIds.has(key)) { selectedSpecs.push(spec); } } // 如果有选中的规格,创建新的购物车项 if (selectedSpecs.length > 0) { const newCart = new Cart(); newCart.goodsId = cart.goodsId; newCart.goodsName = cart.goodsName; newCart.goodsMainPic = cart.goodsMainPic; newCart.spec = selectedSpecs; result.push(newCart); } } return result; } /** * 将购物车项转换为 SelectedGoods * @param {Cart[]} carts 购物车列表 * @returns {SelectedGoods[]} 转换后的 SelectedGoods 列表 */ private convertCartsToSelectedGoods(carts: Cart[]): SelectedGoods[] { const result: SelectedGoods[] = []; for (const cart of carts) { for (const cartSpec of cart.spec) { // 创建规格对象 const spec = new GoodsSpec(); spec.id = cartSpec.id; spec.goodsId = cartSpec.goodsId; spec.name = cartSpec.name; spec.price = cartSpec.price; spec.stock = cartSpec.stock; spec.images = cartSpec.images; // 创建商品信息对象 const goodsInfo = new Goods(); goodsInfo.id = cart.goodsId; goodsInfo.title = cart.goodsName; goodsInfo.mainPic = cart.goodsMainPic; // 创建 SelectedGoods 对象 const selectedGoods = new SelectedGoods(); selectedGoods.goodsId = cart.goodsId; selectedGoods.count = cartSpec.count; selectedGoods.spec = spec; selectedGoods.goodsInfo = goodsInfo; result.push(selectedGoods); } } return result; } /** * 切换编辑模式 * @returns {void} 无返回值 */ toggleEditMode(): void { // 清空选择状态 this.selectedSpecIds = new Set(); // 切换编辑模式 this.isEditing = !this.isEditing; } }
AST#decorated_export_declaration#Left AST#decorator#Left @ ObservedV2 AST#decorator#Right export default AST#class_declaration#Left class CartViewModel extends AST#type_annotation#Left AST#primary_type#Left BaseViewModel AST#primary_type#Right AST#type_annotation#Right AST#class_body#Left { /** * 购物车仓库 */ AST#property_declaration#Left private readonly cartRepository : AST#type_annotation#Left AST#primary_type#Left CartRepository 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 CartRepository AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * 订单缓存本地存储仓库 */ AST#property_declaration#Left private readonly orderCacheStoreRepository : AST#type_annotation#Left AST#primary_type#Left OrderCacheStoreRepository 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 OrderCacheStoreRepository AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * 购物车列表 */ AST#property_declaration#Left AST#decorator#Left @ Trace AST#decorator#Right cartList : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Cart [ ] 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 /** * 选中的规格ID集合 (key: goodsId_specId) */ AST#property_declaration#Left AST#decorator#Left @ Trace AST#decorator#Right selectedSpecIds : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Set 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#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Set AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * 是否正在加载 */ AST#property_declaration#Left AST#decorator#Left @ Trace AST#decorator#Right isLoading : 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 @ Trace AST#decorator#Right isEditing : 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 /** * 获取选中的商品总数量 * @returns {number} 选中商品数量 */ AST#method_declaration#Left get AST#ERROR#Left selectedCount AST#ERROR#Right AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedSpecIds AST#member_expression#Right AST#expression#Right . size AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 获取选中商品的总价 * @returns {number} 总价(单位:分) */ AST#method_declaration#Left get AST#ERROR#Left totalAmount AST#ERROR#Right AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left total = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( const cart of AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cartList AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#for_statement#Left for ( const spec of AST#expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . spec AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left key = AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . goodsId AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right _ AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left spec AST#expression#Right . id AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedSpecIds AST#member_expression#Right AST#expression#Right . has AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left total += AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left spec AST#expression#Right . price AST#member_expression#Right AST#expression#Right * AST#expression#Left spec AST#expression#Right AST#binary_expression#Right AST#expression#Right . count AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left total AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 是否全选 * @returns {boolean} 是否全选 */ AST#method_declaration#Left get AST#ERROR#Left isAllSelected AST#ERROR#Right AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cartList AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( const cart of AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cartList AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#for_statement#Left for ( const spec of AST#expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . spec AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left key = AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . goodsId AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right _ AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left spec AST#expression#Right . id AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . selectedSpecIds AST#member_expression#Right AST#expression#Right . has AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 购物车是否为空 * @returns {boolean} 是否为空 */ AST#method_declaration#Left get AST#ERROR#Left isEmpty AST#ERROR#Right AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cartList AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 加载购物车数据 * @returns {Promise<void>} Promise<void> */ AST#method_declaration#Left async loadCartData 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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLoading AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cartList AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . cartRepository AST#member_expression#Right AST#expression#Right . getAllCarts AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#finally_clause#Left finally AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLoading AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#finally_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 切换规格选中状态 * @param {number} goodsId 商品ID * @param {number} specId 规格ID * @returns {void} 无返回值 */ AST#method_declaration#Left toggleSpecSelected 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#Left specId : 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#variable_declaration#Left const AST#variable_declarator#Left key = AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left goodsId AST#expression#Right } AST#template_substitution#Right _ AST#template_substitution#Left $ { AST#expression#Left specId AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left newSet = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Set AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedSpecIds AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left newSet AST#expression#Right . has AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left newSet AST#expression#Right . delete AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#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 newSet AST#expression#Right . add AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#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 . selectedSpecIds AST#member_expression#Right = AST#expression#Left newSet AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 判断规格是否选中 * @param {number} goodsId 商品ID * @param {number} specId 规格ID * @returns {boolean} 是否选中 */ AST#method_declaration#Left isSpecSelected 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#Left specId : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left key = AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left goodsId AST#expression#Right } AST#template_substitution#Right _ AST#template_substitution#Left $ { AST#expression#Left specId 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#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedSpecIds AST#member_expression#Right AST#expression#Right . has AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 全选/取消全选 * @returns {void} 无返回值 */ AST#method_declaration#Left toggleSelectAll AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isAllSelected AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedSpecIds AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Set 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 } 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 . selectAll 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 /** * 全选所有商品 * @returns {void} 无返回值 */ AST#method_declaration#Left private selectAll AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left newSet = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Set AST#expression#Right AST#new_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( const cart of AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cartList AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#for_statement#Left for ( const spec of AST#expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . spec AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left newSet AST#expression#Right . add 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 cart AST#expression#Right . goodsId AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right _ AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left spec AST#expression#Right . id AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#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#for_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedSpecIds AST#member_expression#Right = AST#expression#Left newSet AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 更新商品规格数量 * @param {number} goodsId 商品ID * @param {number} specId 规格ID * @param {number} count 新数量 * @returns {Promise<void>} Promise<void> */ AST#method_declaration#Left async updateSpecCount 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#Left specId : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left count : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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#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 . cartRepository AST#member_expression#Right AST#expression#Right . updateCartSpecCount AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left goodsId AST#expression#Right , AST#expression#Left specId AST#expression#Right , AST#expression#Left count AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 更新本地数据 AST#statement#Left AST#for_statement#Left for ( const cart of AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cartList AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . goodsId AST#member_expression#Right AST#expression#Right === AST#expression#Left goodsId AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#for_statement#Left for ( const spec of AST#expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . spec AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left spec AST#expression#Right . id AST#member_expression#Right AST#expression#Right === AST#expression#Left specId AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left spec AST#expression#Right . count AST#member_expression#Right = AST#expression#Left count AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#break_statement#Left break ; AST#break_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#statement#Left AST#break_statement#Left break ; AST#break_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right // 触发响应式更新 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cartList AST#member_expression#Right = AST#expression#Left AST#array_literal#Left [ ... AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cartList AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 删除商品规格 * @param {number} goodsId 商品ID * @param {number} specId 规格ID * @returns {Promise<void>} Promise<void> */ AST#method_declaration#Left async removeSpec 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#Left specId : 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#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 . cartRepository AST#member_expression#Right AST#expression#Right . removeSpecFromCart AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left goodsId AST#expression#Right , AST#expression#Left specId AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 更新本地数据 AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . cartList AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left cart = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cartList AST#member_expression#Right AST#expression#Right [ AST#expression#Left i 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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . goodsId AST#member_expression#Right AST#expression#Right === AST#expression#Left goodsId AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . spec 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 cart AST#expression#Right . spec 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 AST#parameter_list#Left ( AST#parameter#Left s : AST#type_annotation#Left AST#primary_type#Left CartGoodsSpec AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean 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 s AST#expression#Right . id AST#member_expression#Right AST#expression#Right !== AST#expression#Left specId 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#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . spec AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cartList AST#member_expression#Right AST#expression#Right . splice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left i 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#statement#Left AST#break_statement#Left break ; AST#break_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right // 移除选中状态 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left key = AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left goodsId AST#expression#Right } AST#template_substitution#Right _ AST#template_substitution#Left $ { AST#expression#Left specId AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left newSet = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Set AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedSpecIds 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 newSet AST#expression#Right . delete AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#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 . selectedSpecIds AST#member_expression#Right = AST#expression#Left newSet 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 . cartList AST#member_expression#Right = AST#expression#Left AST#array_literal#Left [ ... AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cartList AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 删除选中的商品 * @returns {Promise<void>} Promise<void> */ AST#method_declaration#Left async deleteSelected 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#variable_declaration#Left const AST#variable_declarator#Left selectedKeys = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Array AST#expression#Right . from AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedSpecIds 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#for_statement#Left for ( const key of AST#expression#Left selectedKeys AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left parts = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left key AST#expression#Right . split AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '_' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left goodsId = AST#expression#Left AST#call_expression#Left AST#expression#Left parseInt AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left parts AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left specId = AST#expression#Left AST#call_expression#Left AST#expression#Left parseInt AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left parts AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . cartRepository AST#member_expression#Right AST#expression#Right . removeSpecFromCart AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left goodsId AST#expression#Right , AST#expression#Left specId AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 更新本地数据 AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . cartList AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left i AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left cart = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cartList AST#member_expression#Right AST#expression#Right [ AST#expression#Left i 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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . goodsId AST#member_expression#Right AST#expression#Right === AST#expression#Left goodsId AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . spec 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 cart AST#expression#Right . spec 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 AST#parameter_list#Left ( AST#parameter#Left s : AST#type_annotation#Left AST#primary_type#Left CartGoodsSpec AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean 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 s AST#expression#Right . id AST#member_expression#Right AST#expression#Right !== AST#expression#Left specId 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#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . spec AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cartList AST#member_expression#Right AST#expression#Right . splice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left i 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#statement#Left AST#break_statement#Left break ; AST#break_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right // 触发响应式更新 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cartList AST#member_expression#Right = AST#expression#Left AST#array_literal#Left [ ... AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cartList AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 清空选择状态 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedSpecIds AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Set 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#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 . isEditing AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 结算按钮点击 * @returns {Promise<void>} Promise<void> */ AST#method_declaration#Left async onSettleClick AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { // 检查是否有选中的商品 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedSpecIds AST#member_expression#Right AST#expression#Right . size 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 ToastUtils AST#expression#Right . showError AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.please_select_settlement_goods" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#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 // 1. 获取选中的购物车项 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left selectedCarts = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getSelectedCarts 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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left selectedCarts 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 ToastUtils AST#expression#Right . showError AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.get_selected_goods_failed" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#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 // 2. 缓存选中的购物车项 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . orderCacheStoreRepository AST#member_expression#Right AST#expression#Right . saveCarts AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left selectedCarts AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 3. 将购物车项转换为 SelectedGoods AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left selectedGoodsList = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . convertCartsToSelectedGoods AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left selectedCarts 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 // 4. 缓存 SelectedGoods 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 . orderCacheStoreRepository AST#member_expression#Right AST#expression#Right . saveSelectedGoodsList AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left selectedGoodsList AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 5. 导航到订单确认页面 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left OrderNavigator AST#expression#Right . toConfirm AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 获取选中的购物车项 * @returns {Cart[]} 选中的购物车列表 */ AST#method_declaration#Left private getSelectedCarts AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Cart [ ] 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 result : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Cart [ ] 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 cart of AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cartList AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { // 获取该商品下选中的规格 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left selectedSpecs : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left CartGoodsSpec [ ] 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 spec of AST#expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . spec AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left key = AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . goodsId AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right _ AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left spec AST#expression#Right . id AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedSpecIds AST#member_expression#Right AST#expression#Right . has AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left selectedSpecs AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left spec AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right // 如果有选中的规格,创建新的购物车项 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left selectedSpecs AST#expression#Right . length AST#member_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left newCart = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Cart 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 newCart AST#expression#Right . goodsId AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . goodsId 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 newCart AST#expression#Right . goodsName AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . goodsName 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 newCart AST#expression#Right . goodsMainPic AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . goodsMainPic 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 newCart AST#expression#Right . spec AST#member_expression#Right = AST#expression#Left selectedSpecs 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 result AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left newCart AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#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 /** * 将购物车项转换为 SelectedGoods * @param {Cart[]} carts 购物车列表 * @returns {SelectedGoods[]} 转换后的 SelectedGoods 列表 */ AST#method_declaration#Left private convertCartsToSelectedGoods AST#parameter_list#Left ( AST#parameter#Left carts : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Cart [ ] 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 SelectedGoods [ ] 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 result : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left SelectedGoods [ ] 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 cart of AST#expression#Left carts AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#for_statement#Left for ( const cartSpec of AST#expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . spec AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { // 创建规格对象 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left spec = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left GoodsSpec 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 spec AST#expression#Right . id AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left cartSpec 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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left spec AST#expression#Right . goodsId AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left cartSpec AST#expression#Right . goodsId 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 spec AST#expression#Right . name AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left cartSpec AST#expression#Right . name 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 spec AST#expression#Right . price AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left cartSpec AST#expression#Right . price 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 spec AST#expression#Right . stock AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left cartSpec AST#expression#Right . stock 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 spec AST#expression#Right . images AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left cartSpec AST#expression#Right . images AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 创建商品信息对象 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left goodsInfo = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Goods 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 goodsInfo AST#expression#Right . id AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . goodsId 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 goodsInfo AST#expression#Right . title AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . goodsName 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 goodsInfo AST#expression#Right . mainPic AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . goodsMainPic AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 创建 SelectedGoods 对象 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left selectedGoods = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left SelectedGoods 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 selectedGoods AST#expression#Right . goodsId AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left cart AST#expression#Right . goodsId 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 selectedGoods AST#expression#Right . count AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left cartSpec AST#expression#Right . count 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 selectedGoods AST#expression#Right . spec AST#member_expression#Right = AST#expression#Left spec 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 selectedGoods AST#expression#Right . goodsInfo AST#member_expression#Right = AST#expression#Left goodsInfo 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 result AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left selectedGoods AST#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#for_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left result AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 切换编辑模式 * @returns {void} 无返回值 */ AST#method_declaration#Left toggleEditMode AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { // 清空选择状态 AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedSpecIds AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Set 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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isEditing AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . isEditing AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#decorated_export_declaration#Right
@ObservedV2 export default class CartViewModel extends BaseViewModel { private readonly cartRepository: CartRepository = new CartRepository(); private readonly orderCacheStoreRepository: OrderCacheStoreRepository = new OrderCacheStoreRepository(); @Trace cartList: Cart[] = []; @Trace selectedSpecIds: Set<string> = new Set(); @Trace isLoading: boolean = false; @Trace isEditing: boolean = false; get selectedCount(): number { return this.selectedSpecIds.size; } get totalAmount(): number { let total = 0; for (const cart of this.cartList) { for (const spec of cart.spec) { const key = `${cart.goodsId}_${spec.id}`; if (this.selectedSpecIds.has(key)) { total += spec.price * spec.count; } } } return total; } get isAllSelected(): boolean { if (this.cartList.length === 0) { return false; } for (const cart of this.cartList) { for (const spec of cart.spec) { const key = `${cart.goodsId}_${spec.id}`; if (!this.selectedSpecIds.has(key)) { return false; } } } return true; } get isEmpty(): boolean { return this.cartList.length === 0; } async loadCartData(): Promise<void> { this.isLoading = true; try { this.cartList = await this.cartRepository.getAllCarts(); } finally { this.isLoading = false; } } toggleSpecSelected(goodsId: number, specId: number): void { const key = `${goodsId}_${specId}`; const newSet = new Set(this.selectedSpecIds); if (newSet.has(key)) { newSet.delete(key); } else { newSet.add(key); } this.selectedSpecIds = newSet; } isSpecSelected(goodsId: number, specId: number): boolean { const key = `${goodsId}_${specId}`; return this.selectedSpecIds.has(key); } toggleSelectAll(): void { if (this.isAllSelected) { this.selectedSpecIds = new Set(); } else { this.selectAll(); } } private selectAll(): void { const newSet = new Set<string>(); for (const cart of this.cartList) { for (const spec of cart.spec) { newSet.add(`${cart.goodsId}_${spec.id}`); } } this.selectedSpecIds = newSet; } async updateSpecCount(goodsId: number, specId: number, count: number): Promise<void> { await this.cartRepository.updateCartSpecCount(goodsId, specId, count); for (const cart of this.cartList) { if (cart.goodsId === goodsId) { for (const spec of cart.spec) { if (spec.id === specId) { spec.count = count; break; } } break; } } this.cartList = [...this.cartList]; } async removeSpec(goodsId: number, specId: number): Promise<void> { await this.cartRepository.removeSpecFromCart(goodsId, specId); for (let i = 0; i < this.cartList.length; i++) { const cart = this.cartList[i]; if (cart.goodsId === goodsId) { cart.spec = cart.spec.filter((s: CartGoodsSpec): boolean => s.id !== specId); if (cart.spec.length === 0) { this.cartList.splice(i, 1); } break; } } const key = `${goodsId}_${specId}`; const newSet = new Set(this.selectedSpecIds); newSet.delete(key); this.selectedSpecIds = newSet; this.cartList = [...this.cartList]; } async deleteSelected(): Promise<void> { const selectedKeys = Array.from(this.selectedSpecIds); for (const key of selectedKeys) { const parts = key.split('_'); const goodsId = parseInt(parts[0]); const specId = parseInt(parts[1]); await this.cartRepository.removeSpecFromCart(goodsId, specId); for (let i = 0; i < this.cartList.length; i++) { const cart = this.cartList[i]; if (cart.goodsId === goodsId) { cart.spec = cart.spec.filter((s: CartGoodsSpec): boolean => s.id !== specId); if (cart.spec.length === 0) { this.cartList.splice(i, 1); } break; } } } this.cartList = [...this.cartList]; this.selectedSpecIds = new Set(); this.isEditing = false; } async onSettleClick(): Promise<void> { if (this.selectedSpecIds.size === 0) { ToastUtils.showError($r("app.string.please_select_settlement_goods")); return; } const selectedCarts = this.getSelectedCarts(); if (selectedCarts.length === 0) { ToastUtils.showError($r("app.string.get_selected_goods_failed")); return; } await this.orderCacheStoreRepository.saveCarts(selectedCarts); const selectedGoodsList = this.convertCartsToSelectedGoods(selectedCarts); await this.orderCacheStoreRepository.saveSelectedGoodsList(selectedGoodsList); OrderNavigator.toConfirm(); } private getSelectedCarts(): Cart[] { const result: Cart[] = []; for (const cart of this.cartList) { const selectedSpecs: CartGoodsSpec[] = []; for (const spec of cart.spec) { const key = `${cart.goodsId}_${spec.id}`; if (this.selectedSpecIds.has(key)) { selectedSpecs.push(spec); } } if (selectedSpecs.length > 0) { const newCart = new Cart(); newCart.goodsId = cart.goodsId; newCart.goodsName = cart.goodsName; newCart.goodsMainPic = cart.goodsMainPic; newCart.spec = selectedSpecs; result.push(newCart); } } return result; } private convertCartsToSelectedGoods(carts: Cart[]): SelectedGoods[] { const result: SelectedGoods[] = []; for (const cart of carts) { for (const cartSpec of cart.spec) { const spec = new GoodsSpec(); spec.id = cartSpec.id; spec.goodsId = cartSpec.goodsId; spec.name = cartSpec.name; spec.price = cartSpec.price; spec.stock = cartSpec.stock; spec.images = cartSpec.images; const goodsInfo = new Goods(); goodsInfo.id = cart.goodsId; goodsInfo.title = cart.goodsName; goodsInfo.mainPic = cart.goodsMainPic; const selectedGoods = new SelectedGoods(); selectedGoods.goodsId = cart.goodsId; selectedGoods.count = cartSpec.count; selectedGoods.spec = spec; selectedGoods.goodsInfo = goodsInfo; result.push(selectedGoods); } } return result; } toggleEditMode(): void { this.selectedSpecIds = new Set(); this.isEditing = !this.isEditing; } }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/main/src/main/ets/viewmodel/CartViewModel.ets#L11-L357
78ab6c73c8d1862ec7010c3b6f4ed51ec9e9136e
github
openharmony-tpc/ohos_mpchart
4fb43a7137320ef2fee2634598f53d93975dfb4a
library/src/main/ets/components/data/LineDataSet.ets
arkts
getCircleSize
This function is deprecated because of unclarity. Use getCircleRadius instead. @Deprecated
public getCircleSize(): number { return this.getCircleRadius(); }
AST#method_declaration#Left public getCircleSize AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getCircleRadius AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
public getCircleSize(): number { return this.getCircleRadius(); }
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/data/LineDataSet.ets#L206-L208
da120b915d96fb89c98933e0ade9019c1b55708c
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/ImageUtil.ets
arkts
packingFromImageSource
图片压缩或重新打包,使用Promise形式返回结果。 @param source ImageSource-打包的图片源。 @param options 设置打包参数: format 目标格式。当前只支持"image/jpeg"、"image/webp"、"image/png"和"image/heif"12+(不同硬件设备支持情况不同)。 quality JPEG编码中设定输出图片质量的参数,取值范围为0-100。 bufferSize 接收编码数据的缓冲区大小,单位为Byte。默认为10MB。bufferSize需大于编码后图片大小。 @returns
static packingFromImageSource(source: image.ImageSource, options: image.PackingOption): Promise<ArrayBuffer> { const imagePacker: image.ImagePacker = image.createImagePacker(); return imagePacker.packing(source, options).finally(() => { imagePacker.release(); //释放 }); }
AST#method_declaration#Left static packingFromImageSource AST#parameter_list#Left ( AST#parameter#Left source : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left image . ImageSource AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left options : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left image . PackingOption AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#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 ArrayBuffer 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 imagePacker : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left image . ImagePacker AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left image AST#expression#Right . createImagePacker AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left imagePacker AST#expression#Right . packing AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left source AST#expression#Right , AST#expression#Left options AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . finally AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left imagePacker AST#expression#Right . release AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right //释放 } AST#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 packingFromImageSource(source: image.ImageSource, options: image.PackingOption): Promise<ArrayBuffer> { const imagePacker: image.ImagePacker = image.createImagePacker(); return imagePacker.packing(source, options).finally(() => { imagePacker.release(); }); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/ImageUtil.ets#L200-L205
cf336fac69405981b3fc47c5c2b91d25fe63ccba
gitee
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
NetworkManagement/NewsDataArkTS/entry/src/main/ets/view/RefreshLayout.ets
arkts
RefreshLayout
The refresh layout component.
@Component export default struct RefreshLayout { @ObjectLink refreshLayoutClass: CustomRefreshLoadLayoutClass; build() { Column() { if (this.refreshLayoutClass.isVisible) { CustomRefreshLoadLayout({ customRefreshLoadClass: new CustomRefreshLoadLayoutClass (this.refreshLayoutClass.isVisible, this.refreshLayoutClass.imageSrc, this.refreshLayoutClass.textValue, this.refreshLayoutClass.heightValue) }) } } } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export default struct RefreshLayout AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ ObjectLink AST#decorator#Right refreshLayoutClass : AST#type_annotation#Left AST#primary_type#Left CustomRefreshLoadLayoutClass AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . refreshLayoutClass AST#member_expression#Right AST#expression#Right . isVisible AST#member_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left CustomRefreshLoadLayout ( AST#component_parameters#Left { AST#component_parameter#Left customRefreshLoadClass : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left CustomRefreshLoadLayoutClass AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . refreshLayoutClass AST#member_expression#Right AST#expression#Right . isVisible 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 . refreshLayoutClass AST#member_expression#Right AST#expression#Right . imageSrc 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 . refreshLayoutClass AST#member_expression#Right AST#expression#Right . textValue 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 . refreshLayoutClass AST#member_expression#Right AST#expression#Right . heightValue AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Component export default struct RefreshLayout { @ObjectLink refreshLayoutClass: CustomRefreshLoadLayoutClass; build() { Column() { if (this.refreshLayoutClass.isVisible) { CustomRefreshLoadLayout({ customRefreshLoadClass: new CustomRefreshLoadLayoutClass (this.refreshLayoutClass.isVisible, this.refreshLayoutClass.imageSrc, this.refreshLayoutClass.textValue, this.refreshLayoutClass.heightValue) }) } } } }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/NetworkManagement/NewsDataArkTS/entry/src/main/ets/view/RefreshLayout.ets#L22-L35
08abdfeed59b1ac9ac7c693242dc572982caf791
gitee
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/app/views/GridSegmentedPicker.ets
arkts
customBuilder
根据容器宽度计算出的列数 默认UI构建函数
@LocalBuilder private customBuilder(option: GridPickerItem) { Text(option.label) .fontSize(16) .textAlign(TextAlign.Center) }
AST#method_declaration#Left AST#decorator#Left @ LocalBuilder AST#decorator#Right private customBuilder AST#parameter_list#Left ( AST#parameter#Left option : AST#type_annotation#Left AST#primary_type#Left GridPickerItem 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 Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left option AST#expression#Right . label AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
@LocalBuilder private customBuilder(option: GridPickerItem) { Text(option.label) .fontSize(16) .textAlign(TextAlign.Center) }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/app/views/GridSegmentedPicker.ets#L33-L38
c7e7494585fd109efdb793ab202772fe57fcb6a7
github
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
Ability/StageAbilityDemo/entry/src/main/ets/viewmodel/ServicesViewModel.ets
arkts
loadGoodsService
Load the data of goods service for the GoodsServiceList view.
public loadGoodsService(): Service[] { return DataModel.GOOD_SERVICE; }
AST#method_declaration#Left public loadGoodsService AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Service [ ] 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#member_expression#Left AST#expression#Left DataModel AST#expression#Right . GOOD_SERVICE AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
public loadGoodsService(): Service[] { return DataModel.GOOD_SERVICE; }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Ability/StageAbilityDemo/entry/src/main/ets/viewmodel/ServicesViewModel.ets#L21-L23
c031326ce4c2fe527069b84d8fe30b89860a3e6d
gitee
JackJiang2011/harmonychat.git
bca3f3e1ce54d763720510f99acf595a49e37879
entry/src/main/ets/pages/ChatPage.ets
arkts
beKickout
被踢的处理逻辑。
beKickout(kickoutInfo: PKickoutInfo) { // 首先释放IM所占资源 IMClientManager.getInstance().releaseMobileIMSDK(); // 提示信息 let alertContent: string = ''; if (kickoutInfo.code === PKickoutInfo.KICKOUT_FOR_DUPLICATE_LOGIN) { alertContent = '账号已在其它地方登陆,当前会话已断开,请退出后重新登陆!'; } else if (kickoutInfo.code === PKickoutInfo.KICKOUT_FOR_ADMIN) { alertContent = '已被管理员强行踢出聊天,当前会话已断开!'; } else { alertContent = '你已被踢出聊天,当前会话已断开(kickoutInfo=' + JSON.stringify(kickoutInfo) + ')!'; } ClientCoreSDK.Log.error(TAG + alertContent); // 确认Action let primaryAction: Callback<void> = () => { this.switchToLoginPage(); }; // 取消Action let secondaryAction: Callback<void> = () => { let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; ToolKits.exitSystem(context); }; // 显示对话框 ToolKits.showAlertDialog(alertContent, '重新登录', undefined, primaryAction,'退出应用', $r('sys.color.ohos_id_color_badge_red'), secondaryAction); }
AST#method_declaration#Left beKickout AST#parameter_list#Left ( AST#parameter#Left kickoutInfo : AST#type_annotation#Left AST#primary_type#Left PKickoutInfo AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { // 首先释放IM所占资源 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 IMClientManager 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 . releaseMobileIMSDK AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 提示信息 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left alertContent : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '' AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left kickoutInfo AST#expression#Right . code AST#member_expression#Right AST#expression#Right === AST#expression#Left PKickoutInfo AST#expression#Right AST#binary_expression#Right AST#expression#Right . KICKOUT_FOR_DUPLICATE_LOGIN AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left alertContent = AST#expression#Left '账号已在其它地方登陆,当前会话已断开,请退出后重新登陆!' AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#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 kickoutInfo AST#expression#Right . code AST#member_expression#Right AST#expression#Right === AST#expression#Left PKickoutInfo AST#expression#Right AST#binary_expression#Right AST#expression#Right . KICKOUT_FOR_ADMIN AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left alertContent = AST#expression#Left '已被管理员强行踢出聊天,当前会话已断开!' AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left alertContent = 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 '你已被踢出聊天,当前会话已断开(kickoutInfo=' 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 kickoutInfo 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#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ClientCoreSDK AST#expression#Right . Log AST#member_expression#Right AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left TAG AST#expression#Right + AST#expression#Left alertContent 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 // 确认Action AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left primaryAction : 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#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . switchToLoginPage 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 取消Action AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left secondaryAction : 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#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left context : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . UIAbilityContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left getContext AST#expression#Right AST#argument_list#Left ( AST#expression#Left this AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . UIAbilityContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ToolKits AST#expression#Right . exitSystem AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 显示对话框 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ToolKits AST#expression#Right . showAlertDialog AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left alertContent AST#expression#Right , AST#expression#Left '重新登录' AST#expression#Right , AST#expression#Left undefined AST#expression#Right , AST#expression#Left primaryAction AST#expression#Right , AST#expression#Left '退出应用' AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'sys.color.ohos_id_color_badge_red' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left secondaryAction AST#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
beKickout(kickoutInfo: PKickoutInfo) { IMClientManager.getInstance().releaseMobileIMSDK(); let alertContent: string = ''; if (kickoutInfo.code === PKickoutInfo.KICKOUT_FOR_DUPLICATE_LOGIN) { alertContent = '账号已在其它地方登陆,当前会话已断开,请退出后重新登陆!'; } else if (kickoutInfo.code === PKickoutInfo.KICKOUT_FOR_ADMIN) { alertContent = '已被管理员强行踢出聊天,当前会话已断开!'; } else { alertContent = '你已被踢出聊天,当前会话已断开(kickoutInfo=' + JSON.stringify(kickoutInfo) + ')!'; } ClientCoreSDK.Log.error(TAG + alertContent); let primaryAction: Callback<void> = () => { this.switchToLoginPage(); }; let secondaryAction: Callback<void> = () => { let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; ToolKits.exitSystem(context); }; ToolKits.showAlertDialog(alertContent, '重新登录', undefined, primaryAction,'退出应用', $r('sys.color.ohos_id_color_badge_red'), secondaryAction); }
https://github.com/JackJiang2011/harmonychat.git/blob/bca3f3e1ce54d763720510f99acf595a49e37879/entry/src/main/ets/pages/ChatPage.ets#L186-L215
c5855692917fa3a22c7cddd3182e63b49df8656a
github
openharmony/xts_acts
5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686
arkui/ace_ets_module_noui/ace_ets_module_StateMangagement/ace_ets_module_StateMangagement02_api12/entry/src/main/ets/MainAbility/pages/makeObserved/SendableData.ets
arkts
SendableData
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.
@Sendable export class SendableData { public name: string = 'Tom'; public age: number = 20; public gender: number = 1; // .... more other properties public likes: number = 1; public follow: boolean = false; }
AST#decorated_export_declaration#Left AST#decorator#Left @ Sendable AST#decorator#Right export class SendableData AST#class_body#Left { AST#property_declaration#Left public name : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'Tom' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left public age : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 20 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left public gender : 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 // .... more other properties AST#property_declaration#Left public likes : 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 public follow : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#property_declaration#Right } AST#class_body#Right AST#decorated_export_declaration#Right
@Sendable export class SendableData { public name: string = 'Tom'; public age: number = 20; public gender: number = 1; public likes: number = 1; public follow: boolean = false; }
https://github.com/openharmony/xts_acts/blob/5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686/arkui/ace_ets_module_noui/ace_ets_module_StateMangagement/ace_ets_module_StateMangagement02_api12/entry/src/main/ets/MainAbility/pages/makeObserved/SendableData.ets#L15-L23
db41ee1920fa7a0725bfc0eda3328826ebc2733e
gitee
ThePivotPoint/ArkTS-LSP-Server-Plugin.git
6231773905435f000d00d94b26504433082ba40b
packages/declarations/ets/api/@ohos.arkui.advanced.TabTitleBar.d.ets
arkts
TabTitleBar
Declaration of the tabbed title bar. @syscap SystemCapability.ArkUI.ArkUI.Full @since 10 Declaration of the tabbed title bar. @syscap SystemCapability.ArkUI.ArkUI.Full @atomicservice @since 11
@Component export declare struct TabTitleBar { /** * Tab items on the left side. * @type { ?Array<TabTitleBarItem> }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 10 */ /** * Tab items on the left side. * @type { ?Array<TabTitleBarItem> }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 11 */ tabItems: Array<TabTitleBarTabItem>; /** * Menu items on the right side. * @type { Array<TabTitleBarMenuItem> }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 10 */ /** * Menu items on the right side. * @type { Array<TabTitleBarMenuItem> }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 11 */ menuItems?: Array<TabTitleBarMenuItem>; /** * Content builder. Each component corresponds to a tab item. * The builder needs to be transferred. * @type { () => void }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 10 */ /** * Content builder. Each component corresponds to a tab item. * The builder needs to be transferred. * @type { () => void }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 11 */ @BuilderParam swiperContent: () => void; }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export AST#ERROR#Left declare AST#ERROR#Right struct TabTitleBar AST#component_body#Left { /** * Tab items on the left side. * @type { ?Array<TabTitleBarItem> }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 10 */ /** * Tab items on the left side. * @type { ?Array<TabTitleBarItem> }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 11 */ AST#property_declaration#Left tabItems : 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 TabTitleBarTabItem 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 /** * Menu items on the right side. * @type { Array<TabTitleBarMenuItem> }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 10 */ /** * Menu items on the right side. * @type { Array<TabTitleBarMenuItem> }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 11 */ AST#property_declaration#Left menuItems ? : 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 TabTitleBarMenuItem 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 /** * Content builder. Each component corresponds to a tab item. * The builder needs to be transferred. * @type { () => void }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 10 */ /** * Content builder. Each component corresponds to a tab item. * The builder needs to be transferred. * @type { () => void }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 11 */ AST#property_declaration#Left AST#decorator#Left @ BuilderParam AST#decorator#Right swiperContent : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right ; AST#property_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Component export declare struct TabTitleBar { tabItems: Array<TabTitleBarTabItem>; menuItems?: Array<TabTitleBarMenuItem>; @BuilderParam swiperContent: () => void; }
https://github.com/ThePivotPoint/ArkTS-LSP-Server-Plugin.git/blob/6231773905435f000d00d94b26504433082ba40b/packages/declarations/ets/api/@ohos.arkui.advanced.TabTitleBar.d.ets#L134-L181
8ded6732396d6b7b25071ec439bbc16e25422aaa
github
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
feature/user/src/main/ets/viewmodel/AddressDetailViewModel.ets
arkts
requestRepository
请求地址详情 @returns {Promise<NetworkResponse<Address>>} 地址详情响应
protected requestRepository(): Promise<NetworkResponse<Address>> { return this.repository.getAddressInfo(this.addressId); }
AST#method_declaration#Left protected requestRepository AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left NetworkResponse AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left Address AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . repository AST#member_expression#Right AST#expression#Right . getAddressInfo 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 . addressId 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
protected requestRepository(): Promise<NetworkResponse<Address>> { return this.repository.getAddressInfo(this.addressId); }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/user/src/main/ets/viewmodel/AddressDetailViewModel.ets#L139-L141
7830bb7950b49f51c8279711392934b07e854eb5
github
PureHarmonyProject/ScanKit_SampleCode_Clientdemo_ArkTS.git
3b5fa45c650dcae2773a19f122161935e0c0e2bc
entry/src/main/ets/entryability/EntryAbility.ets
arkts
onNewWant
Obtain the code value through the onNewWant callback in warm launch scenarios.
onNewWant(want: Want, _: AbilityConstant.LaunchParam): void { Logger.info(TAG, 'Ability onNewWant'); // Obtain the uri field from the want information. let uri = want?.uri; let status: router.RouterState = router.getState(); if (status && status.name !== 'ScanAccess' && uri) { // Process the service based on the URI. router.pushUrl({ url: 'pages/access/ScanAccess' }); } }
AST#method_declaration#Left onNewWant AST#parameter_list#Left ( AST#parameter#Left want : AST#type_annotation#Left AST#primary_type#Left Want AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left _ : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left AbilityConstant . LaunchParam AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left TAG AST#expression#Right , AST#expression#Left 'Ability onNewWant' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // Obtain the uri field from the want information. AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left uri = AST#expression#Left AST#member_expression#Left AST#expression#Left want AST#expression#Right ?. uri AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left status : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left router . RouterState 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 router AST#expression#Right . getState 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#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 status AST#expression#Right && AST#expression#Left status AST#expression#Right AST#binary_expression#Right AST#expression#Right . name AST#member_expression#Right AST#expression#Right !== AST#expression#Left 'ScanAccess' AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left uri AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { // Process the service based on the URI. AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left router AST#expression#Right . pushUrl AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left url AST#property_name#Right : AST#expression#Left 'pages/access/ScanAccess' 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#method_declaration#Right
onNewWant(want: Want, _: AbilityConstant.LaunchParam): void { Logger.info(TAG, 'Ability onNewWant'); let uri = want?.uri; let status: router.RouterState = router.getState(); if (status && status.name !== 'ScanAccess' && uri) { router.pushUrl({ url: 'pages/access/ScanAccess' }); } }
https://github.com/PureHarmonyProject/ScanKit_SampleCode_Clientdemo_ArkTS.git/blob/3b5fa45c650dcae2773a19f122161935e0c0e2bc/entry/src/main/ets/entryability/EntryAbility.ets#L122-L133
4c9171b9d0ab2b7bffa5f5b6c2be63a2630ac3d7
github
iotjin/JhHarmonyDemo.git
819e6c3b1db9984c042a181967784550e171b2e8
JhCommon/src/main/ets/JhCommon/utils/JhPreferencesUtils.ets
arkts
has
/ 根据key检查缓存值是否存在
public static has(key: string): boolean { return PreferencesUtil.hasSync(key) }
AST#method_declaration#Left public static has AST#parameter_list#Left ( AST#parameter#Left key : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 PreferencesUtil AST#expression#Right . hasSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
public static has(key: string): boolean { return PreferencesUtil.hasSync(key) }
https://github.com/iotjin/JhHarmonyDemo.git/blob/819e6c3b1db9984c042a181967784550e171b2e8/JhCommon/src/main/ets/JhCommon/utils/JhPreferencesUtils.ets#L140-L142
36c9280947622b42e18ec0569027a49adae3a055
github
gracienewd/openharmony-App-YunmoAi.git
181952ab00aab5025a81b7b3a6b88d2a5258c76a
entry/src/main/ets/pages/chat/index.ets
arkts
_chatPlaceHolder
2.默认
@Builder _chatPlaceHolder() { ChatPlaceHolder() }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right _chatPlaceHolder 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 ChatPlaceHolder ( ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
@Builder _chatPlaceHolder() { ChatPlaceHolder() }
https://github.com/gracienewd/openharmony-App-YunmoAi.git/blob/181952ab00aab5025a81b7b3a6b88d2a5258c76a/entry/src/main/ets/pages/chat/index.ets#L90-L93
f60965b7a4182466da01261f8905315ac8ac8822
github
openharmony-tpc/ohos_mpchart
4fb43a7137320ef2fee2634598f53d93975dfb4a
library/src/main/ets/components/highlight/Highlight.ets
arkts
equalTo
Returns true if this highlight object is equal to the other (compares xIndex and dataSetIndex) @param h @return
public equalTo(h: Highlight | null): boolean { if (h == null) return false; else { if (this.mDataSetIndex == h.mDataSetIndex && this.mX == h.mX && this.mStackIndex == h.mStackIndex && this.mDataIndex == h.mDataIndex) return true; else return false; } }
AST#method_declaration#Left public equalTo AST#parameter_list#Left ( AST#parameter#Left h : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Highlight AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left h 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#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 else AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#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 this AST#expression#Right . mDataSetIndex AST#member_expression#Right AST#expression#Right == AST#expression#Left h AST#expression#Right AST#binary_expression#Right AST#expression#Right . mDataSetIndex AST#member_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . mX AST#member_expression#Right AST#expression#Right == AST#expression#Left h AST#expression#Right AST#binary_expression#Right AST#expression#Right . mX AST#member_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . mStackIndex AST#member_expression#Right AST#expression#Right == AST#expression#Left h AST#expression#Right AST#binary_expression#Right AST#expression#Right . mStackIndex AST#member_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . mDataIndex AST#member_expression#Right AST#expression#Right == AST#expression#Left h AST#expression#Right AST#binary_expression#Right AST#expression#Right . mDataIndex AST#member_expression#Right AST#expression#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 else 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#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
public equalTo(h: Highlight | null): boolean { if (h == null) return false; else { if (this.mDataSetIndex == h.mDataSetIndex && this.mX == h.mX && this.mStackIndex == h.mStackIndex && this.mDataIndex == h.mDataIndex) return true; else return false; } }
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/highlight/Highlight.ets#L196-L207
8c271d31a2f82deeb5df191d3d5e796e28825b82
gitee
hqj201013136012/HarmonyMiliUiPro.git
0625e681e07b771998a0ac4430824627d0eb60ed
entry/src/main/ets/common/helper/DialogHelper.ets
arkts
TODO Dialog帮助工具类(全局自定义弹框,不依赖UI组件) author: 桃花镇童长老ᥫ᭡ since: 2024/08/01 仓库主页:https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog github: https://github.com/787107497 gitee: https://gitee.com/tongyuyan/harmony-utils QQ交流群: 1029219059
export class DialogHelper { /** * 显示自定义半模态 * @param wrappedBuilder 自定义半模态中显示的组件内容 * @param options * @returns */ static showBindSheet<T extends BaseSheetOptions>(wrappedBuilder: WrappedBuilder<[T]>, options: T) { DialogHelper.initBindSheetDefault(options); if(options.uiContext){ const componentContent = new ComponentContent(options.uiContext, wrappedBuilder, options); options.uiContext.openBindSheet(componentContent, options); } } /** * 初始化BaseSheetOptions参数 * @param options */ private static initBindSheetDefault(options: BaseSheetOptions) { options.uiContext = options.uiContext ; if (options.title) { //有标题,默认显示关闭图标 options.showClose = options.showClose ?? true; //是否显示关闭图标,默认显示。 } else { //有标题,默认不显示关闭图标 options.showClose = options.showClose ?? false; //是否显示关闭图标,默认显示。 } //半模态高度,默认是FIT_CONTENT。MEDIUM-指定半模态高度为屏幕高度一半。LARGE-指定半模态高度几乎为屏幕高度。FIT_CONTENT-指定半模态高度为适应内容的高度。 options.height = options.height ?? SheetSize.FIT_CONTENT; //设置半模态页面的宽度。百分比参数方式:以父元素宽的百分比来设置半模态页面的宽度。 options.width = options.width ?? '100%'; //设置半模态页面的显示层级。默认值:SheetMode.OVERLAY。 options.mode = options.mode ?? SheetMode.OVERLAY; //半模态页面的样式。BOTTOM-底部弹窗。CENTER-居中弹窗。POPUP-跟手弹窗。跟手弹窗面板不支持跟手滑动,下滑面板不关闭。 options.preferType = options.preferType ?? SheetType.BOTTOM; //是否显示控制条。半模态面板的detents属性设置多个不同高度并且设置生效时,默认显示控制条。否则不显示控制条。 options.dragBar = options.dragBar ?? true; //半模态所在页面是否允许交互。设置为true时允许交互,不显示蒙层;设置为false时不允许交互,显示蒙层;若不进行设置,默认底部弹窗与居中弹窗不允许交互,跟手弹窗允许交互。当设置为true时,maskColor设置无效。 options.enableOutsideInteractive = options.enableOutsideInteractive ?? false; //设置半模态面板滑动时,内容区域刷新时机。默认值:ScrollSizeMode.FOLLOW_DETENT。 options.scrollSizeMode = options.scrollSizeMode ?? ScrollSizeMode.FOLLOW_DETENT; //半模态面板的模糊背景。默认无模糊背景。 options.blurStyle = options.blurStyle ?? BlurStyle.COMPONENT_ULTRA_THICK; //半模态页面的背景蒙层颜色。 options.maskColor = options.maskColor ?? 0x33000000; //设置半模态页面的边框宽度。可分别设置4个边框宽度。默认值:0。百分比参数方式:以父元素半模态页面宽的百分比来设置半模态页面的边框宽度。当半模态页面左边框和右边框大于半模态页面宽度,半模态页面上边框和下边框大于半模态页面高度,显示可能不符合预期。 options.borderWidth = options.borderWidth ?? 0; //设置半模态页面的边框颜色。默认值:Color.Black。如果使用borderColor属性,需要和borderWidth属性一起使用。说明:底部弹窗时,底部边框颜色设置无效。 options.borderColor = options.borderColor ?? Color.Black; //设置半模态页面的边框样式。默认值:BorderStyle.Solid。如果使用borderStyle属性,需要和borderWidth属性一起使用。说明:底部弹窗时,底部边框样式设置无效。 options.borderStyle = options.borderStyle ?? BorderStyle.Solid; } }
AST#export_declaration#Left export AST#class_declaration#Left class DialogHelper AST#class_body#Left { /** * 显示自定义半模态 * @param wrappedBuilder 自定义半模态中显示的组件内容 * @param options * @returns */ AST#method_declaration#Left static showBindSheet AST#type_parameters#Left < AST#type_parameter#Left T extends AST#type_annotation#Left AST#primary_type#Left BaseSheetOptions AST#primary_type#Right AST#type_annotation#Right AST#type_parameter#Right > AST#type_parameters#Right AST#parameter_list#Left ( AST#parameter#Left wrappedBuilder : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left WrappedBuilder AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#tuple_type#Left [ AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right ] AST#tuple_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left options : AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DialogHelper AST#expression#Right . initBindSheetDefault AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left options AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . uiContext AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left const AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left componentContent = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ComponentContent AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . uiContext AST#member_expression#Right AST#expression#Right , AST#expression#Left wrappedBuilder AST#expression#Right , AST#expression#Left options AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . uiContext AST#member_expression#Right AST#expression#Right . openBindSheet AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left componentContent AST#expression#Right , AST#expression#Left options AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right /** * 初始化BaseSheetOptions参数 * @param options */ AST#method_declaration#Left private static initBindSheetDefault AST#parameter_list#Left ( AST#parameter#Left options : AST#type_annotation#Left AST#primary_type#Left BaseSheetOptions AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . uiContext AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . uiContext AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . title AST#member_expression#Right AST#expression#Right ) { //有标题,默认显示关闭图标 AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . showClose AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . showClose AST#member_expression#Right AST#expression#Right ?? AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right //是否显示关闭图标,默认显示。 } else { //有标题,默认不显示关闭图标 AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . showClose AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . showClose AST#member_expression#Right AST#expression#Right ?? AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#binary_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 //半模态高度,默认是FIT_CONTENT。MEDIUM-指定半模态高度为屏幕高度一半。LARGE-指定半模态高度几乎为屏幕高度。FIT_CONTENT-指定半模态高度为适应内容的高度。 AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . height AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . height AST#member_expression#Right AST#expression#Right ?? AST#expression#Left SheetSize AST#expression#Right AST#binary_expression#Right AST#expression#Right . FIT_CONTENT AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right //设置半模态页面的宽度。百分比参数方式:以父元素宽的百分比来设置半模态页面的宽度。 AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . width AST#member_expression#Right = AST#expression#Left AST#binary_expression#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 '100%' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right //设置半模态页面的显示层级。默认值:SheetMode.OVERLAY。 AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . mode AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . mode AST#member_expression#Right AST#expression#Right ?? AST#expression#Left SheetMode AST#expression#Right AST#binary_expression#Right AST#expression#Right . OVERLAY AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right //半模态页面的样式。BOTTOM-底部弹窗。CENTER-居中弹窗。POPUP-跟手弹窗。跟手弹窗面板不支持跟手滑动,下滑面板不关闭。 AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . preferType AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . preferType AST#member_expression#Right AST#expression#Right ?? AST#expression#Left SheetType AST#expression#Right AST#binary_expression#Right AST#expression#Right . BOTTOM AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right //是否显示控制条。半模态面板的detents属性设置多个不同高度并且设置生效时,默认显示控制条。否则不显示控制条。 AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . dragBar AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . dragBar AST#member_expression#Right AST#expression#Right ?? AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right //半模态所在页面是否允许交互。设置为true时允许交互,不显示蒙层;设置为false时不允许交互,显示蒙层;若不进行设置,默认底部弹窗与居中弹窗不允许交互,跟手弹窗允许交互。当设置为true时,maskColor设置无效。 AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . enableOutsideInteractive AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . enableOutsideInteractive AST#member_expression#Right AST#expression#Right ?? AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right //设置半模态面板滑动时,内容区域刷新时机。默认值:ScrollSizeMode.FOLLOW_DETENT。 AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . scrollSizeMode AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . scrollSizeMode AST#member_expression#Right AST#expression#Right ?? AST#expression#Left ScrollSizeMode AST#expression#Right AST#binary_expression#Right AST#expression#Right . FOLLOW_DETENT AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right //半模态面板的模糊背景。默认无模糊背景。 AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . blurStyle AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . blurStyle AST#member_expression#Right AST#expression#Right ?? AST#expression#Left BlurStyle AST#expression#Right AST#binary_expression#Right AST#expression#Right . COMPONENT_ULTRA_THICK AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right //半模态页面的背景蒙层颜色。 AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . maskColor AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . maskColor AST#member_expression#Right AST#expression#Right ?? AST#expression#Left 0x33000000 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right //设置半模态页面的边框宽度。可分别设置4个边框宽度。默认值:0。百分比参数方式:以父元素半模态页面宽的百分比来设置半模态页面的边框宽度。当半模态页面左边框和右边框大于半模态页面宽度,半模态页面上边框和下边框大于半模态页面高度,显示可能不符合预期。 AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . borderWidth AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . borderWidth AST#member_expression#Right AST#expression#Right ?? AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right //设置半模态页面的边框颜色。默认值:Color.Black。如果使用borderColor属性,需要和borderWidth属性一起使用。说明:底部弹窗时,底部边框颜色设置无效。 AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . borderColor AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . borderColor AST#member_expression#Right AST#expression#Right ?? AST#expression#Left Color AST#expression#Right AST#binary_expression#Right AST#expression#Right . Black AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right //设置半模态页面的边框样式。默认值:BorderStyle.Solid。如果使用borderStyle属性,需要和borderWidth属性一起使用。说明:底部弹窗时,底部边框样式设置无效。 AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . borderStyle AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . borderStyle AST#member_expression#Right AST#expression#Right ?? AST#expression#Left BorderStyle AST#expression#Right AST#binary_expression#Right AST#expression#Right . Solid AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class DialogHelper { static showBindSheet<T extends BaseSheetOptions>(wrappedBuilder: WrappedBuilder<[T]>, options: T) { DialogHelper.initBindSheetDefault(options); if(options.uiContext){ const componentContent = new ComponentContent(options.uiContext, wrappedBuilder, options); options.uiContext.openBindSheet(componentContent, options); } } private static initBindSheetDefault(options: BaseSheetOptions) { options.uiContext = options.uiContext ; if (options.title) { options.showClose = options.showClose ?? true; } else { options.showClose = options.showClose ?? false; } options.height = options.height ?? SheetSize.FIT_CONTENT; options.width = options.width ?? '100%'; options.mode = options.mode ?? SheetMode.OVERLAY; options.preferType = options.preferType ?? SheetType.BOTTOM; options.dragBar = options.dragBar ?? true; options.enableOutsideInteractive = options.enableOutsideInteractive ?? false; options.scrollSizeMode = options.scrollSizeMode ?? ScrollSizeMode.FOLLOW_DETENT; options.blurStyle = options.blurStyle ?? BlurStyle.COMPONENT_ULTRA_THICK; options.maskColor = options.maskColor ?? 0x33000000; options.borderWidth = options.borderWidth ?? 0; options.borderColor = options.borderColor ?? Color.Black; options.borderStyle = options.borderStyle ?? BorderStyle.Solid; } }
https://github.com/hqj201013136012/HarmonyMiliUiPro.git/blob/0625e681e07b771998a0ac4430824627d0eb60ed/entry/src/main/ets/common/helper/DialogHelper.ets#L28-L80
223fb4c1a19159cf57bda1447e3f6aa91297fc0a
github
Application-Security-Automation/Arktan.git
3ad9cb05235e38b00cd5828476aa59a345afa1c0
dataset/completeness/function_call/library_function/array_lib_func_005_T.ets
arkts
Introduction 库函数-array_push
export function array_lib_func_005_T(taint_src : string) { let arr : string[] = ["a","b"]; arr.push(taint_src); taint.Sink(arr); }
AST#export_declaration#Left export AST#function_declaration#Left function array_lib_func_005_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 arr : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left "a" AST#expression#Right , AST#expression#Left "b" 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left arr AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left taint_src 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 taint AST#expression#Right . Sink AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left arr AST#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 array_lib_func_005_T(taint_src : string) { let arr : string[] = ["a","b"]; arr.push(taint_src); taint.Sink(arr); }
https://github.com/Application-Security-Automation/Arktan.git/blob/3ad9cb05235e38b00cd5828476aa59a345afa1c0/dataset/completeness/function_call/library_function/array_lib_func_005_T.ets#L6-L10
936ae6187efc5152d790240636bfec85fadc2db8
github
ThePivotPoint/ArkTS-LSP-Server-Plugin.git
6231773905435f000d00d94b26504433082ba40b
packages/declarations/ets/api/@ohos.multimedia.avVolumePanel.d.ets
arkts
@file Defines a panel to set the system audio output volume. @kit AudioKit Declare custom parameters used for volume panel. @syscap SystemCapability.Multimedia.Audio.Volume @atomicservice @since 12
export declare class AVVolumePanelParameter { /** * Sets the position of volume panel. * * @syscap SystemCapability.Multimedia.Audio.Volume * @atomicservice * @since 12 */ position?: Position; }
AST#export_declaration#Left export AST#ERROR#Left declare AST#ERROR#Right AST#class_declaration#Left class AVVolumePanelParameter AST#class_body#Left { /** * Sets the position of volume panel. * * @syscap SystemCapability.Multimedia.Audio.Volume * @atomicservice * @since 12 */ AST#property_declaration#Left position ? : AST#type_annotation#Left AST#primary_type#Left Position 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 AVVolumePanelParameter { position?: Position; }
https://github.com/ThePivotPoint/ArkTS-LSP-Server-Plugin.git/blob/6231773905435f000d00d94b26504433082ba40b/packages/declarations/ets/api/@ohos.multimedia.avVolumePanel.d.ets#L26-L35
8d1a931f5f6330d67bce362831c2fec4b04a3d18
github
harmonyos/samples
f5d967efaa7666550ee3252d118c3c73a77686f5
ETSUI/BorderImageSample/entry/src/main/ets/common/util/StringUtil.ets
arkts
numberToPercentage
Numbers turn into percentages. @param figure , postice number; @return {string} percentage.
public static numberToPercentage(figure: number): string { return figure + '%'; }
AST#method_declaration#Left public static numberToPercentage AST#parameter_list#Left ( AST#parameter#Left figure : 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#binary_expression#Left AST#expression#Left figure AST#expression#Right + AST#expression#Left '%' 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
public static numberToPercentage(figure: number): string { return figure + '%'; }
https://github.com/harmonyos/samples/blob/f5d967efaa7666550ee3252d118c3c73a77686f5/ETSUI/BorderImageSample/entry/src/main/ets/common/util/StringUtil.ets#L27-L29
7c95b6bce62571a7a2bdf624e49555c564d0c0a5
gitee
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
AvoidTimeComsume/entry/src/main/ets/common/Item.ets
arkts
[Start item]
export class ResponseData{ public data: Item[] = []; }
AST#export_declaration#Left export AST#class_declaration#Left class ResponseData AST#class_body#Left { AST#property_declaration#Left public data : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Item [ ] 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#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class ResponseData{ public data: Item[] = []; }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/AvoidTimeComsume/entry/src/main/ets/common/Item.ets#L32-L34
82e4b1658cace2a2a0239a0aefa1bb2a6b88b691
gitee
charon2pluto/MoodDiary-HarmonyOS.git
0ec7ee6861e150bc9b4571062dbf302d1b106b8c
entry/src/main/ets/pages/MoodDetail.ets
arkts
formatDate
格式化日期:2025年12月26日 星期五 08:30
formatDate(timestamp: number): string { const date = new Date(timestamp); const dateStr = `${date.getFullYear()}年${date.getMonth() + 1}月${date.getDate()}日`; const timeStr = `${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}`; return `${dateStr} ${timeStr}`; }
AST#method_declaration#Left formatDate AST#parameter_list#Left ( AST#parameter#Left timestamp : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left date = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left timestamp 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 dateStr = 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 date AST#expression#Right . getFullYear AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right 年 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 date AST#expression#Right . getMonth AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right } AST#template_substitution#Right 月 AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date AST#expression#Right . getDate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right 日 ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left timeStr = AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date 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 . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . padStart AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 2 AST#expression#Right , AST#expression#Left '0' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right : AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date AST#expression#Right . getMinutes AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . padStart AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 2 AST#expression#Right , AST#expression#Left '0' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left dateStr AST#expression#Right } AST#template_substitution#Right AST#template_substitution#Left $ { AST#expression#Left timeStr AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
formatDate(timestamp: number): string { const date = new Date(timestamp); const dateStr = `${date.getFullYear()}年${date.getMonth() + 1}月${date.getDate()}日`; const timeStr = `${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}`; return `${dateStr} ${timeStr}`; }
https://github.com/charon2pluto/MoodDiary-HarmonyOS.git/blob/0ec7ee6861e150bc9b4571062dbf302d1b106b8c/entry/src/main/ets/pages/MoodDetail.ets#L28-L33
9a5fbda91c5defc9951043e03d8929b264488141
github
common-apps/ZRouter
5adc9c4bcca6ba7d9b323451ed464e1e9b47eee6
library/common/src/main/ets/constants/RouterMap.ets
arkts
分组拼接路径
export const HAP_A_PAGE_ONE = GROUP + "hapAPageOne";
AST#export_declaration#Left export AST#variable_declaration#Left const AST#variable_declarator#Left HAP_A_PAGE_ONE = AST#expression#Left AST#binary_expression#Left AST#expression#Left GROUP AST#expression#Right + AST#expression#Left "hapAPageOne" AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#export_declaration#Right
export const HAP_A_PAGE_ONE = GROUP + "hapAPageOne";
https://github.com/common-apps/ZRouter/blob/5adc9c4bcca6ba7d9b323451ed464e1e9b47eee6/library/common/src/main/ets/constants/RouterMap.ets#L17-L17
f645e71329f46a6a4e114d9dac797b46dec99e45
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/common/types/GreetingTypes.ets
arkts
GreetingStyle
重新导出GreetingStyle枚举供其他模块使用
export { GreetingStyle };
AST#export_declaration#Left export { GreetingStyle } ; AST#export_declaration#Right
export { GreetingStyle };
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/types/GreetingTypes.ets#L10-L10
794efa5f70c195e650f2a0117e17e6684c5de7f8
github
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
Security/StringCipherArkTS/entry/src/main/ets/pages/Login.ets
arkts
dealUserData
Processes information entered by users.
async dealUserData() { this.userList = await this.userTableApi.queryUserByUsername(this.username); if (this.userList.length === 0) { PromptUtil.promptMessage($r('app.string.message_user_empty'), CommonConstants.PROMPT_TIME); return; } // Decrypt the password using the string decryption API. this.aesDecrypt(); }
AST#method_declaration#Left async dealUserData AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . userList AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . userTableApi AST#member_expression#Right AST#expression#Right . queryUserByUsername 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 . username AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . userList AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left PromptUtil AST#expression#Right . promptMessage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.message_user_empty' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . PROMPT_TIME AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left return AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right // Decrypt the password using the string decryption API. 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 . aesDecrypt 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 dealUserData() { this.userList = await this.userTableApi.queryUserByUsername(this.username); if (this.userList.length === 0) { PromptUtil.promptMessage($r('app.string.message_user_empty'), CommonConstants.PROMPT_TIME); return; } this.aesDecrypt(); }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Security/StringCipherArkTS/entry/src/main/ets/pages/Login.ets#L171-L179
9d13d09e35672084978e101d2e161ab4bf6ea24e
gitee
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
feature/order/src/main/ets/view/OrderConfirmPage.ets
arkts
RemarkCard
订单备注卡片 @returns {void} 无返回值
@Builder private RemarkCard() { Card() { IBestCellGroup({ inset: true, radius: $r("app.float.radius_medium"), outerMargin: 0 }) { // 标题 IBestCell({ hasBorder: true, titleBuilder: (): void => this.RemarkTitle() }); // 备注输入框 IBestField({ showLabel: false, value: this.vm.remark!!, placeholder: $r("app.string.order_remark_placeholder"), rows: 3, maxlength: 200, showWordLimit: true, hasBorder: false, autosize: true }); } } }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right private RemarkCard AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Card ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left IBestCellGroup ( AST#component_parameters#Left { AST#component_parameter#Left inset : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left radius : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.float.radius_medium" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left outerMargin : AST#expression#Left 0 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { // 标题 AST#ui_custom_component_statement#Left IBestCell ( AST#component_parameters#Left { AST#component_parameter#Left hasBorder : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left titleBuilder : 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 . RemarkTitle 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 IBestField ( AST#component_parameters#Left { AST#component_parameter#Left showLabel : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left value : AST#expression#Left AST#non_null_assertion_expression#Left AST#expression#Left AST#non_null_assertion_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 . remark AST#member_expression#Right AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left placeholder : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.order_remark_placeholder" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left rows : AST#expression#Left 3 AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left maxlength : AST#expression#Left 200 AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left showWordLimit : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left hasBorder : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left autosize : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) ; AST#ui_custom_component_statement#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
@Builder private RemarkCard() { Card() { IBestCellGroup({ inset: true, radius: $r("app.float.radius_medium"), outerMargin: 0 }) { IBestCell({ hasBorder: true, titleBuilder: (): void => this.RemarkTitle() }); IBestField({ showLabel: false, value: this.vm.remark!!, placeholder: $r("app.string.order_remark_placeholder"), rows: 3, maxlength: 200, showWordLimit: true, hasBorder: false, autosize: true }); } } }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/order/src/main/ets/view/OrderConfirmPage.ets#L230-L257
8e7966f0900610f5e10f19cb37d6ff2db0d67fdf
github
IceYuanyyy/OxHornCampus.git
bb5686f77fa36db89687502e35898cda218d601f
entry/src/main/ets/view/ImageViewComponent.ets
arkts
limitScale
Limit scale to keep the image clear.
limitScale(isReset: boolean): void { if (this.imgScale < 1) { this.imgScale = 1; this.curScale = 1; if (isReset) { this.imgOffsetX = 0; this.imgOffsetY = 0; } this.isGesture = false; } else if (this.imgScale > Const.MAX_SCALE) { this.imgScale = Const.MAX_SCALE; this.curScale = Const.MAX_SCALE; } else { this.curScale = this.imgScale; } }
AST#method_declaration#Left limitScale AST#parameter_list#Left ( AST#parameter#Left isReset : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . imgScale AST#member_expression#Right AST#expression#Right < AST#expression#Left 1 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 this AST#expression#Right . imgScale AST#member_expression#Right = AST#expression#Left 1 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . curScale AST#member_expression#Right = AST#expression#Left 1 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left isReset AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . imgOffsetX AST#member_expression#Right = AST#expression#Left 0 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . imgOffsetY AST#member_expression#Right = AST#expression#Left 0 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isGesture 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 } else AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . imgScale AST#member_expression#Right AST#expression#Right > AST#expression#Left Const AST#expression#Right AST#binary_expression#Right AST#expression#Right . MAX_SCALE AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . imgScale AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . MAX_SCALE AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . curScale AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left Const AST#expression#Right . MAX_SCALE AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } else { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . curScale AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . imgScale AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
limitScale(isReset: boolean): void { if (this.imgScale < 1) { this.imgScale = 1; this.curScale = 1; if (isReset) { this.imgOffsetX = 0; this.imgOffsetY = 0; } this.isGesture = false; } else if (this.imgScale > Const.MAX_SCALE) { this.imgScale = Const.MAX_SCALE; this.curScale = Const.MAX_SCALE; } else { this.curScale = this.imgScale; } }
https://github.com/IceYuanyyy/OxHornCampus.git/blob/bb5686f77fa36db89687502e35898cda218d601f/entry/src/main/ets/view/ImageViewComponent.ets#L96-L111
e66a39ef84785a8854e1bdc701338459771733c6
github
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
Card/StepsCardJS/entry/src/main/ets/pages/MainPage.ets
arkts
progressTextStyle
Steps text common style.
@Extend(Text) function progressTextStyle(styleFontSize: number, styleFontWeight: number) { .fontColor(Color.White) .fontSize(styleFontSize) .fontWeight(styleFontWeight) }
AST#decorated_function_declaration#Left AST#decorator#Left @ Extend ( AST#expression#Left Text AST#expression#Right ) AST#decorator#Right function progressTextStyle AST#parameter_list#Left ( AST#parameter#Left styleFontSize : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left styleFontWeight : 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#extend_function_body#Left { 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#Left . fontSize ( AST#expression#Left styleFontSize AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left styleFontWeight AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right } AST#extend_function_body#Right AST#decorated_function_declaration#Right
@Extend(Text) function progressTextStyle(styleFontSize: number, styleFontWeight: number) { .fontColor(Color.White) .fontSize(styleFontSize) .fontWeight(styleFontWeight) }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Card/StepsCardJS/entry/src/main/ets/pages/MainPage.ets#L105-L110
aa8dc28cbca1949015b8e678888d9170c166d2eb
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/crypto/RSA.ets
arkts
recoverSync
对数据进行签名恢复原始数据,同步,目前仅RSA支持 @param signDataBlob 已签名数据 @param pubKey 公钥 @param algName 指定签名算法(RSA1024|PKCS1|SHA256、RSA1024|PKCS1|NoHash|OnlySign、RSA1024|PKCS1|NoHash|Recover、等)。 @returns
static recoverSync(signDataBlob: cryptoFramework.DataBlob, pubKey: cryptoFramework.PubKey, algName: string = 'RSA1024|PKCS1|NoHash|Recover') { let verifier = cryptoFramework.createVerify(algName); verifier.initSync(pubKey); let rawSignData = verifier.recoverSync(signDataBlob); return rawSignData; }
AST#method_declaration#Left static recoverSync AST#parameter_list#Left ( AST#parameter#Left signDataBlob : 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 pubKey : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left cryptoFramework . PubKey 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#expression#Left 'RSA1024|PKCS1|NoHash|Recover' AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left verifier = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cryptoFramework AST#expression#Right . createVerify 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 verifier AST#expression#Right . initSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left pubKey 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 rawSignData = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left verifier AST#expression#Right . recoverSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left signDataBlob 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 rawSignData AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static recoverSync(signDataBlob: cryptoFramework.DataBlob, pubKey: cryptoFramework.PubKey, algName: string = 'RSA1024|PKCS1|NoHash|Recover') { let verifier = cryptoFramework.createVerify(algName); verifier.initSync(pubKey); let rawSignData = verifier.recoverSync(signDataBlob); return rawSignData; }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/crypto/RSA.ets#L352-L357
3d4bb96e88137c9950e1d0f68fc665b63f3b2edd
gitee
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_ui/src/main/ets/ui/prompt/MessageUtil.ets
arkts
txtStyle
文本样式 @param color
@Extend(Text) function txtStyle(color: string) { .margin({ left: UiConst.VP_10 }) .fontColor(color) .fontSize(UiConst.FONT_14) }
AST#decorated_function_declaration#Left AST#decorator#Left @ Extend ( AST#expression#Left Text AST#expression#Right ) AST#decorator#Right function txtStyle 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#extend_function_body#Left { AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left UiConst AST#expression#Right . VP_10 AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left color AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#member_expression#Left AST#expression#Left UiConst AST#expression#Right . FONT_14 AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right } AST#extend_function_body#Right AST#decorated_function_declaration#Right
@Extend(Text) function txtStyle(color: string) { .margin({ left: UiConst.VP_10 }) .fontColor(color) .fontSize(UiConst.FONT_14) }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_ui/src/main/ets/ui/prompt/MessageUtil.ets#L147-L154
68c5754c256fae1ce72b05eee5c2cc79bc4cd30a
gitee
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/pages/NavPathManager.ets
arkts
clear
清空所有导航路径
clear(animated?: boolean) { this._navPath.clear(animated ?? true) }
AST#method_declaration#Left clear AST#parameter_list#Left ( AST#parameter#Left animated ? : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . _navPath AST#member_expression#Right AST#expression#Right . clear AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left animated AST#expression#Right ?? AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
clear(animated?: boolean) { this._navPath.clear(animated ?? true) }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/pages/NavPathManager.ets#L73-L75
c6dab34a6e07648a9fa803935e4956b2511fa454
github
vhall/VHLive_SDK_Harmony
29c820e5301e17ae01bc6bdcc393a4437b518e7c
watchKit/src/main/ets/utils/NetworkUtil.ets
arkts
getSignalInformation
获取指定SIM卡槽对应的注册网络信号强度信息列表。 @param slotId 卡槽ID,如果不指定slotId,默认主卡。 @returns
static async getSignalInformation(slotId?: number): Promise<Array<radio.SignalInformation>> { slotId = slotId ?? await NetworkUtil.getPrimarySlotId(); //获取主卡所在卡槽的索引号。 let signalInfo: Array<radio.SignalInformation> = await radio.getSignalInformation(slotId); return signalInfo; }
AST#method_declaration#Left static async getSignalInformation AST#parameter_list#Left ( AST#parameter#Left slotId ? : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left radio . SignalInformation AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left slotId = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left slotId AST#expression#Right ?? AST#expression#Left AST#await_expression#Left await AST#expression#Left NetworkUtil AST#expression#Right AST#await_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . getPrimarySlotId AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right //获取主卡所在卡槽的索引号。 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left signalInfo : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left radio . SignalInformation 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#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left radio AST#expression#Right AST#await_expression#Right AST#expression#Right . getSignalInformation AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left slotId 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 signalInfo AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static async getSignalInformation(slotId?: number): Promise<Array<radio.SignalInformation>> { slotId = slotId ?? await NetworkUtil.getPrimarySlotId(); let signalInfo: Array<radio.SignalInformation> = await radio.getSignalInformation(slotId); return signalInfo; }
https://github.com/vhall/VHLive_SDK_Harmony/blob/29c820e5301e17ae01bc6bdcc393a4437b518e7c/watchKit/src/main/ets/utils/NetworkUtil.ets#L376-L380
9a9518f395759d4e773f3de3ee1e4f20486a474b
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/social/CommunityService.ets
arkts
getNotifications
获取通知列表
async getNotifications(limit: number = 20, offset: number = 0): Promise<Notification[]> { try { // TODO: 实现真实的API调用 return this.getMockNotifications(limit); } catch (error) { hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to get notifications: ${error}`); return []; } }
AST#method_declaration#Left async getNotifications AST#parameter_list#Left ( AST#parameter#Left limit : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 20 AST#expression#Right AST#parameter#Right , AST#parameter#Left offset : 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#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 Notification [ ] 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 { // TODO: 实现真实的API调用 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 . getMockNotifications AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left limit AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Failed to get notifications: AST#template_substitution#Left $ { AST#expression#Left error AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async getNotifications(limit: number = 20, offset: number = 0): Promise<Notification[]> { try { return this.getMockNotifications(limit); } catch (error) { hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to get notifications: ${error}`); return []; } }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/social/CommunityService.ets#L579-L588
82c3a62544bd181478c53a9ac6c7022b5f70855c
github
ThePivotPoint/ArkTS-LSP-Server-Plugin.git
6231773905435f000d00d94b26504433082ba40b
packages/declarations/ets/api/@ohos.atomicservice.AtomicServiceTabs.d.ets
arkts
AtomicServiceTabs
@file Provides an advanced struct of tabs for atomic services @kit ArkUI Defines AtomicServiceTabs. @struct AtomicServiceTabs @syscap SystemCapability.ArkUI.ArkUI.Full @atomicservice @since 12
@Component export declare struct AtomicServiceTabs { /** * The TabContent array of tabs. * * @type { ?[TabContentBuilder?, TabContentBuilder?, TabContentBuilder?, TabContentBuilder?, TabContentBuilder?] }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ @BuilderParam tabContents?: [ TabContentBuilder?, TabContentBuilder?, TabContentBuilder?, TabContentBuilder?, TabContentBuilder? ]; /** * The tabBar array of tabs. * * @type { [TabBarOptions, TabBarOptions, TabBarOptions?, TabBarOptions?, TabBarOptions?] }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ @Prop tabBarOptionsArray: [ TabBarOptions, TabBarOptions, TabBarOptions?, TabBarOptions?, TabBarOptions? ]; /** * set the positions of tabbar. * * @type { ?TabBarPosition }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ @Prop tabBarPosition?: TabBarPosition; /** * Sets the barBackgroundColor of tabs. * * @type { ?ResourceColor }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ @Prop barBackgroundColor?: ResourceColor; /** * Sets the index of tabs. * * @type { ?number }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ @Prop index?: number; /** * set if need overlap, default value is true. * * @type { ?boolean }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ @Prop barOverlap?: boolean; /** * Provide methods for switching tabs. * * @type { ?TabsController }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ controller?: TabsController; /** * onChange callback of tabs when tabs changed. * * @type { ?Callback<number> }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ onChange?: Callback<number>; /** * onTabBarClick callback of tabs when tabbar is clicked. * * @type { ?Callback<number> }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ onTabBarClick?: Callback<number>; /** * onContentWillChange callback of tabs when tabbar is clicked. * * @type { ?OnContentWillChangeCallback }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ onContentWillChange?: OnContentWillChangeCallback; }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export AST#ERROR#Left declare AST#ERROR#Right struct AtomicServiceTabs AST#component_body#Left { /** * The TabContent array of tabs. * * @type { ?[TabContentBuilder?, TabContentBuilder?, TabContentBuilder?, TabContentBuilder?, TabContentBuilder?] }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#property_declaration#Left AST#decorator#Left @ BuilderParam AST#decorator#Right tabContents ? : AST#type_annotation#Left AST#primary_type#Left AST#tuple_type#Left [ AST#type_annotation#Left AST#primary_type#Left TabContentBuilder AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left ? AST#ERROR#Right , AST#type_annotation#Left AST#primary_type#Left TabContentBuilder AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left ? AST#ERROR#Right , AST#type_annotation#Left AST#primary_type#Left TabContentBuilder AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left ? AST#ERROR#Right , AST#type_annotation#Left AST#primary_type#Left TabContentBuilder AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left ? AST#ERROR#Right , AST#type_annotation#Left AST#primary_type#Left TabContentBuilder AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left ? AST#ERROR#Right ] AST#tuple_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * The tabBar array of tabs. * * @type { [TabBarOptions, TabBarOptions, TabBarOptions?, TabBarOptions?, TabBarOptions?] }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right tabBarOptionsArray : AST#type_annotation#Left AST#primary_type#Left AST#tuple_type#Left [ AST#type_annotation#Left AST#primary_type#Left TabBarOptions AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left TabBarOptions AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left TabBarOptions AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left ? AST#ERROR#Right , AST#type_annotation#Left AST#primary_type#Left TabBarOptions AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left ? AST#ERROR#Right , AST#type_annotation#Left AST#primary_type#Left TabBarOptions AST#primary_type#Right AST#type_annotation#Right AST#ERROR#Left ? AST#ERROR#Right ] AST#tuple_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * set the positions of tabbar. * * @type { ?TabBarPosition }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right tabBarPosition ? : AST#type_annotation#Left AST#primary_type#Left TabBarPosition AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Sets the barBackgroundColor of tabs. * * @type { ?ResourceColor }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right barBackgroundColor ? : AST#type_annotation#Left AST#primary_type#Left ResourceColor AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Sets the index of tabs. * * @type { ?number }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right index ? : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * set if need overlap, default value is true. * * @type { ?boolean }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right barOverlap ? : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Provide methods for switching tabs. * * @type { ?TabsController }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#property_declaration#Left controller ? : AST#type_annotation#Left AST#primary_type#Left TabsController AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * onChange callback of tabs when tabs changed. * * @type { ?Callback<number> }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @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 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 /** * onTabBarClick callback of tabs when tabbar is clicked. * * @type { ?Callback<number> }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#property_declaration#Left onTabBarClick ? : 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 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 /** * onContentWillChange callback of tabs when tabbar is clicked. * * @type { ?OnContentWillChangeCallback }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#property_declaration#Left onContentWillChange ? : AST#type_annotation#Left AST#primary_type#Left OnContentWillChangeCallback 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 AtomicServiceTabs { @BuilderParam tabContents?: [ TabContentBuilder?, TabContentBuilder?, TabContentBuilder?, TabContentBuilder?, TabContentBuilder? ]; @Prop tabBarOptionsArray: [ TabBarOptions, TabBarOptions, TabBarOptions?, TabBarOptions?, TabBarOptions? ]; @Prop tabBarPosition?: TabBarPosition; @Prop barBackgroundColor?: ResourceColor; @Prop index?: number; @Prop barOverlap?: boolean; controller?: TabsController; onChange?: Callback<number>; onTabBarClick?: Callback<number>; onContentWillChange?: OnContentWillChangeCallback; }
https://github.com/ThePivotPoint/ArkTS-LSP-Server-Plugin.git/blob/6231773905435f000d00d94b26504433082ba40b/packages/declarations/ets/api/@ohos.atomicservice.AtomicServiceTabs.d.ets#L27-L137
11ff4df7696ef50cdf778458b0669393ec20ea67
github
openharmony-tpc/ohos_mpchart
4fb43a7137320ef2fee2634598f53d93975dfb4a
library/src/main/ets/components/utils/Utils.ets
arkts
getDefaultValueFormatter
/// - returns: The default value formatter used for all chart components that needs a default
public static getDefaultValueFormatter(): IValueFormatter { return Utils.mDefaultValueFormatter; }
AST#method_declaration#Left public static getDefaultValueFormatter AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left IValueFormatter 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 Utils AST#expression#Right . mDefaultValueFormatter AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
public static getDefaultValueFormatter(): IValueFormatter { return Utils.mDefaultValueFormatter; }
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/utils/Utils.ets#L162-L164
699063cf003531e8df055b17903ecf8d356cbb15
gitee
wasd09090030/MyHongmengProject.git
a8ed386b658ceeac69ef5bc42a92d78c7980821c
entry/src/main/ets/viewmodels/ReviewViewModel.ets
arkts
getAheadCount
获取超预期完成的任务数量
static getAheadCount(completedTasks: TaskItem[]): number { return completedTasks.filter(t => { if (!t.actualTime) return false; return t.estimatedTime / t.actualTime > 1.1; }).length; }
AST#method_declaration#Left static getAheadCount AST#parameter_list#Left ( AST#parameter#Left completedTasks : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left TaskItem [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_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 completedTasks AST#expression#Right . filter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left t => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left t AST#expression#Right AST#unary_expression#Right AST#expression#Right . actualTime AST#member_expression#Right AST#expression#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#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#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left t AST#expression#Right . estimatedTime AST#member_expression#Right AST#expression#Right / AST#expression#Left t AST#expression#Right AST#binary_expression#Right AST#expression#Right . actualTime AST#member_expression#Right AST#expression#Right > AST#expression#Left 1.1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static getAheadCount(completedTasks: TaskItem[]): number { return completedTasks.filter(t => { if (!t.actualTime) return false; return t.estimatedTime / t.actualTime > 1.1; }).length; }
https://github.com/wasd09090030/MyHongmengProject.git/blob/a8ed386b658ceeac69ef5bc42a92d78c7980821c/entry/src/main/ets/viewmodels/ReviewViewModel.ets#L111-L116
8a69c199ec8a1df35404921cd878d7cb3b2fa992
github
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
TaskPoolPractice/entry/src/main/ets/pages/sample1/Sample1.ets
arkts
correctConcurrentFunc
[Start sample_fun] Sample1.ets
@Concurrent function correctConcurrentFunc() { let foo: Foo = new Foo; }
AST#decorated_function_declaration#Left AST#decorator#Left @ Concurrent AST#decorator#Right function correctConcurrentFunc AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left foo : AST#type_annotation#Left AST#primary_type#Left Foo AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#new_expression#Left new AST#expression#Left Foo AST#expression#Right AST#new_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right } AST#block_statement#Right AST#decorated_function_declaration#Right
@Concurrent function correctConcurrentFunc() { let foo: Foo = new Foo; }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/TaskPoolPractice/entry/src/main/ets/pages/sample1/Sample1.ets#L27-L30
c16fbcdd836eb806a85f057e5754de79e6662ff9
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_dialog/src/main/ets/dialog/DialogBuilder.ets
arkts
CustomContentDialogBuilder
CustomContentDialog
@Builder export function CustomContentDialogBuilder(options: BaseContentOptions) { CustomContentDialog(options) .height(options.height) .width(options.width) .constraintSize({ maxWidth: options.maxWidth, maxHeight: options.maxHeight }) .backgroundColor(options.backgroundColor) .backgroundBlurStyle(options.backgroundBlurStyle) .borderRadius(options.cornerRadius) .borderWidth(options.borderWidth) .borderColor(options.borderColor) .borderStyle(options.borderStyle) .clip(true) }
AST#decorated_export_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right export function CustomContentDialogBuilder AST#parameter_list#Left ( AST#parameter#Left options : AST#type_annotation#Left AST#primary_type#Left BaseContentOptions 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 CustomContentDialog ( AST#expression#Left options AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . height AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . width AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . constraintSize ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left maxWidth AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . maxWidth AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left maxHeight AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . maxHeight AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . backgroundColor AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundBlurStyle ( AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . backgroundBlurStyle AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . cornerRadius AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderWidth ( AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . borderWidth AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . borderColor AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderStyle ( AST#expression#Left AST#member_expression#Left AST#expression#Left options AST#expression#Right . borderStyle AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . clip ( AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#decorated_export_declaration#Right
@Builder export function CustomContentDialogBuilder(options: BaseContentOptions) { CustomContentDialog(options) .height(options.height) .width(options.width) .constraintSize({ maxWidth: options.maxWidth, maxHeight: options.maxHeight }) .backgroundColor(options.backgroundColor) .backgroundBlurStyle(options.backgroundBlurStyle) .borderRadius(options.cornerRadius) .borderWidth(options.borderWidth) .borderColor(options.borderColor) .borderStyle(options.borderStyle) .clip(true) }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_dialog/src/main/ets/dialog/DialogBuilder.ets#L117-L130
01de61a337bbc263d1bff024105d845c9de7126b
gitee
wangjinyuan/JS-TS-ArkTS-database.git
a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26
npm/alprazolamdiv/11.5.1/package/src/structures/MessageMentions.ets
arkts
get
Getter方法保持TS语法(约束50)
get members(): Collection<Snowflake, GuildMember> | null { if (this._members) return this._members; if (!this._guild) return null; this._members = new Collection(); this.users.forEach(user => { const member = this._guild!.members.get(user['id']); if (member) this._members!.set(member['id'], member); }); return this._members; }
AST#method_declaration#Left get AST#ERROR#Left members AST#ERROR#Right AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#generic_type#Left Collection AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left Snowflake AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left GuildMember AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . _members AST#member_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . _members AST#member_expression#Right 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#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . _guild AST#member_expression#Right AST#expression#Right ) AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right AST#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 . _members AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Collection 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#statement#Right 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 . users 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 user => AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left member = 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#non_null_assertion_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . _guild AST#member_expression#Right AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right . members AST#member_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left user AST#expression#Right [ AST#expression#Left 'id' 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#if_statement#Left if ( AST#expression#Left member AST#expression#Right ) AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#non_null_assertion_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . _members AST#member_expression#Right AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left member AST#expression#Right [ AST#expression#Left 'id' AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right , AST#expression#Left member AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . _members AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
get members(): Collection<Snowflake, GuildMember> | null { if (this._members) return this._members; if (!this._guild) return null; this._members = new Collection(); this.users.forEach(user => { const member = this._guild!.members.get(user['id']); if (member) this._members!.set(member['id'], member); }); return this._members; }
https://github.com/wangjinyuan/JS-TS-ArkTS-database.git/blob/a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26/npm/alprazolamdiv/11.5.1/package/src/structures/MessageMentions.ets#L96-L105
6c57e92380a025a9e4b6662a1c3c63fb8a479dd0
github
zqaini002/YaoYaoLingXian.git
5095b12cbeea524a87c42d0824b1702978843d39
YaoYaoLingXian/entry/src/main/ets/pages/dream/DreamEditPage.ets
arkts
formatDate
格式化日期为YYYY-MM-DD
formatDate(date: CustomDate): string { return date.toString(); }
AST#method_declaration#Left formatDate AST#parameter_list#Left ( AST#parameter#Left date : AST#type_annotation#Left AST#primary_type#Left CustomDate AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
formatDate(date: CustomDate): string { return date.toString(); }
https://github.com/zqaini002/YaoYaoLingXian.git/blob/5095b12cbeea524a87c42d0824b1702978843d39/YaoYaoLingXian/entry/src/main/ets/pages/dream/DreamEditPage.ets#L450-L452
781afbbc6ca0b95e9b5746f0ee94e756f9820973
github
tomorrowKreswell/Ledger.git
1f2783ae70b8540d677af8a27f29db1b4089ea69
ledger/entry/src/main/ets/common/utils/DateUtils.ets
arkts
格式化日期时间的函数
export function formatDateTime(date: Date | number, format: string): string { // 如果输入的日期是数字,将其转换为日期对象 if (typeof date === 'number') { date = new Date(date) } // 定义日期格式化的参数对象 const o = { 'y+': date.getFullYear(), // 年份 'M+': date.getMonth() + 1, // 月份 'd+': date.getDate(), // 日 'h+': date.getHours() % 12 === 0 ? 12 : date.getHours() % 12, // 小时 'H+': date.getHours(), // 小时 'm+': date.getMinutes(), // 分 's+': date.getSeconds(), // 秒 'q+': Math.floor((date.getMonth() + 3) / 3), // 季度 S: date.getMilliseconds(), // 毫秒 a: date.getHours() < 12 ? '上午' : '下午', // 上午/下午 A: date.getHours() < 12 ? 'AM' : 'PM', // AM/PM }; // 替换日期格式中的占位符 if (/(y+)/.test(format)) { format = format.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length)); } for (let k in o) { if (new RegExp('(' + k + ')').test(format)) { format = format.replace( RegExp.$1, RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length) ); } } // 返回格式化后的日期字符串 return format; }
AST#export_declaration#Left export AST#function_declaration#Left function formatDateTime AST#parameter_list#Left ( AST#parameter#Left date : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Date AST#primary_type#Right | AST#primary_type#Left number AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left format : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { // 如果输入的日期是数字,将其转换为日期对象 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left date AST#expression#Right AST#unary_expression#Right AST#expression#Right === AST#expression#Left 'number' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left date = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left date AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 定义日期格式化的参数对象 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left o = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left 'y+' AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date AST#expression#Right . getFullYear AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , // 年份 AST#property_assignment#Left AST#property_name#Left 'M+' AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date AST#expression#Right . getMonth AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right , // 月份 AST#property_assignment#Left AST#property_name#Left 'd+' AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date AST#expression#Right . getDate 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 'h+' AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date 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 12 AST#expression#Right AST#binary_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left 12 AST#expression#Right : AST#expression#Left date AST#expression#Right AST#conditional_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 12 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right , // 小时 AST#property_assignment#Left AST#property_name#Left 'H+' AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date 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#property_assignment#Right , // 小时 AST#property_assignment#Left AST#property_name#Left 'm+' AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date AST#expression#Right . getMinutes 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 's+' AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date AST#expression#Right . getSeconds 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 'q+' AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . floor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date AST#expression#Right . getMonth AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left 3 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right / AST#expression#Left 3 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , // 季度 AST#property_assignment#Left AST#property_name#Left S AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date AST#expression#Right . getMilliseconds 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 a AST#property_name#Right : AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date AST#expression#Right . 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 12 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left '上午' AST#expression#Right : AST#expression#Left '下午' AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#property_assignment#Right , // 上午/下午 AST#property_assignment#Left AST#property_name#Left A AST#property_name#Right : AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date AST#expression#Right . 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 12 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left 'AM' AST#expression#Right : AST#expression#Left 'PM' AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#property_assignment#Right , // AM/PM } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 替换日期格式中的占位符 AST#statement#Left AST#if_statement#Left if ( AST#ERROR#Left / AST#ERROR#Right AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left y AST#expression#Right + AST#expression#Left AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right / AST#expression#Left AST#expression#Right AST#binary_expression#Right AST#expression#Right . test AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left format AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left format = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left format AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left RegExp AST#expression#Right . $1 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#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date AST#expression#Right . getFullYear AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . substr AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 4 AST#expression#Right - AST#expression#Left RegExp AST#expression#Right AST#binary_expression#Right AST#expression#Right . $1 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#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#for_statement#Left for ( let k in AST#expression#Left o 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 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 AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left '(' AST#expression#Right + AST#expression#Left k AST#expression#Right AST#binary_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 . test AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left format AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left format = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left format AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left RegExp AST#expression#Right . $1 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#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left RegExp AST#expression#Right . $1 AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right === AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#subscript_expression#Left AST#expression#Left o AST#expression#Right [ AST#expression#Left k AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right : AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left '00' AST#expression#Right + AST#expression#Left AST#subscript_expression#Left AST#expression#Left o AST#expression#Right [ AST#expression#Left k AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right . substr AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left '' AST#expression#Right + AST#expression#Left AST#subscript_expression#Left AST#expression#Left o AST#expression#Right [ AST#expression#Left k AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_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#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#for_statement#Right AST#statement#Right // 返回格式化后的日期字符串 AST#statement#Left AST#return_statement#Left return AST#expression#Left format AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export function formatDateTime(date: Date | number, format: string): string { if (typeof date === 'number') { date = new Date(date) } const o = { 'y+': date.getFullYear(), 'M+': date.getMonth() + 1, 'd+': date.getDate(), 'h+': date.getHours() % 12 === 0 ? 12 : date.getHours() % 12, 'H+': date.getHours(), 'm+': date.getMinutes(), 's+': date.getSeconds(), 'q+': Math.floor((date.getMonth() + 3) / 3), S: date.getMilliseconds(), a: date.getHours() < 12 ? '上午' : '下午', A: date.getHours() < 12 ? 'AM' : 'PM', }; if (/(y+)/.test(format)) { format = format.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length)); } for (let k in o) { if (new RegExp('(' + k + ')').test(format)) { format = format.replace( RegExp.$1, RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length) ); } } return format; }
https://github.com/tomorrowKreswell/Ledger.git/blob/1f2783ae70b8540d677af8a27f29db1b4089ea69/ledger/entry/src/main/ets/common/utils/DateUtils.ets#L5-L42
061e44f4c930db99511c90e2faa630875eb2829c
github
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
core/model/src/main/ets/entity/OrderCount.ets
arkts
readNumber
读取数值字段 @param {Object} source - 原始对象 @param {string} key - 字段名 @returns {number | null} 数值或空
private static readNumber(source: Object, key: string): number | null { const value: string | number | undefined = Reflect.get(source, key) as string | number | undefined; if (typeof value === "number") { return value; } if (typeof value === "string") { const parsed: number = Number(value); return Number.isNaN(parsed) ? null : parsed; } return null; }
AST#method_declaration#Left private static readNumber AST#parameter_list#Left ( AST#parameter#Left source : AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left key : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : 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#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left value : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left number AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Reflect AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left source AST#expression#Right , AST#expression#Left key AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left number AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right | AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left value AST#expression#Right AST#unary_expression#Right AST#expression#Right === AST#expression#Left "number" AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left value AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left value AST#expression#Right AST#unary_expression#Right AST#expression#Right === AST#expression#Left "string" AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left parsed : 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 Number AST#expression#Right AST#argument_list#Left ( AST#expression#Left value AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#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 AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Number AST#expression#Right . isNaN AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left parsed AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ? AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right : AST#expression#Left parsed AST#expression#Right AST#conditional_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private static readNumber(source: Object, key: string): number | null { const value: string | number | undefined = Reflect.get(source, key) as string | number | undefined; if (typeof value === "number") { return value; } if (typeof value === "string") { const parsed: number = Number(value); return Number.isNaN(parsed) ? null : parsed; } return null; }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/model/src/main/ets/entity/OrderCount.ets#L89-L99
508ee1a0e0e608afc5ff7577a1216f1286f70568
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/Solutions/Social/GrapeSquare/feature/authorizedControl/src/main/ets/view/TrendsDetailView.ets
arkts
后缀图标
constructor(id: string, des: string | Resource, image: Resource | undefined) { this.id = id; this.des = des; this.image = image; }
AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left id : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left des : 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 image : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Resource AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . id AST#member_expression#Right = AST#expression#Left id AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . des AST#member_expression#Right = AST#expression#Left des AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . image AST#member_expression#Right = AST#expression#Left image AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right
constructor(id: string, des: string | Resource, image: Resource | undefined) { this.id = id; this.des = des; this.image = image; }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/Solutions/Social/GrapeSquare/feature/authorizedControl/src/main/ets/view/TrendsDetailView.ets#L27-L31
077195b6e8e0a6a6cd3cbd7028b2e7cf498294b8
gitee
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
eftool/src/main/ets/device/KvUtil.ets
arkts
get
获取数据 @param key 获取数据的key @param defVal 默认值 @returns 获取到的数据
async get<T>(key: string, defVal: T): Promise<T> { let isAuth = await this.getAuth(); if (isAuth) { try { const value = await this.kvStore?.get(key); if (value === undefined) { return defVal; } return value as T; } catch (e) { return defVal; } } return defVal; }
AST#method_declaration#Left async get 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 defVal : AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left isAuth = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . getAuth 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 isAuth 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 value = 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 . kvStore AST#member_expression#Right AST#expression#Right ?. get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right ) AST#argument_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 value AST#expression#Right === AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left defVal 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 value AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left T 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 ( e ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left defVal AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left defVal AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async get<T>(key: string, defVal: T): Promise<T> { let isAuth = await this.getAuth(); if (isAuth) { try { const value = await this.kvStore?.get(key); if (value === undefined) { return defVal; } return value as T; } catch (e) { return defVal; } } return defVal; }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/eftool/src/main/ets/device/KvUtil.ets#L119-L133
659bc4b2cd668bc4a1de8a2b1adbfa0799a614a5
gitee
openharmony-tpc/ohos_mpchart
4fb43a7137320ef2fee2634598f53d93975dfb4a
library/src/main/ets/components/charts/ChartModel.ets
arkts
calcMinMax
Calculates the y-min and y-max value and the y-delta and x-delta value
protected abstract calcMinMax();
AST#method_declaration#Left protected abstract calcMinMax AST#parameter_list#Left ( ) AST#parameter_list#Right ; AST#method_declaration#Right
protected abstract calcMinMax();
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/charts/ChartModel.ets#L321-L321
1732b5d0b034f3e5c67ae2204568b8741a60ebcd
gitee
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
ArkUI/PureTabsExt/entry/src/main/ets/view/SwitchTabComponent.ets
arkts
SwitchTabComponent
[Start custom_switch_tab]
@Component export default struct SwitchTabComponent { // [StartExclude custom_switch_tab] @State tabItems: string[] = []; // [EndExclude custom_switch_tab] @State currentIndex: number = 0; private tabController: TabsController = new TabsController(); // [StartExclude custom_switch_tab] async aboutToAppear(): Promise<void> { this.updateTabItems(); this.subscribeSystemLanguageUpdate(); } private async updateTabItems() { await this.getUIContext() .getHostContext()?.resourceManager.getStringArrayValue($r('app.strarray.switch_tabs_items').id) .then((strarray: string[]) => { this.tabItems = strarray; }) .catch((err: BusinessError) => { hilog.error(0x000, 'testTag', `getStringArrayValue failed, code=${err.code}, message=${err.message}`) }) } subscribeSystemLanguageUpdate() { let thisComponent = this; let systemLanguage: string | undefined; this.getUIContext().getHostContext()?.getApplicationContext().on('environment', { async onConfigurationUpdated(newConfig: Configuration) { if (systemLanguage !== newConfig.language) { thisComponent.updateTabItems(); systemLanguage = newConfig.language; } }, onMemoryLevel: (level: AbilityConstant.MemoryLevel): void => { // do nothing } }); } // [EndExclude custom_switch_tab] build() { Column() { Row() { Button('Previous Tab') .onClick(() => { this.tabController.changeIndex((this.currentIndex + 3) % 4); // call tabController.changeIndex() to switch tab }) // [StartExclude custom_switch_tab] .width(158) .height(40) .margin({top:10, right: 10 }) .backgroundColor('rgba(0,0,0,0.05)') .fontColor('#0A59F7') .fontSize(16) .fontWeight(FontWeight.Medium) // [EndExclude custom_switch_tab] Button('Next Tab') .onClick(() => { this.currentIndex = (this.currentIndex + 1) % 4; // change currentIndex to switch tab }) // [StartExclude custom_switch_tab] .width(158) .height(40) .margin({top:10, left: 10 }) .backgroundColor('rgba(0,0,0,0.05)') .fontColor('#0A59F7') .fontSize(16) .fontWeight(FontWeight.Medium) // [EndExclude custom_switch_tab] } Tabs({ controller: this.tabController, index: $$this.currentIndex // use $$ for two-way data binding }) { // [StartExclude custom_switch_tab] ForEach(this.tabItems, (item: string, index: number) => { TabContent() { Column() { Text(`${item}`) } .width('100%') .height('70%') .justifyContent(FlexAlign.Center) }.tabBar(item).align(Alignment.Top) }) // [EndExclude custom_switch_tab] } } } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export default struct SwitchTabComponent AST#component_body#Left { // [StartExclude custom_switch_tab] AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right tabItems : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right ; AST#property_declaration#Right // [EndExclude custom_switch_tab] AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right currentIndex : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private tabController : AST#type_annotation#Left AST#primary_type#Left TabsController 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 TabsController 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 // [StartExclude custom_switch_tab] AST#method_declaration#Left async aboutToAppear AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . updateTabItems AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . subscribeSystemLanguageUpdate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left private async updateTabItems AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . getUIContext AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . getHostContext AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ?. resourceManager AST#member_expression#Right AST#expression#Right . getStringArrayValue AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.strarray.switch_tabs_items' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right . id AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . 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 strarray : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . tabItems AST#member_expression#Right = AST#expression#Left strarray AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . catch AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err : AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#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 0x000 AST#expression#Right , AST#expression#Left 'testTag' AST#expression#Right , AST#expression#Left AST#template_literal#Left ` getStringArrayValue failed, 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#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 subscribeSystemLanguageUpdate AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left thisComponent = AST#expression#Left this 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 systemLanguage : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getUIContext AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . getHostContext AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ?. getApplicationContext 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 'environment' AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left async AST#property_name#Left onConfigurationUpdated AST#property_name#Right AST#parameter_list#Left ( AST#parameter#Left newConfig : AST#type_annotation#Left AST#primary_type#Left Configuration 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 systemLanguage AST#expression#Right !== AST#expression#Left newConfig AST#expression#Right AST#binary_expression#Right AST#expression#Right . language 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 thisComponent AST#expression#Right . updateTabItems 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 systemLanguage = AST#expression#Left AST#member_expression#Left AST#expression#Left newConfig AST#expression#Right . language AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left onMemoryLevel AST#property_name#Right : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left level : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left AbilityConstant . MemoryLevel AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right => AST#expression#Left AST#object_literal#Left { // do nothing } AST#object_literal#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right // [EndExclude custom_switch_tab] 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 Button ( AST#expression#Left 'Previous Tab' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . tabController AST#member_expression#Right AST#expression#Right . changeIndex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentIndex AST#member_expression#Right AST#expression#Right + AST#expression#Left 3 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right % AST#expression#Left 4 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 // call tabController.changeIndex() to switch tab } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) // [StartExclude custom_switch_tab] AST#modifier_chain_expression#Left . width ( AST#expression#Left 158 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 40 AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 10 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 10 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 'rgba(0,0,0,0.05)' AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#0A59F7' AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 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#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 // [EndExclude custom_switch_tab] AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#expression#Left 'Next Tab' AST#expression#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 . currentIndex AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . currentIndex AST#member_expression#Right AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right % AST#expression#Left 4 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // change currentIndex to switch tab } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) // [StartExclude custom_switch_tab] AST#modifier_chain_expression#Left . width ( AST#expression#Left 158 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 40 AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 10 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 10 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 'rgba(0,0,0,0.05)' AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#0A59F7' AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 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#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 // [EndExclude custom_switch_tab] } 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 Tabs ( AST#component_parameters#Left { AST#component_parameter#Left controller : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . tabController AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left index : AST#expression#Left AST#member_expression#Left AST#expression#Left $$this AST#expression#Right . currentIndex AST#member_expression#Right AST#expression#Right AST#component_parameter#Right // use $$ for two-way data binding } AST#component_parameters#Right ) AST#container_content_body#Left { // [StartExclude custom_switch_tab] AST#ui_control_flow#Left AST#for_each_statement#Left ForEach ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . tabItems AST#member_expression#Right AST#expression#Right , AST#ui_builder_arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#ui_arrow_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left TabContent ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left item AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#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 . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '70%' AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . tabBar ( AST#expression#Left item AST#expression#Right ) AST#modifier_chain_expression#Left . align ( AST#expression#Left AST#member_expression#Left AST#expression#Left Alignment AST#expression#Right . Top AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_arrow_function_body#Right AST#ui_builder_arrow_function#Right ) AST#for_each_statement#Right AST#ui_control_flow#Right // [EndExclude custom_switch_tab] } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Component export default struct SwitchTabComponent { @State tabItems: string[] = []; @State currentIndex: number = 0; private tabController: TabsController = new TabsController(); async aboutToAppear(): Promise<void> { this.updateTabItems(); this.subscribeSystemLanguageUpdate(); } private async updateTabItems() { await this.getUIContext() .getHostContext()?.resourceManager.getStringArrayValue($r('app.strarray.switch_tabs_items').id) .then((strarray: string[]) => { this.tabItems = strarray; }) .catch((err: BusinessError) => { hilog.error(0x000, 'testTag', `getStringArrayValue failed, code=${err.code}, message=${err.message}`) }) } subscribeSystemLanguageUpdate() { let thisComponent = this; let systemLanguage: string | undefined; this.getUIContext().getHostContext()?.getApplicationContext().on('environment', { async onConfigurationUpdated(newConfig: Configuration) { if (systemLanguage !== newConfig.language) { thisComponent.updateTabItems(); systemLanguage = newConfig.language; } }, onMemoryLevel: (level: AbilityConstant.MemoryLevel): void => { } }); } build() { Column() { Row() { Button('Previous Tab') .onClick(() => { this.tabController.changeIndex((this.currentIndex + 3) % 4); }) .width(158) .height(40) .margin({top:10, right: 10 }) .backgroundColor('rgba(0,0,0,0.05)') .fontColor('#0A59F7') .fontSize(16) .fontWeight(FontWeight.Medium) Button('Next Tab') .onClick(() => { this.currentIndex = (this.currentIndex + 1) % 4; }) .width(158) .height(40) .margin({top:10, left: 10 }) .backgroundColor('rgba(0,0,0,0.05)') .fontColor('#0A59F7') .fontSize(16) .fontWeight(FontWeight.Medium) } Tabs({ controller: this.tabController, index: $$this.currentIndex }) { ForEach(this.tabItems, (item: string, index: number) => { TabContent() { Column() { Text(`${item}`) } .width('100%') .height('70%') .justifyContent(FlexAlign.Center) }.tabBar(item).align(Alignment.Top) }) } } } }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/ArkUI/PureTabsExt/entry/src/main/ets/view/SwitchTabComponent.ets#L20-L116
0f4f3571d818e3b4123a8e4bb2d005b395acf770
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/notification/NotificationManager.ets
arkts
通知类型枚举
export enum NotificationType { BIRTHDAY_TODAY = 'birthday_today', BIRTHDAY_TOMORROW = 'birthday_tomorrow', BIRTHDAY_WEEK = 'birthday_week', ANNIVERSARY_TODAY = 'anniversary_today', SYSTEM_REMINDER = 'system_reminder', SMART_SUGGESTION = 'smart_suggestion' }
AST#export_declaration#Left export AST#enum_declaration#Left enum NotificationType AST#enum_body#Left { AST#enum_member#Left BIRTHDAY_TODAY = AST#expression#Left 'birthday_today' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left BIRTHDAY_TOMORROW = AST#expression#Left 'birthday_tomorrow' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left BIRTHDAY_WEEK = AST#expression#Left 'birthday_week' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left ANNIVERSARY_TODAY = AST#expression#Left 'anniversary_today' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left SYSTEM_REMINDER = AST#expression#Left 'system_reminder' AST#expression#Right AST#enum_member#Right , AST#enum_member#Left SMART_SUGGESTION = AST#expression#Left 'smart_suggestion' AST#expression#Right AST#enum_member#Right } AST#enum_body#Right AST#enum_declaration#Right AST#export_declaration#Right
export enum NotificationType { BIRTHDAY_TODAY = 'birthday_today', BIRTHDAY_TOMORROW = 'birthday_tomorrow', BIRTHDAY_WEEK = 'birthday_week', ANNIVERSARY_TODAY = 'anniversary_today', SYSTEM_REMINDER = 'system_reminder', SMART_SUGGESTION = 'smart_suggestion' }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/notification/NotificationManager.ets#L19-L26
f958902d65448185ada0ece900e1a170aa67b8c5
github
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_core/src/main/ets/core/util/DateUtil.ets
arkts
formatDate
将传入的日期字符串按照传入的format进行格式化输出,不传默认为yyyy-MM-dd,日期格式化年月日时分秒为y-M-d H:m:s @param value @param format 格式化字符串 @returns
static formatDate(value: string, format: string = 'yyyy-MM-dd'): string { const date = new Date(value); if (value.split(' ').length <= 1 && value.split('T').length <= 1) { date.setHours(0); date.setMinutes(0); date.setSeconds(0); } const year = date.getFullYear(); const month = DateUtil.padZero(date.getMonth() + 1); const day = DateUtil.padZero(date.getDate()); const hours = DateUtil.padZero(date.getHours()); const minutes = DateUtil.padZero(date.getMinutes()); const seconds = DateUtil.padZero(date.getSeconds()); let formattedDate = format.replace("yyyy", year.toString()); formattedDate = formattedDate.replace("MM", month); formattedDate = formattedDate.replace("dd", day); formattedDate = formattedDate.replace("HH", hours); formattedDate = formattedDate.replace("mm", minutes); formattedDate = formattedDate.replace("ss", seconds); return formattedDate; }
AST#method_declaration#Left static formatDate AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left format : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 'yyyy-MM-dd' AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left date = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left value AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left value AST#expression#Right . split AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left ' ' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right <= AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left value AST#expression#Right AST#binary_expression#Right AST#expression#Right . split AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'T' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right <= AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date AST#expression#Right . setHours 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#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date AST#expression#Right . setMinutes 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#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date AST#expression#Right . setSeconds 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#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 year = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date AST#expression#Right . getFullYear AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left month = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DateUtil AST#expression#Right . padZero AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left date AST#expression#Right . getMonth AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left day = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DateUtil AST#expression#Right . padZero 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 date AST#expression#Right . getDate 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#variable_declaration#Left const AST#variable_declarator#Left hours = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DateUtil AST#expression#Right . padZero 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 date 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#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left minutes = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DateUtil AST#expression#Right . padZero 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 date AST#expression#Right . getMinutes 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#variable_declaration#Left const AST#variable_declarator#Left seconds = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DateUtil AST#expression#Right . padZero 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 date AST#expression#Right . getSeconds 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#variable_declaration#Left let AST#variable_declarator#Left formattedDate = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left format AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "yyyy" AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left year 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#assignment_expression#Left formattedDate = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left formattedDate AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "MM" AST#expression#Right , AST#expression#Left month 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 formattedDate = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left formattedDate AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "dd" AST#expression#Right , AST#expression#Left day 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 formattedDate = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left formattedDate AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "HH" AST#expression#Right , AST#expression#Left hours 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 formattedDate = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left formattedDate AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "mm" AST#expression#Right , AST#expression#Left minutes 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 formattedDate = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left formattedDate AST#expression#Right . replace AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left "ss" AST#expression#Right , AST#expression#Left seconds AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left formattedDate AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static formatDate(value: string, format: string = 'yyyy-MM-dd'): string { const date = new Date(value); if (value.split(' ').length <= 1 && value.split('T').length <= 1) { date.setHours(0); date.setMinutes(0); date.setSeconds(0); } const year = date.getFullYear(); const month = DateUtil.padZero(date.getMonth() + 1); const day = DateUtil.padZero(date.getDate()); const hours = DateUtil.padZero(date.getHours()); const minutes = DateUtil.padZero(date.getMinutes()); const seconds = DateUtil.padZero(date.getSeconds()); let formattedDate = format.replace("yyyy", year.toString()); formattedDate = formattedDate.replace("MM", month); formattedDate = formattedDate.replace("dd", day); formattedDate = formattedDate.replace("HH", hours); formattedDate = formattedDate.replace("mm", minutes); formattedDate = formattedDate.replace("ss", seconds); return formattedDate; }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_core/src/main/ets/core/util/DateUtil.ets#L40-L60
e22e71cf90d4a178d1f45a1f996a40d4e7d94b85
gitee
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/common/components/Alarm/PermissionManager.ets
arkts
checkPermission
检查单个权限授权状态(异步方法) @param permission 要检查的权限名 @returns Promise对象,解析为是否已授权
static async checkPermission(permission: Permissions): Promise<boolean> { try { const tokenId = PermissionManager.getAccessTokenIdSync(); // 获取令牌ID const atMgr = PermissionManager.getAtManager(); // 获取管理器 // 检查权限状态(类似Swift的AVAuthorizationStatus) const status = await atMgr.checkAccessToken(tokenId, permission); return status === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED; // 返回授权状态 } catch (err) { console.error(`权限检查失败: ${(err as BusinessError).message}`); return false; } }
AST#method_declaration#Left static async checkPermission AST#parameter_list#Left ( AST#parameter#Left permission : AST#type_annotation#Left AST#primary_type#Left Permissions 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#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left tokenId = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left PermissionManager AST#expression#Right . getAccessTokenIdSync 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 // 获取令牌ID AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left atMgr = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left PermissionManager AST#expression#Right . getAtManager 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 // 获取管理器 // 检查权限状态(类似Swift的AVAuthorizationStatus) AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left status = 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 atMgr AST#expression#Right AST#await_expression#Right AST#expression#Right . checkAccessToken AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left tokenId AST#expression#Right , AST#expression#Left permission AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left status AST#expression#Right === AST#expression#Left abilityAccessCtrl AST#expression#Right AST#binary_expression#Right AST#expression#Right . GrantStatus AST#member_expression#Right AST#expression#Right . PERMISSION_GRANTED AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right // 返回授权状态 } AST#block_statement#Right AST#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` 权限检查失败: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left err AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static async checkPermission(permission: Permissions): Promise<boolean> { try { const tokenId = PermissionManager.getAccessTokenIdSync(); const atMgr = PermissionManager.getAtManager(); const status = await atMgr.checkAccessToken(tokenId, permission); return status === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED; } catch (err) { console.error(`权限检查失败: ${(err as BusinessError).message}`); return false; } }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/components/Alarm/PermissionManager.ets#L74-L85
267f5c0fe5a3ec9a496f8dc0ac987b8200126d19
github
openharmony/interface_sdk-js
c349adc73e2ec1f61f6fca489b5af059e3ed6999
api/@system.prompt.d.ets
arkts
Defines the option of ShowActionMenu. @interface ShowActionMenuOptions @syscap SystemCapability.ArkUI.ArkUI.Full @since 6 Defines the option of ShowActionMenu. @interface ShowActionMenuOptions @syscap SystemCapability.ArkUI.ArkUI.Full @atomicservice @since 11
export interface ShowActionMenuOptions { /** * Title of the text to display. * * @type { ?string } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 6 */ /** * Title of the text to display. * * @type { ?string } * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 11 */ title?: string; /** * Array of buttons in the dialog box. * The array structure is {text:'button', color: '#666666'}. * One to six buttons are supported. * * @type { [Button, Button | undefined, Button | undefined, Button | undefined, Button | undefined, Button | undefined] } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 6 */ /** * Array of buttons in the dialog box. * The array structure is {text:'button', color: '#666666'}. * One to six buttons are supported. * * @type { [Button, Button | undefined, Button | undefined, Button | undefined, Button | undefined, Button | undefined] } * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 11 */ buttons: [Button, Button | undefined, Button | undefined, Button | undefined, Button | undefined, Button | undefined]; /** * Called when the dialog box is displayed. * * @type { ?function } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 6 */ /** * Called when the dialog box is displayed. * * @type { ?function } * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 11 */ success?: (tapIndex: number, errMsg: string) => void; /** * Called when the operation is cancelled. * * @type { ?function } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 6 */ /** * Called when the operation is cancelled. * * @type { ?function } * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 11 */ fail?: (errMsg: string) => void; /** * Called when the dialog box is closed. * * @type { ?function } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 6 */ /** * Called when the dialog box is closed. * * @type { ?function } * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 11 */ complete?: () => void; }
AST#export_declaration#Left export AST#interface_declaration#Left interface ShowActionMenuOptions AST#object_type#Left { /** * Title of the text to display. * * @type { ?string } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 6 */ /** * Title of the text to display. * * @type { ?string } * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 11 */ AST#type_member#Left title ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * Array of buttons in the dialog box. * The array structure is {text:'button', color: '#666666'}. * One to six buttons are supported. * * @type { [Button, Button | undefined, Button | undefined, Button | undefined, Button | undefined, Button | undefined] } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 6 */ /** * Array of buttons in the dialog box. * The array structure is {text:'button', color: '#666666'}. * One to six buttons are supported. * * @type { [Button, Button | undefined, Button | undefined, Button | undefined, Button | undefined, Button | undefined] } * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 11 */ AST#type_member#Left buttons : AST#type_annotation#Left AST#primary_type#Left AST#tuple_type#Left [ AST#type_annotation#Left AST#primary_type#Left Button AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Button AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Button AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Button AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Button AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left Button AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right ] AST#tuple_type#Right AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * Called when the dialog box is displayed. * * @type { ?function } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 6 */ /** * Called when the dialog box is displayed. * * @type { ?function } * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 11 */ AST#type_member#Left success ? : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left tapIndex : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left errMsg : 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#function_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * Called when the operation is cancelled. * * @type { ?function } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 6 */ /** * Called when the operation is cancelled. * * @type { ?function } * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 11 */ AST#type_member#Left fail ? : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left errMsg : 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#function_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * Called when the dialog box is closed. * * @type { ?function } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 6 */ /** * Called when the dialog box is closed. * * @type { ?function } * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 11 */ AST#type_member#Left complete ? : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#type_member#Right ; } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
export interface ShowActionMenuOptions { title?: string; buttons: [Button, Button | undefined, Button | undefined, Button | undefined, Button | undefined, Button | undefined]; success?: (tapIndex: number, errMsg: string) => void; fail?: (errMsg: string) => void; complete?: () => void; }
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@system.prompt.d.ets#L287-L376
9e9ca4a5a08488ddf7d4c073697db9cb78c1cd99
gitee
Application-Security-Automation/Arktan.git
3ad9cb05235e38b00cd5828476aa59a345afa1c0
dataset/completeness/function_call/library_function/array_lib_func_001_T.ets
arkts
Introduction 库函数-array_toString
export function array_lib_func_001_T(taint_src : string) { let arr : string[] = [taint_src,"a","b"]; let t = arr.toString(); taint.Sink(t); }
AST#export_declaration#Left export AST#function_declaration#Left function array_lib_func_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 arr : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left taint_src AST#expression#Right , AST#expression#Left "a" AST#expression#Right , AST#expression#Left "b" 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 let AST#variable_declarator#Left t = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left arr 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#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 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 array_lib_func_001_T(taint_src : string) { let arr : string[] = [taint_src,"a","b"]; let t = arr.toString(); taint.Sink(t); }
https://github.com/Application-Security-Automation/Arktan.git/blob/3ad9cb05235e38b00cd5828476aa59a345afa1c0/dataset/completeness/function_call/library_function/array_lib_func_001_T.ets#L6-L10
3cc2110ba5aa0bda370b7c4682a2c475fe478b54
github
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
Media/ImageEdit/entry/src/main/ets/viewModel/ImageEditCrop.ets
arkts
couldReset
Current image whether can reset. @returns true means can reset, false means not.
couldReset(): boolean { let crop = this.cropShow.getCropRect(); MathUtils.roundOutRect(crop); let image = this.cropShow.getImageRect(); MathUtils.roundOutRect(image); if ( this.isFlipHorizontal !== false || this.isFlipVertically !== false || this.rotationAngle !== 0 || this.sliderAngle !== 0 || this.cropRatio !== CropRatioType.RATIO_TYPE_FREE || !MathUtils.areRectsSame(crop, image) ) { return true; } return false; }
AST#method_declaration#Left couldReset 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 let AST#variable_declarator#Left crop = 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 . cropShow AST#member_expression#Right AST#expression#Right . getCropRect 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 MathUtils AST#expression#Right . roundOutRect AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left crop 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 image = 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 . cropShow AST#member_expression#Right AST#expression#Right . getImageRect 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 MathUtils AST#expression#Right . roundOutRect AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left image AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isFlipHorizontal AST#member_expression#Right AST#expression#Right !== AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . isFlipVertically AST#member_expression#Right AST#expression#Right !== AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . rotationAngle AST#member_expression#Right AST#expression#Right !== AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . sliderAngle AST#member_expression#Right AST#expression#Right !== AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . cropRatio AST#member_expression#Right AST#expression#Right !== AST#expression#Left CropRatioType AST#expression#Right AST#binary_expression#Right AST#expression#Right . RATIO_TYPE_FREE AST#member_expression#Right AST#expression#Right || AST#expression#Left AST#unary_expression#Left ! AST#expression#Left MathUtils AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . areRectsSame AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left crop AST#expression#Right , AST#expression#Left image AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left 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
couldReset(): boolean { let crop = this.cropShow.getCropRect(); MathUtils.roundOutRect(crop); let image = this.cropShow.getImageRect(); MathUtils.roundOutRect(image); if ( this.isFlipHorizontal !== false || this.isFlipVertically !== false || this.rotationAngle !== 0 || this.sliderAngle !== 0 || this.cropRatio !== CropRatioType.RATIO_TYPE_FREE || !MathUtils.areRectsSame(crop, image) ) { return true; } return false; }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Media/ImageEdit/entry/src/main/ets/viewModel/ImageEditCrop.ets#L343-L358
49c1eb544e53364b589a32237633689589bb0878
gitee
salehelper/algorithm_arkts.git
61af15272038646775a4745fca98a48ba89e1f4e
entry/src/main/ets/ciphers/HillCipher.ets
arkts
modInverse
计算模26下的乘法逆元 @param a 要计算逆元的数 @returns 逆元,如果不存在则返回null
private static modInverse(a: number): number | null { a = ((a % HillCipher.MOD) + HillCipher.MOD) % HillCipher.MOD; for (let x = 1; x < HillCipher.MOD; x++) { if ((a * x) % HillCipher.MOD === 1) { return x; } } return null; }
AST#method_declaration#Left private static modInverse 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_list#Right : 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#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left a = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left a AST#expression#Right % AST#expression#Left HillCipher AST#expression#Right AST#binary_expression#Right AST#expression#Right . MOD AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right + AST#expression#Left HillCipher AST#expression#Right AST#binary_expression#Right AST#expression#Right . MOD AST#member_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right % AST#expression#Left HillCipher AST#expression#Right AST#binary_expression#Right AST#expression#Right . MOD 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#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left x = AST#expression#Left 1 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left x AST#expression#Right < AST#expression#Left HillCipher AST#expression#Right AST#binary_expression#Right AST#expression#Right . MOD AST#member_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left x AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left a AST#expression#Right * AST#expression#Left x AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right % AST#expression#Left HillCipher AST#expression#Right AST#binary_expression#Right AST#expression#Right . MOD AST#member_expression#Right AST#expression#Right === AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left x AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#for_statement#Right AST#statement#Right AST#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#method_declaration#Right
private static modInverse(a: number): number | null { a = ((a % HillCipher.MOD) + HillCipher.MOD) % HillCipher.MOD; for (let x = 1; x < HillCipher.MOD; x++) { if ((a * x) % HillCipher.MOD === 1) { return x; } } return null; }
https://github.com/salehelper/algorithm_arkts.git/blob/61af15272038646775a4745fca98a48ba89e1f4e/entry/src/main/ets/ciphers/HillCipher.ets#L23-L31
288f243c22968eb79bdbf56a26def2707244f402
github
openharmony/update_update_app
0157b7917e2f48e914b5585991e8b2f4bc25108a
common/src/main/ets/util/DeviceUtils.ets
arkts
获取系统语言 @return 系统语言
export function getSystemLanguage(): string { let language = i18n.getSystemLanguage(); if (language == 'zh-Hans') { language = 'zh-cn'; } else { language = 'en-us'; } return language; }
AST#export_declaration#Left export AST#function_declaration#Left function getSystemLanguage AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left language = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left i18n AST#expression#Right . getSystemLanguage 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#binary_expression#Left AST#expression#Left language AST#expression#Right == AST#expression#Left 'zh-Hans' 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 language = AST#expression#Left 'zh-cn' AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left language = AST#expression#Left 'en-us' 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 language AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export function getSystemLanguage(): string { let language = i18n.getSystemLanguage(); if (language == 'zh-Hans') { language = 'zh-cn'; } else { language = 'en-us'; } return language; }
https://github.com/openharmony/update_update_app/blob/0157b7917e2f48e914b5585991e8b2f4bc25108a/common/src/main/ets/util/DeviceUtils.ets#L48-L56
5c1335d54f06580f5bb5a0b620f6ba803c53c1ea
gitee
awa_Liny/LinysBrowser_NEXT
a5cd96a9aa8114cae4972937f94a8967e55d4a10
home/src/main/ets/hosts/bunch_of_history_index.ets
arkts
search_history_label_link
Searches in the index_map and return eligible history of label-links @param key the keywords, for example "huawei developers harmony" @returns string[][] of label-links
static search_history_label_link(key: string, max?: number) { let history_index_saving = AppStorage.get('history_index_saving') as boolean | undefined; let history_index_loading = AppStorage.get('history_index_loading') as boolean | undefined; let reindexing = AppStorage.get('reindexing_history') as boolean | undefined; if (history_index_saving == true) { console.log(bunch_of_history_index.log_head() + " A history_index_saving task is ongoing! Interrupted this search_history_label_link."); return []; } if (history_index_loading == true) { console.log(bunch_of_history_index.log_head() + " A history_index_loading task is ongoing! Interrupted this search_history_label_link."); return []; } if (reindexing == true) { console.log(bunch_of_history_index.log_head() + " A reindexing task is ongoing! Interrupted this search_history_label_link."); return []; } // TODO: find a more elegant way instead of reverse(). let stamps = bunch_of_history_index.search_timestamps(key, max); stamps.reverse(); let result = get_histories_from_disk(stamps, max); result.reverse(); return result; }
AST#method_declaration#Left static search_history_label_link 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 max ? : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left history_index_saving = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'history_index_saving' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left boolean AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left history_index_loading = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'history_index_loading' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left boolean AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left reindexing = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppStorage AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'reindexing_history' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left boolean AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left history_index_saving AST#expression#Right == AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { 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#member_expression#Left AST#expression#Left bunch_of_history_index AST#expression#Right . log_head 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 " A history_index_saving task is ongoing! Interrupted this search_history_label_link." AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left history_index_loading AST#expression#Right == AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { 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#member_expression#Left AST#expression#Left bunch_of_history_index AST#expression#Right . log_head 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 " A history_index_loading task is ongoing! Interrupted this search_history_label_link." AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left reindexing AST#expression#Right == AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { 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#member_expression#Left AST#expression#Left bunch_of_history_index AST#expression#Right . log_head 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 " A reindexing task is ongoing! Interrupted this search_history_label_link." AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // TODO: find a more elegant way instead of reverse(). AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left stamps = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left bunch_of_history_index AST#expression#Right . search_timestamps AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right , AST#expression#Left max 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 stamps AST#expression#Right . reverse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left result = AST#expression#Left AST#call_expression#Left AST#expression#Left get_histories_from_disk AST#expression#Right AST#argument_list#Left ( AST#expression#Left stamps AST#expression#Right , AST#expression#Left max 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 result AST#expression#Right . reverse 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 result AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static search_history_label_link(key: string, max?: number) { let history_index_saving = AppStorage.get('history_index_saving') as boolean | undefined; let history_index_loading = AppStorage.get('history_index_loading') as boolean | undefined; let reindexing = AppStorage.get('reindexing_history') as boolean | undefined; if (history_index_saving == true) { console.log(bunch_of_history_index.log_head() + " A history_index_saving task is ongoing! Interrupted this search_history_label_link."); return []; } if (history_index_loading == true) { console.log(bunch_of_history_index.log_head() + " A history_index_loading task is ongoing! Interrupted this search_history_label_link."); return []; } if (reindexing == true) { console.log(bunch_of_history_index.log_head() + " A reindexing task is ongoing! Interrupted this search_history_label_link."); return []; } let stamps = bunch_of_history_index.search_timestamps(key, max); stamps.reverse(); let result = get_histories_from_disk(stamps, max); result.reverse(); return result; }
https://github.com/awa_Liny/LinysBrowser_NEXT/blob/a5cd96a9aa8114cae4972937f94a8967e55d4a10/home/src/main/ets/hosts/bunch_of_history_index.ets#L33-L57
d161a5af6b42a89d2c8596f2e3944e26182d42b0
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/calendarswitch/src/main/ets/customcalendar/constant/Constants.ets
arkts
常量
export default class Constants { // 月份数组 public static readonly MONTHS: string[] = ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"]; // 星期 public static readonly WEEKS: string[] = ["日", "一", "二", "三", "四", "五", "六"]; // 农历月份的中文表示 public static readonly CHINESE_MONTH: string[] = ['正', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '腊']; // 农历日期的中文表示 public static readonly CHINESE_DAY: string[] = ['初一', '初二', '初三', '初四', '初五', '初六', '初七', '初八', '初九', '初十', '十一', '十二', '十三', '十四', '十五', '十六', '十七', '十八', '十九', '二十', '廿一', '廿二', '廿三', '廿四', '廿五', '廿六', '廿七', '廿八', '廿九', '三十']; // 一天的总毫秒数。1000 * 60 * 60 * 24 public static readonly TOTAL_MILLISECONDS_IN_DAY: number = 86400000; // 一周的天数 public static readonly DAYS_IN_WEEK: number = 7; // 公历字体大小 public static readonly DAY_FONT_SIZE: number = 16; // 农历字体大小 public static readonly LUNAR_DAY_FONT_SIZE: number = 10; // 星期字体大小 public static readonly WEEK_FONT_SIZE: number = 10; // 年月信息字体大小 public static readonly YEAR_MONTH_FONT_SIZE: number = 18; // 字体倍数 public static readonly FONT_MULTIPLIER: number = 1; // 选中日期边框宽度 public static readonly SELECT_DATE_BORDER_WIDTH: number = 1; // 默认值 public static readonly DEFAULT: number = 0; // 一年12个月 public static readonly MONTHS_NUM: number = 12; // 字体粗细设置 public static readonly FONT_WEIGHT_FIVE_HUNDRED: number = 500; public static readonly FONT_WEIGHT_EIGHT_HUNDRED: number = 800; // 年视图月份字体大小,粗细 public static readonly YEAR_VIEW_MONTH_FONT: string = '60px 500'; // 年视图星期字体大小 public static readonly YEAR_VIEW_WEEK_FONT: string = '35px'; // 年视图日期字体大小,粗细 public static readonly YEAR_VIEW_DAY_FONT: string = '30px 400'; // 年视图下滑线 public static readonly YEAR_VIEW_UNDERLINE: string = '80px'; // 年视图字体颜色灰色 public static readonly YEAR_VIEW_FONT_COLOR: string = '#7e7e7e'; // 年视图月份高度 public static readonly YEAR_VIEW_MONTH_HEIGHT: number = 20; // 年视图星期,日期水平绘制偏移量 public static readonly YEAR_VIEW_HORIZONTAL_OFFSET: number = 15; // 年视图日期垂直绘制偏移量 public static readonly YEAR_VIEW_VERTICAL_OFFSET: number = 18; // 年视图星期初始高度 public static readonly YEAR_VIEW_WEEK_HEIGHT: number = 40; // 年视图日期初始垂直绘制高度 public static readonly YEAR_VIEW_DAY_HEIGHT: number = 58; // 年视图今天日期的圆半径 public static readonly YEAR_VIEW_TODAY_RADIUS: number = 6; // 年视图今天日期的圆的弧线的终止弧度 public static readonly YEAR_VIEW_TODAY_END_ANGLE: number = 6.28; // 年视图月数据的x轴初始值 public static readonly YEAR_VIEW_INIT_THREE: number = 3; // 今天日期 public static readonly TODAY: number = new Date().getDate(); // 本月 public static readonly TODAY_MONTH: number = new Date().getMonth() + 1; // 本年 public static readonly TODAY_YEAR: number = new Date().getFullYear(); // 年视图宽度 public static readonly YEAR_VIEW_WIDTH: number | string = '100%'; // 年视图高度 public static readonly YEAR_VIEW_HEIGHT: number | string = 600; // 月视图宽度 public static readonly MONTH_VIEW_WIDTH: number | string = '100%'; // 月视图高度 public static readonly MONTH_VIEW_HEIGHT: number | string = 400; // 周视图宽度 public static readonly WEEK_VIEW_WIDTH: number | string = '100%'; // 周视图高度 public static readonly WEEK_VIEW_HEIGHT: number | string = 120; // 日程点直径 public static readonly SCHEDULE_POINT_DIAMETER: number = 5; // 日程提醒时间选项 public static readonly REMINDER_TIME_OPTION: string[] = ['准时', '1分钟前', '5分钟前', '30分钟前', '1小时前']; }
AST#export_declaration#Left export default AST#class_declaration#Left class Constants AST#class_body#Left { // 月份数组 AST#property_declaration#Left public static readonly MONTHS : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left "1月" AST#expression#Right , AST#expression#Left "2月" AST#expression#Right , AST#expression#Left "3月" AST#expression#Right , AST#expression#Left "4月" AST#expression#Right , AST#expression#Left "5月" AST#expression#Right , AST#expression#Left "6月" AST#expression#Right , AST#expression#Left "7月" AST#expression#Right , AST#expression#Left "8月" AST#expression#Right , AST#expression#Left "9月" AST#expression#Right , AST#expression#Left "10月" AST#expression#Right , AST#expression#Left "11月" AST#expression#Right , AST#expression#Left "12月" AST#expression#Right ] AST#array_literal#Right AST#expression#Right ; AST#property_declaration#Right // 星期 AST#property_declaration#Left public static readonly WEEKS : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left "日" AST#expression#Right , AST#expression#Left "一" AST#expression#Right , AST#expression#Left "二" AST#expression#Right , AST#expression#Left "三" AST#expression#Right , AST#expression#Left "四" AST#expression#Right , AST#expression#Left "五" AST#expression#Right , AST#expression#Left "六" AST#expression#Right ] AST#array_literal#Right AST#expression#Right ; AST#property_declaration#Right // 农历月份的中文表示 AST#property_declaration#Left public static readonly CHINESE_MONTH : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left '正' AST#expression#Right , AST#expression#Left '二' AST#expression#Right , AST#expression#Left '三' AST#expression#Right , AST#expression#Left '四' AST#expression#Right , AST#expression#Left '五' AST#expression#Right , AST#expression#Left '六' AST#expression#Right , AST#expression#Left '七' AST#expression#Right , AST#expression#Left '八' AST#expression#Right , AST#expression#Left '九' AST#expression#Right , AST#expression#Left '十' AST#expression#Right , AST#expression#Left '十一' AST#expression#Right , AST#expression#Left '腊' AST#expression#Right ] AST#array_literal#Right AST#expression#Right ; AST#property_declaration#Right // 农历日期的中文表示 AST#property_declaration#Left public static readonly CHINESE_DAY : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left '初一' AST#expression#Right , AST#expression#Left '初二' AST#expression#Right , AST#expression#Left '初三' AST#expression#Right , AST#expression#Left '初四' AST#expression#Right , AST#expression#Left '初五' AST#expression#Right , AST#expression#Left '初六' AST#expression#Right , AST#expression#Left '初七' AST#expression#Right , AST#expression#Left '初八' AST#expression#Right , AST#expression#Left '初九' AST#expression#Right , AST#expression#Left '初十' AST#expression#Right , AST#expression#Left '十一' AST#expression#Right , AST#expression#Left '十二' AST#expression#Right , AST#expression#Left '十三' AST#expression#Right , AST#expression#Left '十四' AST#expression#Right , AST#expression#Left '十五' AST#expression#Right , AST#expression#Left '十六' AST#expression#Right , AST#expression#Left '十七' AST#expression#Right , AST#expression#Left '十八' AST#expression#Right , AST#expression#Left '十九' AST#expression#Right , AST#expression#Left '二十' AST#expression#Right , AST#expression#Left '廿一' AST#expression#Right , AST#expression#Left '廿二' AST#expression#Right , AST#expression#Left '廿三' AST#expression#Right , AST#expression#Left '廿四' AST#expression#Right , AST#expression#Left '廿五' AST#expression#Right , AST#expression#Left '廿六' AST#expression#Right , AST#expression#Left '廿七' AST#expression#Right , AST#expression#Left '廿八' AST#expression#Right , AST#expression#Left '廿九' AST#expression#Right , AST#expression#Left '三十' AST#expression#Right ] AST#array_literal#Right AST#expression#Right ; AST#property_declaration#Right // 一天的总毫秒数。1000 * 60 * 60 * 24 AST#property_declaration#Left public static readonly TOTAL_MILLISECONDS_IN_DAY : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 86400000 AST#expression#Right ; AST#property_declaration#Right // 一周的天数 AST#property_declaration#Left public static readonly DAYS_IN_WEEK : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 7 AST#expression#Right ; AST#property_declaration#Right // 公历字体大小 AST#property_declaration#Left public static readonly DAY_FONT_SIZE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 16 AST#expression#Right ; AST#property_declaration#Right // 农历字体大小 AST#property_declaration#Left public static readonly LUNAR_DAY_FONT_SIZE : 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 public static readonly WEEK_FONT_SIZE : 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 public static readonly YEAR_MONTH_FONT_SIZE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 18 AST#expression#Right ; AST#property_declaration#Right // 字体倍数 AST#property_declaration#Left public static readonly FONT_MULTIPLIER : 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 public static readonly SELECT_DATE_BORDER_WIDTH : 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 public static readonly DEFAULT : 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 // 一年12个月 AST#property_declaration#Left public static readonly MONTHS_NUM : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 12 AST#expression#Right ; AST#property_declaration#Right // 字体粗细设置 AST#property_declaration#Left public static readonly FONT_WEIGHT_FIVE_HUNDRED : 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 public static readonly FONT_WEIGHT_EIGHT_HUNDRED : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 800 AST#expression#Right ; AST#property_declaration#Right // 年视图月份字体大小,粗细 AST#property_declaration#Left public static readonly YEAR_VIEW_MONTH_FONT : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '60px 500' AST#expression#Right ; AST#property_declaration#Right // 年视图星期字体大小 AST#property_declaration#Left public static readonly YEAR_VIEW_WEEK_FONT : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '35px' AST#expression#Right ; AST#property_declaration#Right // 年视图日期字体大小,粗细 AST#property_declaration#Left public static readonly YEAR_VIEW_DAY_FONT : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '30px 400' AST#expression#Right ; AST#property_declaration#Right // 年视图下滑线 AST#property_declaration#Left public static readonly YEAR_VIEW_UNDERLINE : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '80px' AST#expression#Right ; AST#property_declaration#Right // 年视图字体颜色灰色 AST#property_declaration#Left public static readonly YEAR_VIEW_FONT_COLOR : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '#7e7e7e' AST#expression#Right ; AST#property_declaration#Right // 年视图月份高度 AST#property_declaration#Left public static readonly YEAR_VIEW_MONTH_HEIGHT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 20 AST#expression#Right ; AST#property_declaration#Right // 年视图星期,日期水平绘制偏移量 AST#property_declaration#Left public static readonly YEAR_VIEW_HORIZONTAL_OFFSET : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 15 AST#expression#Right ; AST#property_declaration#Right // 年视图日期垂直绘制偏移量 AST#property_declaration#Left public static readonly YEAR_VIEW_VERTICAL_OFFSET : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 18 AST#expression#Right ; AST#property_declaration#Right // 年视图星期初始高度 AST#property_declaration#Left public static readonly YEAR_VIEW_WEEK_HEIGHT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 40 AST#expression#Right ; AST#property_declaration#Right // 年视图日期初始垂直绘制高度 AST#property_declaration#Left public static readonly YEAR_VIEW_DAY_HEIGHT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 58 AST#expression#Right ; AST#property_declaration#Right // 年视图今天日期的圆半径 AST#property_declaration#Left public static readonly YEAR_VIEW_TODAY_RADIUS : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 6 AST#expression#Right ; AST#property_declaration#Right // 年视图今天日期的圆的弧线的终止弧度 AST#property_declaration#Left public static readonly YEAR_VIEW_TODAY_END_ANGLE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 6.28 AST#expression#Right ; AST#property_declaration#Right // 年视图月数据的x轴初始值 AST#property_declaration#Left public static readonly YEAR_VIEW_INIT_THREE : 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 public static readonly TODAY : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#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 . getDate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right // 本月 AST#property_declaration#Left public static readonly TODAY_MONTH : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 . getMonth AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#property_declaration#Right // 本年 AST#property_declaration#Left public static readonly TODAY_YEAR : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . getFullYear AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right // 年视图宽度 AST#property_declaration#Left public static readonly YEAR_VIEW_WIDTH : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left number AST#primary_type#Right | AST#primary_type#Left string AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left '100%' AST#expression#Right ; AST#property_declaration#Right // 年视图高度 AST#property_declaration#Left public static readonly YEAR_VIEW_HEIGHT : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left number AST#primary_type#Right | AST#primary_type#Left string AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left 600 AST#expression#Right ; AST#property_declaration#Right // 月视图宽度 AST#property_declaration#Left public static readonly MONTH_VIEW_WIDTH : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left number AST#primary_type#Right | AST#primary_type#Left string AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left '100%' AST#expression#Right ; AST#property_declaration#Right // 月视图高度 AST#property_declaration#Left public static readonly MONTH_VIEW_HEIGHT : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left number AST#primary_type#Right | AST#primary_type#Left string AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left 400 AST#expression#Right ; AST#property_declaration#Right // 周视图宽度 AST#property_declaration#Left public static readonly WEEK_VIEW_WIDTH : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left number AST#primary_type#Right | AST#primary_type#Left string AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left '100%' AST#expression#Right ; AST#property_declaration#Right // 周视图高度 AST#property_declaration#Left public static readonly WEEK_VIEW_HEIGHT : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left number AST#primary_type#Right | AST#primary_type#Left string AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left 120 AST#expression#Right ; AST#property_declaration#Right // 日程点直径 AST#property_declaration#Left public static readonly SCHEDULE_POINT_DIAMETER : 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 public static readonly REMINDER_TIME_OPTION : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ AST#expression#Left '准时' AST#expression#Right , AST#expression#Left '1分钟前' AST#expression#Right , AST#expression#Left '5分钟前' AST#expression#Right , AST#expression#Left '30分钟前' AST#expression#Right , AST#expression#Left '1小时前' AST#expression#Right ] AST#array_literal#Right AST#expression#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export default class Constants { public static readonly MONTHS: string[] = ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"]; public static readonly WEEKS: string[] = ["日", "一", "二", "三", "四", "五", "六"]; public static readonly CHINESE_MONTH: string[] = ['正', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '腊']; public static readonly CHINESE_DAY: string[] = ['初一', '初二', '初三', '初四', '初五', '初六', '初七', '初八', '初九', '初十', '十一', '十二', '十三', '十四', '十五', '十六', '十七', '十八', '十九', '二十', '廿一', '廿二', '廿三', '廿四', '廿五', '廿六', '廿七', '廿八', '廿九', '三十']; public static readonly TOTAL_MILLISECONDS_IN_DAY: number = 86400000; public static readonly DAYS_IN_WEEK: number = 7; public static readonly DAY_FONT_SIZE: number = 16; public static readonly LUNAR_DAY_FONT_SIZE: number = 10; 字体大小 public static readonly WEEK_FONT_SIZE: number = 10; public static readonly YEAR_MONTH_FONT_SIZE: number = 18; public static readonly FONT_MULTIPLIER: number = 1; public static readonly SELECT_DATE_BORDER_WIDTH: number = 1; public static readonly DEFAULT: number = 0; public static readonly MONTHS_NUM: number = 12; public static readonly FONT_WEIGHT_FIVE_HUNDRED: number = 500; public static readonly FONT_WEIGHT_EIGHT_HUNDRED: number = 800; public static readonly YEAR_VIEW_MONTH_FONT: string = '60px 500'; public static readonly YEAR_VIEW_WEEK_FONT: string = '35px'; public static readonly YEAR_VIEW_DAY_FONT: string = '30px 400'; public static readonly YEAR_VIEW_UNDERLINE: string = '80px'; public static readonly YEAR_VIEW_FONT_COLOR: string = '#7e7e7e'; public static readonly YEAR_VIEW_MONTH_HEIGHT: number = 20; public static readonly YEAR_VIEW_HORIZONTAL_OFFSET: number = 15; public static readonly YEAR_VIEW_VERTICAL_OFFSET: number = 18; public static readonly YEAR_VIEW_WEEK_HEIGHT: number = 40; public static readonly YEAR_VIEW_DAY_HEIGHT: number = 58; public static readonly YEAR_VIEW_TODAY_RADIUS: number = 6; public static readonly YEAR_VIEW_TODAY_END_ANGLE: number = 6.28; public static readonly YEAR_VIEW_INIT_THREE: number = 3; public static readonly TODAY: number = new Date().getDate(); public static readonly TODAY_MONTH: number = new Date().getMonth() + 1; public static readonly TODAY_YEAR: number = new Date().getFullYear(); public static readonly YEAR_VIEW_WIDTH: number | string = '100%'; public static readonly YEAR_VIEW_HEIGHT: number | string = 600; public static readonly MONTH_VIEW_WIDTH: number | string = '100%'; public static readonly MONTH_VIEW_HEIGHT: number | string = 400; public static readonly WEEK_VIEW_WIDTH: number | string = '100%'; public static readonly WEEK_VIEW_HEIGHT: number | string = 120; public static readonly SCHEDULE_POINT_DIAMETER: number = 5; public static readonly REMINDER_TIME_OPTION: string[] = ['准时', '1分钟前', '5分钟前', '30分钟前', '1小时前']; }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/calendarswitch/src/main/ets/customcalendar/constant/Constants.ets#L19-L104
27d917b1da48c0ee01a67f7fdc7f696086780549
gitee
openharmony/graphic_graphic_2d
46a11e91c9709942196ad2a7afea2e0fcd1349f3
frameworks/text/interface/export/ani/@ohos.graphics.text.ets
arkts
Describes rect style of text. @typedef RectStyle @syscap SystemCapability.Graphics.Drawing @since 12
export interface RectStyle { /** * The color of rect style. * @type { common2D.Color } The color of rect style * @syscap SystemCapability.Graphics.Drawing * @since 12 */ color: common2D.Color; /** * Radius in left top of rect style. * @type { number } it is double type data * @syscap SystemCapability.Graphics.Drawing * @since 12 */ leftTopRadius: number; /** * Radius in right top of rect style. * @type { number } it is double type data * @syscap SystemCapability.Graphics.Drawing * @since 12 */ rightTopRadius: number; /** * Radius in right bottom of rect style. * @type { number } it is double type data * @syscap SystemCapability.Graphics.Drawing * @since 12 */ rightBottomRadius: number; /** * Radius in left bottom of rect style. * @type { number } it is double type data * @syscap SystemCapability.Graphics.Drawing * @since 12 */ leftBottomRadius: number; }
AST#export_declaration#Left export AST#interface_declaration#Left interface RectStyle AST#object_type#Left { /** * The color of rect style. * @type { common2D.Color } The color of rect style * @syscap SystemCapability.Graphics.Drawing * @since 12 */ AST#type_member#Left color : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common2D . Color AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * Radius in left top of rect style. * @type { number } it is double type data * @syscap SystemCapability.Graphics.Drawing * @since 12 */ AST#type_member#Left leftTopRadius : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * Radius in right top of rect style. * @type { number } it is double type data * @syscap SystemCapability.Graphics.Drawing * @since 12 */ AST#type_member#Left rightTopRadius : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * Radius in right bottom of rect style. * @type { number } it is double type data * @syscap SystemCapability.Graphics.Drawing * @since 12 */ AST#type_member#Left rightBottomRadius : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; /** * Radius in left bottom of rect style. * @type { number } it is double type data * @syscap SystemCapability.Graphics.Drawing * @since 12 */ AST#type_member#Left leftBottomRadius : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
export interface RectStyle { color: common2D.Color; leftTopRadius: number; rightTopRadius: number; rightBottomRadius: number; leftBottomRadius: number; }
https://github.com/openharmony/graphic_graphic_2d/blob/46a11e91c9709942196ad2a7afea2e0fcd1349f3/frameworks/text/interface/export/ani/@ohos.graphics.text.ets#L1389-L1429
ab2daba16eb453a905b171351f7e55a3e3d56e2f
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/properties/componentIDSample/ComponentIDSample.ets
arkts
getComponentRect
获取组件所占矩形区域坐标
static getComponentRect(key: string) { let strJson = getInspectorByKey(key); let obj: Record<string, Object> = JSON.parse(strJson); let rectInfo: Array<string> = JSON.parse('[' + obj.$rect + ']'); Utils.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0]; Utils.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1]; Utils.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0]; Utils.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1]; return Utils.rect_value = { left: Utils.rect_left, top: Utils.rect_top, right: Utils.rect_right, bottom: Utils.rect_bottom } }
AST#method_declaration#Left static getComponentRect AST#parameter_list#Left ( AST#parameter#Left key : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left strJson = AST#expression#Left AST#call_expression#Left AST#expression#Left getInspectorByKey AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left obj : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Record AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . parse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left strJson 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 rectInfo : 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#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#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left '[' AST#expression#Right + AST#expression#Left obj AST#expression#Right AST#binary_expression#Right AST#expression#Right . $rect 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#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 Utils AST#expression#Right . rect_left AST#member_expression#Right = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . parse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left '[' AST#expression#Right + AST#expression#Left AST#subscript_expression#Left AST#expression#Left rectInfo AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#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#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left Utils AST#expression#Right . rect_top AST#member_expression#Right = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . parse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left '[' AST#expression#Right + AST#expression#Left AST#subscript_expression#Left AST#expression#Left rectInfo AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#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#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left Utils AST#expression#Right . rect_right AST#member_expression#Right = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . parse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left '[' AST#expression#Right + AST#expression#Left AST#subscript_expression#Left AST#expression#Left rectInfo AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#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#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left Utils AST#expression#Right . rect_bottom AST#member_expression#Right = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . parse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left '[' AST#expression#Right + AST#expression#Left AST#subscript_expression#Left AST#expression#Left rectInfo AST#expression#Right [ AST#expression#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#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#Left 1 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left Utils AST#expression#Right . rect_value AST#member_expression#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Utils AST#expression#Right . rect_left AST#member_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#member_expression#Left AST#expression#Left Utils AST#expression#Right . rect_top AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Utils AST#expression#Right . rect_right AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left Utils AST#expression#Right . rect_bottom 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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static getComponentRect(key: string) { let strJson = getInspectorByKey(key); let obj: Record<string, Object> = JSON.parse(strJson); let rectInfo: Array<string> = JSON.parse('[' + obj.$rect + ']'); Utils.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0]; Utils.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1]; Utils.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0]; Utils.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1]; return Utils.rect_value = { left: Utils.rect_left, top: Utils.rect_top, right: Utils.rect_right, bottom: Utils.rect_bottom } }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/UI/ArkTsComponentCollection/ComponentCollection/entry/src/main/ets/pages/universal/properties/componentIDSample/ComponentIDSample.ets#L42-L53
4108ec6c51e8a003a8549cc1ac04464693ab635b
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/videocreategif/src/main/ets/components/SelectGifTimeFrameView.ets
arkts
setStateChangeCallback
设置播放状态机AVPlayerState切换的事件 @returns
async setStateChangeCallback(): Promise<void> { if (this.avPlayer) { this.avPlayer?.on('stateChange', async (state, reason) => { switch (state) { case 'idle': logger.info('state idle called'); break; case 'initialized': logger.info('state initialized called'); this.avPlayer!.surfaceId = this.surfaceId; this.avPlayer!.prepare(); break; case 'prepared': this.videoPrepared();
AST#method_declaration#Left async setStateChangeCallback AST#parameter_list#Left ( ) AST#parameter_list#Right AST#ERROR#Left : 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 { if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . avPlayer 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 . avPlayer AST#member_expression#Right AST#expression#Right ?. on AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'stateChange' AST#expression#Right , AST#ERROR#Left async AST#parameter_list#Left ( AST#parameter#Left state AST#parameter#Right , AST#parameter#Left reason AST#parameter#Right ) AST#parameter_list#Right AST#ERROR#Left => { AST#ERROR#Left AST#property_name#Left switch AST#property_name#Right AST#parameter_list#Left ( AST#parameter#Left state AST#parameter#Right ) AST#parameter_list#Right AST#ERROR#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left 'idle' AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Right : AST#qualified_type#Left logger . info AST#qualified_type#Right ( 'state idle called' ) ; AST#ERROR#Right AST#statement#Left AST#break_statement#Left break ; AST#break_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left 'initialized' AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Right : AST#qualified_type#Left logger . info AST#qualified_type#Right ( AST#ERROR#Right AST#expression#Left 'state initialized called' 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#non_null_assertion_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . avPlayer AST#member_expression#Right AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right . surfaceId AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . surfaceId AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#non_null_assertion_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . avPlayer AST#member_expression#Right AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right . prepare AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left break AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left 'prepared' AST#expression#Right AST#expression_statement#Right : AST#ERROR#Left AST#qualified_type#Left this . videoPrepared AST#qualified_type#Right AST#ERROR#Right AST#parameter_list#Left ( ) AST#parameter_list#Right AST#ERROR#Right ; AST#method_declaration#Right
async setStateChangeCallback(): Promise<void> { if (this.avPlayer) { this.avPlayer?.on('stateChange', async (state, reason) => { switch (state) { case 'idle': logger.info('state idle called'); break; case 'initialized': logger.info('state initialized called'); this.avPlayer!.surfaceId = this.surfaceId; this.avPlayer!.prepare(); break; case 'prepared': this.videoPrepared();
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/videocreategif/src/main/ets/components/SelectGifTimeFrameView.ets#L143-L158
9a2bf75ca5bad6e2b8aea7c99270808f760d93c6
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
entry/src/main/ets/pages/index/DialogPage.ets
arkts
customConfig2
统一配置二
customConfig2() { DialogHelper.setDefaultConfig((config) => { config.autoCancel = false; //点击遮障层时,是否关闭弹窗,true表示关闭弹窗。 config.backCancel = false; //点击返回键或手势返回时,是否关闭弹窗;实现onWillDismiss函数时,该参数不起作用。 config.actionCancel = true; //点击操作按钮时,是否关闭弹窗。false表示不关闭弹窗。 config.alignment = DialogAlignment.Bottom; //弹窗的对齐方式。 config.offset = { dx: 0, dy: -35 }; //弹窗相对alignment所在位置的偏移量。 config.maskColor = 0x11000000; //自定义蒙层颜色。默认值 0x33000000 config.backgroundColor = Color.White; //弹窗背板颜色。默认值:Color.White config.backgroundBlurStyle = BlurStyle.COMPONENT_ULTRA_THICK; //弹窗背板模糊材质 config.cornerRadius = 20; //设置背板的圆角半径。可分别设置4个圆角的半径。 config.title = '提示'; //弹框标题 config.primaryButton = '取消'; //弹框左侧按钮。 config.secondaryButton = '确定'; //弹框右侧按钮。 config.imageRes = undefined; //TipsDialog用到,展示的图片。 config.imageSize = { width: '64vp', height: '64vp' }; //TipsDialog用到,自定义图片尺寸。 config.loading_loadSize = 60; //加载动画或进度条的大小 config.loading_loadColor = Color.White; //加载动画或进度条的颜色 config.loading_content = ''; //加载动画的提示文字 config.loading_fontSize = 16; //文字大小 config.loading_fontColor = Color.White; //文字颜色 config.loading_backgroundColor = '#CC56D866'; //背景颜色,八位色值前两位为透明度 config.loading_borderRadius = 10; //背景圆角 config.toast_fontSize = 16; //文字大小 config.toast_fontColor = Color.Black; //文字颜色 config.toast_backgroundColor = '#CC0FCEE3'; //背景颜色,建议八位色值前两位为透明度 config.toast_alignment = Alignment.Top; //土司Top显示 config.toast_borderRadius = 8; //背景圆角 config.toast_padding = { left: 16, right: 16, top: 12, bottom: 12 }; //Padding config.toast_imageSize = { width: 45, height: 45 }; //Tip图片尺寸。默认值:45*45vp config.toast_duration = 1500; //显示时长(1500ms-10000ms) config.toast_durationLong = 5000; //显示时长 }); ToastUtil.showToast("统二配置设置成功!"); }
AST#method_declaration#Left customConfig2 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 DialogHelper AST#expression#Right . setDefaultConfig 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 config 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 config AST#expression#Right . autoCancel 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 //点击遮障层时,是否关闭弹窗,true表示关闭弹窗。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . backCancel 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 //点击返回键或手势返回时,是否关闭弹窗;实现onWillDismiss函数时,该参数不起作用。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . actionCancel 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 //点击操作按钮时,是否关闭弹窗。false表示不关闭弹窗。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . alignment AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left DialogAlignment AST#expression#Right . Bottom 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 config AST#expression#Right . offset AST#member_expression#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left dx AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left dy AST#property_name#Right : AST#expression#Left AST#unary_expression#Left - AST#expression#Left 35 AST#expression#Right AST#unary_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 //弹窗相对alignment所在位置的偏移量。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . maskColor AST#member_expression#Right = AST#expression#Left 0x11000000 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right //自定义蒙层颜色。默认值 0x33000000 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . backgroundColor AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . White AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right //弹窗背板颜色。默认值:Color.White AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . backgroundBlurStyle AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left BlurStyle AST#expression#Right . COMPONENT_ULTRA_THICK AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right //弹窗背板模糊材质 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . cornerRadius AST#member_expression#Right = AST#expression#Left 20 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right //设置背板的圆角半径。可分别设置4个圆角的半径。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . title AST#member_expression#Right = AST#expression#Left '提示' AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right //弹框标题 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . primaryButton AST#member_expression#Right = AST#expression#Left '取消' AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right //弹框左侧按钮。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . secondaryButton AST#member_expression#Right = AST#expression#Left '确定' AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right //弹框右侧按钮。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . imageRes AST#member_expression#Right = AST#expression#Left undefined AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right //TipsDialog用到,展示的图片。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . imageSize AST#member_expression#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left '64vp' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left height AST#property_name#Right : AST#expression#Left '64vp' 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 //TipsDialog用到,自定义图片尺寸。 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . loading_loadSize AST#member_expression#Right = AST#expression#Left 60 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 config AST#expression#Right . loading_loadColor AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . White AST#member_expression#Right AST#expression#Right AST#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 config AST#expression#Right . loading_content AST#member_expression#Right = AST#expression#Left '' AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right //加载动画的提示文字 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . loading_fontSize AST#member_expression#Right = AST#expression#Left 16 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 config AST#expression#Right . loading_fontColor AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . White AST#member_expression#Right AST#expression#Right AST#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 config AST#expression#Right . loading_backgroundColor AST#member_expression#Right = AST#expression#Left '#CC56D866' 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 config AST#expression#Right . loading_borderRadius AST#member_expression#Right = AST#expression#Left 10 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 config AST#expression#Right . toast_fontSize AST#member_expression#Right = AST#expression#Left 16 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 config AST#expression#Right . toast_fontColor AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Black 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 config AST#expression#Right . toast_backgroundColor AST#member_expression#Right = AST#expression#Left '#CC0FCEE3' 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 config AST#expression#Right . toast_alignment AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left Alignment AST#expression#Right . Top AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right //土司Top显示 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . toast_borderRadius AST#member_expression#Right = AST#expression#Left 8 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 config AST#expression#Right . toast_padding AST#member_expression#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 12 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right //Padding AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . toast_imageSize AST#member_expression#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left 45 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left height AST#property_name#Right : AST#expression#Left 45 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 //Tip图片尺寸。默认值:45*45vp AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . toast_duration AST#member_expression#Right = AST#expression#Left 1500 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right //显示时长(1500ms-10000ms) AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . toast_durationLong AST#member_expression#Right = AST#expression#Left 5000 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right //显示时长 } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ToastUtil AST#expression#Right . showToast 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#builder_function_body#Right AST#method_declaration#Right
customConfig2() { DialogHelper.setDefaultConfig((config) => { config.autoCancel = false; config.backCancel = false; config.actionCancel = true; config.alignment = DialogAlignment.Bottom; config.offset = { dx: 0, dy: -35 }; config.maskColor = 0x11000000; config.backgroundColor = Color.White; config.backgroundBlurStyle = BlurStyle.COMPONENT_ULTRA_THICK; config.cornerRadius = 20; config.title = '提示'; config.primaryButton = '取消'; config.secondaryButton = '确定'; config.imageRes = undefined; config.imageSize = { width: '64vp', height: '64vp' }; config.loading_loadSize = 60; config.loading_loadColor = Color.White; config.loading_content = ''; config.loading_fontSize = 16; config.loading_fontColor = Color.White; config.loading_backgroundColor = '#CC56D866'; config.loading_borderRadius = 10; config.toast_fontSize = 16; config.toast_fontColor = Color.Black; config.toast_backgroundColor = '#CC0FCEE3'; config.toast_alignment = Alignment.Top; config.toast_borderRadius = 8; config.toast_padding = { left: 16, right: 16, top: 12, bottom: 12 }; config.toast_imageSize = { width: 45, height: 45 }; config.toast_duration = 1500; config.toast_durationLong = 5000; }); ToastUtil.showToast("统二配置设置成功!"); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/entry/src/main/ets/pages/index/DialogPage.ets#L105-L142
1f4fe2f40593e1fd371d44b953dea24b44f1abd5
gitee
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
Data/Preferences/entry/src/main/ets/model/PreferenceModel.ets
arkts
getPreference
Get preference data.
async getPreference() { let fruit = ''; if (!preference) { await this.getPreferencesFromStorage(); } try { fruit = (await preference.get(CommonConstants.KEY_NAME, '')).toString(); } catch (err) { Logger.error(CommonConstants.TAG, `Failed to get value, Cause: ${err}`); } // If the data is empty, a message is displayed indicating that data needs to be written. if (fruit === '') { this.showToastMessage($r('app.string.data_is_null_msg')); return; } this.showToastMessage($r('app.string.read_success_msg')); return JSON.parse(fruit); }
AST#method_declaration#Left async getPreference AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left fruit = 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#unary_expression#Left ! AST#expression#Left preference 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 AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . getPreferencesFromStorage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left fruit = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left preference AST#expression#Right AST#await_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . KEY_NAME AST#member_expression#Right AST#expression#Right , AST#expression#Left '' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#parenthesized_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#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Failed to get value, Cause: AST#template_substitution#Left $ { AST#expression#Left err AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right // If the data is empty, a message is displayed indicating that data needs to be written. AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left fruit AST#expression#Right === AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showToastMessage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.data_is_null_msg' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . showToastMessage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.read_success_msg' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#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 fruit AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async getPreference() { let fruit = ''; if (!preference) { await this.getPreferencesFromStorage(); } try { fruit = (await preference.get(CommonConstants.KEY_NAME, '')).toString(); } catch (err) { Logger.error(CommonConstants.TAG, `Failed to get value, Cause: ${err}`); } if (fruit === '') { this.showToastMessage($r('app.string.data_is_null_msg')); return; } this.showToastMessage($r('app.string.read_success_msg')); return JSON.parse(fruit); }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Data/Preferences/entry/src/main/ets/model/PreferenceModel.ets#L80-L97
7b946a3451e3d84b6e63f624a468fec94a30923f
gitee
openharmony/update_update_app
0157b7917e2f48e914b5585991e8b2f4bc25108a
feature/ota/src/main/ets/manager/StateManager.ets
arkts
状态--解压中 @since 2022-06-10
export class Installing extends BaseState { constructor() { super(); this.actionSet.push(UpdateAction.SHOW_NEW_VERSION); this.actionSet.push(UpdateAction.SHOW_PROCESS_VIEW); this.checkAbStreamInstall(); } async checkAbStreamInstall() { let isABStreamInstall = await VersionUtils.isABStreamInstall(); this.state = UpdateState.INSTALLING; this.downloadStateText = $r('app.string.new_version_status_installing'); if (isABStreamInstall) { this.buttonText = $r('app.string.cancel'); this.isButtonClickable = true; this.buttonClickAction = UpdateAction.CANCEL; } else { this.buttonText = $r('app.string.btn_upgrade'); this.isButtonClickable = false; } } async notify(context?: common.Context): Promise<void> { if (this.percent == 100) { await UpgradeAdapter.getInstance().getNotifyInstance()?.cancelAll(); return; } if (!VersionUtils.isInNewVersionPage()) { let versionName = await VersionUtils.obtainNewVersionName(globalThis.cachedNewVersionInfo); await UpgradeAdapter.getInstance().getNotifyInstance()?.showInstalling(versionName, this.percent, context); } } }
AST#export_declaration#Left export AST#class_declaration#Left class Installing extends AST#type_annotation#Left AST#primary_type#Left BaseState AST#primary_type#Right AST#type_annotation#Right AST#class_body#Left { AST#constructor_declaration#Left constructor AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left super AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . actionSet 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 UpdateAction AST#expression#Right . SHOW_NEW_VERSION AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . actionSet 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 UpdateAction AST#expression#Right . SHOW_PROCESS_VIEW 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 . checkAbStreamInstall AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right AST#method_declaration#Left async checkAbStreamInstall AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left isABStreamInstall = 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 VersionUtils AST#expression#Right AST#await_expression#Right AST#expression#Right . isABStreamInstall AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . state AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left UpdateState AST#expression#Right . INSTALLING AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloadStateText AST#member_expression#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.new_version_status_installing' AST#expression#Right ) AST#resource_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 isABStreamInstall 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 . buttonText AST#member_expression#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.cancel' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#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 . isButtonClickable AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . buttonClickAction AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left UpdateAction AST#expression#Right . CANCEL AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . buttonText AST#member_expression#Right = AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.btn_upgrade' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isButtonClickable AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left async notify AST#parameter_list#Left ( AST#parameter#Left context ? : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . Context AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . percent AST#member_expression#Right AST#expression#Right == AST#expression#Left 100 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left UpgradeAdapter AST#expression#Right AST#await_expression#Right 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 . getNotifyInstance AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right 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#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#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 VersionUtils AST#expression#Right AST#unary_expression#Right AST#expression#Right . isInNewVersionPage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left versionName = 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 VersionUtils AST#expression#Right AST#await_expression#Right AST#expression#Right . obtainNewVersionName AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left globalThis AST#expression#Right . cachedNewVersionInfo 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left UpgradeAdapter AST#expression#Right AST#await_expression#Right 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 . getNotifyInstance AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ?. showInstalling AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left versionName AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . percent AST#member_expression#Right AST#expression#Right , AST#expression#Left context AST#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#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class Installing extends BaseState { constructor() { super(); this.actionSet.push(UpdateAction.SHOW_NEW_VERSION); this.actionSet.push(UpdateAction.SHOW_PROCESS_VIEW); this.checkAbStreamInstall(); } async checkAbStreamInstall() { let isABStreamInstall = await VersionUtils.isABStreamInstall(); this.state = UpdateState.INSTALLING; this.downloadStateText = $r('app.string.new_version_status_installing'); if (isABStreamInstall) { this.buttonText = $r('app.string.cancel'); this.isButtonClickable = true; this.buttonClickAction = UpdateAction.CANCEL; } else { this.buttonText = $r('app.string.btn_upgrade'); this.isButtonClickable = false; } } async notify(context?: common.Context): Promise<void> { if (this.percent == 100) { await UpgradeAdapter.getInstance().getNotifyInstance()?.cancelAll(); return; } if (!VersionUtils.isInNewVersionPage()) { let versionName = await VersionUtils.obtainNewVersionName(globalThis.cachedNewVersionInfo); await UpgradeAdapter.getInstance().getNotifyInstance()?.showInstalling(versionName, this.percent, context); } } }
https://github.com/openharmony/update_update_app/blob/0157b7917e2f48e914b5585991e8b2f4bc25108a/feature/ota/src/main/ets/manager/StateManager.ets#L493-L525
df9949145874601b503690c135a22a86eb33e252
gitee
Piagari/arkts_example.git
a63b868eaa2a50dc480d487b84c4650cc6a40fc8
hmos_app-main/hmos_app-main/legado-Harmony-master/entry/src/main/ets/common/utils/DataPreferencesUtils.ets
arkts
initPreferences
初始化preferences实例
initPreferences() { this.preferences = dataPreferences.getPreferencesSync(context, { name: this.preferencesName }); }
AST#method_declaration#Left initPreferences AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . preferences AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left dataPreferences AST#expression#Right . getPreferencesSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left name AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . preferencesName 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#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
initPreferences() { this.preferences = dataPreferences.getPreferencesSync(context, { name: this.preferencesName }); }
https://github.com/Piagari/arkts_example.git/blob/a63b868eaa2a50dc480d487b84c4650cc6a40fc8/hmos_app-main/hmos_app-main/legado-Harmony-master/entry/src/main/ets/common/utils/DataPreferencesUtils.ets#L13-L15
f120e9830dffc6355089690603d8aa0fd2c62a18
github
seasonZhu/HarmonyStudy.git
b55e58c962e9b39d5211337590bdd45f2c2349b3
entry/src/main/ets/router/PagesConstant.ets
arkts
/ 需要再当前工程下resources/base/profile/main_pages.json中进行注册才能正常路由,目前已经支持自动注册
export abstract class PagesConstant { public static Splash = "pages/Splash" public static Index = "pages/Index" public static Login = "pages/Login" public static Register = "pages/Register" public static MyCoin = "pages/MyCoin" public static Rank = "pages/Rank" public static SearchResult = "pages/SearchResult" public static MyCollect = "pages/MyCollect" public static Web = "pages/WebPage" public static Hotkey = "pages/HotKey" public static TreeDetail = "pages/TreeDetail" public static Setting = "pages/Setting" public static WebExample = "pages/WebExample" public static WebComponent = "pages/WebComponent" public static ObservedV2TestPage = "pages/ObservedV2TestPage" }
AST#export_declaration#Left export AST#class_declaration#Left abstract class PagesConstant AST#class_body#Left { AST#property_declaration#Left public static Splash = AST#expression#Left "pages/Splash" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left public static Index = AST#expression#Left "pages/Index" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left public static Login = AST#expression#Left "pages/Login" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left public static Register = AST#expression#Left "pages/Register" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left public static MyCoin = AST#expression#Left "pages/MyCoin" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left public static Rank = AST#expression#Left "pages/Rank" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left public static SearchResult = AST#expression#Left "pages/SearchResult" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left public static MyCollect = AST#expression#Left "pages/MyCollect" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left public static Web = AST#expression#Left "pages/WebPage" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left public static Hotkey = AST#expression#Left "pages/HotKey" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left public static TreeDetail = AST#expression#Left "pages/TreeDetail" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left public static Setting = AST#expression#Left "pages/Setting" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left public static WebExample = AST#expression#Left "pages/WebExample" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left public static WebComponent = AST#expression#Left "pages/WebComponent" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left public static ObservedV2TestPage = AST#expression#Left "pages/ObservedV2TestPage" AST#expression#Right AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export abstract class PagesConstant { public static Splash = "pages/Splash" public static Index = "pages/Index" public static Login = "pages/Login" public static Register = "pages/Register" public static MyCoin = "pages/MyCoin" public static Rank = "pages/Rank" public static SearchResult = "pages/SearchResult" public static MyCollect = "pages/MyCollect" public static Web = "pages/WebPage" public static Hotkey = "pages/HotKey" public static TreeDetail = "pages/TreeDetail" public static Setting = "pages/Setting" public static WebExample = "pages/WebExample" public static WebComponent = "pages/WebComponent" public static ObservedV2TestPage = "pages/ObservedV2TestPage" }
https://github.com/seasonZhu/HarmonyStudy.git/blob/b55e58c962e9b39d5211337590bdd45f2c2349b3/entry/src/main/ets/router/PagesConstant.ets#L3-L19
6eb538677314a8d2cb259199d59ee59eb2553d24
github
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_crypto/src/main/ets/crypto/encryption/RSA.ets
arkts
decodePKCS1Segment
解密-分段 @param decodeStr 待解密的字符串 @param priKey RSA私钥
static async decodePKCS1Segment(str: string, priKey: string): Promise<string> { return CryptoUtil.decodeAsymSegment(str, priKey, 'RSA1024', 'RSA1024|PKCS1', 1024); }
AST#method_declaration#Left static async decodePKCS1Segment AST#parameter_list#Left ( AST#parameter#Left str : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left priKey : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_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 CryptoUtil AST#expression#Right . decodeAsymSegment AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left str AST#expression#Right , AST#expression#Left priKey AST#expression#Right , AST#expression#Left 'RSA1024' AST#expression#Right , AST#expression#Left 'RSA1024|PKCS1' AST#expression#Right , AST#expression#Left 1024 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 decodePKCS1Segment(str: string, priKey: string): Promise<string> { return CryptoUtil.decodeAsymSegment(str, priKey, 'RSA1024', 'RSA1024|PKCS1', 1024); }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto/src/main/ets/crypto/encryption/RSA.ets#L96-L98
6bcda3555a9913edd802a3dad9933e5db19be4cd
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/TypeUtil.ets
arkts
isUint32Array
检查是否为Uint32Array数组类型。 @param value @returns
static isUint32Array(value: Object): boolean { return new util.types().isUint32Array(value); }
AST#method_declaration#Left static isUint32Array 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#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left util AST#expression#Right AST#new_expression#Right AST#expression#Right . types AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . isUint32Array AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left value AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static isUint32Array(value: Object): boolean { return new util.types().isUint32Array(value); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/TypeUtil.ets#L191-L193
733a2817752f2f6efc69f36fecf201d26669eb23
gitee
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
Media/AudioPlayer/entry/src/main/ets/common/utils/CommonUtil.ets
arkts
formatDuration
Convert milliseconds to component second format. @param ms Milliseconds. @returns
public static formatDuration(ms: number): string { if (ms < 0) { ms = 0; } const secondPrecision = CommonConstants.SECOND_PRECISION; const secondDuration = ms / CommonConstants.SECOND_TO_MS; let min = Math.floor(secondDuration / CommonConstants.MIN_TO_SEC); let sec = Math.round(secondDuration - min * CommonConstants.MIN_TO_SEC); let secStr = sec.toFixed(secondPrecision); if (Number.parseInt(secStr) <= CommonConstants.MAX_OF_INDIVIDUAL) { secStr = `0${secStr}`; } return `${min}:${secStr}`; }
AST#method_declaration#Left public static formatDuration AST#parameter_list#Left ( AST#parameter#Left ms : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#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 ms 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#assignment_expression#Left ms = AST#expression#Left 0 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 const AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left secondPrecision = AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . SECOND_PRECISION AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left const AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left secondDuration = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left ms AST#expression#Right / AST#expression#Left CommonConstants AST#expression#Right AST#binary_expression#Right AST#expression#Right . SECOND_TO_MS AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left let AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left min = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . floor AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left secondDuration AST#expression#Right / AST#expression#Left CommonConstants AST#expression#Right AST#binary_expression#Right AST#expression#Right . MIN_TO_SEC AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left let AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left sec = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . round AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left secondDuration AST#expression#Right - AST#expression#Left AST#binary_expression#Left AST#expression#Left min AST#expression#Right * AST#expression#Left CommonConstants AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . MIN_TO_SEC AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left let AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left secStr = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left sec AST#expression#Right . toFixed AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left secondPrecision AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Number AST#expression#Right . parseInt AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left secStr AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right <= AST#expression#Left CommonConstants AST#expression#Right AST#binary_expression#Right AST#expression#Right . MAX_OF_INDIVIDUAL AST#member_expression#Right AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left secStr = AST#expression#Left AST#template_literal#Left ` 0 AST#template_substitution#Left $ { AST#expression#Left secStr AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#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#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left min AST#expression#Right } AST#template_substitution#Right : AST#template_substitution#Left $ { AST#expression#Left secStr AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
public static formatDuration(ms: number): string { if (ms < 0) { ms = 0; } const secondPrecision = CommonConstants.SECOND_PRECISION; const secondDuration = ms / CommonConstants.SECOND_TO_MS; let min = Math.floor(secondDuration / CommonConstants.MIN_TO_SEC); let sec = Math.round(secondDuration - min * CommonConstants.MIN_TO_SEC); let secStr = sec.toFixed(secondPrecision); if (Number.parseInt(secStr) <= CommonConstants.MAX_OF_INDIVIDUAL) { secStr = `0${secStr}`; } return `${min}:${secStr}`; }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/Media/AudioPlayer/entry/src/main/ets/common/utils/CommonUtil.ets#L28-L41
3bf85109c8bc1c6d1cb0103e135c7e58828a9cac
gitee
zqaini002/YaoYaoLingXian.git
5095b12cbeea524a87c42d0824b1702978843d39
YaoYaoLingXian/entry/src/main/ets/pages/dream/DreamEditPage.ets
arkts
fetchDreamDetail
获取梦想详情信息
private async fetchDreamDetail(dreamId: number) { try { this.isLoading = true; console.info(`获取梦想详情,ID: ${dreamId}`); const dreamDetail: Dream = await ApiService.getDreamById(dreamId); console.info(`获取到梦想详情: ${JSON.stringify(dreamDetail)}`); // 将后端返回的数据填充到表单 this.dream = dreamDetail; // 确保tags字段始终存在且为数组 this.dream.tags = this.dream.tags || []; // 处理日期字符串转CustomDate对象(假设格式为YYYY-MM-DD) if (dreamDetail.deadline && typeof dreamDetail.deadline === 'string') { const customDate = CustomDate.fromString(dreamDetail.deadline); if (customDate) { this.selectedDate = customDate; console.info(`解析日期成功: ${this.selectedDate.toString()}`); } else { console.warn(`日期解析失败,使用当前日期: ${dreamDetail.deadline}`); this.selectedDate = new CustomDate(); // 如果解析失败,使用当前日期 } } else { console.info(`未提供deadline或格式不是字符串,使用当前日期`); this.selectedDate = new CustomDate(); // 如果没有提供deadline,使用当前日期 } } catch (error) { // 提取错误信息 let errorMessage = ''; if (error instanceof Error) { errorMessage = error.message; } else if (error !== null && error !== undefined) { errorMessage = String(error); } console.error(`获取梦想详情失败: ${errorMessage}`); this.errorMessage = `获取梦想详情失败: ${errorMessage}`; const toastOpts: ToastOptions = { message: this.errorMessage }; promptAction.showToast(toastOpts); } finally { this.isLoading = false; } }
AST#method_declaration#Left private async fetchDreamDetail AST#parameter_list#Left ( AST#parameter#Left dreamId : 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLoading AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#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 dreamId 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 dreamDetail : AST#type_annotation#Left AST#primary_type#Left Dream 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 ApiService AST#expression#Right AST#await_expression#Right AST#expression#Right . getDreamById AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left dreamId AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#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 dreamDetail AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 将后端返回的数据填充到表单 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dream AST#member_expression#Right = AST#expression#Left dreamDetail AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 确保tags字段始终存在且为数组 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 . dream AST#member_expression#Right AST#expression#Right . tags AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . dream AST#member_expression#Right AST#expression#Right . tags AST#member_expression#Right AST#expression#Right || AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 处理日期字符串转CustomDate对象(假设格式为YYYY-MM-DD) AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left dreamDetail AST#expression#Right . deadline AST#member_expression#Right AST#expression#Right && AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left dreamDetail AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . deadline AST#member_expression#Right AST#expression#Right === AST#expression#Left 'string' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left customDate = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CustomDate AST#expression#Right . fromString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left dreamDetail AST#expression#Right . deadline AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left customDate 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 . selectedDate AST#member_expression#Right = AST#expression#Left customDate 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedDate 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#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 . warn 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 dreamDetail AST#expression#Right . deadline AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedDate AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left CustomDate 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#statement#Right // 如果解析失败,使用当前日期 } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#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 ` 未提供deadline或格式不是字符串,使用当前日期 ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedDate AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left CustomDate 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#statement#Right // 如果没有提供deadline,使用当前日期 } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { // 提取错误信息 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left 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 else AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left error 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 error AST#expression#Right !== AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left errorMessage = AST#expression#Left AST#call_expression#Left AST#expression#Left String AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 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#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . errorMessage AST#member_expression#Right = AST#expression#Left AST#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#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left toastOpts : AST#type_annotation#Left AST#primary_type#Left ToastOptions AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . errorMessage AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#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 toastOpts AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#finally_clause#Left finally AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLoading AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#finally_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private async fetchDreamDetail(dreamId: number) { try { this.isLoading = true; console.info(`获取梦想详情,ID: ${dreamId}`); const dreamDetail: Dream = await ApiService.getDreamById(dreamId); console.info(`获取到梦想详情: ${JSON.stringify(dreamDetail)}`); this.dream = dreamDetail; this.dream.tags = this.dream.tags || []; if (dreamDetail.deadline && typeof dreamDetail.deadline === 'string') { const customDate = CustomDate.fromString(dreamDetail.deadline); if (customDate) { this.selectedDate = customDate; console.info(`解析日期成功: ${this.selectedDate.toString()}`); } else { console.warn(`日期解析失败,使用当前日期: ${dreamDetail.deadline}`); this.selectedDate = new CustomDate(); } } else { console.info(`未提供deadline或格式不是字符串,使用当前日期`); this.selectedDate = new CustomDate(); } } catch (error) { let errorMessage = ''; if (error instanceof Error) { errorMessage = error.message; } else if (error !== null && error !== undefined) { errorMessage = String(error); } console.error(`获取梦想详情失败: ${errorMessage}`); this.errorMessage = `获取梦想详情失败: ${errorMessage}`; const toastOpts: ToastOptions = { message: this.errorMessage }; promptAction.showToast(toastOpts); } finally { this.isLoading = false; } }
https://github.com/zqaini002/YaoYaoLingXian.git/blob/5095b12cbeea524a87c42d0824b1702978843d39/YaoYaoLingXian/entry/src/main/ets/pages/dream/DreamEditPage.ets#L399-L442
eda607c9e8e180a1035eaef46d7c42167d1439b7
github
YShelter/Accouting_ArkTS.git
8c663c85f2c11738d4eabf269c23dc1ec84eb013
entry/src/main/ets/common/database/Rdb/RdbHelperImp.ets
arkts
addTableColumn
上层接口 向表格中添加一行属性 调用 addTableColumnSql 生成 sql 语句, executeSql 执行
addTableColumn(tableName: string, column: ColumnInfo): Promise<void> { let addTableColumnSql = tableHelper.addTableColumnSql(tableName, column); return this.executeSql(addTableColumnSql); }
AST#method_declaration#Left addTableColumn AST#parameter_list#Left ( AST#parameter#Left tableName : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left column : AST#type_annotation#Left AST#primary_type#Left ColumnInfo AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left addTableColumnSql = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left tableHelper AST#expression#Right . addTableColumnSql AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left tableName AST#expression#Right , AST#expression#Left column 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 . executeSql AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left addTableColumnSql 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
addTableColumn(tableName: string, column: ColumnInfo): Promise<void> { let addTableColumnSql = tableHelper.addTableColumnSql(tableName, column); return this.executeSql(addTableColumnSql); }
https://github.com/YShelter/Accouting_ArkTS.git/blob/8c663c85f2c11738d4eabf269c23dc1ec84eb013/entry/src/main/ets/common/database/Rdb/RdbHelperImp.ets#L57-L60
27807275dd6ea655c6664c350861e1d6d81f7d2e
github
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_core/src/main/ets/core/cache/CacheUtil.ets
arkts
存值 @param key 存入key @param value 存入数据
export function save<T>(key: string, value: T): void { cache[key] = value as Object; }
AST#export_declaration#Left export AST#function_declaration#Left function save 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 value : AST#type_annotation#Left AST#primary_type#Left T AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#as_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left cache AST#expression#Right [ AST#expression#Left key AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#ERROR#Left = value AST#ERROR#Right as AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right AST#as_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 save<T>(key: string, value: T): void { cache[key] = value as Object; }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_core/src/main/ets/core/cache/CacheUtil.ets#L36-L38
2c3267abc806cf6e94e791cbfe7cc8b73b6baa4e
gitee
sithvothykiv/dialog_hub.git
b676c102ef2d05f8994d170abe48dcc40cd39005
custom_dialog/src/main/ets/core/proxy/BaseBuilderProxy.ets
arkts
maskColor
弹窗背景遮罩颜色 @param maskColor 不设置获取config默认 @returns
maskColor(maskColor: ResourceColor) { this.builderOptions.maskColor = maskColor; return this; }
AST#method_declaration#Left maskColor AST#parameter_list#Left ( AST#parameter#Left maskColor : AST#type_annotation#Left AST#primary_type#Left ResourceColor AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . builderOptions AST#member_expression#Right AST#expression#Right . maskColor AST#member_expression#Right = AST#expression#Left maskColor AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left this AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
maskColor(maskColor: ResourceColor) { this.builderOptions.maskColor = maskColor; return this; }
https://github.com/sithvothykiv/dialog_hub.git/blob/b676c102ef2d05f8994d170abe48dcc40cd39005/custom_dialog/src/main/ets/core/proxy/BaseBuilderProxy.ets#L131-L134
f73d19056b5862ffa8ba134bf24f4ea7429a6ae3
github
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/PermissionUtil.ets
arkts
requestGlobalSwitch
用于UIAbility/UIExtensionAbility拉起全局开关设置弹框。部分情况下,录音、拍照等功能禁用,应用可拉起此弹框请求用户同意开启对应功能。如果当前全局开关的状态为开启,则不拉起弹框 @param type 全局开关类型。 @returns
static async requestGlobalSwitch(type: abilityAccessCtrl.SwitchType): Promise<boolean> { const atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager(); const context: Context = AppUtil.getContext(); return await atManager.requestGlobalSwitch(context, type); }
AST#method_declaration#Left static async requestGlobalSwitch AST#parameter_list#Left ( AST#parameter#Left type : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left abilityAccessCtrl . SwitchType 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 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 atManager : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left abilityAccessCtrl . AtManager 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 abilityAccessCtrl AST#expression#Right . createAtManager AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left 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 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left atManager AST#expression#Right AST#await_expression#Right AST#expression#Right . requestGlobalSwitch AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right , AST#expression#Left type AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static async requestGlobalSwitch(type: abilityAccessCtrl.SwitchType): Promise<boolean> { const atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager(); const context: Context = AppUtil.getContext(); return await atManager.requestGlobalSwitch(context, type); }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/PermissionUtil.ets#L136-L140
cc86fbecdd5effff1762d1f9aeeee146852e3386
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_web/src/main/ets/utils/FileUtils.ets
arkts
getDownloadUri
获取当前应用的Download目录下当前应用包名对应的Uri @param relativePath 文件路径;相对路径(wps/doc);传空字符串表示根目录 @param fileName 不传或传空 返回当前应用的Download文件夹uri
static getDownloadUri(relativePath: string | undefined = undefined, fileName?: string): string { const downloadPath = FileUtils.getDownloadPath(relativePath, fileName); //'file://docs/storage/Users/currentUser/Download/' + bundleName let downloadUri = FileUtils.getUriFromPath(downloadPath); return downloadUri; }
AST#method_declaration#Left static getDownloadUri AST#parameter_list#Left ( AST#parameter#Left relativePath : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left undefined AST#expression#Right AST#parameter#Right , AST#parameter#Left fileName ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left downloadPath = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left FileUtils AST#expression#Right . getDownloadPath AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left relativePath AST#expression#Right , AST#expression#Left fileName 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 //'file://docs/storage/Users/currentUser/Download/' + bundleName AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left downloadUri = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left FileUtils AST#expression#Right . getUriFromPath AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left downloadPath 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 downloadUri AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static getDownloadUri(relativePath: string | undefined = undefined, fileName?: string): string { const downloadPath = FileUtils.getDownloadPath(relativePath, fileName); let downloadUri = FileUtils.getUriFromPath(downloadPath); return downloadUri; }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_web/src/main/ets/utils/FileUtils.ets#L121-L126
174b2848fd7f14f2fe66f83e2231b16ebb53f48c
gitee
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/foldablescreencases/src/main/ets/components/MusicPlayerInfoComp.ets
arkts
MusicPlayerInfoComp
播放器歌曲信息组件,包括歌名、歌手、歌曲封面、歌词 实现步骤: 1.组件创建时,根据当前折叠屏状态和横竖屏状态初始化组件树上各组件属性 2.通过父组件监听屏幕折叠态变更事件,同时通过单项绑定通知到此组件的状态变量,修改组件树上各组件属性 3.通过媒体查询监听横竖屏变更,修改组件树上各组件属性 4.通过配置属性动画,动态变更各组件样式
@Component export struct MusicPlayerInfoComp { // 父组件单向绑定的屏幕状态 @Prop @Watch('updateWithFoldStatus') curFoldStatus: display.FoldStatus; // 通知Navigation组件隐藏导航栏 @Consume('isFullScreen') isFullScreen: boolean; // 当前页面的vm实例 @Consume('musicPlayerViewModel') @Watch('onViewModelChanged') viewModel: MusicPlayerViewModel; // list控制器 private lyricsScrollerCtrl: Scroller = new Scroller(); // 歌词展示索引 @State lyricsCurIndex: number = 0; // 当前是否横屏状态 private isLandscape: boolean = false; // TODO:知识点:通过媒体查询监听显示屏幕横竖屏方向状态变更 private landscapeListener: mediaquery.MediaQueryListener = mediaquery.matchMediaSync('(orientation: landscape)'); // 属性动画配置 private attrAniCfg: AnimateParam = { duration: 2000, curve: Curve.EaseOut, iterations: 1, playMode: PlayMode.Normal } // 歌曲信息组件整体高度百分比 @State totalHeightPer: string = CommonConstants.MUSIC_INFO_COMP_HEIGHT_COMMON; // 歌词子组件高度百分比 @State lyricsHeightPer: string = CommonConstants.MUSIC_LYRICS_COMP_HEIGHT_EXPANDED; // 歌词子组件外边距 @State lyricsMargin: Margin = { top: CommonConstants.MUSIC_LYRICS_COMP_MARGIN_TOP_COMMON }; // 歌曲封面图片尺寸 @State curImgSize: number = CommonConstants.MUSIC_COVER_SIZE_COMMON; // 歌曲信息组件Flex布局方向 @State curFlexDirection: FlexDirection = FlexDirection.Row; private screenW: number = px2vp(display.getDefaultDisplaySync().width); private readonly DEVICESIZE: number = 600; // 依据Navigation的mode属性说明,如使用Auto,窗口宽度>=600vp时,采用Split模式显示;窗口宽度<600vp时,采用Stack模式显示。 private callBack = async (curFoldStatus: display.FoldStatus) => { // 同一个状态重复触发不做处理 if (this.curFoldStatus === curFoldStatus) { return; } // 缓存当前折叠状态 this.curFoldStatus = curFoldStatus; this.hideNavBar(this.curFoldStatus); } aboutToAppear(): void { // 初始化各组件样式 this.updateWithFoldStatus(); if (display.isFoldable()) { this.regDisplayListener(); } else { if (this.screenW >= this.DEVICESIZE) { this.navigationAnimation(true); } else { this.navigationAnimation(false); }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct MusicPlayerInfoComp AST#ERROR#Left { // 父组件单向绑定的屏幕状态 AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right AST#decorator#Left @ Watch ( AST#expression#Left 'updateWithFoldStatus' AST#expression#Right ) AST#decorator#Right curFoldStatus : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left display . FoldStatus AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right // 通知Navigation组件隐藏导航栏 AST#property_declaration#Left AST#decorator#Left @ Consume ( AST#expression#Left 'isFullScreen' AST#expression#Right ) AST#decorator#Right isFullScreen : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right // 当前页面的vm实例 AST#property_declaration#Left AST#decorator#Left @ Consume ( AST#expression#Left 'musicPlayerViewModel' AST#expression#Right ) AST#decorator#Right AST#decorator#Left @ Watch ( AST#expression#Left 'onViewModelChanged' AST#expression#Right ) AST#decorator#Right viewModel : AST#type_annotation#Left AST#primary_type#Left MusicPlayerViewModel AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right // list控制器 AST#property_declaration#Left private lyricsScrollerCtrl : AST#type_annotation#Left AST#primary_type#Left Scroller AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Scroller AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right // 歌词展示索引 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right lyricsCurIndex : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right ; AST#property_declaration#Right // 当前是否横屏状态 AST#property_declaration#Left private isLandscape : 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 // TODO:知识点:通过媒体查询监听显示屏幕横竖屏方向状态变更 AST#property_declaration#Left private landscapeListener : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left mediaquery . MediaQueryListener 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 mediaquery AST#expression#Right . matchMediaSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '(orientation: landscape)' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right // 属性动画配置 AST#property_declaration#Left private attrAniCfg : AST#type_annotation#Left AST#primary_type#Left AnimateParam AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left duration AST#property_name#Right : AST#expression#Left 2000 AST#expression#Right AST#property_assignment#Right , AST#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 . EaseOut AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left iterations AST#property_name#Right : AST#expression#Left 1 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left playMode AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left PlayMode AST#expression#Right . Normal AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right // 歌曲信息组件整体高度百分比 AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right totalHeightPer : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . MUSIC_INFO_COMP_HEIGHT_COMMON AST#member_expression#Right AST#expression#Right ; AST#property_declaration#Right // 歌词子组件高度百分比 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right lyricsHeightPer : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . MUSIC_LYRICS_COMP_HEIGHT_EXPANDED AST#member_expression#Right AST#expression#Right ; AST#property_declaration#Right // 歌词子组件外边距 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right lyricsMargin : AST#type_annotation#Left AST#primary_type#Left Margin AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . MUSIC_LYRICS_COMP_MARGIN_TOP_COMMON AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ; AST#property_declaration#Right // 歌曲封面图片尺寸 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right curImgSize : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . MUSIC_COVER_SIZE_COMMON AST#member_expression#Right AST#expression#Right ; AST#property_declaration#Right // 歌曲信息组件Flex布局方向 AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right curFlexDirection : AST#type_annotation#Left AST#primary_type#Left FlexDirection AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left FlexDirection AST#expression#Right . Row AST#member_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left private screenW : 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 px2vp AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left display AST#expression#Right . getDefaultDisplaySync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . width AST#member_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 readonly DEVICESIZE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 600 AST#expression#Right ; AST#property_declaration#Right // 依据Navigation的mode属性说明,如使用Auto,窗口宽度>=600vp时,采用Split模式显示;窗口宽度<600vp时,采用Stack模式显示。 AST#property_declaration#Left private callBack = AST#ERROR#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#arrow_function#Left async AST#parameter_list#Left ( AST#parameter#Left curFoldStatus : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left display . FoldStatus AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { // 同一个状态重复触发不做处理 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . curFoldStatus AST#member_expression#Right AST#expression#Right === AST#expression#Left curFoldStatus AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 缓存当前折叠状态 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . curFoldStatus AST#member_expression#Right = AST#expression#Left curFoldStatus AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . hideNavBar 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 . curFoldStatus 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#ERROR#Left aboutToAppear AST#ERROR#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right : AST#ERROR#Right AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left void AST#expression#Left AST#object_literal#Left { // 初始化各组件样式 AST#property_assignment#Left this AST#property_assignment#Right AST#object_literal#Right AST#expression#Right AST#unary_expression#Right AST#expression#Right . updateWithFoldStatus AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#method_declaration#Left if AST#ERROR#Left ( display . isFoldable AST#ERROR#Right AST#parameter_list#Left ( ) AST#parameter_list#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 . regDisplayListener AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left else AST#ERROR#Left { if AST#ERROR#Right AST#parameter_list#Left ( AST#parameter#Left this AST#parameter#Right AST#ERROR#Left . screenW >= this . DEVICESIZE AST#ERROR#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . navigationAnimation AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right else AST#ERROR#Right AST#component_body#Left { AST#method_declaration#Left this AST#ERROR#Left . navigationAnimation AST#ERROR#Right AST#parameter_list#Left ( AST#parameter#Left false AST#parameter#Right ) AST#parameter_list#Right ; AST#method_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Component export struct MusicPlayerInfoComp { @Prop @Watch('updateWithFoldStatus') curFoldStatus: display.FoldStatus; @Consume('isFullScreen') isFullScreen: boolean; @Consume('musicPlayerViewModel') @Watch('onViewModelChanged') viewModel: MusicPlayerViewModel; private lyricsScrollerCtrl: Scroller = new Scroller(); @State lyricsCurIndex: number = 0; private isLandscape: boolean = false; private landscapeListener: mediaquery.MediaQueryListener = mediaquery.matchMediaSync('(orientation: landscape)'); private attrAniCfg: AnimateParam = { duration: 2000, curve: Curve.EaseOut, iterations: 1, playMode: PlayMode.Normal } @State totalHeightPer: string = CommonConstants.MUSIC_INFO_COMP_HEIGHT_COMMON; @State lyricsHeightPer: string = CommonConstants.MUSIC_LYRICS_COMP_HEIGHT_EXPANDED; @State lyricsMargin: Margin = { top: CommonConstants.MUSIC_LYRICS_COMP_MARGIN_TOP_COMMON }; @State curImgSize: number = CommonConstants.MUSIC_COVER_SIZE_COMMON; @State curFlexDirection: FlexDirection = FlexDirection.Row; private screenW: number = px2vp(display.getDefaultDisplaySync().width); private readonly DEVICESIZE: number = 600; private callBack = async (curFoldStatus: display.FoldStatus) => { if (this.curFoldStatus === curFoldStatus) { return; } this.curFoldStatus = curFoldStatus; this.hideNavBar(this.curFoldStatus); } aboutToAppear(): void { this.updateWithFoldStatus(); if (display.isFoldable()) { this.regDisplayListener(); } else { if (this.screenW >= this.DEVICESIZE) { this.navigationAnimation(true); } else { this.navigationAnimation(false); }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/foldablescreencases/src/main/ets/components/MusicPlayerInfoComp.ets#L31-L87
ab58617d4366c7d4c1b59481c6a5e20abe2c7597
gitee
dcm23333/FishManager.git
952dde4475268ac16f3480f3d55f82033aa6b467
FishManager/entry/src/main/ets/common/contants/commonContants.ets
arkts
‘56%’
export const THOUSANDTH_800: string = '80%';
AST#export_declaration#Left export AST#variable_declaration#Left const AST#variable_declarator#Left THOUSANDTH_800 : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '80%' AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#export_declaration#Right
export const THOUSANDTH_800: string = '80%';
https://github.com/dcm23333/FishManager.git/blob/952dde4475268ac16f3480f3d55f82033aa6b467/FishManager/entry/src/main/ets/common/contants/commonContants.ets#L58-L58
c78904866cc1a7c5201d0fd55c7153b7881cf460
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/expandtitle/src/main/ets/page/DataSource.ets
arkts
pushData
存储数据到懒加载数据源中
pushData(data: MemoInfo): void { this.memoData.push(data); // 在数组头部添加数据 this.notifyDataAdd(this.memoData.length - 1); }
AST#method_declaration#Left pushData AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left MemoInfo 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 . memoData AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left data AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right // 在数组头部添加数据 AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . notifyDataAdd AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . memoData AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right - AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
pushData(data: MemoInfo): void { this.memoData.push(data); this.notifyDataAdd(this.memoData.length - 1); }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/expandtitle/src/main/ets/page/DataSource.ets#L99-L103
b27b4eb01e17d1172ad4b7e95077827182c36fd7
gitee
openharmony/arkui_ace_engine
30c7d1ee12fbedf0fabece54291d75897e2ad44f
examples/Select/entry/src/main/ets/pages/components/select/selectLevel5.ets
arkts
SelectLevel5Builder
Copyright (c) 2025 Huawei Device Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
@Builder export function SelectLevel5Builder(name: string, param: Object) { SelectLevel5Example() }
AST#decorated_export_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right export function SelectLevel5Builder AST#parameter_list#Left ( AST#parameter#Left name : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left param : AST#type_annotation#Left AST#primary_type#Left Object AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left SelectLevel5Example ( ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#decorated_export_declaration#Right
@Builder export function SelectLevel5Builder(name: string, param: Object) { SelectLevel5Example() }
https://github.com/openharmony/arkui_ace_engine/blob/30c7d1ee12fbedf0fabece54291d75897e2ad44f/examples/Select/entry/src/main/ets/pages/components/select/selectLevel5.ets#L16-L19
9abad7b5cefd6565d24d4c02c9a3210a3b382836
gitee
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/models/managers/plan/plancurve/Piece.ets
arkts
get
MARK: - Getter 方法 获取piece编号
get pieceNo(): number { return this._pieceNo; }
AST#method_declaration#Left get AST#ERROR#Left pieceNo AST#ERROR#Right AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . _pieceNo AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
get pieceNo(): number { return this._pieceNo; }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/managers/plan/plancurve/Piece.ets#L25-L27
b5430332b7f7ae4c2c64ebaf7712f2269117c44d
github
bigbear20240612/planner_build-.git
89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1
entry/src/main/ets/viewmodel/TaskViewModel.ets
arkts
isThisWeek
判断是否为本周
private isThisWeek(date: Date): boolean { const now = new Date(); const startOfWeek = new Date(now); startOfWeek.setDate(now.getDate() - now.getDay()); startOfWeek.setHours(0, 0, 0, 0); return date >= startOfWeek; }
AST#method_declaration#Left private isThisWeek AST#parameter_list#Left ( AST#parameter#Left date : AST#type_annotation#Left AST#primary_type#Left Date AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 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 startOfWeek = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left now 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 startOfWeek AST#expression#Right . setDate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left now AST#expression#Right . getDate 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 now AST#expression#Right AST#binary_expression#Right AST#expression#Right . getDay AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#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 startOfWeek AST#expression#Right . setHours 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 0 AST#expression#Right , AST#expression#Left 0 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#binary_expression#Left AST#expression#Left date AST#expression#Right >= AST#expression#Left startOfWeek AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private isThisWeek(date: Date): boolean { const now = new Date(); const startOfWeek = new Date(now); startOfWeek.setDate(now.getDate() - now.getDay()); startOfWeek.setHours(0, 0, 0, 0); return date >= startOfWeek; }
https://github.com/bigbear20240612/planner_build-.git/blob/89c0e0027d9c46fa1d0112b71fcc95bb0b97ace1/entry/src/main/ets/viewmodel/TaskViewModel.ets#L629-L636
14fa1a882a40d1e2ca5c1e9d84a4215557ab1d15
github
harmonyos/samples
f5d967efaa7666550ee3252d118c3c73a77686f5
HarmonyOS_NEXT/MultiDeviceAppDev/Settings/features/settingitems/src/main/ets/components/ItemGroup.ets
arkts
ItemGroup
Copyright (c) 2021-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.
@Component export struct ItemGroup { @BuilderParam noParam: () => void build() { Column() { this.noParam() } .width('100%') .borderRadius(24) .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')) .padding(4) } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct ItemGroup AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ BuilderParam AST#decorator#Right noParam : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#property_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . noParam AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 24 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'sys.color.ohos_id_color_foreground_contrary' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left 4 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 ItemGroup { @BuilderParam noParam: () => void build() { Column() { this.noParam() } .width('100%') .borderRadius(24) .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary')) .padding(4) } }
https://github.com/harmonyos/samples/blob/f5d967efaa7666550ee3252d118c3c73a77686f5/HarmonyOS_NEXT/MultiDeviceAppDev/Settings/features/settingitems/src/main/ets/components/ItemGroup.ets#L16-L29
d1ffc3fa81c3b2412a7cb316d70cdd3dc6508049
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/DocsSample/Media/AVPlayer/AVPlayerArkTSStreamingMedia/entry/src/main/ets/pages/Index.ets
arkts
changeBitrate
HLS切换码率
changeBitrate(bitrate: number) { if (this.avPlayer == null) { return; } // 设置播放码率 try { this.avPlayer.setBitrate(bitrate); } catch (error) { console.error(`${this.tag}: setBitrate failed, error message is = ${JSON.stringify(error.message)}`); } }
AST#method_declaration#Left changeBitrate AST#parameter_list#Left ( AST#parameter#Left bitrate : 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#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 . avPlayer AST#member_expression#Right AST#expression#Right == AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 设置播放码率 AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . avPlayer AST#member_expression#Right AST#expression#Right . setBitrate AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left bitrate AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . tag AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right : setBitrate failed, error message is = AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 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#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
changeBitrate(bitrate: number) { if (this.avPlayer == null) { return; } try { this.avPlayer.setBitrate(bitrate); } catch (error) { console.error(`${this.tag}: setBitrate failed, error message is = ${JSON.stringify(error.message)}`); } }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/Media/AVPlayer/AVPlayerArkTSStreamingMedia/entry/src/main/ets/pages/Index.ets#L173-L183
57b27dfc487f43a3862fae2fbd8238d4063403a6
gitee
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
JSCrash/entry/src/main/ets/pages/utils.ets
arkts
[End TestJSErrorUtils]
export class Log { /** * Outputs info-level logs. * * @param tag Identifies the log tag. * @param format Indicates the log format string. * @param args Indicates the log parameters. * @since 7 */ static showInfo(tag: string): void { if (Log.isLoggable(tag, hilog.LogLevel.INFO)) { hilog.info(DOMAIN, TAG, tag + SYMBOL); } } /** * Outputs debug-level logs. * * @param tag Identifies the log tag. * @param format Indicates the log format string. * @param args Indicates the log parameters. * @since 7 */ static showDebug(tag: string, format: string, ...args: string[]): void { if (Log.isLoggable(tag, hilog.LogLevel.DEBUG)) { hilog.debug(DOMAIN, TAG, tag + SYMBOL + format, args); } } /** * Outputs warning-level logs. * * @param tag Identifies the log tag. * @param format Indicates the log format string. * @param args Indicates the log parameters. * @since 7 */ static showWarn(tag: string, format: string, ...args: string[]): void { if (Log.isLoggable(tag, hilog.LogLevel.WARN)) { hilog.warn(DOMAIN, TAG, tag + SYMBOL + format, args); } } /** * Outputs error-level logs. * * @param tag Identifies the log tag. * @param format Indicates the log format string. * @param args Indicates the log parameters. * @since 7 */ static showError(tag: string): void { if (Log.isLoggable(tag, hilog.LogLevel.ERROR)) { hilog.error(DOMAIN, TAG, tag + SYMBOL); } } /** * Outputs fatal-level logs. * * @param tag Identifies the log tag. * @param format Indicates the log format string. * @param args Indicates the log parameters. * @since 7 */ static showFatal(tag: string, format: string, ...args: string[]): void { if (Log.isLoggable(tag, hilog.LogLevel.FATAL)) { hilog.fatal(DOMAIN, TAG, tag + SYMBOL + format, args); } } /** * Checks whether logs of the specified tag, and level can be printed. * * @param tag Identifies the log tag. * @param level log level * @since 7 */ private static isLoggable(tag: string, level: hilog.LogLevel): boolean { return hilog.isLoggable(DOMAIN, tag, level); } }
AST#export_declaration#Left export AST#class_declaration#Left class Log AST#class_body#Left { /** * Outputs info-level logs. * * @param tag Identifies the log tag. * @param format Indicates the log format string. * @param args Indicates the log parameters. * @since 7 */ AST#method_declaration#Left static showInfo AST#parameter_list#Left ( AST#parameter#Left tag : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 Log AST#expression#Right . isLoggable AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left tag AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . LogLevel AST#member_expression#Right AST#expression#Right . INFO AST#member_expression#Right 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 hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left DOMAIN AST#expression#Right , AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left tag AST#expression#Right + AST#expression#Left SYMBOL AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right /** * Outputs debug-level logs. * * @param tag Identifies the log tag. * @param format Indicates the log format string. * @param args Indicates the log parameters. * @since 7 */ 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 format : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left ... args : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#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 Log AST#expression#Right . isLoggable AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left tag AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . LogLevel AST#member_expression#Right AST#expression#Right . DEBUG AST#member_expression#Right 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 hilog AST#expression#Right . debug AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left DOMAIN AST#expression#Right , AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left tag AST#expression#Right + AST#expression#Left SYMBOL AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left format AST#expression#Right AST#binary_expression#Right AST#expression#Right , AST#expression#Left args AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right /** * Outputs warning-level logs. * * @param tag Identifies the log tag. * @param format Indicates the log format string. * @param args Indicates the log parameters. * @since 7 */ AST#method_declaration#Left static showWarn 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 format : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left ... args : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#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 Log AST#expression#Right . isLoggable AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left tag AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . LogLevel AST#member_expression#Right AST#expression#Right . WARN AST#member_expression#Right 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 hilog AST#expression#Right . warn AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left DOMAIN AST#expression#Right , AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left tag AST#expression#Right + AST#expression#Left SYMBOL AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left format AST#expression#Right AST#binary_expression#Right AST#expression#Right , AST#expression#Left args AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right /** * Outputs error-level logs. * * @param tag Identifies the log tag. * @param format Indicates the log format string. * @param args Indicates the log parameters. * @since 7 */ AST#method_declaration#Left static showError AST#parameter_list#Left ( AST#parameter#Left tag : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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 Log AST#expression#Right . isLoggable AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left tag AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . LogLevel AST#member_expression#Right AST#expression#Right . ERROR AST#member_expression#Right 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 hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left DOMAIN AST#expression#Right , AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left tag AST#expression#Right + AST#expression#Left SYMBOL AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right /** * Outputs fatal-level logs. * * @param tag Identifies the log tag. * @param format Indicates the log format string. * @param args Indicates the log parameters. * @since 7 */ AST#method_declaration#Left static showFatal 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 format : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left ... args : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#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 Log AST#expression#Right . isLoggable AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left tag AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . LogLevel AST#member_expression#Right AST#expression#Right . FATAL AST#member_expression#Right 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 hilog AST#expression#Right . fatal AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left DOMAIN AST#expression#Right , AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left tag AST#expression#Right + AST#expression#Left SYMBOL AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left format AST#expression#Right AST#binary_expression#Right AST#expression#Right , AST#expression#Left args AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right /** * Checks whether logs of the specified tag, and level can be printed. * * @param tag Identifies the log tag. * @param level log level * @since 7 */ AST#method_declaration#Left private static isLoggable 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 level : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left hilog . LogLevel 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 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 hilog AST#expression#Right . isLoggable AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left DOMAIN AST#expression#Right , AST#expression#Left tag AST#expression#Right , AST#expression#Left level 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 Log { static showInfo(tag: string): void { if (Log.isLoggable(tag, hilog.LogLevel.INFO)) { hilog.info(DOMAIN, TAG, tag + SYMBOL); } } static showDebug(tag: string, format: string, ...args: string[]): void { if (Log.isLoggable(tag, hilog.LogLevel.DEBUG)) { hilog.debug(DOMAIN, TAG, tag + SYMBOL + format, args); } } static showWarn(tag: string, format: string, ...args: string[]): void { if (Log.isLoggable(tag, hilog.LogLevel.WARN)) { hilog.warn(DOMAIN, TAG, tag + SYMBOL + format, args); } } static showError(tag: string): void { if (Log.isLoggable(tag, hilog.LogLevel.ERROR)) { hilog.error(DOMAIN, TAG, tag + SYMBOL); } } static showFatal(tag: string, format: string, ...args: string[]): void { if (Log.isLoggable(tag, hilog.LogLevel.FATAL)) { hilog.fatal(DOMAIN, TAG, tag + SYMBOL + format, args); } } private static isLoggable(tag: string, level: hilog.LogLevel): boolean { return hilog.isLoggable(DOMAIN, tag, level); } }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/JSCrash/entry/src/main/ets/pages/utils.ets#L13-L94
ddeb300cf9394bff1f215c575ba00b42a04b322d
gitee
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
feature/order/src/main/ets/view/OrderLogisticsPage.ets
arkts
LogisticsNumberValue
物流编号展示区域 @param {Logistics} logistics - 物流信息 @returns {void} 无返回值
@Builder private LogisticsNumberValue(logistics: Logistics): void { RowStartCenter() { Text(logistics.number ?? $r("app.string.none")) .fontSize($r("app.float.body_medium")) .fontColor($r("app.color.text_secondary")); SpaceHorizontalSmall(); Text($r("app.string.copy")) .fontSize($r("app.float.body_medium")) .fontColor($r("app.color.primary")); SpaceHorizontalXSmall(); } }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right private LogisticsNumberValue AST#parameter_list#Left ( AST#parameter#Left logistics : AST#type_annotation#Left AST#primary_type#Left Logistics 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#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left RowStartCenter ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left logistics AST#expression#Right . number AST#member_expression#Right AST#expression#Right ?? AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.none" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.float.body_medium" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.color.text_secondary" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#expression_statement#Left AST#expression#Left AST#expression#Right ; AST#expression_statement#Right AST#ui_custom_component_statement#Left SpaceHorizontalSmall ( ) ; AST#ui_custom_component_statement#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.string.copy" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.float.body_medium" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.color.primary" 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#expression_statement#Left AST#expression#Left AST#expression#Right ; AST#expression_statement#Right AST#ui_custom_component_statement#Left SpaceHorizontalXSmall ( ) ; 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#builder_function_body#Right AST#method_declaration#Right
@Builder private LogisticsNumberValue(logistics: Logistics): void { RowStartCenter() { Text(logistics.number ?? $r("app.string.none")) .fontSize($r("app.float.body_medium")) .fontColor($r("app.color.text_secondary")); SpaceHorizontalSmall(); Text($r("app.string.copy")) .fontSize($r("app.float.body_medium")) .fontColor($r("app.color.primary")); SpaceHorizontalXSmall(); } }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/order/src/main/ets/view/OrderLogisticsPage.ets#L186-L201
d52625878d813094a9e08bd2532dd7e6eb30c48a
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/ai/AIAssistantService.ets
arkts
sendMessage
发送消息并获取AI响应
async sendMessage(message: string, sessionId?: string): Promise<AIResponse> { try { const currentSessionId = sessionId || this.currentSessionId; const context = this.conversations.get(currentSessionId); if (!context) { throw new Error('会话不存在'); } // 创建用户消息 const userMessage: ChatMessage = { id: `msg_${Date.now()}_user`, content: message, type: MessageType.TEXT, sender: MessageSender.USER, timestamp: new Date().toISOString(), metadata: {} }; // 添加到历史记录 context.history.push(userMessage); // 意图识别 const intent = await this.recognizeIntent(message, context); // 生成AI响应 const aiResponse = await this.generateResponse(message, intent, context); // 创建AI消息 const assistantMessage: ChatMessage = { id: `msg_${Date.now()}_ai`, content: aiResponse.content, type: aiResponse.type || MessageType.TEXT, sender: MessageSender.ASSISTANT, timestamp: new Date().toISOString(), metadata: aiResponse.metadata || {}, attachments: aiResponse.attachments }; // 添加到历史记录 context.history.push(assistantMessage); // 更新上下文 context.lastIntent = intent.intent; Object.assign(context.entities, intent.entities); // 限制历史记录长度 if (context.history.length > context.preferences.maxHistoryLength) { context.history = context.history.slice(-context.preferences.maxHistoryLength); } // 学习用户行为 await this.learnUserBehavior(message, context); const response: AIResponse = { message: assistantMessage, intent, suggestions: intent.suggestedActions, followUpQuestions: await this.generateFollowUpQuestions(intent, context), context: { currentTopic: intent.intent, entities: context.entities } }; hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `AI response generated for intent: ${intent.intent}`); return response; } catch (error) { hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to process message: ${error}`); throw error; } }
AST#method_declaration#Left async sendMessage 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#Left sessionId ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AIResponse 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 currentSessionId = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left sessionId AST#expression#Right || AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . currentSessionId AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left context = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . conversations AST#member_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left currentSessionId AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left context AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#throw_statement#Left throw AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Error AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '会话不存在' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#throw_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 创建用户消息 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left userMessage : AST#type_annotation#Left AST#primary_type#Left ChatMessage AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left id AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` msg_ AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Date AST#expression#Right . now AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right _user ` AST#template_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left content AST#property_name#Right : AST#expression#Left message AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left type AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left MessageType AST#expression#Right . TEXT AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left sender AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left MessageSender AST#expression#Right . USER 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 AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . toISOString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left metadata AST#property_name#Right : AST#expression#Left AST#object_literal#Left { } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 添加到历史记录 AST#statement#Left AST#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 context AST#expression#Right . history AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left userMessage 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 intent = 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 . recognizeIntent AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left message AST#expression#Right , AST#expression#Left context AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 生成AI响应 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left aiResponse = 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 . generateResponse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left message AST#expression#Right , AST#expression#Left intent AST#expression#Right , AST#expression#Left context AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 创建AI消息 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left assistantMessage : AST#type_annotation#Left AST#primary_type#Left ChatMessage AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left id AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` msg_ AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Date AST#expression#Right . now AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right _ai ` AST#template_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left content AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left aiResponse AST#expression#Right . content AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left type AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left aiResponse AST#expression#Right . type AST#member_expression#Right AST#expression#Right || AST#expression#Left MessageType AST#expression#Right AST#binary_expression#Right AST#expression#Right . TEXT AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left sender AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left MessageSender AST#expression#Right . ASSISTANT 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 AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . toISOString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left metadata AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left aiResponse AST#expression#Right . metadata AST#member_expression#Right AST#expression#Right || AST#expression#Left AST#object_literal#Left { } AST#object_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left attachments AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left aiResponse AST#expression#Right . attachments AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 添加到历史记录 AST#statement#Left AST#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 context AST#expression#Right . history AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left assistantMessage 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 context AST#expression#Right . lastIntent AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left intent AST#expression#Right . intent 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 Object AST#expression#Right . assign AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left context AST#expression#Right . entities AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left intent AST#expression#Right . entities 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 AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left context AST#expression#Right . history AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right > AST#expression#Left context AST#expression#Right AST#binary_expression#Right AST#expression#Right . preferences AST#member_expression#Right AST#expression#Right . maxHistoryLength AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left context AST#expression#Right . history 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 context AST#expression#Right . history AST#member_expression#Right AST#expression#Right . slice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left - AST#expression#Left context AST#expression#Right AST#unary_expression#Right AST#expression#Right . preferences AST#member_expression#Right AST#expression#Right . maxHistoryLength 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#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 . learnUserBehavior AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left message AST#expression#Right , AST#expression#Left context AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left response : AST#type_annotation#Left AST#primary_type#Left AIResponse AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left assistantMessage AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left intent AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left suggestions AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left intent AST#expression#Right . suggestedActions AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left followUpQuestions AST#property_name#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 . generateFollowUpQuestions AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left intent AST#expression#Right , AST#expression#Left context AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left context AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left currentTopic AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left intent AST#expression#Right . intent AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left entities AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left context AST#expression#Right . entities 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . DOMAIN_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left LogConstants AST#expression#Right . TAG_APP AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` AI response generated for intent: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left intent AST#expression#Right . intent AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left response AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 process message: 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 sendMessage(message: string, sessionId?: string): Promise<AIResponse> { try { const currentSessionId = sessionId || this.currentSessionId; const context = this.conversations.get(currentSessionId); if (!context) { throw new Error('会话不存在'); } const userMessage: ChatMessage = { id: `msg_${Date.now()}_user`, content: message, type: MessageType.TEXT, sender: MessageSender.USER, timestamp: new Date().toISOString(), metadata: {} }; context.history.push(userMessage); const intent = await this.recognizeIntent(message, context); const aiResponse = await this.generateResponse(message, intent, context); const assistantMessage: ChatMessage = { id: `msg_${Date.now()}_ai`, content: aiResponse.content, type: aiResponse.type || MessageType.TEXT, sender: MessageSender.ASSISTANT, timestamp: new Date().toISOString(), metadata: aiResponse.metadata || {}, attachments: aiResponse.attachments }; context.history.push(assistantMessage); context.lastIntent = intent.intent; Object.assign(context.entities, intent.entities); if (context.history.length > context.preferences.maxHistoryLength) { context.history = context.history.slice(-context.preferences.maxHistoryLength); } await this.learnUserBehavior(message, context); const response: AIResponse = { message: assistantMessage, intent, suggestions: intent.suggestedActions, followUpQuestions: await this.generateFollowUpQuestions(intent, context), context: { currentTopic: intent.intent, entities: context.entities } }; hilog.info(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `AI response generated for intent: ${intent.intent}`); return response; } catch (error) { hilog.error(LogConstants.DOMAIN_APP, LogConstants.TAG_APP, `Failed to process message: ${error}`); throw error; } }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/ai/AIAssistantService.ets#L352-L425
817e0542d9bc1fa97cf7a2ece9a1f582e613a140
github