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
Joker-x-dev/HarmonyKit.git
f97197ce157df7f303244fba42e34918306dfb08
core/designsystem/src/main/ets/component/Column.ets
arkts
渲染布局 @returns {void} 无返回值 @example ColumnEndCenter() { Text("Hi"); }
build(): void { ColumnBase({ options: this.options, justifyContent: FlexAlign.End, alignItems: HorizontalAlign.Center, widthValue: this.widthValue, heightValue: this.heightValue, sizeValue: this.sizeValue, paddingValue: this.paddingValue, marginValue: this.marginValue, fillMaxSize: this.fillMaxSize, bgColor: this.bgColor, onTap: this.onTap, content: this.content }); }
AST#build_method#Left build ( ) : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#build_body#Left { AST#ui_custom_component_statement#Left ColumnBase ( AST#component_parameters#Left { AST#component_parameter#Left options : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left justifyContent : AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . End AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left alignItems : AST#expression#Left AST#member_expression#Left AST#expression#Left HorizontalAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left widthValue : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . widthValue AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left heightValue : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . heightValue AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left sizeValue : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . sizeValue AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left paddingValue : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . paddingValue AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left marginValue : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . marginValue AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left fillMaxSize : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . fillMaxSize AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left bgColor : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . bgColor AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left onTap : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . onTap AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left content : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . content AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) ; AST#ui_custom_component_statement#Right } AST#build_body#Right AST#build_method#Right
build(): void { ColumnBase({ options: this.options, justifyContent: FlexAlign.End, alignItems: HorizontalAlign.Center, widthValue: this.widthValue, heightValue: this.heightValue, sizeValue: this.sizeValue, paddingValue: this.paddingValue, marginValue: this.marginValue, fillMaxSize: this.fillMaxSize, bgColor: this.bgColor, onTap: this.onTap, content: this.content }); }
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/designsystem/src/main/ets/component/Column.ets#L924-L939
0e395e38135a7283514d96c6622769552202ebf2
github
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
feature/main/src/main/ets/viewmodel/MainViewModel.ets
arkts
playSelectedAnimation
播放选中 Tab 的动画并重置其他动画帧 @param {number} index - 选中的 Tab 索引 @returns {void} 无返回值
playSelectedAnimation(index: number): void { this.lottieControllers.forEach((controller: LottieController, controllerIndex: number) => { if (controllerIndex === index) { controller.stop(); controller.play(); return; } controller.stop(); controller.goToAndStop(0, true); }); }
AST#method_declaration#Left playSelectedAnimation AST#parameter_list#Left ( AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . lottieControllers AST#member_expression#Right AST#expression#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left controller : AST#type_annotation#Left AST#primary_type#Left LottieController AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left controllerIndex : 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 controllerIndex AST#expression#Right === AST#expression#Left index 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 controller AST#expression#Right . stop AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left controller AST#expression#Right . play AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#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 controller AST#expression#Right . stop AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left controller AST#expression#Right . goToAndStop AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
playSelectedAnimation(index: number): void { this.lottieControllers.forEach((controller: LottieController, controllerIndex: number) => { if (controllerIndex === index) { controller.stop(); controller.play(); return; } controller.stop(); controller.goToAndStop(0, true); }); }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/main/src/main/ets/viewmodel/MainViewModel.ets#L117-L127
bcfeba4e28d3e2f496b8d5c204ff7be86b232a99
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/recommendation/RecommendationEngine.ets
arkts
推荐项接口
export interface RecommendationItem { id: string; type: RecommendationType; title: string; description: string; confidence: number; // 推荐置信度 (0-1) priority: number; // 优先级 (1-10) metadata: Record<string, string | number | boolean>; tags: string[]; imageUrl?: string; price?: number; rating?: number; createdAt: string; expiresAt?: string; }
AST#export_declaration#Left export AST#interface_declaration#Left interface RecommendationItem AST#object_type#Left { AST#type_member#Left id : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left type : AST#type_annotation#Left AST#primary_type#Left RecommendationType AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left title : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left description : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left confidence : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; // 推荐置信度 (0-1) AST#type_member#Left priority : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; // 优先级 (1-10) AST#type_member#Left metadata : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Record AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left number AST#primary_type#Right | AST#primary_type#Left boolean AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left 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#type_member#Left imageUrl ? : 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 price ? : 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 createdAt : 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 expiresAt ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
export interface RecommendationItem { id: string; type: RecommendationType; title: string; description: string; confidence: number; priority: number; metadata: Record<string, string | number | boolean>; tags: string[]; imageUrl?: string; price?: number; rating?: number; createdAt: string; expiresAt?: string; }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/recommendation/RecommendationEngine.ets#L30-L44
8e5a5c6592dc4d137d3b72cc20dae25ff3fc985e
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/common/components/Alarm/PermissionManager.ets
arkts
权限管理工具类(类似Swift中的static class) 封装权限申请、检查等操作
export default class PermissionManager { /** * 权限组常量声明(类似Kotlin中的companion object) * 包含各功能对应的权限列表 */ static readonly PERMISSION_GROUP: PermissionGroup = { RECORD: ['ohos.permission.MICROPHONE'], // 麦克风权限 STORAGE: ['ohos.permission.STORE_PERSISTENT_DATA'], // 持久化存储权限 CAMERA: ['ohos.permission.CAMERA'], // 相机权限 VIBRATOR: ['ohos.permission.VIBRATE'], // 震动权限 IMAGES: ['ohos.permission.READ_MEDIA'], // 媒体读取权限 NOTIFICATION: ['ohos.permission.PUBLISH_AGENT_REMINDER'], // 代理提醒权限 CAMERA_AND_IMAGES: ['ohos.permission.CAMERA', 'ohos.permission.READ_MEDIA'], // 相机+媒体组合 }; /** * 创建权限管理器实例(类似SwiftUI中的EnvironmentObject) * @returns 权限管理器对象 */ private static getAtManager(): abilityAccessCtrl.AtManager { return abilityAccessCtrl.createAtManager(); // 创建权限管理实例 } /** * 同步获取应用的访问令牌ID(类似Kotlin中的同步方法) * @returns 应用的唯一令牌ID * @throws 获取失败时抛出错误 */ private static getAccessTokenIdSync(): number { try { // 组合标志位获取完整包信息 const flags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA; // 同步获取当前应用包信息 const info = bundleManager.getBundleInfoForSelfSync(flags); return info.appInfo.accessTokenId; // 返回访问令牌ID } catch (err) { throw new Error(`TokenID 获取失败: ${(err as BusinessError).code}`); } } /** * 检查单个权限授权状态(异步方法) * @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; } } /** * 请求权限授权(首次申请) * @param context UIAbility上下文(类似SwiftUI的ViewContext) * @param permissions 权限列表 * @param rationale 权限说明文案(可选) * @returns Promise对象,解析为是否全部授权 */ static async requestPermissions( context: common.UIAbilityContext, permissions: Permissions[], rationale?: string | Resource ): Promise<boolean> { ///检查是是否已经有授权? const allGranted = await Promise.all( permissions.map(permission => PermissionManager.checkPermission(permission)) ); if (allGranted.every(granted => granted)) { return true; } // 如果有说明文案则先显示(类似SwiftUI的alert) if (rationale) { const isGo = await PermissionManager.showRationale(rationale) if(!isGo) { //用户点击取消 return false } } const atMgr = PermissionManager.getAtManager(); try { // 弹出系统权限申请对话框(类似Android的requestPermissions) const result = await atMgr.requestPermissionsFromUser(context, permissions); // 检查所有权限是否都被授予 return result.authResults.every(status => status === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED); } catch (err) { console.error(`权限请求失败: ${(err as BusinessError).code}`); return false; } } /** * 跳转设置页进行二次授权(类似Android的shouldShowRequestPermissionRationale) * @param context UIAbility上下文 * @param permissions 权限列表 * @returns Promise对象,解析为是否全部授权 */ static async requestPermissionOnSetting( context: common.UIAbilityContext, permissions: Permissions[] ): Promise<boolean> { const atMgr = PermissionManager.getAtManager(); try { // 跳转到应用设置页面 const results = await atMgr.requestPermissionOnSetting(context, permissions); return results.every(status => status === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED ); } catch (err) { console.error(`二次授权失败: ${(err as BusinessError).code}`); // 方案3:终极回退方案(跳转应用详情页)[8](@ref) const want: Want = { action: 'action.settings.app.info', uri: `package:${context.abilityInfo.bundleName}` }; await context.startAbility(want); return false; } } /** * 显示权限说明弹窗(私有方法) * @param message 说明文案 * @returns Promise对象,用户点击"继续"后resolve */ private static async showRationale(message: string | Resource): Promise<boolean> { return new Promise((resolve) => { // 创建系统弹窗(类似SwiftUI的Alert) promptAction.showDialog({ title: '权限说明', message, buttons: [ { text: '取消', color: '#999999' }, { text: '继续', color: '#0A59F7' }, ] }).then(res => { if (res.index === 1) { // 用户点击"继续" resolve(true); }else{ resolve(false); } }); }); } /** * 确保权限授权(完整流程:先申请→失败则跳设置页) * @param context UIAbility上下文 * @param permissions 权限列表 * @param rationale 说明文案(可选) * @returns Promise对象,解析为最终是否全部授权 */ static async ensurePermission( context: common.UIAbilityContext, permissions: Permissions[], rationale?: string | Resource ): Promise<boolean> { // 先尝试常规申请 const grantedAll = await PermissionManager.requestPermissions(context, permissions, rationale); if (grantedAll) return true; // 失败后跳转设置页 return await PermissionManager.requestPermissionOnSetting(context, permissions); } // 新增方法:带二次申请流程的权限确保 static async ensurePermissionWithRetry( context: common.UIAbilityContext, permissions: Permissions[], rationale?: string | Resource, retryMessage?: string | Resource // 二次授权提示文案[1](@ref) ): Promise<boolean> { // 1. 首次申请 const firstGranted = await PermissionManager.requestPermissions(context, permissions, rationale); if (firstGranted) return true; // 2. 显示二次授权提示(类似Android的shouldShowRequestPermissionRationale[4,7](@ref)) return new Promise<boolean>(async (resolve) => { promptAction.showDialog({ title: '权限说明', message: retryMessage || '该功能需要权限才能使用,请前往设置开启', buttons: [ { text: '取消', color: '#999999' }, { text: '去设置', color: '#0A59F7' } ] }).then(async (res) => { if (res.index === 1) { // 3. 跳转系统设置页进行二次授权[2,5](@ref) const settingGranted = await PermissionManager.requestPermissionOnSetting(context, permissions); resolve(settingGranted); } else { resolve(false); } }); }); } // ================= 具体权限封装方法 ================= /** 请求录音权限(封装方法) */ static async requestRecordPermission( context: common.UIAbilityContext, rationale?: string | Resource ): Promise<boolean> { return await PermissionManager.requestPermissions( context, [...PermissionManager.PERMISSION_GROUP.RECORD], rationale ); } /** 请求存储权限(封装方法) */ static async requestStoragePermission( context: common.UIAbilityContext, rationale?: string | Resource ): Promise<boolean> { return await PermissionManager.requestPermissions( context, [...PermissionManager.PERMISSION_GROUP.STORAGE], rationale ); } /** 请求相机+媒体权限(封装方法) */ static async requestCameraAndImagesPermission( context: common.UIAbilityContext, rationale?: string | Resource ): Promise<boolean> { return await PermissionManager.requestPermissions( context, [...PermissionManager.PERMISSION_GROUP.CAMERA_AND_IMAGES], rationale ); } /** 请求通知权限(封装方法) */ static async requestNotificationPermission( context: common.UIAbilityContext, rationale?: string | Resource ): Promise<boolean> { return await PermissionManager.requestPermissions( context, [...PermissionManager.PERMISSION_GROUP.NOTIFICATION], rationale ); } }
AST#export_declaration#Left export default AST#class_declaration#Left class PermissionManager AST#class_body#Left { /** * 权限组常量声明(类似Kotlin中的companion object) * 包含各功能对应的权限列表 */ AST#property_declaration#Left static readonly PERMISSION_GROUP : AST#type_annotation#Left AST#primary_type#Left PermissionGroup AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left RECORD AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left 'ohos.permission.MICROPHONE' AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#property_assignment#Right , // 麦克风权限 AST#property_assignment#Left AST#property_name#Left STORAGE AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left 'ohos.permission.STORE_PERSISTENT_DATA' AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#property_assignment#Right , // 持久化存储权限 AST#property_assignment#Left AST#property_name#Left CAMERA AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left 'ohos.permission.CAMERA' AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#property_assignment#Right , // 相机权限 AST#property_assignment#Left AST#property_name#Left VIBRATOR AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left 'ohos.permission.VIBRATE' AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#property_assignment#Right , // 震动权限 AST#property_assignment#Left AST#property_name#Left IMAGES AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left 'ohos.permission.READ_MEDIA' AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#property_assignment#Right , // 媒体读取权限 AST#property_assignment#Left AST#property_name#Left NOTIFICATION AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left 'ohos.permission.PUBLISH_AGENT_REMINDER' AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#property_assignment#Right , // 代理提醒权限 AST#property_assignment#Left AST#property_name#Left CAMERA_AND_IMAGES AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left 'ohos.permission.CAMERA' AST#expression#Right , AST#expression#Left 'ohos.permission.READ_MEDIA' AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#property_assignment#Right , // 相机+媒体组合 } AST#object_literal#Right AST#expression#Right ; AST#property_declaration#Right /** * 创建权限管理器实例(类似SwiftUI中的EnvironmentObject) * @returns 权限管理器对象 */ AST#method_declaration#Left private static getAtManager AST#parameter_list#Left ( ) AST#parameter_list#Right : 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#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 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#return_statement#Right AST#statement#Right // 创建权限管理实例 } AST#block_statement#Right AST#method_declaration#Right /** * 同步获取应用的访问令牌ID(类似Kotlin中的同步方法) * @returns 应用的唯一令牌ID * @throws 获取失败时抛出错误 */ AST#method_declaration#Left private static getAccessTokenIdSync 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#try_statement#Left try AST#block_statement#Left { // 组合标志位获取完整包信息 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left flags = 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 bundleManager AST#expression#Right . BundleFlag AST#member_expression#Right AST#expression#Right . GET_BUNDLE_INFO_WITH_APPLICATION AST#member_expression#Right AST#expression#Right | AST#expression#Left bundleManager AST#expression#Right AST#binary_expression#Right AST#expression#Right . BundleFlag AST#member_expression#Right AST#expression#Right . GET_BUNDLE_INFO_WITH_METADATA 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 info = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left bundleManager AST#expression#Right . getBundleInfoForSelfSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left flags 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 info AST#expression#Right . appInfo AST#member_expression#Right AST#expression#Right . accessTokenId AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right // 返回访问令牌ID } AST#block_statement#Right AST#catch_clause#Left catch ( err ) 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#template_literal#Left ` TokenID 获取失败: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#as_expression#Left AST#expression#Left err AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#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 /** * 检查单个权限授权状态(异步方法) * @param permission 要检查的权限名 * @returns Promise对象,解析为是否已授权 */ 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 /** * 请求权限授权(首次申请) * @param context UIAbility上下文(类似SwiftUI的ViewContext) * @param permissions 权限列表 * @param rationale 权限说明文案(可选) * @returns Promise对象,解析为是否全部授权 */ AST#method_declaration#Left static async requestPermissions AST#parameter_list#Left ( AST#parameter#Left context : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . UIAbilityContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left permissions : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Permissions [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left rationale ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left Resource AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#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 allGranted = 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 Promise AST#expression#Right AST#await_expression#Right AST#expression#Right . all 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 permissions AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left permission => AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left PermissionManager AST#expression#Right . checkPermission AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left permission AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_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 allGranted AST#expression#Right . every AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left granted => AST#expression#Left granted AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#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 // 如果有说明文案则先显示(类似SwiftUI的alert) AST#statement#Left AST#if_statement#Left if ( AST#expression#Left rationale AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left isGo = 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 PermissionManager AST#expression#Right AST#await_expression#Right AST#expression#Right . showRationale AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left rationale 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 isGo AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#block_statement#Left { //用户点击取消 AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#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#if_statement#Right AST#statement#Right 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 AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { // 弹出系统权限申请对话框(类似Android的requestPermissions) AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left result = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left atMgr AST#expression#Right AST#await_expression#Right AST#expression#Right . requestPermissionsFromUser AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right , AST#expression#Left permissions AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 检查所有权限是否都被授予 AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . authResults AST#member_expression#Right AST#expression#Right . every AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left status => 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#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#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 . 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#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 /** * 跳转设置页进行二次授权(类似Android的shouldShowRequestPermissionRationale) * @param context UIAbility上下文 * @param permissions 权限列表 * @returns Promise对象,解析为是否全部授权 */ AST#method_declaration#Left static async requestPermissionOnSetting AST#parameter_list#Left ( AST#parameter#Left context : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . UIAbilityContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left permissions : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Permissions [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left 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 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 AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { // 跳转到应用设置页面 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left results = 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 . requestPermissionOnSetting AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right , AST#expression#Left permissions 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 results AST#expression#Right . every AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left status => 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#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#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 . 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 // 方案3:终极回退方案(跳转应用详情页)[8](@ref) 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 'action.settings.app.info' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left uri AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` package: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left context AST#expression#Right . abilityInfo AST#member_expression#Right AST#expression#Right . bundleName AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_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#await_expression#Left await AST#expression#Left context AST#expression#Right AST#await_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#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 /** * 显示权限说明弹窗(私有方法) * @param message 说明文案 * @returns Promise对象,用户点击"继续"后resolve */ AST#method_declaration#Left private static async showRationale 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_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Promise AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left resolve AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { // 创建系统弹窗(类似SwiftUI的Alert) 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 promptAction AST#expression#Right . showDialog 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 title AST#property_name#Right : AST#expression#Left '权限说明' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left message AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left buttons AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left text AST#property_name#Right : AST#expression#Left '取消' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left '#999999' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left text AST#property_name#Right : AST#expression#Left '继续' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left '#0A59F7' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , ] AST#array_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#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 res => 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 res AST#expression#Right . index 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 resolve AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left resolve AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#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 /** * 确保权限授权(完整流程:先申请→失败则跳设置页) * @param context UIAbility上下文 * @param permissions 权限列表 * @param rationale 说明文案(可选) * @returns Promise对象,解析为最终是否全部授权 */ AST#method_declaration#Left static async ensurePermission AST#parameter_list#Left ( AST#parameter#Left context : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . UIAbilityContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left permissions : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Permissions [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left rationale ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left Resource AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#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 grantedAll = 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 PermissionManager AST#expression#Right AST#await_expression#Right AST#expression#Right . requestPermissions AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right , AST#expression#Left permissions AST#expression#Right , AST#expression#Left rationale 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 grantedAll 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 AST#if_statement#Right AST#statement#Right // 失败后跳转设置页 AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left PermissionManager AST#expression#Right AST#await_expression#Right AST#expression#Right . requestPermissionOnSetting AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right , AST#expression#Left permissions AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right // 新增方法:带二次申请流程的权限确保 AST#method_declaration#Left static async ensurePermissionWithRetry AST#parameter_list#Left ( AST#parameter#Left context : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . UIAbilityContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left permissions : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Permissions [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left rationale ? : 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 retryMessage ? : 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 // 二次授权提示文案[1](@ref) ) 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 { // 1. 首次申请 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left firstGranted = 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 PermissionManager AST#expression#Right AST#await_expression#Right AST#expression#Right . requestPermissions AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right , AST#expression#Left permissions AST#expression#Right , AST#expression#Left rationale 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 firstGranted 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 AST#if_statement#Right AST#statement#Right // 2. 显示二次授权提示(类似Android的shouldShowRequestPermissionRationale[4,7](@ref)) AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Promise AST#expression#Right AST#new_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left async AST#parameter_list#Left ( AST#parameter#Left resolve AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left promptAction AST#expression#Right . showDialog 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 title AST#property_name#Right : AST#expression#Left '权限说明' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left retryMessage AST#expression#Right || AST#expression#Left '该功能需要权限才能使用,请前往设置开启' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left buttons AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left text AST#property_name#Right : AST#expression#Left '取消' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left '#999999' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left text AST#property_name#Right : AST#expression#Left '去设置' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left '#0A59F7' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left async AST#parameter_list#Left ( AST#parameter#Left res 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 res AST#expression#Right . index 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 { // 3. 跳转系统设置页进行二次授权[2,5](@ref) AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left settingGranted = 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 PermissionManager AST#expression#Right AST#await_expression#Right AST#expression#Right . requestPermissionOnSetting AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right , AST#expression#Left permissions 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 resolve AST#expression#Right AST#argument_list#Left ( AST#expression#Left settingGranted AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left resolve AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#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 // ================= 具体权限封装方法 ================= /** 请求录音权限(封装方法) */ AST#method_declaration#Left static async requestRecordPermission AST#parameter_list#Left ( AST#parameter#Left context : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . UIAbilityContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left rationale ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left Resource AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left PermissionManager AST#expression#Right AST#await_expression#Right AST#expression#Right . requestPermissions AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right , AST#expression#Left AST#array_literal#Left [ ... AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left PermissionManager AST#expression#Right . PERMISSION_GROUP AST#member_expression#Right AST#expression#Right . RECORD AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right , AST#expression#Left rationale AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** 请求存储权限(封装方法) */ AST#method_declaration#Left static async requestStoragePermission AST#parameter_list#Left ( AST#parameter#Left context : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . UIAbilityContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left rationale ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left Resource AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left PermissionManager AST#expression#Right AST#await_expression#Right AST#expression#Right . requestPermissions AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right , AST#expression#Left AST#array_literal#Left [ ... AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left PermissionManager AST#expression#Right . PERMISSION_GROUP AST#member_expression#Right AST#expression#Right . STORAGE AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right , AST#expression#Left rationale AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** 请求相机+媒体权限(封装方法) */ AST#method_declaration#Left static async requestCameraAndImagesPermission AST#parameter_list#Left ( AST#parameter#Left context : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . UIAbilityContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left rationale ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left Resource AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left PermissionManager AST#expression#Right AST#await_expression#Right AST#expression#Right . requestPermissions AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right , AST#expression#Left AST#array_literal#Left [ ... AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left PermissionManager AST#expression#Right . PERMISSION_GROUP AST#member_expression#Right AST#expression#Right . CAMERA_AND_IMAGES AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right , AST#expression#Left rationale AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** 请求通知权限(封装方法) */ AST#method_declaration#Left static async requestNotificationPermission AST#parameter_list#Left ( AST#parameter#Left context : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . UIAbilityContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left rationale ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left Resource AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left PermissionManager AST#expression#Right AST#await_expression#Right AST#expression#Right . requestPermissions AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right , AST#expression#Left AST#array_literal#Left [ ... AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left PermissionManager AST#expression#Right . PERMISSION_GROUP AST#member_expression#Right AST#expression#Right . NOTIFICATION AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right , AST#expression#Left rationale 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 default class PermissionManager { static readonly PERMISSION_GROUP: PermissionGroup = { RECORD: ['ohos.permission.MICROPHONE'], STORAGE: ['ohos.permission.STORE_PERSISTENT_DATA'], CAMERA: ['ohos.permission.CAMERA'], VIBRATOR: ['ohos.permission.VIBRATE'], IMAGES: ['ohos.permission.READ_MEDIA'], NOTIFICATION: ['ohos.permission.PUBLISH_AGENT_REMINDER'], CAMERA_AND_IMAGES: ['ohos.permission.CAMERA', 'ohos.permission.READ_MEDIA'], }; private static getAtManager(): abilityAccessCtrl.AtManager { return abilityAccessCtrl.createAtManager(); } private static getAccessTokenIdSync(): number { try { const flags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA; const info = bundleManager.getBundleInfoForSelfSync(flags); return info.appInfo.accessTokenId; } catch (err) { throw new Error(`TokenID 获取失败: ${(err as BusinessError).code}`); } } 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; } } static async requestPermissions( context: common.UIAbilityContext, permissions: Permissions[], rationale?: string | Resource ): Promise<boolean> { const allGranted = await Promise.all( permissions.map(permission => PermissionManager.checkPermission(permission)) ); if (allGranted.every(granted => granted)) { return true; } if (rationale) { const isGo = await PermissionManager.showRationale(rationale) if(!isGo) { return false } } const atMgr = PermissionManager.getAtManager(); try { const result = await atMgr.requestPermissionsFromUser(context, permissions); return result.authResults.every(status => status === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED); } catch (err) { console.error(`权限请求失败: ${(err as BusinessError).code}`); return false; } } static async requestPermissionOnSetting( context: common.UIAbilityContext, permissions: Permissions[] ): Promise<boolean> { const atMgr = PermissionManager.getAtManager(); try { const results = await atMgr.requestPermissionOnSetting(context, permissions); return results.every(status => status === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED ); } catch (err) { console.error(`二次授权失败: ${(err as BusinessError).code}`); const want: Want = { action: 'action.settings.app.info', uri: `package:${context.abilityInfo.bundleName}` }; await context.startAbility(want); return false; } } private static async showRationale(message: string | Resource): Promise<boolean> { return new Promise((resolve) => { promptAction.showDialog({ title: '权限说明', message, buttons: [ { text: '取消', color: '#999999' }, { text: '继续', color: '#0A59F7' }, ] }).then(res => { if (res.index === 1) { resolve(true); }else{ resolve(false); } }); }); } static async ensurePermission( context: common.UIAbilityContext, permissions: Permissions[], rationale?: string | Resource ): Promise<boolean> { const grantedAll = await PermissionManager.requestPermissions(context, permissions, rationale); if (grantedAll) return true; return await PermissionManager.requestPermissionOnSetting(context, permissions); } static async ensurePermissionWithRetry( context: common.UIAbilityContext, permissions: Permissions[], rationale?: string | Resource, retryMessage?: string | Resource ): Promise<boolean> { const firstGranted = await PermissionManager.requestPermissions(context, permissions, rationale); if (firstGranted) return true; return new Promise<boolean>(async (resolve) => { promptAction.showDialog({ title: '权限说明', message: retryMessage || '该功能需要权限才能使用,请前往设置开启', buttons: [ { text: '取消', color: '#999999' }, { text: '去设置', color: '#0A59F7' } ] }).then(async (res) => { if (res.index === 1) { const settingGranted = await PermissionManager.requestPermissionOnSetting(context, permissions); resolve(settingGranted); } else { resolve(false); } }); }); } static async requestRecordPermission( context: common.UIAbilityContext, rationale?: string | Resource ): Promise<boolean> { return await PermissionManager.requestPermissions( context, [...PermissionManager.PERMISSION_GROUP.RECORD], rationale ); } static async requestStoragePermission( context: common.UIAbilityContext, rationale?: string | Resource ): Promise<boolean> { return await PermissionManager.requestPermissions( context, [...PermissionManager.PERMISSION_GROUP.STORAGE], rationale ); } static async requestCameraAndImagesPermission( context: common.UIAbilityContext, rationale?: string | Resource ): Promise<boolean> { return await PermissionManager.requestPermissions( context, [...PermissionManager.PERMISSION_GROUP.CAMERA_AND_IMAGES], rationale ); } static async requestNotificationPermission( context: common.UIAbilityContext, rationale?: string | Resource ): Promise<boolean> { return await PermissionManager.requestPermissions( context, [...PermissionManager.PERMISSION_GROUP.NOTIFICATION], rationale ); } }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/components/Alarm/PermissionManager.ets#L28-L288
855dbd355783b08ccebc291ef0a1d950404a07a1
github
openharmony/codelabs
d899f32a52b2ae0dfdbb86e34e8d94645b5d4090
ETSUI/OHLayoutAlign/entry/src/main/ets/viewmodel/IndexData.ets
arkts
get Index page dataList
export function getIndexList(): Array<IndexListItem> { let indexModuleArray: Array<IndexListItem> = [] INDEX_LIST.forEach((item: IndexListItem) => { indexModuleArray.push(item); }) return indexModuleArray; }
AST#export_declaration#Left export AST#function_declaration#Left function getIndexList AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left IndexListItem 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 indexModuleArray : 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 IndexListItem 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#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#ERROR#Left INDEX_LIST AST#ERROR#Right . forEach AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left IndexListItem 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 indexModuleArray AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left item AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left return AST#ERROR#Right in AST#expression#Left dexModuleArray AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export function getIndexList(): Array<IndexListItem> { let indexModuleArray: Array<IndexListItem> = [] INDEX_LIST.forEach((item: IndexListItem) => { indexModuleArray.push(item); }) return indexModuleArray; }
https://github.com/openharmony/codelabs/blob/d899f32a52b2ae0dfdbb86e34e8d94645b5d4090/ETSUI/OHLayoutAlign/entry/src/main/ets/viewmodel/IndexData.ets#L23-L29
c18e8cad02a20c71d5225059f550f46e7c066823
gitee
WinWang/HarmoneyOpenEye.git
57f0542795336009aa0d46fd9fa5b07facc2ae87
entry/src/main/ets/utils/DialogUtils.ets
arkts
隐藏loading
export function hideLoadingDialog() { emitter.emit(loadingEvent, LoadingDialogEvent(false, "")) }
AST#export_declaration#Left export AST#function_declaration#Left function hideLoadingDialog 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 emitter AST#expression#Right . emit AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left loadingEvent AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left LoadingDialogEvent AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right , AST#expression#Left "" AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export function hideLoadingDialog() { emitter.emit(loadingEvent, LoadingDialogEvent(false, "")) }
https://github.com/WinWang/HarmoneyOpenEye.git/blob/57f0542795336009aa0d46fd9fa5b07facc2ae87/entry/src/main/ets/utils/DialogUtils.ets#L16-L18
12a637ab7f1fa1d06a1fd94f642adf1c177134be
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/iconmaincolor/src/main/ets/components/utils/ColorUtils.ets
arkts
rgb2hsv
RGB格式转换为HSV格式,公式参考resources/base/media/rgb_to_hsv.png @param color RGB像素值 @returns HSV像素值
public static rgb2hsv(color: ColorRgb): ColorHsv { // RGB颜色取值范围是0~255,需要转换为0~1的浮点数 const red: number = color.red / MAX_RGB_VALUE; const green: number = color.green / MAX_RGB_VALUE; const blue: number = color.blue / MAX_RGB_VALUE; const max: number = Math.max(red, green, blue); const min: number = Math.min(red, green, blue); const delta: number = max - min; // 色调 let hue: number = 0; // 饱和度 let saturation: number = 0; // 明度 let value: number = 0; // 计算hue值 if (max === min) { hue = 0; } else if (Math.abs(max - red) < Number.EPSILON) { hue = (green >= blue ? ((green - blue) / delta) * 60 : ((green - blue) / delta) * 60 + 360); } else if (Math.abs(max - green) < Number.EPSILON) { hue = (((blue - red) / delta) + 2) * 60; } else if (Math.abs(max - blue) < Number.EPSILON) { hue = (((red - green) / delta) + 4) * 60; } // 计算saturation值 saturation = (max === 0 ? 0 : delta / max); // 计算value值 value = max; return { hue: hue, saturation: saturation, value: value, alpha: color.alpha } }
AST#method_declaration#Left public static rgb2hsv AST#parameter_list#Left ( AST#parameter#Left color : AST#type_annotation#Left AST#primary_type#Left ColorRgb AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left ColorHsv AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { // RGB颜色取值范围是0~255,需要转换为0~1的浮点数 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left red : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left color AST#expression#Right . red AST#member_expression#Right AST#expression#Right / AST#expression#Left MAX_RGB_VALUE AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left green : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left color AST#expression#Right . green AST#member_expression#Right AST#expression#Right / AST#expression#Left MAX_RGB_VALUE AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left blue : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left color AST#expression#Right . blue AST#member_expression#Right AST#expression#Right / AST#expression#Left MAX_RGB_VALUE AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left max : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . max AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left red AST#expression#Right , AST#expression#Left green AST#expression#Right , AST#expression#Left blue 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 min : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . min AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left red AST#expression#Right , AST#expression#Left green AST#expression#Right , AST#expression#Left blue 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 delta : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left max AST#expression#Right - AST#expression#Left min AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 色调 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left hue : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 饱和度 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left saturation : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 明度 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left value : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 计算hue值 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left max AST#expression#Right === AST#expression#Left min 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 hue = AST#expression#Left 0 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#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 Math AST#expression#Right . abs AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left max AST#expression#Right - AST#expression#Left red AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right < AST#expression#Left Number AST#expression#Right AST#binary_expression#Right AST#expression#Right . EPSILON 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 hue = AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left green AST#expression#Right >= AST#expression#Left blue AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left green AST#expression#Right - AST#expression#Left blue AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right / AST#expression#Left delta AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right * AST#expression#Left 60 AST#expression#Right AST#binary_expression#Right AST#expression#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#parenthesized_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 green AST#expression#Right - AST#expression#Left blue AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right / AST#expression#Left delta AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right * AST#expression#Left 60 AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left 360 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#conditional_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 else AST#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 Math AST#expression#Right . abs AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left max AST#expression#Right - AST#expression#Left green AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right < AST#expression#Left Number AST#expression#Right AST#binary_expression#Right AST#expression#Right . EPSILON 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 hue = 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#parenthesized_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 blue AST#expression#Right - AST#expression#Left red AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right / AST#expression#Left delta AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right + AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right * AST#expression#Left 60 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#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 Math AST#expression#Right . abs AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left max AST#expression#Right - AST#expression#Left blue AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right < AST#expression#Left Number AST#expression#Right AST#binary_expression#Right AST#expression#Right . EPSILON 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 hue = 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#parenthesized_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 red AST#expression#Right - AST#expression#Left green AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right / AST#expression#Left delta 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#parenthesized_expression#Right AST#expression#Right * AST#expression#Left 60 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#if_statement#Right AST#if_statement#Right AST#statement#Right // 计算saturation值 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left saturation = AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left max AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left 0 AST#expression#Right : AST#expression#Left AST#binary_expression#Left AST#expression#Left delta AST#expression#Right / AST#expression#Left max AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#conditional_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 // 计算value值 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left value = AST#expression#Left max 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#object_literal#Left { AST#property_assignment#Left AST#property_name#Left hue AST#property_name#Right : AST#expression#Left hue AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left saturation AST#property_name#Right : AST#expression#Left saturation AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left value AST#property_name#Right : AST#expression#Left value AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left alpha AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left color AST#expression#Right . alpha 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
public static rgb2hsv(color: ColorRgb): ColorHsv { const red: number = color.red / MAX_RGB_VALUE; const green: number = color.green / MAX_RGB_VALUE; const blue: number = color.blue / MAX_RGB_VALUE; const max: number = Math.max(red, green, blue); const min: number = Math.min(red, green, blue); const delta: number = max - min; let hue: number = 0; let saturation: number = 0; let value: number = 0; if (max === min) { hue = 0; } else if (Math.abs(max - red) < Number.EPSILON) { hue = (green >= blue ? ((green - blue) / delta) * 60 : ((green - blue) / delta) * 60 + 360); } else if (Math.abs(max - green) < Number.EPSILON) { hue = (((blue - red) / delta) + 2) * 60; } else if (Math.abs(max - blue) < Number.EPSILON) { hue = (((red - green) / delta) + 4) * 60; } saturation = (max === 0 ? 0 : delta / max); value = max; return { hue: hue, saturation: saturation, value: value, alpha: color.alpha } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/iconmaincolor/src/main/ets/components/utils/ColorUtils.ets#L59-L96
74aedd1b436fe3434fed1738869b415d9d7b1f83
gitee
openharmony/xts_acts
5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686
arkui/ace_ets_module_ui/ace_ets_module_animation/ace_ets_module_animation_api11/entry/src/main/ets/MainAbility/pages/RouteType/RouteType1.ets
arkts
pageTransition
自定义方式1:完全自定义转场过程的效果
pageTransition() { PageTransitionEnter({ type: RouteType.Pop, duration: 1200, curve: Curve.Linear }) .onEnter((type: RouteType, progress: number) => { this.scale1 = 1 this.opacity1 = progress }) // 进场过程中会逐帧触发onEnter回调,入参为动效的归一化进度(0% -- 100%) PageTransitionExit({ duration: 1200, curve: Curve.Ease }) .onExit((type: RouteType, progress: number) => { this.scale1 = 1 - progress this.opacity1 = 1 }) // 退场过程中会逐帧触发onExit回调,入参为动效的归一化进度(0% -- 100%) }
AST#method_declaration#Left pageTransition 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 PageTransitionEnter ( AST#component_parameters#Left { AST#component_parameter#Left type : AST#expression#Left AST#member_expression#Left AST#expression#Left RouteType AST#expression#Right . Pop AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left duration : AST#expression#Left 1200 AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left curve : AST#expression#Left AST#member_expression#Left AST#expression#Left Curve AST#expression#Right . Linear AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . onEnter ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left type : AST#type_annotation#Left AST#primary_type#Left RouteType AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left progress : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#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 . scale1 AST#member_expression#Right = AST#expression#Left 1 AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . opacity1 AST#member_expression#Right = AST#expression#Left progress AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 进场过程中会逐帧触发onEnter回调,入参为动效的归一化进度(0% -- 100%) AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left PageTransitionExit ( AST#component_parameters#Left { AST#component_parameter#Left duration : AST#expression#Left 1200 AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left curve : AST#expression#Left AST#member_expression#Left AST#expression#Left Curve AST#expression#Right . Ease AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . onExit ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left type : AST#type_annotation#Left AST#primary_type#Left RouteType AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left progress : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#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 . scale1 AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left 1 AST#expression#Right - AST#expression#Left progress AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . opacity1 AST#member_expression#Right = AST#expression#Left 1 AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 退场过程中会逐帧触发onExit回调,入参为动效的归一化进度(0% -- 100%) } AST#builder_function_body#Right AST#method_declaration#Right
pageTransition() { PageTransitionEnter({ type: RouteType.Pop, duration: 1200, curve: Curve.Linear }) .onEnter((type: RouteType, progress: number) => { this.scale1 = 1 this.opacity1 = progress }) PageTransitionExit({ duration: 1200, curve: Curve.Ease }) .onExit((type: RouteType, progress: number) => { this.scale1 = 1 - progress this.opacity1 = 1 }) }
https://github.com/openharmony/xts_acts/blob/5eb33396ca0ffafd9e5d0ba4b5dedfde44aff686/arkui/ace_ets_module_ui/ace_ets_module_animation/ace_ets_module_animation_api11/entry/src/main/ets/MainAbility/pages/RouteType/RouteType1.ets#L35-L46
63cab27f9768459840fc75798898be1713984f46
gitee
open9527/OpenHarmony
fdea69ed722d426bf04e817ec05bff4002e81a4e
libs/core/src/main/ets/utils/StringUtils.ets
arkts
capitalize
转换字符串首字母为大写,剩下为小写 @param str 待转换的字符串 @returns 转换后的
static capitalize(str: string = ''): string { if (!str) { return ''; } const firstChar = str.charAt(0).toUpperCase(); const restChars = str.slice(1).toLowerCase(); return firstChar + restChars; }
AST#method_declaration#Left static capitalize 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#expression#Left '' AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left str AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left '' AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left firstChar = 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 str AST#expression#Right . charAt 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 . toUpperCase 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 restChars = 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 str AST#expression#Right . slice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 1 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . toLowerCase AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left firstChar AST#expression#Right + AST#expression#Left restChars AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static capitalize(str: string = ''): string { if (!str) { return ''; } const firstChar = str.charAt(0).toUpperCase(); const restChars = str.slice(1).toLowerCase(); return firstChar + restChars; }
https://github.com/open9527/OpenHarmony/blob/fdea69ed722d426bf04e817ec05bff4002e81a4e/libs/core/src/main/ets/utils/StringUtils.ets#L168-L175
16cee4632313d274cb87c4523e61ae390f201305
gitee
openharmony/arkui_ace_engine
30c7d1ee12fbedf0fabece54291d75897e2ad44f
examples/Select/entry/src/main/ets/pages/components/form.ets
arkts
handleProvinceChange
处理省份选择变化
private handleProvinceChange(province: string) { this.formData.province = province this.formData.city = '' const selectedProvince = this.areaData.find(item => item.province === province) this.cityOptions = selectedProvince ? selectedProvince.cities.map(item => { return { value: item } as SelectOption }) : [{ value: '' }] }
AST#method_declaration#Left private handleProvinceChange AST#parameter_list#Left ( AST#parameter#Left province : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . formData AST#member_expression#Right AST#expression#Right . province AST#member_expression#Right = AST#expression#Left province AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . formData AST#member_expression#Right AST#expression#Right . city AST#member_expression#Right = AST#expression#Left '' AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left const AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left selectedProvince = 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 . areaData AST#member_expression#Right AST#expression#Right . find 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 . province AST#member_expression#Right AST#expression#Right === AST#expression#Left province AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . cityOptions AST#member_expression#Right = AST#expression#Left AST#conditional_expression#Left AST#expression#Left selectedProvince AST#expression#Right ? AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left selectedProvince AST#expression#Right . cities AST#member_expression#Right AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left item => AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#as_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left value AST#property_name#Right : AST#expression#Left item AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left SelectOption AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left value AST#property_name#Right : AST#expression#Left '' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#conditional_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
private handleProvinceChange(province: string) { this.formData.province = province this.formData.city = '' const selectedProvince = this.areaData.find(item => item.province === province) this.cityOptions = selectedProvince ? selectedProvince.cities.map(item => { return { value: item } as SelectOption }) : [{ value: '' }] }
https://github.com/openharmony/arkui_ace_engine/blob/30c7d1ee12fbedf0fabece54291d75897e2ad44f/examples/Select/entry/src/main/ets/pages/components/form.ets#L194-L201
0a480823520351e2e69c05fa1fa1902c45e728c2
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/llm/LLMService.ets
arkts
getStatus
获取状态
getStatus(): LLMStatus { return { configured: this.status.configured, provider: this.status.provider, lastUsed: this.status.lastUsed, errorCount: this.status.errorCount }; }
AST#method_declaration#Left getStatus AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left LLMStatus AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left configured AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . status AST#member_expression#Right AST#expression#Right . configured AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left provider AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . status AST#member_expression#Right AST#expression#Right . provider AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left lastUsed AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . status AST#member_expression#Right AST#expression#Right . lastUsed AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left errorCount AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . status AST#member_expression#Right AST#expression#Right . errorCount 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
getStatus(): LLMStatus { return { configured: this.status.configured, provider: this.status.provider, lastUsed: this.status.lastUsed, errorCount: this.status.errorCount }; }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/llm/LLMService.ets#L263-L270
f444ba19b056b1ec22f1ba29db586eaab0a65331
github
wangjinyuan/JS-TS-ArkTS-database.git
a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26
npm/ali-react-table-monorepo/99.10.9/package/index.ets
arkts
getPathChunks
应用约束:9. 使用let代替var
function getPathChunks(path: string): string { let str = "p"; const chunks = path.split('/'); for (let i = 0; i < chunks.length; i++) { str += toHex(chunks[i]) + "."; } str = str.slice(0, -1) + "p"; return str; }
AST#function_declaration#Left function getPathChunks AST#parameter_list#Left ( AST#parameter#Left path : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left str = AST#expression#Left "p" 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 chunks = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left path 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#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left i = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left i AST#expression#Right < AST#expression#Left chunks AST#expression#Right AST#binary_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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left str += AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left toHex AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left chunks AST#expression#Right [ AST#expression#Left i AST#expression#Right ] AST#subscript_expression#Right 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#for_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left str = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . slice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left "p" AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left str AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right
function getPathChunks(path: string): string { let str = "p"; const chunks = path.split('/'); for (let i = 0; i < chunks.length; i++) { str += toHex(chunks[i]) + "."; } str = str.slice(0, -1) + "p"; return str; }
https://github.com/wangjinyuan/JS-TS-ArkTS-database.git/blob/a84793be4f73d4fc7ff0a44d2e15dbb93c5aab26/npm/ali-react-table-monorepo/99.10.9/package/index.ets#L65-L73
06cacfbe5326874ee22b8bf68ca69a2f975d9f22
github
openharmony-tpc/ohos_mpchart
4fb43a7137320ef2fee2634598f53d93975dfb4a
library/src/main/ets/components/charts/PieChartModel.ets
arkts
getHoleRadius
Returns the size of the hole radius in percent of the total radius. @return
public getHoleRadius(): number { return this.mHoleRadiusPercent; }
AST#method_declaration#Left public getHoleRadius 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 . mHoleRadiusPercent AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
public getHoleRadius(): number { return this.mHoleRadiusPercent; }
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/library/src/main/ets/components/charts/PieChartModel.ets#L632-L634
83b142eda8670c90e9b619ca9ffd8f756358cc8d
gitee
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/SystemFeature/DeviceManagement/DeviceManagementCollection/feature/capabilities/src/main/ets/util/DeviceUtil.ets
arkts
buildUser
构建用户
static buildUser(): string { return deviceInfo.buildUser }
AST#method_declaration#Left static buildUser AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left deviceInfo AST#expression#Right . buildUser AST#member_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static buildUser(): string { return deviceInfo.buildUser }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/SystemFeature/DeviceManagement/DeviceManagementCollection/feature/capabilities/src/main/ets/util/DeviceUtil.ets#L195-L197
ccb866c57ddc378feda77f13a47408d09d5b9632
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/pages/Index.ets
arkts
buildGeneratedGreeting
生成的祝福语项
@Builder buildGeneratedGreeting(text: string) { Row({ space: 12 }) { Text(text) .fontSize(14) .fontColor(this.COLORS.textPrimary) .lineHeight(20) .layoutWeight(1) Row({ space: 8 }) { // 复制按钮 Text('📋') .fontSize(16) .padding(6) .backgroundColor(this.COLORS.gray100) .borderRadius(6) .onClick(async () => { await this.copyGreetingToClipboard(text); }) // 收藏按钮 Text(this.isGreetingFavorited(text) ? '❤️' : '🤍') .fontSize(16) .padding(6) .backgroundColor(this.isGreetingFavorited(text) ? this.COLORS.redLight : this.COLORS.gray100) .borderRadius(6) .onClick(() => { this.toggleGreetingFavorite(text); }) } } .width('100%') .padding(12) .backgroundColor(this.COLORS.gray50) .borderRadius(8) }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildGeneratedGreeting AST#parameter_list#Left ( AST#parameter#Left text : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 12 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left text AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . COLORS AST#member_expression#Right AST#expression#Right . textPrimary AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . lineHeight ( AST#expression#Left 20 AST#expression#Right ) AST#modifier_chain_expression#Left . layoutWeight ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 8 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { // 复制按钮 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '📋' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left 6 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . COLORS AST#member_expression#Right AST#expression#Right . gray100 AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 6 AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left async AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#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 . copyGreetingToClipboard AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left text AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 收藏按钮 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isGreetingFavorited AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left text AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ? AST#expression#Left '❤️' AST#expression#Right : AST#expression#Left '🤍' AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left 6 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isGreetingFavorited AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left text AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . COLORS AST#member_expression#Right AST#expression#Right . redLight AST#member_expression#Right AST#expression#Right : AST#expression#Left this AST#expression#Right AST#conditional_expression#Right AST#expression#Right . COLORS AST#member_expression#Right AST#expression#Right . gray100 AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 6 AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . toggleGreetingFavorite AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left text AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left 12 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . COLORS AST#member_expression#Right AST#expression#Right . gray50 AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 8 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
@Builder buildGeneratedGreeting(text: string) { Row({ space: 12 }) { Text(text) .fontSize(14) .fontColor(this.COLORS.textPrimary) .lineHeight(20) .layoutWeight(1) Row({ space: 8 }) { Text('📋') .fontSize(16) .padding(6) .backgroundColor(this.COLORS.gray100) .borderRadius(6) .onClick(async () => { await this.copyGreetingToClipboard(text); }) Text(this.isGreetingFavorited(text) ? '❤️' : '🤍') .fontSize(16) .padding(6) .backgroundColor(this.isGreetingFavorited(text) ? this.COLORS.redLight : this.COLORS.gray100) .borderRadius(6) .onClick(() => { this.toggleGreetingFavorite(text); }) } } .width('100%') .padding(12) .backgroundColor(this.COLORS.gray50) .borderRadius(8) }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/Index.ets#L3187-L3222
205e36c738d2d31f459031d9b9c3cad13a5cef8c
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/componentstack/src/main/ets/view/ComponentStack.ets
arkts
ComponentStackComponent
向上偏移的距离
@Component export struct ComponentStackComponent { build() { // TODO: 知识点:堆叠容器,子组件按照顺序依次入栈,后一个子组件覆盖前一个子组件。 Stack({ alignContent: Alignment.Top }) { Flex({ justifyContent: FlexAlign.SpaceBetween }) { Image($r("app.media.component_stack_user_portrait")) .width($r("app.integer.component_stack_user_portrait_width")) .aspectRatio(ASPECTRATIO) .borderRadius($r("app.integer.component_stack_user_portrait_border_radius")) .onClick(() => { promptAction.showToast({ message: $r('app.string.component_stack_other_function') }); }); Image($r("app.media.component_stack_stack_scan")) .width($r("app.integer.component_stack_scan_width")) .aspectRatio(ASPECTRATIO) .onClick(() => { promptAction.showToast({ message: $r('app.string.component_stack_other_function') }); }); } .padding({ left: $r("app.integer.component_stack_flex_padding_left"), right: $r("app.integer.component_stack_flex_padding_right"), top: $r("app.integer.component_stack_flex_padding_top") }) .width('100%').height($r("app.integer.component_stack_flex_height")) ScrollView() // 自身和子节点都响应触摸测试,不会阻塞兄弟节点的触摸测试。 .hitTestBehavior(HitTestMode.Transparent) } .width('100%') .height('100%') .backgroundColor($r('app.color.component_stack_product_background')) .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM]) } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct ComponentStackComponent AST#component_body#Left { AST#build_method#Left build ( ) AST#build_body#Left { // TODO: 知识点:堆叠容器,子组件按照顺序依次入栈,后一个子组件覆盖前一个子组件。 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Stack ( AST#component_parameters#Left { AST#component_parameter#Left alignContent : AST#expression#Left AST#member_expression#Left AST#expression#Left Alignment AST#expression#Right . Top AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Flex ( AST#component_parameters#Left { AST#component_parameter#Left justifyContent : AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . SpaceBetween AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.media.component_stack_user_portrait" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.component_stack_user_portrait_width" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . aspectRatio ( AST#expression#Left ASPECTRATIO AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.component_stack_user_portrait_border_radius" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left promptAction AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.component_stack_other_function' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.media.component_stack_stack_scan" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.component_stack_scan_width" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . aspectRatio ( AST#expression#Left ASPECTRATIO AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left promptAction AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.component_stack_other_function' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#ERROR#Left ; AST#ERROR#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.component_stack_flex_padding_left" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.component_stack_flex_padding_right" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.component_stack_flex_padding_top" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.integer.component_stack_flex_height" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left ScrollView ( ) AST#ui_component#Right // 自身和子节点都响应触摸测试,不会阻塞兄弟节点的触摸测试。 AST#modifier_chain_expression#Left . hitTestBehavior ( AST#expression#Left AST#member_expression#Left AST#expression#Left HitTestMode AST#expression#Right . Transparent AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.component_stack_product_background' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . expandSafeArea ( AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left SafeAreaType AST#expression#Right . SYSTEM AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left SafeAreaEdge AST#expression#Right . BOTTOM AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right ) AST#modifier_chain_expression#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 ComponentStackComponent { build() { Stack({ alignContent: Alignment.Top }) { Flex({ justifyContent: FlexAlign.SpaceBetween }) { Image($r("app.media.component_stack_user_portrait")) .width($r("app.integer.component_stack_user_portrait_width")) .aspectRatio(ASPECTRATIO) .borderRadius($r("app.integer.component_stack_user_portrait_border_radius")) .onClick(() => { promptAction.showToast({ message: $r('app.string.component_stack_other_function') }); }); Image($r("app.media.component_stack_stack_scan")) .width($r("app.integer.component_stack_scan_width")) .aspectRatio(ASPECTRATIO) .onClick(() => { promptAction.showToast({ message: $r('app.string.component_stack_other_function') }); }); } .padding({ left: $r("app.integer.component_stack_flex_padding_left"), right: $r("app.integer.component_stack_flex_padding_right"), top: $r("app.integer.component_stack_flex_padding_top") }) .width('100%').height($r("app.integer.component_stack_flex_height")) ScrollView() .hitTestBehavior(HitTestMode.Transparent) } .width('100%') .height('100%') .backgroundColor($r('app.color.component_stack_product_background')) .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM]) } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/componentstack/src/main/ets/view/ComponentStack.ets#L49-L86
74ab2b25f28d68718b95432d29ffef37cb84e9b6
gitee
851432669/Smart-Home-ArkTs-Hi3861.git
0451f85f072ed3281cc23d9cdc2843d79f60f975
entry/src/main/ets/common/utils/GlobalDataManager.ets
arkts
setEnvironmentData
设置环境数据
setEnvironmentData(data: EnvironmentDataItem[]): void { this.environmentData = data; this.isDataLoaded = true; }
AST#method_declaration#Left setEnvironmentData AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left EnvironmentDataItem [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . environmentData AST#member_expression#Right = AST#expression#Left data 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 . isDataLoaded 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#builder_function_body#Right AST#method_declaration#Right
setEnvironmentData(data: EnvironmentDataItem[]): void { this.environmentData = data; this.isDataLoaded = true; }
https://github.com/851432669/Smart-Home-ArkTs-Hi3861.git/blob/0451f85f072ed3281cc23d9cdc2843d79f60f975/entry/src/main/ets/common/utils/GlobalDataManager.ets#L132-L135
fbd3088c9441bfb68bd663c763dbe87871483b44
github
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
NetworkManagement/entry/src/main/ets/pages/WiFiQuery.ets
arkts
addCandidateConfig
[End get_signal_level] [Start add_candidate_config]
addCandidateConfig() { try { let config: wifiManager.WifiDeviceConfig = { ssid: '****', preSharedKey: '****', securityType: 0 }; wifiManager.addCandidateConfig(config).then(result => { hilog.info(0x0000, 'Sample', 'result: %{public}s', JSON.stringify(result)); }).catch((err: number) => { hilog.error(0x0000, 'Sample', 'failed: err->: %{public}s', JSON.stringify(err)); }); // [StartExclude add_candidate_config] this.textArea = JSON.stringify(config); // [EndExclude add_candidate_config] } catch (error) { hilog.error(0x0000, 'Sample', 'failed: err->: %{public}s', JSON.stringify(error)); } }
AST#method_declaration#Left addCandidateConfig AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left config : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left wifiManager . WifiDeviceConfig AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left ssid AST#property_name#Right : AST#expression#Left '****' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left preSharedKey AST#property_name#Right : AST#expression#Left '****' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left securityType AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#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 wifiManager AST#expression#Right . addCandidateConfig AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left config AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left result => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left 'Sample' AST#expression#Right , AST#expression#Left 'result: %{public}s' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left result AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . 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 number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left 'Sample' AST#expression#Right , AST#expression#Left 'failed: err->: %{public}s' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // [StartExclude add_candidate_config] 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 . textArea AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left config 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 // [EndExclude add_candidate_config] } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left 'Sample' AST#expression#Right , AST#expression#Left 'failed: err->: %{public}s' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
addCandidateConfig() { try { let config: wifiManager.WifiDeviceConfig = { ssid: '****', preSharedKey: '****', securityType: 0 }; wifiManager.addCandidateConfig(config).then(result => { hilog.info(0x0000, 'Sample', 'result: %{public}s', JSON.stringify(result)); }).catch((err: number) => { hilog.error(0x0000, 'Sample', 'failed: err->: %{public}s', JSON.stringify(err)); }); this.textArea = JSON.stringify(config); } catch (error) { hilog.error(0x0000, 'Sample', 'failed: err->: %{public}s', JSON.stringify(error)); } }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/NetworkManagement/entry/src/main/ets/pages/WiFiQuery.ets#L88-L106
ea86e1374382c3d7a4c035907a24811a1f5f41fd
gitee
zqaini002/YaoYaoLingXian.git
5095b12cbeea524a87c42d0824b1702978843d39
YaoYaoLingXian/entry/src/main/ets/utils/PromptUtils.ets
arkts
显示加载提示 @param message 消息内容
export function showLoading(message: string = '加载中...') { try { promptAction.showToast({ message: message, duration: 2000 }); } catch (error) { console.error('显示加载提示失败:', error); } }
AST#export_declaration#Left export AST#function_declaration#Left function showLoading 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#expression#Left '加载中...' AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 2000 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '显示加载提示失败:' AST#expression#Right , AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export function showLoading(message: string = '加载中...') { try { promptAction.showToast({ message: message, duration: 2000 }); } catch (error) { console.error('显示加载提示失败:', error); } }
https://github.com/zqaini002/YaoYaoLingXian.git/blob/5095b12cbeea524a87c42d0824b1702978843d39/YaoYaoLingXian/entry/src/main/ets/utils/PromptUtils.ets#L77-L86
b7c586d3f23dabe2156b9f4a2c6d86502b490b12
github
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_crypto/src/main/ets/crypto/encryption/SM4.ets
arkts
decodeCBC
解密-CBC模式 @param str 加密的字符串 @param aesKey SM4密钥 @param iv iv偏移量字符串 @returns
static async decodeCBC(str: string, sm4Key: string, iv: string): Promise<string> { return CryptoUtil.decodeCBC(str, sm4Key, iv, 'SM4_128', 'SM4_128|CBC|PKCS7',128); }
AST#method_declaration#Left static async decodeCBC 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 sm4Key : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left iv : 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 . decodeCBC AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left str AST#expression#Right , AST#expression#Left sm4Key AST#expression#Right , AST#expression#Left iv AST#expression#Right , AST#expression#Left 'SM4_128' AST#expression#Right , AST#expression#Left 'SM4_128|CBC|PKCS7' AST#expression#Right , AST#expression#Left 128 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static async decodeCBC(str: string, sm4Key: string, iv: string): Promise<string> { return CryptoUtil.decodeCBC(str, sm4Key, iv, 'SM4_128', 'SM4_128|CBC|PKCS7',128); }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto/src/main/ets/crypto/encryption/SM4.ets#L73-L75
778008772c4755433ff30768b6600232f1977dfe
gitee
awa_Liny/LinysBrowser_NEXT
a5cd96a9aa8114cae4972937f94a8967e55d4a10
home/src/main/ets/processes/tabs_actions.ets
arkts
Determines if extra background is needed, and saves this to key 'extra_background' in AppStorage. An extra background is for those websites who do not have background colors, so that they would be more readable.
export function determine_extra_background(storage: LocalStorage) { let need_extra_background = true; // Determine background if (!storage.get('meowWebView_init_OK') as boolean) { need_extra_background = false; } let tab_urls = storage.get('tab_urls') as string[]; let tabs = storage.get('bunch_of_tabs') as bunch_of_tabs; let main_tab_url = tab_urls[tabs.main_tab_idx]; main_tab_url = url_resource_to_meow(main_tab_url); let sub_tab_url = tab_urls[tabs.sub_tab_idx]; sub_tab_url = url_resource_to_meow(sub_tab_url); if (tabs.sub_tab_idx > -1) { // Paralleowing if (main_tab_url == 'meow://home' && sub_tab_url == 'meow://home') { console.log('[Meow] Extra background false due to paralleow home!') need_extra_background = false; } } else { // Not Paralleowing if (main_tab_url == 'meow://home') { need_extra_background = false; } } storage.set('extra_background', need_extra_background); }
AST#export_declaration#Left export AST#function_declaration#Left function determine_extra_background AST#parameter_list#Left ( AST#parameter#Left storage : AST#type_annotation#Left AST#primary_type#Left LocalStorage AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left need_extra_background = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // Determine background AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left storage AST#expression#Right AST#unary_expression#Right AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'meowWebView_init_OK' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left need_extra_background = 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#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left tab_urls = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left storage AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'tab_urls' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left string [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left tabs = AST#expression#Left AST#as_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left storage AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'bunch_of_tabs' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left bunch_of_tabs AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left main_tab_url = AST#expression#Left AST#subscript_expression#Left AST#expression#Left tab_urls AST#expression#Right [ AST#expression#Left AST#member_expression#Left AST#expression#Left tabs AST#expression#Right . main_tab_idx AST#member_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 main_tab_url = AST#expression#Left AST#call_expression#Left AST#expression#Left url_resource_to_meow AST#expression#Right AST#argument_list#Left ( AST#expression#Left main_tab_url AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left sub_tab_url = AST#expression#Left AST#subscript_expression#Left AST#expression#Left tab_urls AST#expression#Right [ AST#expression#Left AST#member_expression#Left AST#expression#Left tabs AST#expression#Right . sub_tab_idx AST#member_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 sub_tab_url = AST#expression#Left AST#call_expression#Left AST#expression#Left url_resource_to_meow AST#expression#Right AST#argument_list#Left ( AST#expression#Left sub_tab_url 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 tabs AST#expression#Right . sub_tab_idx AST#member_expression#Right AST#expression#Right > AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { // Paralleowing 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 main_tab_url AST#expression#Right == AST#expression#Left 'meow://home' AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left AST#binary_expression#Left AST#expression#Left sub_tab_url AST#expression#Right == AST#expression#Left 'meow://home' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '[Meow] Extra background false due to paralleow home!' 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 need_extra_background = 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 else AST#block_statement#Left { // Not Paralleowing AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left main_tab_url AST#expression#Right == AST#expression#Left 'meow://home' 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 need_extra_background = 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#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 storage AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'extra_background' AST#expression#Right , AST#expression#Left need_extra_background AST#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 determine_extra_background(storage: LocalStorage) { let need_extra_background = true; if (!storage.get('meowWebView_init_OK') as boolean) { need_extra_background = false; } let tab_urls = storage.get('tab_urls') as string[]; let tabs = storage.get('bunch_of_tabs') as bunch_of_tabs; let main_tab_url = tab_urls[tabs.main_tab_idx]; main_tab_url = url_resource_to_meow(main_tab_url); let sub_tab_url = tab_urls[tabs.sub_tab_idx]; sub_tab_url = url_resource_to_meow(sub_tab_url); if (tabs.sub_tab_idx > -1) { if (main_tab_url == 'meow://home' && sub_tab_url == 'meow://home') { console.log('[Meow] Extra background false due to paralleow home!') need_extra_background = false; } } else { if (main_tab_url == 'meow://home') { need_extra_background = false; } } storage.set('extra_background', need_extra_background); }
https://github.com/awa_Liny/LinysBrowser_NEXT/blob/a5cd96a9aa8114cae4972937f94a8967e55d4a10/home/src/main/ets/processes/tabs_actions.ets#L103-L131
76c665b5ffa07031c3138db1d7daabe4f3785586
gitee
Application-Security-Automation/Arktan.git
3ad9cb05235e38b00cd5828476aa59a345afa1c0
dataset/accuracy/field_sensitive/container/array_001_T.ets
arkts
Introduction 数组索引
export function array_001_T(taint_src : string) { let arr = [taint_src, "b", "c"] taint.Sink(arr[0]); }
AST#export_declaration#Left export AST#function_declaration#Left function array_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#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#array_literal#Left [ AST#expression#Left taint_src AST#expression#Right , AST#expression#Left "b" AST#expression#Right , AST#expression#Left "c" AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#ERROR#Left ta AST#ERROR#Right in AST#expression#Left t AST#expression#Right AST#binary_expression#Right AST#expression#Right . Sink AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left arr 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#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export function array_001_T(taint_src : string) { let arr = [taint_src, "b", "c"] taint.Sink(arr[0]); }
https://github.com/Application-Security-Automation/Arktan.git/blob/3ad9cb05235e38b00cd5828476aa59a345afa1c0/dataset/accuracy/field_sensitive/container/array_001_T.ets#L6-L9
286d6b051815724d0dfed5c3f9cec836c4efa118
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/swipercomponent/src/main/ets/common/CommonConstants.ets
arkts
Copyright (c) 2024 Huawei Device Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
export class CommonConstants { // 轮播切换动画时间 static readonly SWIPER_ANIMATION_DURATION: number = 300; // 轮播图每5s切换一次 static readonly SWIPER_SWITCH_DURATION: number = 2000; // 是否循环切换 static readonly SWIPER_IS_LOOP: boolean = true; // 导航点间隔 static readonly INDICATOR_SPACE: number = 10; // 导航点默认宽度 static readonly INDICATOR_DEFAULT_WIDTH: number = 8; // 导航点选中宽度 static readonly INDICATOR_SELECTED_WIDTH: number = 10; // 导航点高度 static readonly INDICATOR_HEIGHT: number = 8; // 导航点透明度 static readonly INDICATOR_FILL_OPACITY: number = 0.6; // 导航点上外间距 static readonly INDICATOR_MARGIN_TOP: number = 12; // 百分之百 static readonly CONTENT_FULL_VIEW: string = '100%'; // 轮播图蒙层透明度 static readonly SWIPER_MASK_OPACITY: number = 0.3; // 标题名称字体大小 static readonly SWIPER_TITLE_NAME_FONT_SIZE: number = 16; // 轮播图模糊效果值 static readonly SWIPER_BLUR_VALUE: number = 12; // 轮播图圆角 static readonly SWIPER_BORDER_RADIUS: number = 8; // 左滑临界值 static readonly SWIPER_LEFT_SCROLL: number = 50; // 右滑临界值 static readonly SWIPER_RIGHT_SCROLL: number = -50; // 横轴偏移量 static readonly SWIPER_OFFSET_X: number = -35; }
AST#export_declaration#Left export AST#class_declaration#Left class CommonConstants AST#class_body#Left { // 轮播切换动画时间 AST#property_declaration#Left static readonly SWIPER_ANIMATION_DURATION : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 300 AST#expression#Right ; AST#property_declaration#Right // 轮播图每5s切换一次 AST#property_declaration#Left static readonly SWIPER_SWITCH_DURATION : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 2000 AST#expression#Right ; AST#property_declaration#Right // 是否循环切换 AST#property_declaration#Left static readonly SWIPER_IS_LOOP : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#property_declaration#Right // 导航点间隔 AST#property_declaration#Left static readonly INDICATOR_SPACE : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 10 AST#expression#Right ; AST#property_declaration#Right // 导航点默认宽度 AST#property_declaration#Left static readonly INDICATOR_DEFAULT_WIDTH : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 8 AST#expression#Right ; AST#property_declaration#Right // 导航点选中宽度 AST#property_declaration#Left static readonly INDICATOR_SELECTED_WIDTH : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 10 AST#expression#Right ; AST#property_declaration#Right // 导航点高度 AST#property_declaration#Left static readonly INDICATOR_HEIGHT : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 8 AST#expression#Right ; AST#property_declaration#Right // 导航点透明度 AST#property_declaration#Left static readonly INDICATOR_FILL_OPACITY : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0.6 AST#expression#Right ; AST#property_declaration#Right // 导航点上外间距 AST#property_declaration#Left static readonly INDICATOR_MARGIN_TOP : 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 static readonly CONTENT_FULL_VIEW : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '100%' AST#expression#Right ; AST#property_declaration#Right // 轮播图蒙层透明度 AST#property_declaration#Left static readonly SWIPER_MASK_OPACITY : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0.3 AST#expression#Right ; AST#property_declaration#Right // 标题名称字体大小 AST#property_declaration#Left static readonly SWIPER_TITLE_NAME_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 static readonly SWIPER_BLUR_VALUE : 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 static readonly SWIPER_BORDER_RADIUS : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 8 AST#expression#Right ; AST#property_declaration#Right // 左滑临界值 AST#property_declaration#Left static readonly SWIPER_LEFT_SCROLL : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 50 AST#expression#Right ; AST#property_declaration#Right // 右滑临界值 AST#property_declaration#Left static readonly SWIPER_RIGHT_SCROLL : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#unary_expression#Left - AST#expression#Left 50 AST#expression#Right AST#unary_expression#Right AST#expression#Right ; AST#property_declaration#Right // 横轴偏移量 AST#property_declaration#Left static readonly SWIPER_OFFSET_X : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#unary_expression#Left - AST#expression#Left 35 AST#expression#Right AST#unary_expression#Right AST#expression#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class CommonConstants { static readonly SWIPER_ANIMATION_DURATION: number = 300; static readonly SWIPER_SWITCH_DURATION: number = 2000; static readonly SWIPER_IS_LOOP: boolean = true; static readonly INDICATOR_SPACE: number = 10; static readonly INDICATOR_DEFAULT_WIDTH: number = 8; static readonly INDICATOR_SELECTED_WIDTH: number = 10; static readonly INDICATOR_HEIGHT: number = 8; static readonly INDICATOR_FILL_OPACITY: number = 0.6; static readonly INDICATOR_MARGIN_TOP: number = 12; static readonly CONTENT_FULL_VIEW: string = '100%'; static readonly SWIPER_MASK_OPACITY: number = 0.3; static readonly SWIPER_TITLE_NAME_FONT_SIZE: number = 16; static readonly SWIPER_BLUR_VALUE: number = 12; static readonly SWIPER_BORDER_RADIUS: number = 8; static readonly SWIPER_LEFT_SCROLL: number = 50; static readonly SWIPER_RIGHT_SCROLL: number = -50; static readonly SWIPER_OFFSET_X: number = -35; }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/swipercomponent/src/main/ets/common/CommonConstants.ets#L16-L51
1bd0483c57c8f1e9c2ba686ea589a70115e5311a
gitee
openharmony/arkui_ace_engine
30c7d1ee12fbedf0fabece54291d75897e2ad44f
frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/arkui/src/handwritten/component/base.ets
arkts
Improve: implement this
export interface SubscribaleAbstract { }
AST#export_declaration#Left export AST#interface_declaration#Left interface SubscribaleAbstract AST#object_type#Left { } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
export interface SubscribaleAbstract { }
https://github.com/openharmony/arkui_ace_engine/blob/30c7d1ee12fbedf0fabece54291d75897e2ad44f/frameworks/bridge/arkts_frontend/koala_mirror/arkoala-arkts/arkui/src/handwritten/component/base.ets#L262-L262
48de4829cab3dd417baddc9c4e4d0e16b12ee7e8
gitee
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/views/books/BookListView.ets
arkts
actionShowLanguages
/切换 语言
actionShowLanguages(){ let options: ItemOption[] = []; let isCns = LanguageManager.getCurrentLanguage() === AppLanguage.Simplified let isCnt = LanguageManager.getCurrentLanguage() === AppLanguage.Traditional ///简体中文 options.push( {text: `简体中文`, color: isCns ? $r('app.color.color_red') : $r('app.color.color_black') , action: ()=>{ LanguageManager.switchLanguage(AppLanguage.Simplified) }}) ///繁體中文 options.push( {text: `繁體中文`, color: isCnt ? $r('app.color.color_red') : $r('app.color.color_black'),action: ()=>{ LanguageManager.switchLanguage(AppLanguage.Traditional) }}) // 显示 Toast.showSelectOptions('', undefined, options) }
AST#method_declaration#Left actionShowLanguages AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left options : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left ItemOption [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left isCns = 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 LanguageManager AST#expression#Right . getCurrentLanguage 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 AppLanguage AST#expression#Right AST#binary_expression#Right AST#expression#Right . Simplified 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 isCnt = AST#expression#Left AST#call_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 AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LanguageManager AST#expression#Right . getCurrentLanguage 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 AppLanguage AST#expression#Right AST#binary_expression#Right AST#expression#Right . Traditional AST#member_expression#Right AST#expression#Right ///简体中文 AST#ERROR#Left options AST#ERROR#Right . push 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 text AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` 简体中文 ` AST#template_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left AST#conditional_expression#Left AST#expression#Left isCns AST#expression#Right ? AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.color_red' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.color_black' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left action AST#property_name#Right : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LanguageManager AST#expression#Right . switchLanguage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AppLanguage AST#expression#Right . Simplified AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ///繁體中文 AST#ERROR#Left options AST#ERROR#Right . push 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 text AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` 繁體中文 ` AST#template_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left AST#conditional_expression#Left AST#expression#Left isCnt AST#expression#Right ? AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.color_red' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.color_black' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left action AST#property_name#Right : AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LanguageManager AST#expression#Right . switchLanguage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AppLanguage AST#expression#Right . Traditional AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right // 显示 AST#ERROR#Left To AST#ERROR#Right as AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left t . showSelectOptions AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '' AST#expression#Right , AST#expression#Left undefined AST#expression#Right , AST#expression#Left options AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
actionShowLanguages(){ let options: ItemOption[] = []; let isCns = LanguageManager.getCurrentLanguage() === AppLanguage.Simplified let isCnt = LanguageManager.getCurrentLanguage() === AppLanguage.Traditional options.push( {text: `简体中文`, color: isCns ? $r('app.color.color_red') : $r('app.color.color_black') , action: ()=>{ LanguageManager.switchLanguage(AppLanguage.Simplified) }}) options.push( {text: `繁體中文`, color: isCnt ? $r('app.color.color_red') : $r('app.color.color_black'),action: ()=>{ LanguageManager.switchLanguage(AppLanguage.Traditional) }}) Toast.showSelectOptions('', undefined, options) }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/views/books/BookListView.ets#L133-L156
18ce5354a85309fe9de82e9dd71cc0d9f1f73f89
github
texiwustion/chinese-herbal-shopping--arkts.git
3f71338f3c6d88bc74342e0322867f3a0c2c17d1
entry/src/main/ets/database/HerbalTable.ets
arkts
deleteData
updateData(herb: IHerbalModel, callback: Function) { this.query(herb.id, (result) => { if (result.length === 0) { callback(new Error('Herb not found')); } else { const valueBucket = this.generateBucket(herb); this.herbalTable.updateData(valueBucket, { key: 'id', value: herb.id }, callback); callback(null); } }); }
deleteData(id: number, callback: Function) { let predicates = new relationalStore.RdbPredicates(CommonConstants.HERBAL_TABLE.tableName); predicates.equalTo('id', id); this.herbalTable.deleteData(predicates, callback); }
AST#method_declaration#Left deleteData AST#parameter_list#Left ( AST#parameter#Left id : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left callback : AST#type_annotation#Left AST#primary_type#Left Function AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left predicates = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left relationalStore AST#expression#Right AST#new_expression#Right AST#expression#Right . RdbPredicates AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left CommonConstants AST#expression#Right . HERBAL_TABLE AST#member_expression#Right AST#expression#Right . tableName 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 predicates AST#expression#Right . equalTo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'id' AST#expression#Right , AST#expression#Left id AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . herbalTable AST#member_expression#Right AST#expression#Right . deleteData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left predicates AST#expression#Right , AST#expression#Left callback AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
deleteData(id: number, callback: Function) { let predicates = new relationalStore.RdbPredicates(CommonConstants.HERBAL_TABLE.tableName); predicates.equalTo('id', id); this.herbalTable.deleteData(predicates, callback); }
https://github.com/texiwustion/chinese-herbal-shopping--arkts.git/blob/3f71338f3c6d88bc74342e0322867f3a0c2c17d1/entry/src/main/ets/database/HerbalTable.ets#L137-L141
032f68aa35cff881c00f4a081effa0b3c47b0ace
github
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
core/model/src/main/ets/entity/SearchHistory.ets
arkts
@file 搜索历史模型 @author Joker.X
export class SearchHistory { /** * 搜索关键词 */ keyword: string = ""; /** * 搜索时间戳 */ searchTime: number = Date.now(); constructor(init?: Partial<SearchHistory>) { if (!init) { return; } this.keyword = init.keyword ?? this.keyword; this.searchTime = init.searchTime ?? this.searchTime; } }
AST#export_declaration#Left export AST#class_declaration#Left class SearchHistory AST#class_body#Left { /** * 搜索关键词 */ AST#property_declaration#Left keyword : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "" AST#expression#Right ; AST#property_declaration#Right /** * 搜索时间戳 */ AST#property_declaration#Left searchTime : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Date AST#expression#Right . now AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#property_declaration#Right AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left init ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Partial AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left SearchHistory AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left init AST#expression#Right AST#unary_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 . keyword 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 init AST#expression#Right . keyword AST#member_expression#Right AST#expression#Right ?? AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . keyword 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 . searchTime 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 init AST#expression#Right . searchTime AST#member_expression#Right AST#expression#Right ?? AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . searchTime AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class SearchHistory { keyword: string = ""; searchTime: number = Date.now(); constructor(init?: Partial<SearchHistory>) { if (!init) { return; } this.keyword = init.keyword ?? this.keyword; this.searchTime = init.searchTime ?? this.searchTime; } }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/model/src/main/ets/entity/SearchHistory.ets#L5-L22
b98e074a2286b20aa7fde5b3ba7e050b651404c4
github
openharmony/developtools_profiler
73d26bb5acfcafb2b1f4f94ead5640241d1e5f73
host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/components/YAxis.ets
arkts
isInverted
If this returns true, the y-axis is inverted. @return
public isInverted(): boolean { return this.mInverted; }
AST#method_declaration#Left public isInverted AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mInverted AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
public isInverted(): boolean { return this.mInverted; }
https://github.com/openharmony/developtools_profiler/blob/73d26bb5acfcafb2b1f4f94ead5640241d1e5f73/host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/components/YAxis.ets#L248-L250
1f0d1823d20e70c181fd093e5e22382163e7eecb
gitee
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
BptaUseSoftware/entry/src/main/ets/pages/LockBySystem.ets
arkts
[EndExclude bpta_lock_by_system]
export default class EntryAbility extends UIAbility { // ... onForeground(): void { //Apply for the resources required by the system, or reapply for the resources released in onBackground () audio.createAudioRenderer(audioRendererOptions,(err: BusinessError) => {}); } onBackground(): void { //Release resources when the UI is invisible audioRenderer.stop((err: BusinessError) => {}); } }
AST#export_declaration#Left export default AST#class_declaration#Left class EntryAbility extends AST#type_annotation#Left AST#primary_type#Left UIAbility AST#primary_type#Right AST#type_annotation#Right AST#class_body#Left { // ... AST#method_declaration#Left onForeground AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { //Apply for the resources required by the system, or reapply for the resources released in onBackground () AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left audio AST#expression#Right . createAudioRenderer AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left audioRendererOptions AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err : AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#object_literal#Left { } AST#object_literal#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right AST#method_declaration#Left onBackground AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { //Release resources when the UI is invisible AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left audioRenderer AST#expression#Right . stop 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#expression#Left AST#object_literal#Left { } AST#object_literal#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export default class EntryAbility extends UIAbility { onForeground(): void { audio.createAudioRenderer(audioRendererOptions,(err: BusinessError) => {}); } onBackground(): void { audioRenderer.stop((err: BusinessError) => {}); } }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/BptaUseSoftware/entry/src/main/ets/pages/LockBySystem.ets#L53-L65
cea7b5fd29735f6f1283da491915941419f98e54
gitee
vhall/VHLive_SDK_Harmony
29c820e5301e17ae01bc6bdcc393a4437b518e7c
watchKit/src/main/ets/utils/NetworkUtil.ets
arkts
TODO 网络相关工具类 需要 ohos.permission.GET_NETWORK_INFO、ohos.permission.GET_WIFI_INFO 权限。 author: 桃花镇童长老 since: 2024/05/01
export class NetworkUtil { private static netConnection: connection.NetConnection; /** * 检查当前网络上的数据流量使用是否被计量 * @returns */ static async isDefaultNetMetered(): Promise<boolean> { return connection.isDefaultNetMetered(); } /** * 检查当前网络上的数据流量使用是否被计量 * @returns */ static isDefaultNetMeteredSync(): boolean { return connection.isDefaultNetMeteredSync(); } /** * 检查默认数据网络是否被激活 */ static hasDefaultNet(): Promise<boolean> { return connection.hasDefaultNet(); } /** * 检查默认数据网络是否被激活,是否有网络 */ static hasDefaultNetSync(): boolean { return connection.hasDefaultNetSync(); } /** * 获取默认激活的数据网络 * @returns */ static getDefaultNet(): Promise<connection.NetHandle> { return connection.getDefaultNet(); } /** * 获取默认激活的数据网络 * @returns */ static getDefaultNetSync(): connection.NetHandle { return connection.getDefaultNetSync(); } /** * 获取App绑定的网络信息 * @returns */ static getAppNet(): Promise<connection.NetHandle> { return connection.getAppNet(); } /** * 获取App绑定的网络信息 * @returns */ static getAppNetSync(): connection.NetHandle { return connection.getAppNetSync(); } /** * 获取所有处于连接状态的网络列表 * @returns */ static getAllNets(): Promise<Array<connection.NetHandle>> { return connection.getAllNets(); } /** * 获取所有处于连接状态的网络列表 * @returns */ static getAllNetsSync(): Array<connection.NetHandle> { return connection.getAllNetsSync(); } /** * 判断当前设备网络是否可用 * @returns */ static isNetworkAvailable(): boolean { let allNets = NetworkUtil.getAllNetsSync(); if (allNets && allNets.length > 0) { return true; } else { return false; } } /** * 判断当前网络是否是蜂窝网络(移动网络)。 */ static hasNetMobile(): boolean { return NetworkUtil.hasNetBearType(connection.NetBearType.BEARER_CELLULAR); } /** * 判断当前网络是否是Wi-Fi网络。 */ static hasNetWiFi(): boolean { return NetworkUtil.hasNetBearType(connection.NetBearType.BEARER_WIFI); } /** * 判断当前网络是否是以太网网络。 */ static hasNetEthernet(): boolean { return NetworkUtil.hasNetBearType(connection.NetBearType.BEARER_ETHERNET); } /** * 判断当前网络是否是VPN网络。 */ static hasNetVPN(): boolean { return NetworkUtil.hasNetBearType(connection.NetBearType.BEARER_VPN); } /** * 是否存在指定的网络 * @param netType 网络类型。 * @returns */ static hasNetBearType(netType: connection.NetBearType): boolean { const netBearTypes = NetworkUtil.getNetBearTypes() for (let item of netBearTypes.values()) { if (item === netType) { return true; } } return false; } /** * 获取网络类型,数组里面只包含了一种具体的网络类型。 */ static getNetBearTypes(): Array<connection.NetBearType> { const netCapabilities = NetworkUtil.getNetCapabilitiesSync(NetworkUtil.getDefaultNetSync()); return netCapabilities.bearerTypes; } /** * 获取网络类型。 */ static getNetBearType(): connection.NetBearType { return NetworkUtil.getNetBearTypes()[0]; } /** * 获取netHandle对应的网络的能力信息 * @param netHandle 默认激活的数据网络 * @returns */ static async getNetCapabilities(netHandle: connection.NetHandle = NetworkUtil.getDefaultNetSync()): Promise<connection.NetCapabilities> { return connection.getNetCapabilities(netHandle); } /** * 获取netHandle对应的网络的能力信息 * @param netHandle 默认激活的数据网络 * @returns */ static getNetCapabilitiesSync(netHandle: connection.NetHandle = NetworkUtil.getDefaultNetSync()): connection.NetCapabilities { return connection.getNetCapabilitiesSync(netHandle); } /** * 获取netHandle对应的网络的连接信息 * @param netHandle 默认激活的数据网络 * @returns */ static async getConnectionProperties(netHandle: connection.NetHandle = NetworkUtil.getDefaultNetSync()): Promise<connection.ConnectionProperties> { return connection.getConnectionProperties(netHandle); } /** * 获取netHandle对应的网络的连接信息 * @param netHandle 默认激活的数据网络 * @returns */ static getConnectionPropertiesSync(netHandle: connection.NetHandle = NetworkUtil.getDefaultNetSync()): connection.ConnectionProperties { return connection.getConnectionPropertiesSync(netHandle); } /** * 获取当前设备的IP地址(设备连接Wi-Fi后) */ static getIpAddress() { let ipAddress = wifiManager.getIpInfo().ipAddress; let ip = (ipAddress >>> 24) + "." + (ipAddress >> 16 & 0xFF) + "." + (ipAddress >> 8 & 0xFF) + "." + (ipAddress & 0xFF); return ip; } /** * 订阅指定网络状态变化的通知,支持多事件监听回调。 * @param netAvailableCallback 订阅网络可用事件回调。 * @param netUnavailableCallback 订阅网络不可用事件回调。 * @param netCapabilitiesChangeCallback 订阅网络能力变化事件回调。比如切换Wi-Fi、切换VPN、切换为手机流量。 * @param netConnectionPropertiesChangeCallback 订阅网络连接信息变化事件回调。比如更改Wi-Fi、切换Wi-Fi、切换蜂窝网络。 * @param netBlockStatusChangeCallback 订阅网络阻塞状态事件回调。 * @param netLostCallback 订阅网络丢失事件回调。 */ static register(netAvailableCallback?: Callback<connection.NetHandle>, netUnavailableCallback?: Callback<void>, netCapabilitiesChangeCallback?: Callback<connection.NetCapabilityInfo>, netConnectionPropertiesChangeCallback?: Callback<connection.NetConnectionPropertyInfo>, netBlockStatusChangeCallback?: Callback<connection.NetBlockStatusInfo>, netLostCallback?: Callback<connection.NetHandle>) { if (!NetworkUtil.netConnection) { NetworkUtil.netConnection = connection.createNetConnection(); //创建NetConnection对象 } connection.getDefaultNet((error: BusinessError, netHandle: connection.NetHandle) => { if (error) { LogUtil.error(error); } if (netHandle && netAvailableCallback) { netAvailableCallback(netHandle); } }); //先使用register接口注册订阅事件 NetworkUtil.netConnection.register((error: BusinessError) => { if (error) { LogUtil.error(error); } }); if (netAvailableCallback) { NetworkUtil.netConnection.on('netAvailable', netAvailableCallback); //订阅网络可用事件。 } if (netUnavailableCallback) { NetworkUtil.netConnection.on('netUnavailable', netUnavailableCallback); //订阅网络不可用事件。 } if (netCapabilitiesChangeCallback) { NetworkUtil.netConnection.on('netCapabilitiesChange',netCapabilitiesChangeCallback); //订阅网络能力变化事件。比如切换Wi-Fi、切换VPN、切换为手机流量。 } if (netConnectionPropertiesChangeCallback) { NetworkUtil.netConnection.on('netConnectionPropertiesChange',netConnectionPropertiesChangeCallback); //订阅网络连接信息变化事件。比如更改Wi-Fi、切换Wi-Fi、切换蜂窝网络。 } if (netBlockStatusChangeCallback) { NetworkUtil.netConnection.on('netBlockStatusChange',netBlockStatusChangeCallback); //订阅网络阻塞状态事件。 } if (netLostCallback) { NetworkUtil.netConnection.on('netLost',netLostCallback); //订阅网络丢失事件。 } } /** * 取消订阅默认网络状态变化的通知。 */ static unregister() { if (NetworkUtil.netConnection) { NetworkUtil.netConnection.unregister((error: BusinessError) => { if (error) { LogUtil.error(error); } }); } } /** * 判断当前设备是否支持NR(New Radio)。也就是5G。 * @param slotId 卡槽ID,不传默认主卡。 */ static isNRSupported(slotId?: number): boolean { if (slotId) { return radio.isNRSupported(slotId); } return radio.isNRSupported(); } /** * 判断Radio是否打开。 * @param slotId 卡槽ID,如果不指定slotId,默认主卡。 * @returns */ static async isRadioOn(slotId?: number): Promise<boolean> { if (slotId) { return radio.isRadioOn(slotId); } return radio.isRadioOn(); } /** * 获取主卡所在卡槽的索引号。使用Promise异步回调。 * @returns */ static async getPrimarySlotId(): Promise<number> { return radio.getPrimarySlotId(); } /** * 获取运营商名称 * @param slotId 卡槽ID,如果不指定slotId,默认主卡。 * @returns */ static async getOperatorName(slotId?: number): Promise<string> { slotId = slotId ?? await NetworkUtil.getPrimarySlotId(); //获取主卡所在卡槽的索引号 return radio.getOperatorName(slotId); } /** * 获取网络状态 * @param slotId 卡槽ID,如果不指定slotId,默认主卡。 * @returns */ static async getNetworkState(slotId?: number): Promise<radio.NetworkState> { slotId = slotId ?? await NetworkUtil.getPrimarySlotId(); //获取主卡所在卡槽的索引号 return radio.getNetworkState(slotId); } /** * 获取当前选网模式。使用Promise异步回调。 * @param slotId 卡槽ID,如果不指定slotId,默认主卡。 * @returns */ static async getNetworkSelectionMode(slotId?: number): Promise<radio.NetworkSelectionMode> { slotId = slotId ?? await NetworkUtil.getPrimarySlotId(); //获取主卡所在卡槽的索引号 return radio.getNetworkSelectionMode(slotId); } /** * 获取指定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; } /** * 获取网络类型。 */ static async getNetworkType(): Promise<NetworkType> { try { if (NetworkUtil.hasNetWiFi()) { return NetworkType.NETWORK_TYPE_WIFI } if (NetworkUtil.hasNetMobile()) { let signalInfo: Array<radio.SignalInformation> = await NetworkUtil.getSignalInformation(); for (let item of signalInfo) { if (item.signalType === radio.NetworkType.NETWORK_TYPE_UNKNOWN) { return NetworkType.NETWORK_TYPE_UNKNOWN; } else if (item.signalType === radio.NetworkType.NETWORK_TYPE_GSM || item.signalType === radio.NetworkType.NETWORK_TYPE_CDMA) { return NetworkType.NETWORK_TYPE_2G; } else if (item.signalType === radio.NetworkType.NETWORK_TYPE_WCDMA || item.signalType === radio.NetworkType.NETWORK_TYPE_TDSCDMA) { return NetworkType.NETWORK_TYPE_3G; } else if (item.signalType === radio.NetworkType.NETWORK_TYPE_LTE) { return NetworkType.NETWORK_TYPE_4G; } else if (item.signalType === radio.NetworkType.NETWORK_TYPE_NR) { return NetworkType.NETWORK_TYPE_5G; } } } } catch (err) { LogUtil.error(err); } return NetworkType.NETWORK_TYPE_UNKNOWN; } /** * 获取网络类型,返回字符类型。 */ static async getNetworkTypeStr(): Promise<string> { const networkType = await NetworkUtil.getNetworkType(); switch (networkType) { case NetworkType.NETWORK_TYPE_WIFI: return "Wi-Fi"; case NetworkType.NETWORK_TYPE_2G: return "2G"; case NetworkType.NETWORK_TYPE_3G: return "3G"; case NetworkType.NETWORK_TYPE_4G: return "4G"; case NetworkType.NETWORK_TYPE_5G: return "5G"; } return "UNKNOWN"; }
AST#export_declaration#Left export AST#class_declaration#Left class NetworkUtil AST#class_body#Left { AST#property_declaration#Left private static netConnection : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left connection . NetConnection AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * 检查当前网络上的数据流量使用是否被计量 * @returns */ AST#method_declaration#Left static async isDefaultNetMetered AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left connection AST#expression#Right . isDefaultNetMetered 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 /** * 检查当前网络上的数据流量使用是否被计量 * @returns */ AST#method_declaration#Left static isDefaultNetMeteredSync 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left connection AST#expression#Right . isDefaultNetMeteredSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 检查默认数据网络是否被激活 */ AST#method_declaration#Left static hasDefaultNet AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left connection AST#expression#Right . hasDefaultNet AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 检查默认数据网络是否被激活,是否有网络 */ AST#method_declaration#Left static hasDefaultNetSync 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left connection AST#expression#Right . hasDefaultNetSync 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 /** * 获取默认激活的数据网络 * @returns */ AST#method_declaration#Left static getDefaultNet AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left connection . NetHandle AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left connection AST#expression#Right . getDefaultNet 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 /** * 获取默认激活的数据网络 * @returns */ AST#method_declaration#Left static getDefaultNetSync AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left connection . NetHandle AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left connection AST#expression#Right . getDefaultNetSync 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 /** * 获取App绑定的网络信息 * @returns */ AST#method_declaration#Left static getAppNet AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left connection . NetHandle AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left connection AST#expression#Right . getAppNet 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 /** * 获取App绑定的网络信息 * @returns */ AST#method_declaration#Left static getAppNetSync AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left connection . NetHandle AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left connection AST#expression#Right . getAppNetSync 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 /** * 获取所有处于连接状态的网络列表 * @returns */ AST#method_declaration#Left static getAllNets 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 Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left connection . NetHandle AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left connection AST#expression#Right . getAllNets 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 /** * 获取所有处于连接状态的网络列表 * @returns */ AST#method_declaration#Left static getAllNetsSync AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left connection . NetHandle AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left connection AST#expression#Right . getAllNetsSync 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 /** * 判断当前设备网络是否可用 * @returns */ AST#method_declaration#Left static isNetworkAvailable 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 allNets = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left NetworkUtil AST#expression#Right . getAllNetsSync 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 AST#binary_expression#Left AST#expression#Left allNets AST#expression#Right && AST#expression#Left allNets AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 判断当前网络是否是蜂窝网络(移动网络)。 */ AST#method_declaration#Left static hasNetMobile 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left NetworkUtil AST#expression#Right . hasNetBearType 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 connection AST#expression#Right . NetBearType AST#member_expression#Right AST#expression#Right . BEARER_CELLULAR 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 /** * 判断当前网络是否是Wi-Fi网络。 */ AST#method_declaration#Left static hasNetWiFi 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left NetworkUtil AST#expression#Right . hasNetBearType 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 connection AST#expression#Right . NetBearType AST#member_expression#Right AST#expression#Right . BEARER_WIFI AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 判断当前网络是否是以太网网络。 */ AST#method_declaration#Left static hasNetEthernet 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left NetworkUtil AST#expression#Right . hasNetBearType 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 connection AST#expression#Right . NetBearType AST#member_expression#Right AST#expression#Right . BEARER_ETHERNET 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 /** * 判断当前网络是否是VPN网络。 */ AST#method_declaration#Left static hasNetVPN 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left NetworkUtil AST#expression#Right . hasNetBearType 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 connection AST#expression#Right . NetBearType AST#member_expression#Right AST#expression#Right . BEARER_VPN 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 /** * 是否存在指定的网络 * @param netType 网络类型。 * @returns */ AST#method_declaration#Left static hasNetBearType AST#parameter_list#Left ( AST#parameter#Left netType : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left connection . NetBearType 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#variable_declaration#Left const AST#variable_declarator#Left netBearTypes = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left NetworkUtil AST#expression#Right . getNetBearTypes 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#for_statement#Left for ( let item of AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left netBearTypes AST#expression#Right . values 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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left item AST#expression#Right === AST#expression#Left netType AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right 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#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 /** * 获取网络类型,数组里面只包含了一种具体的网络类型。 */ AST#method_declaration#Left static getNetBearTypes AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Array AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left connection . NetBearType AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left netCapabilities = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left NetworkUtil AST#expression#Right . getNetCapabilitiesSync 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 NetworkUtil AST#expression#Right . getDefaultNetSync 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#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left netCapabilities AST#expression#Right . bearerTypes AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 获取网络类型。 */ AST#method_declaration#Left static getNetBearType AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left connection . NetBearType AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left NetworkUtil AST#expression#Right . getNetBearTypes 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 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 获取netHandle对应的网络的能力信息 * @param netHandle 默认激活的数据网络 * @returns */ AST#method_declaration#Left static async getNetCapabilities AST#parameter_list#Left ( AST#parameter#Left netHandle : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left connection . NetHandle 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 NetworkUtil AST#expression#Right . getDefaultNetSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left connection . NetCapabilities AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left connection AST#expression#Right . getNetCapabilities AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left netHandle 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 /** * 获取netHandle对应的网络的能力信息 * @param netHandle 默认激活的数据网络 * @returns */ AST#method_declaration#Left static getNetCapabilitiesSync AST#parameter_list#Left ( AST#parameter#Left netHandle : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left connection . NetHandle 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 NetworkUtil AST#expression#Right . getDefaultNetSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left connection . NetCapabilities AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left connection AST#expression#Right . getNetCapabilitiesSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left netHandle 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 /** * 获取netHandle对应的网络的连接信息 * @param netHandle 默认激活的数据网络 * @returns */ AST#method_declaration#Left static async getConnectionProperties AST#parameter_list#Left ( AST#parameter#Left netHandle : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left connection . NetHandle 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 NetworkUtil AST#expression#Right . getDefaultNetSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left connection . ConnectionProperties AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left connection AST#expression#Right . getConnectionProperties AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left netHandle 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 /** * 获取netHandle对应的网络的连接信息 * @param netHandle 默认激活的数据网络 * @returns */ AST#method_declaration#Left static getConnectionPropertiesSync AST#parameter_list#Left ( AST#parameter#Left netHandle : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left connection . NetHandle 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 NetworkUtil AST#expression#Right . getDefaultNetSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left connection . ConnectionProperties AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left connection AST#expression#Right . getConnectionPropertiesSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left netHandle 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 /** * 获取当前设备的IP地址(设备连接Wi-Fi后) */ AST#method_declaration#Left static getIpAddress AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left ipAddress = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left wifiManager AST#expression#Right . getIpInfo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . ipAddress 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 ip = 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 AST#binary_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 ipAddress AST#expression#Right >>> AST#expression#Left 24 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right + AST#expression#Left "." AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left ipAddress AST#expression#Right >> AST#expression#Left 16 AST#expression#Right AST#binary_expression#Right AST#expression#Right & AST#expression#Left 0xFF 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#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left ipAddress AST#expression#Right >> AST#expression#Left 8 AST#expression#Right AST#binary_expression#Right AST#expression#Right & AST#expression#Left 0xFF 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#expression#Right AST#binary_expression#Right AST#expression#Right + AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left ipAddress AST#expression#Right & AST#expression#Left 0xFF AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left ip AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 订阅指定网络状态变化的通知,支持多事件监听回调。 * @param netAvailableCallback 订阅网络可用事件回调。 * @param netUnavailableCallback 订阅网络不可用事件回调。 * @param netCapabilitiesChangeCallback 订阅网络能力变化事件回调。比如切换Wi-Fi、切换VPN、切换为手机流量。 * @param netConnectionPropertiesChangeCallback 订阅网络连接信息变化事件回调。比如更改Wi-Fi、切换Wi-Fi、切换蜂窝网络。 * @param netBlockStatusChangeCallback 订阅网络阻塞状态事件回调。 * @param netLostCallback 订阅网络丢失事件回调。 */ AST#method_declaration#Left static register AST#parameter_list#Left ( AST#parameter#Left netAvailableCallback ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Callback AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left connection . NetHandle AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left netUnavailableCallback ? : 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 netCapabilitiesChangeCallback ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Callback AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left connection . NetCapabilityInfo AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left netConnectionPropertiesChangeCallback ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Callback AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left connection . NetConnectionPropertyInfo AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left netBlockStatusChangeCallback ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Callback AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left connection . NetBlockStatusInfo AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left netLostCallback ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Callback AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left connection . NetHandle AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#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 NetworkUtil AST#expression#Right AST#unary_expression#Right AST#expression#Right . netConnection 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 NetworkUtil AST#expression#Right . netConnection AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left connection AST#expression#Right . createNetConnection 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 //创建NetConnection对象 } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left connection AST#expression#Right . getDefaultNet AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left error : AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left netHandle : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left connection . NetHandle AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left error AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LogUtil AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#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 netHandle AST#expression#Right && AST#expression#Left netAvailableCallback 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 netAvailableCallback AST#expression#Right AST#argument_list#Left ( AST#expression#Left netHandle AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right //先使用register接口注册订阅事件 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 NetworkUtil AST#expression#Right . netConnection AST#member_expression#Right AST#expression#Right . register AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left error : AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left error AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LogUtil AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left netAvailableCallback 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 NetworkUtil AST#expression#Right . netConnection AST#member_expression#Right AST#expression#Right . on AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'netAvailable' AST#expression#Right , AST#expression#Left netAvailableCallback AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right //订阅网络可用事件。 } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left netUnavailableCallback 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 NetworkUtil AST#expression#Right . netConnection AST#member_expression#Right AST#expression#Right . on AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'netUnavailable' AST#expression#Right , AST#expression#Left netUnavailableCallback AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right //订阅网络不可用事件。 } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left netCapabilitiesChangeCallback 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 NetworkUtil AST#expression#Right . netConnection AST#member_expression#Right AST#expression#Right . on AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'netCapabilitiesChange' AST#expression#Right , AST#expression#Left netCapabilitiesChangeCallback AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right //订阅网络能力变化事件。比如切换Wi-Fi、切换VPN、切换为手机流量。 } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left netConnectionPropertiesChangeCallback 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 NetworkUtil AST#expression#Right . netConnection AST#member_expression#Right AST#expression#Right . on AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'netConnectionPropertiesChange' AST#expression#Right , AST#expression#Left netConnectionPropertiesChangeCallback AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right //订阅网络连接信息变化事件。比如更改Wi-Fi、切换Wi-Fi、切换蜂窝网络。 } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left netBlockStatusChangeCallback 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 NetworkUtil AST#expression#Right . netConnection AST#member_expression#Right AST#expression#Right . on AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'netBlockStatusChange' AST#expression#Right , AST#expression#Left netBlockStatusChangeCallback AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right //订阅网络阻塞状态事件。 } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left netLostCallback 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 NetworkUtil AST#expression#Right . netConnection AST#member_expression#Right AST#expression#Right . on AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'netLost' AST#expression#Right , AST#expression#Left netLostCallback AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right //订阅网络丢失事件。 } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right /** * 取消订阅默认网络状态变化的通知。 */ AST#method_declaration#Left static unregister AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left NetworkUtil AST#expression#Right . netConnection 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 NetworkUtil AST#expression#Right . netConnection AST#member_expression#Right AST#expression#Right . unregister AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left error : AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left error AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LogUtil AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right /** * 判断当前设备是否支持NR(New Radio)。也就是5G。 * @param slotId 卡槽ID,不传默认主卡。 */ AST#method_declaration#Left static isNRSupported 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 boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left slotId AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left radio AST#expression#Right . isNRSupported 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#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 radio AST#expression#Right . isNRSupported 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 /** * 判断Radio是否打开。 * @param slotId 卡槽ID,如果不指定slotId,默认主卡。 * @returns */ AST#method_declaration#Left static async isRadioOn 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 boolean AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left slotId AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left radio AST#expression#Right . isRadioOn 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#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 radio AST#expression#Right . isRadioOn AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 获取主卡所在卡槽的索引号。使用Promise异步回调。 * @returns */ AST#method_declaration#Left static async getPrimarySlotId 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 number AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left radio 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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 获取运营商名称 * @param slotId 卡槽ID,如果不指定slotId,默认主卡。 * @returns */ AST#method_declaration#Left static async getOperatorName 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 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#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#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left radio AST#expression#Right . getOperatorName 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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 获取网络状态 * @param slotId 卡槽ID,如果不指定slotId,默认主卡。 * @returns */ AST#method_declaration#Left static async getNetworkState 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#qualified_type#Left radio . NetworkState AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#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#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left radio AST#expression#Right . getNetworkState 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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 获取当前选网模式。使用Promise异步回调。 * @param slotId 卡槽ID,如果不指定slotId,默认主卡。 * @returns */ AST#method_declaration#Left static async getNetworkSelectionMode 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#qualified_type#Left radio . NetworkSelectionMode AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#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#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left radio AST#expression#Right . getNetworkSelectionMode 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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 获取指定SIM卡槽对应的注册网络信号强度信息列表。 * @param slotId 卡槽ID,如果不指定slotId,默认主卡。 * @returns */ 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 /** * 获取网络类型。 */ AST#method_declaration#Left static async getNetworkType 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 NetworkType AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left NetworkUtil AST#expression#Right . hasNetWiFi AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left NetworkType AST#expression#Right . NETWORK_TYPE_WIFI AST#member_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left NetworkUtil AST#expression#Right . hasNetMobile 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 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 NetworkUtil AST#expression#Right AST#await_expression#Right AST#expression#Right . getSignalInformation 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#for_statement#Left for ( let item of AST#expression#Left signalInfo AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . signalType AST#member_expression#Right AST#expression#Right === AST#expression#Left radio AST#expression#Right AST#binary_expression#Right AST#expression#Right . NetworkType AST#member_expression#Right AST#expression#Right . NETWORK_TYPE_UNKNOWN AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left NetworkType AST#expression#Right . NETWORK_TYPE_UNKNOWN AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#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#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 item AST#expression#Right . signalType AST#member_expression#Right AST#expression#Right === AST#expression#Left radio AST#expression#Right AST#binary_expression#Right AST#expression#Right . NetworkType AST#member_expression#Right AST#expression#Right . NETWORK_TYPE_GSM AST#member_expression#Right AST#expression#Right || AST#expression#Left item AST#expression#Right AST#binary_expression#Right AST#expression#Right . signalType AST#member_expression#Right AST#expression#Right === AST#expression#Left radio AST#expression#Right AST#binary_expression#Right AST#expression#Right . NetworkType AST#member_expression#Right AST#expression#Right . NETWORK_TYPE_CDMA AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left NetworkType AST#expression#Right . NETWORK_TYPE_2G AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#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#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 item AST#expression#Right . signalType AST#member_expression#Right AST#expression#Right === AST#expression#Left radio AST#expression#Right AST#binary_expression#Right AST#expression#Right . NetworkType AST#member_expression#Right AST#expression#Right . NETWORK_TYPE_WCDMA AST#member_expression#Right AST#expression#Right || AST#expression#Left item AST#expression#Right AST#binary_expression#Right AST#expression#Right . signalType AST#member_expression#Right AST#expression#Right === AST#expression#Left radio AST#expression#Right AST#binary_expression#Right AST#expression#Right . NetworkType AST#member_expression#Right AST#expression#Right . NETWORK_TYPE_TDSCDMA AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left NetworkType AST#expression#Right . NETWORK_TYPE_3G AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#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 item AST#expression#Right . signalType AST#member_expression#Right AST#expression#Right === AST#expression#Left radio AST#expression#Right AST#binary_expression#Right AST#expression#Right . NetworkType AST#member_expression#Right AST#expression#Right . NETWORK_TYPE_LTE AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left NetworkType AST#expression#Right . NETWORK_TYPE_4G AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#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 item AST#expression#Right . signalType AST#member_expression#Right AST#expression#Right === AST#expression#Left radio AST#expression#Right AST#binary_expression#Right AST#expression#Right . NetworkType AST#member_expression#Right AST#expression#Right . NETWORK_TYPE_NR AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left NetworkType AST#expression#Right . NETWORK_TYPE_5G AST#member_expression#Right AST#expression#Right ; AST#return_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#for_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( err ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left LogUtil AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left NetworkType AST#expression#Right . NETWORK_TYPE_UNKNOWN AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 获取网络类型,返回字符类型。 */ AST#method_declaration#Left static async getNetworkTypeStr AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#ERROR#Left AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left networkType = 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 NetworkUtil AST#expression#Right AST#await_expression#Right AST#expression#Right . getNetworkType 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 switch AST#expression#Right AST#argument_list#Left ( AST#expression#Left networkType AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right { AST#property_name#Left case AST#property_name#Right Network Type AST#modifier_chain_expression#Left . NETWORK_TYPE_WIFI AST#modifier_chain_expression#Right : AST#ERROR#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left "Wi-Fi" AST#expression#Right ; AST#return_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left NetworkType AST#expression#Right . NETWORK_TYPE_2G AST#member_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left : AST#ERROR#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left "2G" AST#expression#Right ; AST#return_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left NetworkType AST#expression#Right . NETWORK_TYPE_3G AST#member_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left : AST#ERROR#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left "3G" AST#expression#Right ; AST#return_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left NetworkType AST#expression#Right . NETWORK_TYPE_4G AST#member_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left : AST#ERROR#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left "4G" AST#expression#Right ; AST#return_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left case AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#member_expression#Left AST#expression#Left NetworkType AST#expression#Right . NETWORK_TYPE_5G AST#member_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#ERROR#Left : AST#ERROR#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left "5G" AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#property_declaration#Left return AST#ERROR#Left "UNKNOWN" AST#ERROR#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class NetworkUtil { private static netConnection: connection.NetConnection; static async isDefaultNetMetered(): Promise<boolean> { return connection.isDefaultNetMetered(); } static isDefaultNetMeteredSync(): boolean { return connection.isDefaultNetMeteredSync(); } static hasDefaultNet(): Promise<boolean> { return connection.hasDefaultNet(); } static hasDefaultNetSync(): boolean { return connection.hasDefaultNetSync(); } static getDefaultNet(): Promise<connection.NetHandle> { return connection.getDefaultNet(); } static getDefaultNetSync(): connection.NetHandle { return connection.getDefaultNetSync(); } static getAppNet(): Promise<connection.NetHandle> { return connection.getAppNet(); } static getAppNetSync(): connection.NetHandle { return connection.getAppNetSync(); } static getAllNets(): Promise<Array<connection.NetHandle>> { return connection.getAllNets(); } static getAllNetsSync(): Array<connection.NetHandle> { return connection.getAllNetsSync(); } static isNetworkAvailable(): boolean { let allNets = NetworkUtil.getAllNetsSync(); if (allNets && allNets.length > 0) { return true; } else { return false; } } static hasNetMobile(): boolean { return NetworkUtil.hasNetBearType(connection.NetBearType.BEARER_CELLULAR); } static hasNetWiFi(): boolean { return NetworkUtil.hasNetBearType(connection.NetBearType.BEARER_WIFI); } static hasNetEthernet(): boolean { return NetworkUtil.hasNetBearType(connection.NetBearType.BEARER_ETHERNET); } static hasNetVPN(): boolean { return NetworkUtil.hasNetBearType(connection.NetBearType.BEARER_VPN); } static hasNetBearType(netType: connection.NetBearType): boolean { const netBearTypes = NetworkUtil.getNetBearTypes() for (let item of netBearTypes.values()) { if (item === netType) { return true; } } return false; } static getNetBearTypes(): Array<connection.NetBearType> { const netCapabilities = NetworkUtil.getNetCapabilitiesSync(NetworkUtil.getDefaultNetSync()); return netCapabilities.bearerTypes; } static getNetBearType(): connection.NetBearType { return NetworkUtil.getNetBearTypes()[0]; } static async getNetCapabilities(netHandle: connection.NetHandle = NetworkUtil.getDefaultNetSync()): Promise<connection.NetCapabilities> { return connection.getNetCapabilities(netHandle); } static getNetCapabilitiesSync(netHandle: connection.NetHandle = NetworkUtil.getDefaultNetSync()): connection.NetCapabilities { return connection.getNetCapabilitiesSync(netHandle); } static async getConnectionProperties(netHandle: connection.NetHandle = NetworkUtil.getDefaultNetSync()): Promise<connection.ConnectionProperties> { return connection.getConnectionProperties(netHandle); } static getConnectionPropertiesSync(netHandle: connection.NetHandle = NetworkUtil.getDefaultNetSync()): connection.ConnectionProperties { return connection.getConnectionPropertiesSync(netHandle); } static getIpAddress() { let ipAddress = wifiManager.getIpInfo().ipAddress; let ip = (ipAddress >>> 24) + "." + (ipAddress >> 16 & 0xFF) + "." + (ipAddress >> 8 & 0xFF) + "." + (ipAddress & 0xFF); return ip; } static register(netAvailableCallback?: Callback<connection.NetHandle>, netUnavailableCallback?: Callback<void>, netCapabilitiesChangeCallback?: Callback<connection.NetCapabilityInfo>, netConnectionPropertiesChangeCallback?: Callback<connection.NetConnectionPropertyInfo>, netBlockStatusChangeCallback?: Callback<connection.NetBlockStatusInfo>, netLostCallback?: Callback<connection.NetHandle>) { if (!NetworkUtil.netConnection) { NetworkUtil.netConnection = connection.createNetConnection(); } connection.getDefaultNet((error: BusinessError, netHandle: connection.NetHandle) => { if (error) { LogUtil.error(error); } if (netHandle && netAvailableCallback) { netAvailableCallback(netHandle); } }); NetworkUtil.netConnection.register((error: BusinessError) => { if (error) { LogUtil.error(error); } }); if (netAvailableCallback) { NetworkUtil.netConnection.on('netAvailable', netAvailableCallback); } if (netUnavailableCallback) { NetworkUtil.netConnection.on('netUnavailable', netUnavailableCallback); } if (netCapabilitiesChangeCallback) { NetworkUtil.netConnection.on('netCapabilitiesChange',netCapabilitiesChangeCallback); } if (netConnectionPropertiesChangeCallback) { NetworkUtil.netConnection.on('netConnectionPropertiesChange',netConnectionPropertiesChangeCallback); } if (netBlockStatusChangeCallback) { NetworkUtil.netConnection.on('netBlockStatusChange',netBlockStatusChangeCallback); } if (netLostCallback) { NetworkUtil.netConnection.on('netLost',netLostCallback); } } static unregister() { if (NetworkUtil.netConnection) { NetworkUtil.netConnection.unregister((error: BusinessError) => { if (error) { LogUtil.error(error); } }); } } static isNRSupported(slotId?: number): boolean { if (slotId) { return radio.isNRSupported(slotId); } return radio.isNRSupported(); } static async isRadioOn(slotId?: number): Promise<boolean> { if (slotId) { return radio.isRadioOn(slotId); } return radio.isRadioOn(); } static async getPrimarySlotId(): Promise<number> { return radio.getPrimarySlotId(); } static async getOperatorName(slotId?: number): Promise<string> { slotId = slotId ?? await NetworkUtil.getPrimarySlotId(); return radio.getOperatorName(slotId); } static async getNetworkState(slotId?: number): Promise<radio.NetworkState> { slotId = slotId ?? await NetworkUtil.getPrimarySlotId(); return radio.getNetworkState(slotId); } static async getNetworkSelectionMode(slotId?: number): Promise<radio.NetworkSelectionMode> { slotId = slotId ?? await NetworkUtil.getPrimarySlotId(); return radio.getNetworkSelectionMode(slotId); } 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; } static async getNetworkType(): Promise<NetworkType> { try { if (NetworkUtil.hasNetWiFi()) { return NetworkType.NETWORK_TYPE_WIFI } if (NetworkUtil.hasNetMobile()) { let signalInfo: Array<radio.SignalInformation> = await NetworkUtil.getSignalInformation(); for (let item of signalInfo) { if (item.signalType === radio.NetworkType.NETWORK_TYPE_UNKNOWN) { return NetworkType.NETWORK_TYPE_UNKNOWN; } else if (item.signalType === radio.NetworkType.NETWORK_TYPE_GSM || item.signalType === radio.NetworkType.NETWORK_TYPE_CDMA) { return NetworkType.NETWORK_TYPE_2G; } else if (item.signalType === radio.NetworkType.NETWORK_TYPE_WCDMA || item.signalType === radio.NetworkType.NETWORK_TYPE_TDSCDMA) { return NetworkType.NETWORK_TYPE_3G; } else if (item.signalType === radio.NetworkType.NETWORK_TYPE_LTE) { return NetworkType.NETWORK_TYPE_4G; } else if (item.signalType === radio.NetworkType.NETWORK_TYPE_NR) { return NetworkType.NETWORK_TYPE_5G; } } } } catch (err) { LogUtil.error(err); } return NetworkType.NETWORK_TYPE_UNKNOWN; } static async getNetworkTypeStr(): Promise<string> { const networkType = await NetworkUtil.getNetworkType(); switch (networkType) { case NetworkType.NETWORK_TYPE_WIFI: return "Wi-Fi"; case NetworkType.NETWORK_TYPE_2G: return "2G"; case NetworkType.NETWORK_TYPE_3G: return "3G"; case NetworkType.NETWORK_TYPE_4G: return "4G"; case NetworkType.NETWORK_TYPE_5G: return "5G"; } return "UNKNOWN"; }
https://github.com/vhall/VHLive_SDK_Harmony/blob/29c820e5301e17ae01bc6bdcc393a4437b518e7c/watchKit/src/main/ets/utils/NetworkUtil.ets#L29-L434
51f514e99afdff43e6e9ef9fafdf97d5adfd4fbe
gitee
liudi25385/mybit.git
865f64ff6b2e10f5b79100064dff05e67607a5bc
entry/src/main/ets/net/CustomNetPlugin.ets
arkts
didReceive
收到Response响应,响应的所有信息
didReceive(result: http.HttpResponse): void { }
AST#method_declaration#Left didReceive AST#parameter_list#Left ( AST#parameter#Left result : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left http . HttpResponse AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { } AST#builder_function_body#Right AST#method_declaration#Right
didReceive(result: http.HttpResponse): void { }
https://github.com/liudi25385/mybit.git/blob/865f64ff6b2e10f5b79100064dff05e67607a5bc/entry/src/main/ets/net/CustomNetPlugin.ets#L10-L12
d9f3a7cd7047aee6347eb2b2dd8e343544d6550d
github
ikunbranch666-auto/SimpleCalculator.git
ea24568014d05285ad3def5b741380294308aef2
entry/src/main/ets/common/InputComponent.ets
arkts
InputComponent
Copyright (c) 2022 Huawei Device Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
@Component export struct InputComponent { @Link result: string @Link expression: string private isLand: boolean = false build() { Stack({ alignContent: this.isLand ? Alignment.BottomStart : Alignment.TopEnd }) { Column() { Row() { Text(this.expression) .margin({ top: '3%' }) .height('100%') .width('100%') .id('expression') .opacity(0.9) .fontWeight(400) .textAlign(TextAlign.Start) .fontSize(this.isLand ? '50px' : '35px') } .height('48%') .width('90%') .align(this.isLand ? Alignment.End : Alignment.Start) Row() { Text(this.result) .margin({ top: '1%' }) .height('100%') .width('100%') .id('result') .opacity(0.38) .textAlign(TextAlign.Start) .fontSize(this.isLand ? '50px' : '31px') .margin(this.isLand ? { bottom: 64 } : {}) } .height('46%') .width('90%') .align(this.isLand ? Alignment.End : Alignment.Start) } .width('100%') .align(Alignment.Center) } .width(this.isLand ? '34%' : '100%') .height(this.isLand ? '100%' : '34%') } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct InputComponent AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ Link AST#decorator#Right result : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Link AST#decorator#Right expression : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#property_declaration#Right AST#property_declaration#Left private isLand : 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#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Stack ( AST#component_parameters#Left { AST#component_parameter#Left alignContent : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLand AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left Alignment AST#expression#Right . BottomStart AST#member_expression#Right AST#expression#Right : AST#expression#Left Alignment AST#expression#Right AST#conditional_expression#Right AST#expression#Right . TopEnd AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . expression AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left '3%' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . id ( AST#expression#Left 'expression' AST#expression#Right ) AST#modifier_chain_expression#Left . opacity ( AST#expression#Left 0.9 AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left 400 AST#expression#Right ) AST#modifier_chain_expression#Left . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLand AST#member_expression#Right AST#expression#Right ? AST#expression#Left '50px' AST#expression#Right : AST#expression#Left '35px' AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . height ( AST#expression#Left '48%' AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '90%' AST#expression#Right ) AST#modifier_chain_expression#Left . align ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLand AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left Alignment AST#expression#Right . End AST#member_expression#Right AST#expression#Right : AST#expression#Left Alignment AST#expression#Right AST#conditional_expression#Right AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . result AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left '1%' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . id ( AST#expression#Left 'result' AST#expression#Right ) AST#modifier_chain_expression#Left . opacity ( AST#expression#Left 0.38 AST#expression#Right ) AST#modifier_chain_expression#Left . textAlign ( AST#expression#Left AST#member_expression#Left AST#expression#Left TextAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLand AST#member_expression#Right AST#expression#Right ? AST#expression#Left '50px' AST#expression#Right : AST#expression#Left '31px' AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLand AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 64 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right : AST#expression#Left AST#object_literal#Left { } AST#object_literal#Right AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . height ( AST#expression#Left '46%' AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '90%' AST#expression#Right ) AST#modifier_chain_expression#Left . align ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLand AST#member_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left Alignment AST#expression#Right . End AST#member_expression#Right AST#expression#Right : AST#expression#Left Alignment AST#expression#Right AST#conditional_expression#Right AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . align ( AST#expression#Left AST#member_expression#Left AST#expression#Left Alignment AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLand AST#member_expression#Right AST#expression#Right ? AST#expression#Left '34%' AST#expression#Right : AST#expression#Left '100%' AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isLand AST#member_expression#Right AST#expression#Right ? AST#expression#Left '100%' AST#expression#Right : AST#expression#Left '34%' AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@Component export struct InputComponent { @Link result: string @Link expression: string private isLand: boolean = false build() { Stack({ alignContent: this.isLand ? Alignment.BottomStart : Alignment.TopEnd }) { Column() { Row() { Text(this.expression) .margin({ top: '3%' }) .height('100%') .width('100%') .id('expression') .opacity(0.9) .fontWeight(400) .textAlign(TextAlign.Start) .fontSize(this.isLand ? '50px' : '35px') } .height('48%') .width('90%') .align(this.isLand ? Alignment.End : Alignment.Start) Row() { Text(this.result) .margin({ top: '1%' }) .height('100%') .width('100%') .id('result') .opacity(0.38) .textAlign(TextAlign.Start) .fontSize(this.isLand ? '50px' : '31px') .margin(this.isLand ? { bottom: 64 } : {}) } .height('46%') .width('90%') .align(this.isLand ? Alignment.End : Alignment.Start) } .width('100%') .align(Alignment.Center) } .width(this.isLand ? '34%' : '100%') .height(this.isLand ? '100%' : '34%') } }
https://github.com/ikunbranch666-auto/SimpleCalculator.git/blob/ea24568014d05285ad3def5b741380294308aef2/entry/src/main/ets/common/InputComponent.ets#L15-L61
c089871ec81c17f8d42913cc947fd8c4f27744e3
github
jianguo888/nut-recipes
262304b5d2bee2d5f1df4e29c094c9ddd58f9d51
entry/src/main/ets/MainAbility/pages/Main.ets
arkts
getRequest
请求方式:GET
getRequest() { // 每一个httpRequest对应一个http请求任务,不可复用 let httpRequest = http.createHttp() let url = "https://way.jd.com/jisuapi/search?keyword=白菜&num=10&start=0&appkey=7c913be32b690701cd994d804a6d4294" httpRequest.request(url, (err, data) => { if (!err) { if (data.responseCode == 200) { console.info('=====data.result=====' + data.result) // 解析数据 //this.content= data.result; // 解析数据 var cookModel: CookModel = JSON.parse(data.result.toString()) // 判断接口返回码,0成功 if (cookModel.code == 1000) { // 设置数据 this.future = cookModel.result.result.list.material this.cookdetail = cookModel.result.result.list this.isRequestSucceed = true; console.info('=====data.result===this.content==' + cookModel.result.result.list.material) } else { // 接口异常,弹出提示 prompt.showToast({ message: "数据请求失败" }) prompt.showToast({ message: jokeModel.error_code }) } } else { // 请求失败,弹出提示 prompt.showToast({ message: '网络异常' }) } } else { // 请求失败,弹出提示 prompt.showToast({ message: err.message }) } }) }
AST#method_declaration#Left getRequest AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { // 每一个httpRequest对应一个http请求任务,不可复用 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left httpRequest = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left http AST#expression#Right . createHttp AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left url = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left "https://way.jd.com/jisuapi/search?keyword=白菜&num=10&start=0&appkey=7c913be32b690701cd994d804a6d4294" AST#expression#Right AST#ERROR#Left httpRequest AST#ERROR#Right . request AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left url AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left err AST#parameter#Right , AST#parameter#Left data AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left err AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . responseCode AST#member_expression#Right AST#expression#Right == AST#expression#Left 200 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left '=====data.result=====' AST#expression#Right + AST#expression#Left data AST#expression#Right AST#binary_expression#Right AST#expression#Right . result 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 // 解析数据 //this.content= data.result; // 解析数据 AST#statement#Left AST#variable_declaration#Left var AST#variable_declarator#Left cookModel : AST#type_annotation#Left AST#primary_type#Left CookModel AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . parse AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left data AST#expression#Right . result AST#member_expression#Right AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right // 判断接口返回码,0成功 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 cookModel AST#expression#Right . code AST#member_expression#Right AST#expression#Right == AST#expression#Left 1000 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { // 设置数据 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . future AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cookModel AST#expression#Right . result AST#member_expression#Right AST#expression#Right . result AST#member_expression#Right AST#expression#Right . list AST#member_expression#Right AST#expression#Right . material 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 . cookdetail AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left cookModel AST#expression#Right . result AST#member_expression#Right AST#expression#Right . result AST#member_expression#Right AST#expression#Right . list 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 . isRequestSucceed 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#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left '=====data.result===this.content==' AST#expression#Right + AST#expression#Left cookModel AST#expression#Right AST#binary_expression#Right AST#expression#Right . result AST#member_expression#Right AST#expression#Right . result AST#member_expression#Right AST#expression#Right . list AST#member_expression#Right AST#expression#Right . material AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { // 接口异常,弹出提示 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left prompt AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left "数据请求失败" AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left prompt AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left jokeModel AST#expression#Right . error_code AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right 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 prompt AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left '网络异常' AST#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 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 prompt AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . message AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
getRequest() { let httpRequest = http.createHttp() let url = "https://way.jd.com/jisuapi/search?keyword=白菜&num=10&start=0&appkey=7c913be32b690701cd994d804a6d4294" httpRequest.request(url, (err, data) => { if (!err) { if (data.responseCode == 200) { console.info('=====data.result=====' + data.result) var cookModel: CookModel = JSON.parse(data.result.toString()) if (cookModel.code == 1000) { this.future = cookModel.result.result.list.material this.cookdetail = cookModel.result.result.list this.isRequestSucceed = true; console.info('=====data.result===this.content==' + cookModel.result.result.list.material) } else { prompt.showToast({ message: "数据请求失败" }) prompt.showToast({ message: jokeModel.error_code }) } } else { prompt.showToast({ message: '网络异常' }) } } else { prompt.showToast({ message: err.message }) } }) }
https://github.com/jianguo888/nut-recipes/blob/262304b5d2bee2d5f1df4e29c094c9ddd58f9d51/entry/src/main/ets/MainAbility/pages/Main.ets#L168-L206
d2395cf0b0ba201bc85e8e7052c6f45cb61755a1
gitee
openharmony/graphic_graphic_2d
46a11e91c9709942196ad2a7afea2e0fcd1349f3
interfaces/kits/ani/drawing/ets/@ohos.graphics.drawing.ets
arkts
Provides an interface to the drawing, and samplingOptions used when sampling from the image. @syscap SystemCapability.Graphics.Drawing @since 12
export class SamplingOptions { static { loadLibraryWithPermissionCheck("drawing_ani_core", "@ohos.graphics.drawing"); }
AST#export_declaration#Left export AST#class_declaration#Left class SamplingOptions AST#ERROR#Left { static AST#ERROR#Right AST#class_body#Left { AST#method_declaration#Left loadLibraryWithPermissionCheck AST#parameter_list#Left ( AST#ERROR#Left "drawing_ani_core" , "@ohos.graphics.drawing" AST#ERROR#Right ) AST#parameter_list#Right ; AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class SamplingOptions { static { loadLibraryWithPermissionCheck("drawing_ani_core", "@ohos.graphics.drawing"); }
https://github.com/openharmony/graphic_graphic_2d/blob/46a11e91c9709942196ad2a7afea2e0fcd1349f3/interfaces/kits/ani/drawing/ets/@ohos.graphics.drawing.ets#L305-L306
6026c84eccef3bbc81efff2a674140b29e73ae57
gitee
openharmony/interface_sdk-js
c349adc73e2ec1f61f6fca489b5af059e3ed6999
api/@ohos.deviceInfo.d.ets
arkts
get
Obtains the software model represented by a string. @syscap SystemCapability.Startup.SystemInfo @crossplatform @since 20 @arkts 1.2
static get softwareModel(): string;
AST#method_declaration#Left static get AST#ERROR#Left s of twareModel AST#ERROR#Right 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#method_declaration#Right
static get softwareModel(): string;
https://github.com/openharmony/interface_sdk-js/blob/c349adc73e2ec1f61f6fca489b5af059e3ed6999/api/@ohos.deviceInfo.d.ets#L120-L120
9d1de2acab4dda57799a853bf7fd73d0ca3c331e
gitee
2763981847/Klotski.git
35bfb313c07e25ea53d2f4e66df0c441dd51675b
entry/src/main/ets/view/ImageSelectComponent.ets
arkts
smallImgClickAction
处理缩略图的点击事件
smallImgClickAction(index: number): void { this.selectedIndex = index; this.smallScroller.scrollToIndex(this.selectedIndex); }
AST#method_declaration#Left smallImgClickAction AST#parameter_list#Left ( AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedIndex AST#member_expression#Right = AST#expression#Left index AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . smallScroller AST#member_expression#Right AST#expression#Right . scrollToIndex 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 . selectedIndex 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
smallImgClickAction(index: number): void { this.selectedIndex = index; this.smallScroller.scrollToIndex(this.selectedIndex); }
https://github.com/2763981847/Klotski.git/blob/35bfb313c07e25ea53d2f4e66df0c441dd51675b/entry/src/main/ets/view/ImageSelectComponent.ets#L41-L44
46c9a583bc2090847ffde4a9a9522d7ea68151fc
github
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/RandomUtil.ets
arkts
getRandomInt
生成随机整数(可指定范围) @return 随机数
static getRandomInt(min: number = 0, max: number = Number.MAX_SAFE_INTEGER): number { min = Math.ceil(min); //向上取整 max = Math.floor(max); //向下取整 return Math.floor(Math.random() * (max - min)) + min; }
AST#method_declaration#Left static getRandomInt AST#parameter_list#Left ( AST#parameter#Left min : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left 0 AST#expression#Right AST#parameter#Right , AST#parameter#Left max : 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 Number AST#expression#Right . MAX_SAFE_INTEGER AST#member_expression#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { 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 . ceil AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left min AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right //向上取整 AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left max = 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 max AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right //向下取整 AST#expression_statement#Left AST#expression#Left return AST#expression#Right AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#binary_expression#Left 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . random AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right * AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left max AST#expression#Right - AST#expression#Left min AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#parenthesized_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right + AST#expression#Left min AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
static getRandomInt(min: number = 0, max: number = Number.MAX_SAFE_INTEGER): number { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min)) + min; }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/RandomUtil.ets#L40-L44
e4da4b2509f4a3e41c14b9bafd95ca77b4489af7
gitee
zqaini002/YaoYaoLingXian.git
5095b12cbeea524a87c42d0824b1702978843d39
YaoYaoLingXian/entry/src/main/ets/services/ApiService.ets
arkts
获取帖子详情 @param id 帖子ID @returns 帖子详情
export function getPostById(id: number): Promise<Post> { try { console.info(`获取帖子详情, id: ${id}`); return request<ApiResponse<Post>>(RequestMethod.GET, `/posts/${id}`) .then(response => { if (!response || !response.data) { console.error('获取帖子详情失败: 无效的API响应格式'); throw new Error('获取帖子详情失败: 服务器返回无效数据'); } const post = response.data; console.info(`收到帖子详情: ID=${post.id}, 作者信息=${post.author ? '已包含' : '不存在'}`); // 确保author字段存在,如果不存在则根据其他字段创建 if (!post.author && post.userId) { // 使用postVO中的用户相关字段创建author对象 const userId = post.userId || 0; const username = post.username || '未知用户'; const nickname = post.nickname || post.username || '未知用户'; const avatar = post.userAvatar || ''; console.info(`创建作者对象: userId=${userId}, username=${username}, nickname=${nickname}`); post.author = { id: userId, username: username, nickname: nickname, avatar: avatar, isFollowed: false }; } else if (!post.author) { // 如果没有用户相关信息,则创建默认作者对象 post.author = { id: 0, username: '未知用户', nickname: '未知用户', avatar: '', isFollowed: false }; } // 处理作者头像URL if (post.author && post.author.avatar) { try { post.author.avatar = processImageUrl(post.author.avatar); console.info(`处理后的作者头像URL: ${post.author.avatar.substring(0, 50)}...`); } catch (error) { console.error(`处理作者头像URL失败: ${error instanceof Error ? error.message : String(error)}`); // 确保avatar字段不为undefined post.author.avatar = ''; } } // 处理图片URLs if (!post.imageUrls) { post.imageUrls = []; } if (post.images) { try { if (typeof post.images === 'string' && post.images.trim() !== '') { post.imageUrls = post.images.split(',') .filter(url => url && url.trim() !== '') .map((url: string) => processImageUrl(url)); console.info(`处理后的图片URLs: ${post.imageUrls.length}张`); } else if (Array.isArray(post.images)) { post.imageUrls = post.images.map((url: string) => processImageUrl(url)); console.info(`图片URLs数组: ${post.imageUrls.length}张`); } else { console.info(`无图片数据`); } } catch (error) { console.error(`处理图片URL失败: ${error instanceof Error ? error.message : String(error)}`); post.imageUrls = []; } } else { console.info(`帖子无图片字段`); } return post; }); } catch (error) { const errorMsg = `获取帖子详情失败: ${error instanceof Error ? error.message : String(error)}`; console.error(errorMsg); throw new Error(errorMsg); } }
AST#export_declaration#Left export AST#function_declaration#Left function getPostById AST#parameter_list#Left ( AST#parameter#Left id : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left Post AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` 获取帖子详情, id: AST#template_substitution#Left $ { AST#expression#Left id AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#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 request AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left ApiResponse AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left Post AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left RequestMethod AST#expression#Right . GET AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` /posts/ AST#template_substitution#Left $ { AST#expression#Left id AST#expression#Right } AST#template_substitution#Right ` AST#template_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 response => 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#unary_expression#Left ! AST#expression#Left response AST#expression#Right AST#unary_expression#Right AST#expression#Right || AST#expression#Left AST#unary_expression#Left ! AST#expression#Left response AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right . data AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '获取帖子详情失败: 无效的API响应格式' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#throw_statement#Left throw AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Error AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '获取帖子详情失败: 服务器返回无效数据' AST#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 post = AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . data AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#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 AST#member_expression#Left AST#expression#Left post AST#expression#Right . id AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , 作者信息= AST#template_substitution#Left $ { AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left post AST#expression#Right . author AST#member_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#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 // 确保author字段存在,如果不存在则根据其他字段创建 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left post AST#expression#Right AST#unary_expression#Right AST#expression#Right . author AST#member_expression#Right AST#expression#Right && AST#expression#Left post AST#expression#Right AST#binary_expression#Right AST#expression#Right . userId AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { // 使用postVO中的用户相关字段创建author对象 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left userId = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left post AST#expression#Right . userId AST#member_expression#Right AST#expression#Right || AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left username = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left post AST#expression#Right . username AST#member_expression#Right AST#expression#Right || AST#expression#Left '未知用户' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left nickname = 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 post AST#expression#Right . nickname AST#member_expression#Right AST#expression#Right || AST#expression#Left post AST#expression#Right AST#binary_expression#Right AST#expression#Right . username AST#member_expression#Right AST#expression#Right || AST#expression#Left '未知用户' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left avatar = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left post AST#expression#Right . userAvatar AST#member_expression#Right AST#expression#Right || AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` 创建作者对象: userId= AST#template_substitution#Left $ { AST#expression#Left userId AST#expression#Right } AST#template_substitution#Right , username= AST#template_substitution#Left $ { AST#expression#Left username AST#expression#Right } AST#template_substitution#Right , nickname= AST#template_substitution#Left $ { AST#expression#Left nickname 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 post AST#expression#Right . author AST#member_expression#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left id AST#property_name#Right : AST#expression#Left userId AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left username AST#property_name#Right : AST#expression#Left username AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left nickname AST#property_name#Right : AST#expression#Left nickname AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left avatar AST#property_name#Right : AST#expression#Left avatar AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left isFollowed AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#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#unary_expression#Left ! AST#expression#Left post AST#expression#Right AST#unary_expression#Right AST#expression#Right . author 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 post AST#expression#Right . author AST#member_expression#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left id AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left username AST#property_name#Right : AST#expression#Left '未知用户' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left nickname AST#property_name#Right : AST#expression#Left '未知用户' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left avatar AST#property_name#Right : AST#expression#Left '' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left isFollowed AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#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 // 处理作者头像URL 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 post AST#expression#Right . author AST#member_expression#Right AST#expression#Right && AST#expression#Left post AST#expression#Right AST#binary_expression#Right AST#expression#Right . author AST#member_expression#Right AST#expression#Right . avatar AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left post AST#expression#Right . author AST#member_expression#Right AST#expression#Right . avatar AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left processImageUrl AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left post AST#expression#Right . author AST#member_expression#Right AST#expression#Right . avatar AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` 处理后的作者头像URL: 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 AST#member_expression#Left AST#expression#Left post AST#expression#Right . author AST#member_expression#Right AST#expression#Right . avatar AST#member_expression#Right AST#expression#Right . substring AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left 50 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#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 ` 处理作者头像URL失败: AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left error AST#expression#Right instanceof AST#expression#Left Error AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . message AST#member_expression#Right AST#expression#Right : AST#expression#Left String AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 确保avatar字段不为undefined 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 post AST#expression#Right . author AST#member_expression#Right AST#expression#Right . avatar AST#member_expression#Right = AST#expression#Left '' AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 处理图片URLs 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 post AST#expression#Right AST#unary_expression#Right AST#expression#Right . imageUrls 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 post AST#expression#Right . imageUrls AST#member_expression#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left post AST#expression#Right . images AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#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 AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left typeof AST#expression#Left post AST#expression#Right AST#unary_expression#Right AST#expression#Right . images AST#member_expression#Right AST#expression#Right === AST#expression#Left 'string' AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left post AST#expression#Right AST#binary_expression#Right AST#expression#Right . images AST#member_expression#Right AST#expression#Right . trim AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right !== AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left post AST#expression#Right . imageUrls AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left post AST#expression#Right . images AST#member_expression#Right 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 . filter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left url => 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 url AST#expression#Right && AST#expression#Left url AST#expression#Right AST#binary_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#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left url : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left processImageUrl AST#expression#Right AST#argument_list#Left ( AST#expression#Left url AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#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 ` 处理后的图片URLs: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left post AST#expression#Right . imageUrls AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right 张 ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#if_statement#Left if ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Array AST#expression#Right . isArray AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left post AST#expression#Right . images AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left post AST#expression#Right . imageUrls 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 post AST#expression#Right . images AST#member_expression#Right AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left url : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left AST#call_expression#Left AST#expression#Left processImageUrl AST#expression#Right AST#argument_list#Left ( AST#expression#Left url AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#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 ` 图片URLs数组: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left post AST#expression#Right . imageUrls AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right 张 ` AST#template_literal#Right AST#expression#Right ) AST#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 . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` 无图片数据 ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` 处理图片URL失败: AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left error AST#expression#Right instanceof AST#expression#Left Error AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . message AST#member_expression#Right AST#expression#Right : AST#expression#Left String AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#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 post AST#expression#Right . imageUrls AST#member_expression#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right 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 ` 帖子无图片字段 ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left post AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left errorMsg = AST#expression#Left AST#template_literal#Left ` 获取帖子详情失败: AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left error AST#expression#Right instanceof AST#expression#Left Error AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left AST#member_expression#Left AST#expression#Left error AST#expression#Right . message AST#member_expression#Right AST#expression#Right : AST#expression#Left String AST#expression#Right AST#conditional_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left errorMsg AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#throw_statement#Left throw AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Error AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left errorMsg AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#throw_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export function getPostById(id: number): Promise<Post> { try { console.info(`获取帖子详情, id: ${id}`); return request<ApiResponse<Post>>(RequestMethod.GET, `/posts/${id}`) .then(response => { if (!response || !response.data) { console.error('获取帖子详情失败: 无效的API响应格式'); throw new Error('获取帖子详情失败: 服务器返回无效数据'); } const post = response.data; console.info(`收到帖子详情: ID=${post.id}, 作者信息=${post.author ? '已包含' : '不存在'}`); if (!post.author && post.userId) { const userId = post.userId || 0; const username = post.username || '未知用户'; const nickname = post.nickname || post.username || '未知用户'; const avatar = post.userAvatar || ''; console.info(`创建作者对象: userId=${userId}, username=${username}, nickname=${nickname}`); post.author = { id: userId, username: username, nickname: nickname, avatar: avatar, isFollowed: false }; } else if (!post.author) { post.author = { id: 0, username: '未知用户', nickname: '未知用户', avatar: '', isFollowed: false }; } if (post.author && post.author.avatar) { try { post.author.avatar = processImageUrl(post.author.avatar); console.info(`处理后的作者头像URL: ${post.author.avatar.substring(0, 50)}...`); } catch (error) { console.error(`处理作者头像URL失败: ${error instanceof Error ? error.message : String(error)}`); post.author.avatar = ''; } } if (!post.imageUrls) { post.imageUrls = []; } if (post.images) { try { if (typeof post.images === 'string' && post.images.trim() !== '') { post.imageUrls = post.images.split(',') .filter(url => url && url.trim() !== '') .map((url: string) => processImageUrl(url)); console.info(`处理后的图片URLs: ${post.imageUrls.length}张`); } else if (Array.isArray(post.images)) { post.imageUrls = post.images.map((url: string) => processImageUrl(url)); console.info(`图片URLs数组: ${post.imageUrls.length}张`); } else { console.info(`无图片数据`); } } catch (error) { console.error(`处理图片URL失败: ${error instanceof Error ? error.message : String(error)}`); post.imageUrls = []; } } else { console.info(`帖子无图片字段`); } return post; }); } catch (error) { const errorMsg = `获取帖子详情失败: ${error instanceof Error ? error.message : String(error)}`; console.error(errorMsg); throw new Error(errorMsg); } }
https://github.com/zqaini002/YaoYaoLingXian.git/blob/5095b12cbeea524a87c42d0824b1702978843d39/YaoYaoLingXian/entry/src/main/ets/services/ApiService.ets#L1057-L1143
31b99c721ae9283df8b8512595aaeb68c07d5eaa
github
queueit/harmony-sdk.git
ba7b4b38c03730bfbe305789acba6db0012d5f5c
entry/src/main/ets/pages/DemoPage.ets
arkts
DemoPageBuilder
Input field value
@Builder export function DemoPageBuilder() { DemoPage(); }
AST#decorated_export_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right export function DemoPageBuilder AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#ui_custom_component_statement#Left DemoPage ( ) ; AST#ui_custom_component_statement#Right } AST#builder_function_body#Right AST#decorated_export_declaration#Right
@Builder export function DemoPageBuilder() { DemoPage(); }
https://github.com/queueit/harmony-sdk.git/blob/ba7b4b38c03730bfbe305789acba6db0012d5f5c/entry/src/main/ets/pages/DemoPage.ets#L32-L35
88894b51483484a7a44678a1669311beabff9049
github
awa_Liny/LinysBrowser_NEXT
a5cd96a9aa8114cae4972937f94a8967e55d4a10
home/src/main/ets/hosts/bunch_of_history_index_lite.ets
arkts
This bunch_of_history_index could only clear and push data in a sorted manner.
constructor() { }
AST#constructor_declaration#Left constructor AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { } AST#block_statement#Right AST#constructor_declaration#Right
constructor() { }
https://github.com/awa_Liny/LinysBrowser_NEXT/blob/a5cd96a9aa8114cae4972937f94a8967e55d4a10/home/src/main/ets/hosts/bunch_of_history_index_lite.ets#L14-L15
0c302a8552a6be4575974b07dd42b9b4347bae2a
gitee
ashcha0/line-inspection-terminal-frontend_arkts.git
c82616097e8a3b257b7b01e75b6b83ce428b518c
entry/src/main/ets/services/TaskService.ets
arkts
上传信息接口
export interface AgvUploadInfoVO { info: string; type: string; status: string; }
AST#export_declaration#Left export AST#interface_declaration#Left interface AgvUploadInfoVO AST#object_type#Left { AST#type_member#Left info : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left type : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left status : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
export interface AgvUploadInfoVO { info: string; type: string; status: string; }
https://github.com/ashcha0/line-inspection-terminal-frontend_arkts.git/blob/c82616097e8a3b257b7b01e75b6b83ce428b518c/entry/src/main/ets/services/TaskService.ets#L43-L47
6d747f52cb16551594ae61ba6d39a2422afd3893
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/imagecompression/src/main/ets/view/ImageCompression.ets
arkts
saveTestPhoto
测试图片保存到图库
async saveTestPhoto(context: common.UIAbilityContext) { let helper = photoAccessHelper.getPhotoAccessHelper(context); try { this.beforeCompressFmt = 'jpeg'; this.afterCompressFmt = this.beforeCompressFmt; // 创建图片文件 this.uris[0] = await helper.createAsset(photoAccessHelper.PhotoType.IMAGE, 'jpeg'); // 打开文件 let file = await fileIo.open(this.uris[0], fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE); // 获取测试图片 context.resourceManager.getMediaContent($r('app.media.image_compression_test').id, 0) .then(async value => { let media = value.buffer; await fileIo.write(file.fd, media); this.beforeCompressByteLength = fs.statSync(file.fd).size; await fileIo.close(file.fd); promptAction.showToast({ message: $r('app.string.image_compression_save_test_image') }); // 设置photoCount,用于刷新显示压缩前图片 this.photoCount = 1; this.testUri = this.uris[0]; emitter.emit('ImageCompression2', { data: { testUri: this.testUri } }); }); } catch (error) { const err: BusinessError = error as BusinessError; hilog.error(0x0000, TAG, `Failed to save photo. Code is ${err.code}, message is ${err.message}`); } }
AST#method_declaration#Left async saveTestPhoto AST#parameter_list#Left ( AST#parameter#Left context : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left common . UIAbilityContext AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left helper = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left photoAccessHelper AST#expression#Right . getPhotoAccessHelper AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#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 . beforeCompressFmt AST#member_expression#Right = AST#expression#Left 'jpeg' 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 . afterCompressFmt AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . beforeCompressFmt 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#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . uris AST#member_expression#Right 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left helper AST#expression#Right AST#await_expression#Right AST#expression#Right . createAsset 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 photoAccessHelper AST#expression#Right . PhotoType AST#member_expression#Right AST#expression#Right . IMAGE AST#member_expression#Right AST#expression#Right , AST#expression#Left 'jpeg' 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 file = 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 fileIo AST#expression#Right AST#await_expression#Right AST#expression#Right . open AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . uris AST#member_expression#Right AST#expression#Right [ AST#expression#Left 0 AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fileIo AST#expression#Right . OpenMode AST#member_expression#Right AST#expression#Right . READ_WRITE AST#member_expression#Right AST#expression#Right | AST#expression#Left fileIo AST#expression#Right AST#binary_expression#Right AST#expression#Right . OpenMode AST#member_expression#Right AST#expression#Right . CREATE AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right // 获取测试图片 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left context AST#expression#Right . resourceManager AST#member_expression#Right AST#expression#Right . getMediaContent 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.media.image_compression_test' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right . id 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 . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left async value => AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left media = AST#expression#Left AST#member_expression#Left AST#expression#Left value AST#expression#Right . buffer AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left fileIo AST#expression#Right AST#await_expression#Right AST#expression#Right . write AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left file AST#expression#Right . fd AST#member_expression#Right AST#expression#Right , AST#expression#Left media 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 . beforeCompressByteLength AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left fs AST#expression#Right . statSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left file AST#expression#Right . fd AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . size AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left fileIo AST#expression#Right AST#await_expression#Right AST#expression#Right . close AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left file AST#expression#Right . fd AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; 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 promptAction AST#expression#Right . showToast AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.image_compression_save_test_image' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 设置photoCount,用于刷新显示压缩前图片 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 . photoCount AST#member_expression#Right = AST#expression#Left 1 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . testUri AST#member_expression#Right = AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . uris AST#member_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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left emitter AST#expression#Right . emit AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'ImageCompression2' AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left data AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left testUri AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . testUri AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#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#variable_declaration#Left const AST#variable_declarator#Left err : AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left BusinessError AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left hilog AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0x0000 AST#expression#Right , AST#expression#Left TAG AST#expression#Right , AST#expression#Left AST#template_literal#Left ` Failed to save photo. Code is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . code AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right , message is AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . message AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async saveTestPhoto(context: common.UIAbilityContext) { let helper = photoAccessHelper.getPhotoAccessHelper(context); try { this.beforeCompressFmt = 'jpeg'; this.afterCompressFmt = this.beforeCompressFmt; this.uris[0] = await helper.createAsset(photoAccessHelper.PhotoType.IMAGE, 'jpeg'); let file = await fileIo.open(this.uris[0], fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE); context.resourceManager.getMediaContent($r('app.media.image_compression_test').id, 0) .then(async value => { let media = value.buffer; await fileIo.write(file.fd, media); this.beforeCompressByteLength = fs.statSync(file.fd).size; await fileIo.close(file.fd); promptAction.showToast({ message: $r('app.string.image_compression_save_test_image') }); this.photoCount = 1; this.testUri = this.uris[0]; emitter.emit('ImageCompression2', { data: { testUri: this.testUri } }); }); } catch (error) { const err: BusinessError = error as BusinessError; hilog.error(0x0000, TAG, `Failed to save photo. Code is ${err.code}, message is ${err.message}`); } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/imagecompression/src/main/ets/view/ImageCompression.ets#L135-L165
71a025191e81835f886b314d7aa881191b000295
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/common/utils/LunarCalendar.ets
arkts
getYearDays
获取指定年份的总天数
static getYearDays(year: number): number { let totalDays = 0; const yearInfo = ComprehensiveLunarDatabase.getYearInfo(year); // 计算12个月的天数 for (let month = 1; month <= 12; month++) { totalDays += ComprehensiveLunarDatabase.getMonthDays(year, month); } // 加上闰月天数 totalDays += ComprehensiveLunarDatabase.getLeapMonthDays(year); return totalDays; }
AST#method_declaration#Left static getYearDays AST#parameter_list#Left ( AST#parameter#Left year : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#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 totalDays = AST#expression#Left 0 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left yearInfo = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ComprehensiveLunarDatabase AST#expression#Right . getYearInfo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left year 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 // 计算12个月的天数 AST#statement#Left AST#for_statement#Left for ( AST#variable_declaration#Left let AST#variable_declarator#Left month = AST#expression#Left 1 AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#expression#Left AST#binary_expression#Left AST#expression#Left month AST#expression#Right <= AST#expression#Left 12 AST#expression#Right AST#binary_expression#Right AST#expression#Right ; AST#expression#Left AST#update_expression#Left AST#expression#Left month AST#expression#Right ++ AST#update_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left totalDays += AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ComprehensiveLunarDatabase AST#expression#Right . getMonthDays AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left year 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#block_statement#Right AST#for_statement#Right AST#statement#Right // 加上闰月天数 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left totalDays += AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ComprehensiveLunarDatabase AST#expression#Right . getLeapMonthDays AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left year 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 totalDays AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static getYearDays(year: number): number { let totalDays = 0; const yearInfo = ComprehensiveLunarDatabase.getYearInfo(year); for (let month = 1; month <= 12; month++) { totalDays += ComprehensiveLunarDatabase.getMonthDays(year, month); } totalDays += ComprehensiveLunarDatabase.getLeapMonthDays(year); return totalDays; }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/utils/LunarCalendar.ets#L161-L174
df2476049654b7e8bed6b48d6ad6b30eff86513d
github
iotjin/JhHarmonyDemo.git
819e6c3b1db9984c042a181967784550e171b2e8
entry/src/main/ets/pages/one/models/WxHomeModel.ets
arkts
type 0 没有侧滑 type 1 删除 type 2 标为未读和删除 type 3 不在关注和删除
export interface WxHomeItemType { title?: string subtitle?: string img?: string time?: string isNew?: boolean type?: string }
AST#export_declaration#Left export AST#interface_declaration#Left interface WxHomeItemType AST#object_type#Left { AST#type_member#Left title ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right AST#type_member#Left subtitle ? : 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 img ? : 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 time ? : 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 isNew ? : 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 type ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
export interface WxHomeItemType { title?: string subtitle?: string img?: string time?: string isNew?: boolean type?: string }
https://github.com/iotjin/JhHarmonyDemo.git/blob/819e6c3b1db9984c042a181967784550e171b2e8/entry/src/main/ets/pages/one/models/WxHomeModel.ets#L15-L22
44b052809eec5053775b51f7977486a60e267126
github
waylau/harmonyos-tutorial
74e23dfa769317f8f057cc77c2d09f0b1f2e0773
samples/ArkUIExperience/entry/src/main/ets/common/constants/Constants.ets
arkts
Input组件样式
export const InputStyle = { TEXT_INPUT_OPACITY: .2, TEXT_INPUT_PLACEHOLDER_SIZE: 20, TEXT_INPUT_PLACEHOLDER_WEIGHT: 300, TEXT_INPUT_PLACEHOLDER_HEIGHT: '100%', TEXT_INPUT_PLACEHOLDER_RADIUS: 2, TEXT_INPUT_PLACEHOLDER_PADDING_RIGHT: 70, TEXT_INPUT_PLACEHOLDER_MARGIN_RIGHT: 5, TEXT_INPUT_PLACEHOLDER_MARGIN_LEFT: 5, BUTTON_CONFIRM_OFFSET_X: -70, BUTTON_CONFIRM_WIDTH: 70, BUTTON_CONFIRM_HEIGHT: '100%', BUTTON_CONFIRM_RADIUS: 6, ROW_WIDTH: 292, ROW_HEIGHT: 40, ROW_RADIUS: 6 };
AST#export_declaration#Left export AST#variable_declaration#Left const AST#variable_declarator#Left InputStyle = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left TEXT_INPUT_OPACITY AST#property_name#Right : AST#ERROR#Left . AST#ERROR#Right AST#expression#Left 2 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left TEXT_INPUT_PLACEHOLDER_SIZE AST#property_name#Right : AST#expression#Left 20 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left TEXT_INPUT_PLACEHOLDER_WEIGHT AST#property_name#Right : AST#expression#Left 300 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left TEXT_INPUT_PLACEHOLDER_HEIGHT AST#property_name#Right : AST#expression#Left '100%' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left TEXT_INPUT_PLACEHOLDER_RADIUS AST#property_name#Right : AST#expression#Left 2 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left TEXT_INPUT_PLACEHOLDER_PADDING_RIGHT AST#property_name#Right : AST#expression#Left 70 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left TEXT_INPUT_PLACEHOLDER_MARGIN_RIGHT AST#property_name#Right : AST#expression#Left 5 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left TEXT_INPUT_PLACEHOLDER_MARGIN_LEFT AST#property_name#Right : AST#expression#Left 5 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left BUTTON_CONFIRM_OFFSET_X AST#property_name#Right : AST#expression#Left AST#unary_expression#Left - AST#expression#Left 70 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left BUTTON_CONFIRM_WIDTH AST#property_name#Right : AST#expression#Left 70 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left BUTTON_CONFIRM_HEIGHT AST#property_name#Right : AST#expression#Left '100%' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left BUTTON_CONFIRM_RADIUS AST#property_name#Right : AST#expression#Left 6 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left ROW_WIDTH AST#property_name#Right : AST#expression#Left 292 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left ROW_HEIGHT AST#property_name#Right : AST#expression#Left 40 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left ROW_RADIUS AST#property_name#Right : AST#expression#Left 6 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#export_declaration#Right
export const InputStyle = { TEXT_INPUT_OPACITY: .2, TEXT_INPUT_PLACEHOLDER_SIZE: 20, TEXT_INPUT_PLACEHOLDER_WEIGHT: 300, TEXT_INPUT_PLACEHOLDER_HEIGHT: '100%', TEXT_INPUT_PLACEHOLDER_RADIUS: 2, TEXT_INPUT_PLACEHOLDER_PADDING_RIGHT: 70, TEXT_INPUT_PLACEHOLDER_MARGIN_RIGHT: 5, TEXT_INPUT_PLACEHOLDER_MARGIN_LEFT: 5, BUTTON_CONFIRM_OFFSET_X: -70, BUTTON_CONFIRM_WIDTH: 70, BUTTON_CONFIRM_HEIGHT: '100%', BUTTON_CONFIRM_RADIUS: 6, ROW_WIDTH: 292, ROW_HEIGHT: 40, ROW_RADIUS: 6 };
https://github.com/waylau/harmonyos-tutorial/blob/74e23dfa769317f8f057cc77c2d09f0b1f2e0773/samples/ArkUIExperience/entry/src/main/ets/common/constants/Constants.ets#L65-L81
f1acaf393d8819c27224b997b8132890b0a8252a
gitee
awa_Liny/LinysBrowser_NEXT
a5cd96a9aa8114cae4972937f94a8967e55d4a10
home/src/main/ets/hosts/bunch_of_tabs.ets
arkts
newTab
Creates a new tab. @param target_url A string, if link is "", then load the default new_tab_url set in this object. @param recover_on_creation A boolean, if set true, then the tab will restore the serialized web state in @returns A number, the index of the new tab. @description While if new_tab_url is also not set ("" or undefined), then will load the url_default_blank().
newTab(context: UIContext, target_url: string, init_state: boolean, placeholder_label?: string) { if (!this.my_storage) { console.warn(`[bunch_of_tabs] INTERCEPTED for undefined my_storage! newTab: url=${target_url}`); return; } console.log(`[bunch_of_tabs] newTab: url=${target_url}, label=${placeholder_label}`); if (target_url == "") { // If newing an empty tab if (bunch_of_tabs.new_tab_url == "" || bunch_of_tabs.new_tab_url == undefined) { // If new tab not specified target_url = url_default_blank(); } else { // If new tab is specified target_url = bunch_of_tabs.new_tab_url; } } let idx = this.Tabs.length; let new_TabInfo: tab_info_packed = new tab_info_packed(placeholder_label || 'Meow', target_url, this.my_storage, idx, init_state); let Date_ID = Date.now(); while (this.tab_timestamp_collide(Date_ID)) { // Date_ID crash prevention Date_ID += 1; } this.used_timestamps.add(Date_ID); let new_TabLabel: tab_label = new tab_label(Date_ID, idx); this.Tabs.push(new_TabInfo); if (init_state) { this.NodeControllers.push(undefined); } else { this.NodeControllers.push(new TabNodeController(createNWeb(context, new_TabInfo))); } this.Labels.push(new_TabLabel); this.main_tab_idx = this.Tabs.length - 1; // Turn on auto save web state // new_TabInfo.on_regular_save(); return this.main_tab_idx as number; }
AST#method_declaration#Left newTab 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 target_url : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left init_state : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left placeholder_label ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . my_storage AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . warn AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` [bunch_of_tabs] INTERCEPTED for undefined my_storage! newTab: url= AST#template_substitution#Left $ { AST#expression#Left target_url 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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` [bunch_of_tabs] newTab: url= AST#template_substitution#Left $ { AST#expression#Left target_url AST#expression#Right } AST#template_substitution#Right , label= AST#template_substitution#Left $ { AST#expression#Left placeholder_label AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left target_url AST#expression#Right == AST#expression#Left "" AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { // If newing an empty tab AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left bunch_of_tabs AST#expression#Right . new_tab_url AST#member_expression#Right AST#expression#Right == AST#expression#Left "" AST#expression#Right AST#binary_expression#Right AST#expression#Right || AST#expression#Left bunch_of_tabs AST#expression#Right AST#binary_expression#Right AST#expression#Right . new_tab_url AST#member_expression#Right AST#expression#Right == AST#expression#Left undefined AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { // If new tab not specified AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left target_url = AST#expression#Left AST#call_expression#Left AST#expression#Left url_default_blank 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 else AST#block_statement#Left { // If new tab is specified AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left target_url = AST#expression#Left AST#member_expression#Left AST#expression#Left bunch_of_tabs AST#expression#Right . new_tab_url AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left idx = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . Tabs AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left new_TabInfo : AST#type_annotation#Left AST#primary_type#Left tab_info_packed 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 tab_info_packed AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left placeholder_label AST#expression#Right || AST#expression#Left 'Meow' AST#expression#Right AST#binary_expression#Right AST#expression#Right , AST#expression#Left target_url AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . my_storage AST#member_expression#Right AST#expression#Right , AST#expression#Left idx AST#expression#Right , AST#expression#Left init_state 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 Date_ID = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Date AST#expression#Right . now AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#while_statement#Left while ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . tab_timestamp_collide AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left Date_ID AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { // Date_ID crash prevention AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left Date_ID += AST#expression#Left 1 AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#while_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . used_timestamps AST#member_expression#Right AST#expression#Right . add AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left Date_ID AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left new_TabLabel : AST#type_annotation#Left AST#primary_type#Left tab_label 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 tab_label AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left Date_ID AST#expression#Right , AST#expression#Left idx AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . Tabs AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left new_TabInfo 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 init_state 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 . NodeControllers AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left undefined AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . NodeControllers AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left TabNodeController AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left createNWeb AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right , AST#expression#Left new_TabInfo AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . Labels AST#member_expression#Right AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left new_TabLabel 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 . main_tab_idx 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 . Tabs 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#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // Turn on auto save web state // new_TabInfo.on_regular_save(); AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#as_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . main_tab_idx AST#member_expression#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
newTab(context: UIContext, target_url: string, init_state: boolean, placeholder_label?: string) { if (!this.my_storage) { console.warn(`[bunch_of_tabs] INTERCEPTED for undefined my_storage! newTab: url=${target_url}`); return; } console.log(`[bunch_of_tabs] newTab: url=${target_url}, label=${placeholder_label}`); if (target_url == "") { if (bunch_of_tabs.new_tab_url == "" || bunch_of_tabs.new_tab_url == undefined) { target_url = url_default_blank(); } else { target_url = bunch_of_tabs.new_tab_url; } } let idx = this.Tabs.length; let new_TabInfo: tab_info_packed = new tab_info_packed(placeholder_label || 'Meow', target_url, this.my_storage, idx, init_state); let Date_ID = Date.now(); while (this.tab_timestamp_collide(Date_ID)) { Date_ID += 1; } this.used_timestamps.add(Date_ID); let new_TabLabel: tab_label = new tab_label(Date_ID, idx); this.Tabs.push(new_TabInfo); if (init_state) { this.NodeControllers.push(undefined); } else { this.NodeControllers.push(new TabNodeController(createNWeb(context, new_TabInfo))); } this.Labels.push(new_TabLabel); this.main_tab_idx = this.Tabs.length - 1; return this.main_tab_idx as number; }
https://github.com/awa_Liny/LinysBrowser_NEXT/blob/a5cd96a9aa8114cae4972937f94a8967e55d4a10/home/src/main/ets/hosts/bunch_of_tabs.ets#L339-L382
b4c7a68c34af748e6edf158e75128e22a4da17f8
gitee
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_dialog/src/main/ets/model/DateTimePickerOptions.ets
arkts
TODO 弹窗工具类,DatePicker参数类 author: 桃花镇童长老ᥫ᭡ since: 2024/08/18
export interface DateTimePickerOptions extends BasePickerOptions { dateType: DateType; //选择的日期类型 selected?: Date; // 选中日期,不传默认当前日期 start?: Date; //开始日期(1900-01-01 00:00:00) end?: Date; //结束日期(2199-12-31 23:59:59) onAction: ActionDateCallBack; //按钮的CallBack事件。 }
AST#export_declaration#Left export AST#interface_declaration#Left interface DateTimePickerOptions AST#extends_clause#Left extends BasePickerOptions AST#extends_clause#Right AST#object_type#Left { AST#type_member#Left dateType : AST#type_annotation#Left AST#primary_type#Left DateType AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; //选择的日期类型 AST#type_member#Left selected ? : AST#type_annotation#Left AST#primary_type#Left Date AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; // 选中日期,不传默认当前日期 AST#type_member#Left start ? : AST#type_annotation#Left AST#primary_type#Left Date AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; //开始日期(1900-01-01 00:00:00) AST#type_member#Left end ? : AST#type_annotation#Left AST#primary_type#Left Date AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; //结束日期(2199-12-31 23:59:59) AST#type_member#Left onAction : AST#type_annotation#Left AST#primary_type#Left ActionDateCallBack AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; //按钮的CallBack事件。 } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
export interface DateTimePickerOptions extends BasePickerOptions { dateType: DateType; selected?: Date; start?: Date; end?: Date; onAction: ActionDateCallBack; }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_dialog/src/main/ets/model/DateTimePickerOptions.ets#L26-L35
ce1a60d8252af4c58a2af86921d528580a4d55ed
gitee
openharmony/arkui_ace_engine
30c7d1ee12fbedf0fabece54291d75897e2ad44f
examples/BindSheet/entry/src/main/ets/pages/multiDeviceConversion/Index04.ets
arkts
mySheet
半模态页面
@Builder mySheet() { Column({space: 20}) { Text('bindSheet page') .fontSize(30) Row({space: 40}) { Column({space: 20}) { ForEach([1, 2, 3, 4], () => { Stack() .backgroundColor(Color.Pink) .borderRadius(20) .width(60) .height(60) }) } Column() { if (this.isShowImage) { // 半模态页面的自定义图片节点 ImageNode() } else { // 抓取布局和占位用,实际不显示 Image($r('app.media.startIcon')) .visibility(Visibility.Hidden) } } .height(300) .width(200) .borderRadius(20) .clip(true) .id('target') } .alignItems(VerticalAlign.Top) } .alignItems(HorizontalAlign.Start) .height('100%') .width('100%') .margin(40) }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right mySheet AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 20 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left 'bindSheet page' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 30 AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 40 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 20 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#ui_control_flow#Left AST#for_each_statement#Left ForEach ( AST#expression#Left AST#array_literal#Left [ AST#expression#Left 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#array_literal#Right AST#expression#Right , AST#ui_builder_arrow_function#Left AST#parameter_list#Left ( ) 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 Stack ( ) AST#ui_component#Right AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Pink AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 20 AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_arrow_function_body#Right AST#ui_builder_arrow_function#Right ) AST#for_each_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isShowImage AST#member_expression#Right AST#expression#Right ) { // 半模态页面的自定义图片节点 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left ImageNode ( ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } else { // 抓取布局和占位用,实际不显示 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.startIcon' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . visibility ( AST#expression#Left AST#member_expression#Left AST#expression#Left Visibility AST#expression#Right . Hidden AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . height ( AST#expression#Left 300 AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left 200 AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 20 AST#expression#Right ) AST#modifier_chain_expression#Left . clip ( AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . id ( AST#expression#Left 'target' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left VerticalAlign AST#expression#Right . Top AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left HorizontalAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left 40 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
@Builder mySheet() { Column({space: 20}) { Text('bindSheet page') .fontSize(30) Row({space: 40}) { Column({space: 20}) { ForEach([1, 2, 3, 4], () => { Stack() .backgroundColor(Color.Pink) .borderRadius(20) .width(60) .height(60) }) } Column() { if (this.isShowImage) { ImageNode() } else { Image($r('app.media.startIcon')) .visibility(Visibility.Hidden) } } .height(300) .width(200) .borderRadius(20) .clip(true) .id('target') } .alignItems(VerticalAlign.Top) } .alignItems(HorizontalAlign.Start) .height('100%') .width('100%') .margin(40) }
https://github.com/openharmony/arkui_ace_engine/blob/30c7d1ee12fbedf0fabece54291d75897e2ad44f/examples/BindSheet/entry/src/main/ets/pages/multiDeviceConversion/Index04.ets#L212-L249
2124e76e31379d263a037b333b20deca1c41425f
gitee
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/common/utils/strings/StringUtils.ets
arkts
isValidEmail
验证邮箱格式是否正确 @param email 输入的邮箱字符串 @returns 是否是合法的邮箱格式
static isValidEmail(email: string): boolean { const emailRegex: RegExp = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,64}$/i; return emailRegex.test(email); }
AST#method_declaration#Left static isValidEmail AST#parameter_list#Left ( AST#parameter#Left email : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left emailRegex : AST#type_annotation#Left AST#primary_type#Left RegExp AST#primary_type#Right AST#type_annotation#Right = AST#ERROR#Left / ^ AST#ERROR#Right AST#expression#Left AST#array_literal#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 A AST#expression#Right - AST#expression#Left Z0 AST#expression#Right AST#binary_expression#Right AST#expression#Right - AST#expression#Left 9 AST#expression#Right AST#binary_expression#Right AST#expression#Right . _ AST#member_expression#Right AST#expression#Right % AST#expression#Left AST#unary_expression#Left + AST#expression#Left AST#unary_expression#Left - AST#ERROR#Left ] AST#ERROR#Right AST#expression#Left AST#unary_expression#Left + AST#ERROR#Left @ AST#ERROR#Right AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left A AST#expression#Right - AST#expression#Left Z0 AST#expression#Right AST#binary_expression#Right AST#expression#Right - AST#expression#Left 9 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#ERROR#Left . - AST#ERROR#Right ] AST#array_literal#Right AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right + AST#ERROR#Left \ . AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#binary_expression#Left AST#expression#Left A AST#expression#Right - AST#expression#Left Z AST#expression#Right AST#binary_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right { AST#ERROR#Right AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left 64 AST#expression#Right AST#ERROR#Left } $ AST#ERROR#Right / AST#expression#Left i AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left emailRegex AST#expression#Right . test AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left email 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 isValidEmail(email: string): boolean { const emailRegex: RegExp = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,64}$/i; return emailRegex.test(email); }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/utils/strings/StringUtils.ets#L153-L156
58afba777761d7c5f219c28a179f7a8af3061954
github
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_crypto/src/main/ets/crypto/encryption/sm2/SM2Convert.ets
arkts
d2c
ASN.1格式的字符串转换成C1C2C3格式的字符 @param standard_data ASN.1格式的字符 @returns C1C3C2格式的字符
d2c(standard_data: string): string { let message: string = standard_data; if (!message.startsWith(ASN1Util.SEQUENCE)) { Logger.error('转换SM2字符串出错'); } message = message.slice(ASN1Util.SEQUENCE.length, message.length); let sequence_lexHex: string = this.getLenHex(message); message = message.slice(sequence_lexHex.length, message.length); let sequence_len: number = this.lenHex2number(sequence_lexHex); if (sequence_len != message.length / 2) { Logger.error('转换SM2字符串出错'); } let sm2_sequence = new SM2Sequence(); message = this.readC1(sm2_sequence, message); message = this.readC3(sm2_sequence, message); message = this.readC2(sm2_sequence, message); console.log(sm2_sequence.toString()); let primal_data: string = sm2_sequence.C1x + sm2_sequence.C1y + sm2_sequence.C2 + sm2_sequence.C3; return primal_data; }
AST#method_declaration#Left d2c AST#parameter_list#Left ( AST#parameter#Left standard_data : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left message : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left standard_data 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 message AST#expression#Right AST#unary_expression#Right AST#expression#Right . startsWith AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left ASN1Util AST#expression#Right . SEQUENCE AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#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 '转换SM2字符串出错' AST#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 message = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left message AST#expression#Right . slice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left ASN1Util AST#expression#Right . SEQUENCE AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left message AST#expression#Right . length AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left sequence_lexHex : 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 this AST#expression#Right . getLenHex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left message 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 message = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left message 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 sequence_lexHex AST#expression#Right . length AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left message AST#expression#Right . length AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left sequence_len : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . lenHex2number AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sequence_lexHex 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 sequence_len AST#expression#Right != AST#expression#Left message AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right / AST#expression#Left 2 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '转换SM2字符串出错' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left sm2_sequence = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left SM2Sequence 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 message = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . readC1 AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sm2_sequence AST#expression#Right , AST#expression#Left message 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 message = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . readC3 AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sm2_sequence AST#expression#Right , AST#expression#Left message 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 message = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . readC2 AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left sm2_sequence AST#expression#Right , AST#expression#Left message AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left sm2_sequence AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left primal_data : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#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 sm2_sequence AST#expression#Right . C1x AST#member_expression#Right AST#expression#Right + AST#expression#Left sm2_sequence AST#expression#Right AST#binary_expression#Right AST#expression#Right . C1y AST#member_expression#Right AST#expression#Right + AST#expression#Left sm2_sequence AST#expression#Right AST#binary_expression#Right AST#expression#Right . C2 AST#member_expression#Right AST#expression#Right + AST#expression#Left sm2_sequence AST#expression#Right AST#binary_expression#Right AST#expression#Right . C3 AST#member_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 primal_data AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
d2c(standard_data: string): string { let message: string = standard_data; if (!message.startsWith(ASN1Util.SEQUENCE)) { Logger.error('转换SM2字符串出错'); } message = message.slice(ASN1Util.SEQUENCE.length, message.length); let sequence_lexHex: string = this.getLenHex(message); message = message.slice(sequence_lexHex.length, message.length); let sequence_len: number = this.lenHex2number(sequence_lexHex); if (sequence_len != message.length / 2) { Logger.error('转换SM2字符串出错'); } let sm2_sequence = new SM2Sequence(); message = this.readC1(sm2_sequence, message); message = this.readC3(sm2_sequence, message); message = this.readC2(sm2_sequence, message); console.log(sm2_sequence.toString()); let primal_data: string = sm2_sequence.C1x + sm2_sequence.C1y + sm2_sequence.C2 + sm2_sequence.C3; return primal_data; }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_crypto/src/main/ets/crypto/encryption/sm2/SM2Convert.ets#L134-L156
e597426d5a5fd5d6d3d99da558568c0e9f098c8a
gitee
Joker-x-dev/HarmonyKit.git
f97197ce157df7f303244fba42e34918306dfb08
core/ui/src/main/ets/component/empty/EmptyNetwork.ets
arkts
EmptyNetwork
@file 网络缺省页 @author Joker.X
@ComponentV2 export struct EmptyNetwork { /** * 描述文案 */ @Param description: ResourceStr = "网络异常"; /** * 操作按钮文案(仅当 onAction 存在时展示) */ @Param actionText: ResourceStr = "重试"; /** * 操作按钮点击回调(不传则不展示按钮) */ @Param onAction: (() => void) | undefined = undefined; /** * 构建网络缺省页视图 * @returns {void} 无返回值 */ build(): void { Empty({ description: this.description, imageRes: $r("app.media.ic_empty_network"), actionText: this.actionText, onAction: this.onAction }); } }
AST#decorated_export_declaration#Left AST#decorator#Left @ ComponentV2 AST#decorator#Right export struct EmptyNetwork AST#component_body#Left { /** * 描述文案 */ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right description : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "网络异常" AST#expression#Right ; AST#property_declaration#Right /** * 操作按钮文案(仅当 onAction 存在时展示) */ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right actionText : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left "重试" AST#expression#Right ; AST#property_declaration#Right /** * 操作按钮点击回调(不传则不展示按钮) */ AST#property_declaration#Left AST#decorator#Left @ Param AST#decorator#Right onAction : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#parenthesized_type#Left ( 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#parenthesized_type#Right AST#primary_type#Right | AST#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left undefined AST#expression#Right ; AST#property_declaration#Right /** * 构建网络缺省页视图 * @returns {void} 无返回值 */ AST#build_method#Left build ( ) : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#build_body#Left { AST#ui_custom_component_statement#Left Empty ( AST#component_parameters#Left { AST#component_parameter#Left description : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . description AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left imageRes : AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left "app.media.ic_empty_network" AST#expression#Right ) AST#resource_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left actionText : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . actionText AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left onAction : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . onAction AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) ; AST#ui_custom_component_statement#Right } AST#build_body#Right AST#build_method#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@ComponentV2 export struct EmptyNetwork { @Param description: ResourceStr = "网络异常"; @Param actionText: ResourceStr = "重试"; @Param onAction: (() => void) | undefined = undefined; build(): void { Empty({ description: this.description, imageRes: $r("app.media.ic_empty_network"), actionText: this.actionText, onAction: this.onAction }); } }
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/ui/src/main/ets/component/empty/EmptyNetwork.ets#L7-L37
864172c09408332981d74202b9dda8c3ad1546b0
github
Joker-x-dev/HarmonyKit.git
f97197ce157df7f303244fba42e34918306dfb08
core/designsystem/src/main/ets/component/Row.ets
arkts
渲染布局 @returns {void} 无返回值 @example RowEndCenter() { Text("Hi"); }
build(): void { RowBase({ options: this.options, justifyContent: FlexAlign.End, alignItems: VerticalAlign.Center, widthValue: this.widthValue, heightValue: this.heightValue, sizeValue: this.sizeValue, paddingValue: this.paddingValue, marginValue: this.marginValue, fillMaxSize: this.fillMaxSize, bgColor: this.bgColor, onTap: this.onTap, content: this.content }); }
AST#build_method#Left build ( ) : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#build_body#Left { AST#ui_custom_component_statement#Left RowBase ( AST#component_parameters#Left { AST#component_parameter#Left options : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . options AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left justifyContent : AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . End AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left alignItems : AST#expression#Left AST#member_expression#Left AST#expression#Left VerticalAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left widthValue : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . widthValue AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left heightValue : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . heightValue AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left sizeValue : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . sizeValue AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left paddingValue : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . paddingValue AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left marginValue : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . marginValue AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left fillMaxSize : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . fillMaxSize AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left bgColor : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . bgColor AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left onTap : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . onTap AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left content : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . content AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) ; AST#ui_custom_component_statement#Right } AST#build_body#Right AST#build_method#Right
build(): void { RowBase({ options: this.options, justifyContent: FlexAlign.End, alignItems: VerticalAlign.Center, widthValue: this.widthValue, heightValue: this.heightValue, sizeValue: this.sizeValue, paddingValue: this.paddingValue, marginValue: this.marginValue, fillMaxSize: this.fillMaxSize, bgColor: this.bgColor, onTap: this.onTap, content: this.content }); }
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/core/designsystem/src/main/ets/component/Row.ets#L364-L379
56b3bf3d2602af8d2439c9436b0a6bcce25fd154
github
Joker-x-dev/HarmonyKit.git
f97197ce157df7f303244fba42e34918306dfb08
feature/main/src/main/ets/viewmodel/AboutViewModel.ets
arkts
openUrl
打开链接 @param {Resource} urlRes - 链接资源 @returns {void} 无返回值
openUrl(urlRes: Resource): void { try { const url: string = this.context.resourceManager.getStringSync(urlRes.id); const want: Want = { action: "ohos.want.action.viewData", entities: ["entity.system.browsable"], uri: url }; this.context.startAbility(want).catch((error: Error) => { console.error(`打开链接失败: ${JSON.stringify(error)}`); }); } catch (error) { console.error(`打开链接失败: ${JSON.stringify(error)}`); } }
AST#method_declaration#Left openUrl AST#parameter_list#Left ( AST#parameter#Left urlRes : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left url : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . context AST#member_expression#Right AST#expression#Right . resourceManager AST#member_expression#Right AST#expression#Right . getStringSync AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left urlRes AST#expression#Right . id AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left 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.viewData" AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left entities AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left "entity.system.browsable" AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left uri AST#property_name#Right : AST#expression#Left url AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . context AST#member_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 . catch AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left error : AST#type_annotation#Left AST#primary_type#Left Error AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
openUrl(urlRes: Resource): void { try { const url: string = this.context.resourceManager.getStringSync(urlRes.id); const want: Want = { action: "ohos.want.action.viewData", entities: ["entity.system.browsable"], uri: url }; this.context.startAbility(want).catch((error: Error) => { console.error(`打开链接失败: ${JSON.stringify(error)}`); }); } catch (error) { console.error(`打开链接失败: ${JSON.stringify(error)}`); } }
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/feature/main/src/main/ets/viewmodel/AboutViewModel.ets#L56-L70
acf8a9db4e99c901c6b5c438068a253c434f7f70
github
htliang128/arkts_oss.git
9da4a87c36272873c649f556854bd793ac337a18
htliang_oss/src/main/ets/common/comm/RequestConfig.ets
arkts
getUserAgent
Getter and setter for userAgent
getUserAgent(): string | undefined { return this.userAgent; }
AST#method_declaration#Left getUserAgent 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 { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . userAgent AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
getUserAgent(): string | undefined { return this.userAgent; }
https://github.com/htliang128/arkts_oss.git/blob/9da4a87c36272873c649f556854bd793ac337a18/htliang_oss/src/main/ets/common/comm/RequestConfig.ets#L40-L42
2e014a8e30384f6e5714af44edcc1ce49cb10b7f
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/common/components/timer/SimperTimerCountDown.ets
arkts
getTotalInterval
获取总时长
getTotalInterval(): number { return this.totalMs; }
AST#method_declaration#Left getTotalInterval 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 . totalMs AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
getTotalInterval(): number { return this.totalMs; }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/components/timer/SimperTimerCountDown.ets#L133-L135
66d3a7cfba3a704a76c1ae40b5ae5b65c52b46c2
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/models/dbUtils/DBAccessor.ets
arkts
closeDatabase
关闭数据库连接(私有方法)
private closeDatabase(): void { try { this.rdbStore?.close(); this.rdbStore = null; this.isInitialized = false; DebugLog.d('DBAccessor-closeDatabased') } catch (err) { DebugLog.d("DBAccessor: 关闭数据库连接失败:" + err, ); } }
AST#method_declaration#Left private closeDatabase AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rdbStore AST#member_expression#Right AST#expression#Right ?. close AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rdbStore AST#member_expression#Right = AST#expression#Left AST#null_literal#Left null AST#null_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isInitialized AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left DebugLog AST#expression#Right . d AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'DBAccessor-closeDatabased' AST#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 DebugLog AST#expression#Right . d AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left "DBAccessor: 关闭数据库连接失败:" AST#expression#Right + AST#expression#Left err AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#ERROR#Left , AST#ERROR#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private closeDatabase(): void { try { this.rdbStore?.close(); this.rdbStore = null; this.isInitialized = false; DebugLog.d('DBAccessor-closeDatabased') } catch (err) { DebugLog.d("DBAccessor: 关闭数据库连接失败:" + err, ); } }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/dbUtils/DBAccessor.ets#L129-L138
d2d68e344b2dcbd01e5afc714b51ff213c9001df
github
harmonyos/samples
f5d967efaa7666550ee3252d118c3c73a77686f5
HarmonyOS_NEXT/ArkUI/ComponentCollection/entry/src/main/ets/pages/globalMethods/dialogs/customDialogSample/CustomDialog.ets
arkts
UpgradeDialog
Copyright (c) 2022 Huawei Device Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
@CustomDialog export struct UpgradeDialog { private controller: CustomDialogController build() { Column() { Text($r('app.string.custom_dialog_title')) .padding(8) .fontSize(24) this.PermissionIntroduction($r('app.media.ic_custom_dialog_voice'), $r('app.string.custom_dialog_permission_microphone'), $r('app.string.custom_dialog_permission_microphone_info')) this.PermissionIntroduction($r('app.media.ic_custom_dialog_location'), $r('app.string.custom_dialog_permission_location'), $r('app.string.custom_dialog_permission_location_info')) Blank() Button($r('app.string.custom_dialog_start')) .height(40) .fontSize(24) .fontColor(Color.White) .margin({ left: 4, right: 4, top: 12 }) .onClick(() => { this.controller.close() }) } .margin(20) .height(380) .borderRadius(24) .padding({ top: 20, bottom: 32 }) .backgroundColor($r('app.color.background_shallow_grey')) } @Builder PermissionIntroduction(image: Resource, permissionName: Resource, introduction: Resource) { Row() { Image(image) .width(50) .height(50) .margin({ left: 30, right: 30 }) Column({ space: 4 }) { Text(permissionName) .fontSize(20) Text(introduction) .fontSize(18) .fontColor($r('app.color.font_color_shallow')) .constraintSize({ maxWidth: 280 }) } .alignItems(HorizontalAlign.Start) } .width('100%') .margin({ top: 20 }) } }
AST#decorated_export_declaration#Left AST#decorator#Left @ CustomDialog AST#decorator#Right export struct UpgradeDialog AST#component_body#Left { AST#property_declaration#Left private controller : AST#type_annotation#Left AST#primary_type#Left CustomDialogController 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#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.custom_dialog_title' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . padding ( AST#expression#Left 8 AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 24 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . PermissionIntroduction AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.ic_custom_dialog_voice' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.custom_dialog_permission_microphone' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.custom_dialog_permission_microphone_info' 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . PermissionIntroduction AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.ic_custom_dialog_location' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.custom_dialog_permission_location' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right , AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.custom_dialog_permission_location_info' 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#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Blank ( ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Button ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.custom_dialog_start' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . height ( AST#expression#Left 40 AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 24 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . White AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#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 4 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 4 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#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . controller AST#member_expression#Right AST#expression#Right . close AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . margin ( AST#expression#Left 20 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 380 AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 24 AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 20 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 32 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.background_shallow_grey' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#build_body#Right AST#build_method#Right AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right PermissionIntroduction AST#parameter_list#Left ( AST#parameter#Left image : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left permissionName : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left introduction : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left image AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 50 AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left 50 AST#expression#Right ) AST#modifier_chain_expression#Left . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 30 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left right AST#property_name#Right : AST#expression#Left 30 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 4 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left permissionName AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 20 AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left introduction AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 18 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.color.font_color_shallow' AST#expression#Right ) AST#resource_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 280 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . alignItems ( AST#expression#Left AST#member_expression#Left AST#expression#Left HorizontalAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#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 . margin ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left top AST#property_name#Right : AST#expression#Left 20 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right } AST#component_body#Right AST#decorated_export_declaration#Right
@CustomDialog export struct UpgradeDialog { private controller: CustomDialogController build() { Column() { Text($r('app.string.custom_dialog_title')) .padding(8) .fontSize(24) this.PermissionIntroduction($r('app.media.ic_custom_dialog_voice'), $r('app.string.custom_dialog_permission_microphone'), $r('app.string.custom_dialog_permission_microphone_info')) this.PermissionIntroduction($r('app.media.ic_custom_dialog_location'), $r('app.string.custom_dialog_permission_location'), $r('app.string.custom_dialog_permission_location_info')) Blank() Button($r('app.string.custom_dialog_start')) .height(40) .fontSize(24) .fontColor(Color.White) .margin({ left: 4, right: 4, top: 12 }) .onClick(() => { this.controller.close() }) } .margin(20) .height(380) .borderRadius(24) .padding({ top: 20, bottom: 32 }) .backgroundColor($r('app.color.background_shallow_grey')) } @Builder PermissionIntroduction(image: Resource, permissionName: Resource, introduction: Resource) { Row() { Image(image) .width(50) .height(50) .margin({ left: 30, right: 30 }) Column({ space: 4 }) { Text(permissionName) .fontSize(20) Text(introduction) .fontSize(18) .fontColor($r('app.color.font_color_shallow')) .constraintSize({ maxWidth: 280 }) } .alignItems(HorizontalAlign.Start) } .width('100%') .margin({ top: 20 }) } }
https://github.com/harmonyos/samples/blob/f5d967efaa7666550ee3252d118c3c73a77686f5/HarmonyOS_NEXT/ArkUI/ComponentCollection/entry/src/main/ets/pages/globalMethods/dialogs/customDialogSample/CustomDialog.ets#L16-L63
8a79ddbd1c4b399140e2ed7633195d296f8ad4f5
gitee
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
core/model/src/main/ets/request/GoodsSearchRequest.ets
arkts
@file 商品搜索分页请求模型 @author Joker.X
export class GoodsSearchRequest { /** * 页码 */ page: number = 1; /** * 每页大小 */ size: number = 20; /** * 商品分类ID列表 */ typeId?: number[] | null; /** * 最低价格 */ minPrice?: string | null; /** * 最高价格 */ maxPrice?: string | null; /** * 搜索关键词 */ keyWord?: string | null; /** * 排序字段 */ order?: string | null; /** * 排序方式 */ sort?: string | null; /** * 推荐 */ recommend?: boolean; /** * 精选 */ featured?: boolean; /** * @param {Partial<GoodsSearchRequest>} init - 初始化数据 */ constructor(init?: Partial<GoodsSearchRequest>) { if (!init) { return; } this.page = init.page ?? this.page; this.size = init.size ?? this.size; this.typeId = init.typeId ?? this.typeId; this.minPrice = init.minPrice ?? this.minPrice; this.maxPrice = init.maxPrice ?? this.maxPrice; this.keyWord = init.keyWord ?? this.keyWord; this.order = init.order ?? this.order; this.sort = init.sort ?? this.sort; this.recommend = init.recommend ?? this.recommend; this.featured = init.featured ?? this.featured; } }
AST#export_declaration#Left export AST#class_declaration#Left class GoodsSearchRequest AST#class_body#Left { /** * 页码 */ AST#property_declaration#Left page : 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 size : 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 /** * 商品分类ID列表 */ AST#property_declaration#Left typeId ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left AST#array_type#Left number [ ] AST#array_type#Right AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * 最低价格 */ AST#property_declaration#Left minPrice ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * 最高价格 */ AST#property_declaration#Left maxPrice ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * 搜索关键词 */ AST#property_declaration#Left keyWord ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * 排序字段 */ AST#property_declaration#Left order ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * 排序方式 */ AST#property_declaration#Left sort ? : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * 推荐 */ AST#property_declaration#Left recommend ? : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * 精选 */ AST#property_declaration#Left featured ? : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * @param {Partial<GoodsSearchRequest>} init - 初始化数据 */ AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left init ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Partial AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left GoodsSearchRequest AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left init AST#expression#Right AST#unary_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 . page 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 init AST#expression#Right . page AST#member_expression#Right AST#expression#Right ?? AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . page 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 . size 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 init AST#expression#Right . size AST#member_expression#Right AST#expression#Right ?? AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . size 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 . typeId 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 init AST#expression#Right . typeId AST#member_expression#Right AST#expression#Right ?? AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . typeId 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 . minPrice 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 init AST#expression#Right . minPrice AST#member_expression#Right AST#expression#Right ?? AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . minPrice 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 . maxPrice 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 init AST#expression#Right . maxPrice AST#member_expression#Right AST#expression#Right ?? AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . maxPrice 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 . keyWord 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 init AST#expression#Right . keyWord AST#member_expression#Right AST#expression#Right ?? AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . keyWord 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 . order 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 init AST#expression#Right . order AST#member_expression#Right AST#expression#Right ?? AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . order 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 . sort 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 init AST#expression#Right . sort AST#member_expression#Right AST#expression#Right ?? AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . sort 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 . recommend 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 init AST#expression#Right . recommend AST#member_expression#Right AST#expression#Right ?? AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . recommend 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 . featured 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 init AST#expression#Right . featured AST#member_expression#Right AST#expression#Right ?? AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . featured AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#constructor_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class GoodsSearchRequest { page: number = 1; size: number = 20; typeId?: number[] | null; minPrice?: string | null; maxPrice?: string | null; keyWord?: string | null; order?: string | null; sort?: string | null; recommend?: boolean; featured?: boolean; constructor(init?: Partial<GoodsSearchRequest>) { if (!init) { return; } this.page = init.page ?? this.page; this.size = init.size ?? this.size; this.typeId = init.typeId ?? this.typeId; this.minPrice = init.minPrice ?? this.minPrice; this.maxPrice = init.maxPrice ?? this.maxPrice; this.keyWord = init.keyWord ?? this.keyWord; this.order = init.order ?? this.order; this.sort = init.sort ?? this.sort; this.recommend = init.recommend ?? this.recommend; this.featured = init.featured ?? this.featured; } }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/model/src/main/ets/request/GoodsSearchRequest.ets#L5-L65
205cc8969436c728742164d8054bfa7735beaa42
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/app/constants/AppTheme.ets
arkts
========================== 项目主题定义 ========================== 当前主题(默认绿色主题)
export let theme: Theme = new ThemeGreen()
AST#export_declaration#Left export AST#variable_declaration#Left let AST#variable_declarator#Left theme : AST#type_annotation#Left AST#primary_type#Left Theme 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 ThemeGreen 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#export_declaration#Right
export let theme: Theme = new ThemeGreen()
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/app/constants/AppTheme.ets#L66-L66
5bab9580925d7650a4bfb69e64c73edf1f4a30be
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/models/managers/member/MemberManager.ets
arkts
checkCigenUsable
/ 检查 是否可以使用词根助记
public checkCigenUsable(showMessage: boolean = true): boolean { if (!this.nonMember.isLockedCigen) { return true } // 非会员 锁定词根助记 功能是否启用 if (this.isActive) { return true } // 非会员才做检查 if (showMessage) { Toast.showMessage($r('app.string.member_manager_msg_limit_use_cigen')) } return false }
AST#method_declaration#Left public checkCigenUsable AST#parameter_list#Left ( AST#parameter#Left showMessage : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left 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#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 . nonMember AST#member_expression#Right AST#expression#Right . isLockedCigen AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left 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#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isActive AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#boolean_literal#Left 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#if_statement#Left if ( AST#expression#Left showMessage 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 Toast AST#expression#Right . showMessage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.string.member_manager_msg_limit_use_cigen' 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#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
public checkCigenUsable(showMessage: boolean = true): boolean { if (!this.nonMember.isLockedCigen) { return true } if (this.isActive) { return true } if (showMessage) { Toast.showMessage($r('app.string.member_manager_msg_limit_use_cigen')) } return false }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/managers/member/MemberManager.ets#L338-L347
5251193795a924c33e562b2f84c4b1e4c36b680a
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/Solutions/IM/Chat/products/phone/entry/src/main/ets/pages/FullImagePage.ets
arkts
AnimationComp
下载状态组件
@Builder AnimationComp() { if (this.downloadStatus) { Stack() { Column() { } .width('100%') .height('100%') .backgroundColor(Color.Black) .opacity(OPACITY) Image($r('app.media.loading')) .width($r('app.integer.loading_size')) .height($r('app.integer.loading_size')) .rotate({ angle: this.rotateAngle }) }.width('100%') .height('100%') // 脱离文档流,x轴和y轴偏离位置为0 .position({ x: 0, y: 0 }) } }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right AnimationComp AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . downloadStatus AST#member_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Stack ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Black AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . opacity ( AST#expression#Left OPACITY AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Image ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.media.loading' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.loading_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left AST#resource_expression#Left $r ( AST#expression#Left 'app.integer.loading_size' AST#expression#Right ) AST#resource_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . rotate ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left angle AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . rotateAngle AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '100%' AST#expression#Right ) // 脱离文档流,x轴和y轴偏离位置为0 AST#modifier_chain_expression#Left . position ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left x AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left y AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
@Builder AnimationComp() { if (this.downloadStatus) { Stack() { Column() { } .width('100%') .height('100%') .backgroundColor(Color.Black) .opacity(OPACITY) Image($r('app.media.loading')) .width($r('app.integer.loading_size')) .height($r('app.integer.loading_size')) .rotate({ angle: this.rotateAngle }) }.width('100%') .height('100%') .position({ x: 0, y: 0 }) } }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/Solutions/IM/Chat/products/phone/entry/src/main/ets/pages/FullImagePage.ets#L76-L96
dd155475561027236e963244d87ea419e712f34b
gitee
openharmony-tpc/ohos_mpchart
4fb43a7137320ef2fee2634598f53d93975dfb4a
entry/src/main/ets/pageconfig/ContentItem.ets
arkts
Copyright (C) 2022 Huawei Device Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
export default class ContentItem { private name: string; private desc: string; private pagePath: string; private isSection: boolean = false; constructor(n: string, d?: string, pagePath?: string) { this.name = n; if (d == null || d == undefined) { this.desc = ""; this.isSection = true; } else { this.desc = d; } this.pagePath = ((pagePath == null || pagePath == undefined) ? "" : pagePath); } public getName(): string { return this.name } public getDesc(): string { return this.desc } public getPagePath(): string { return this.pagePath } public getIsSection(): boolean { return this.isSection; } }
AST#export_declaration#Left export default AST#class_declaration#Left class ContentItem AST#class_body#Left { AST#property_declaration#Left private name : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left private desc : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left private pagePath : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right AST#property_declaration#Left private isSection : 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#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left n : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left d ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left pagePath ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . name AST#member_expression#Right = AST#expression#Left n 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#binary_expression#Left AST#expression#Left d 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 d 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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . desc 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 this AST#expression#Right . isSection AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . desc AST#member_expression#Right = AST#expression#Left d AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . pagePath AST#member_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#binary_expression#Left AST#expression#Left pagePath 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 pagePath 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#parenthesized_expression#Right AST#expression#Right ? AST#expression#Left "" AST#expression#Right : AST#expression#Left pagePath AST#expression#Right AST#conditional_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#constructor_declaration#Right AST#method_declaration#Left public getName AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . name AST#member_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left public getDesc AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . desc AST#member_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left public getPagePath AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . pagePath AST#member_expression#Right AST#expression#Right AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right AST#method_declaration#Left public getIsSection AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isSection AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export default class ContentItem { private name: string; private desc: string; private pagePath: string; private isSection: boolean = false; constructor(n: string, d?: string, pagePath?: string) { this.name = n; if (d == null || d == undefined) { this.desc = ""; this.isSection = true; } else { this.desc = d; } this.pagePath = ((pagePath == null || pagePath == undefined) ? "" : pagePath); } public getName(): string { return this.name } public getDesc(): string { return this.desc } public getPagePath(): string { return this.pagePath } public getIsSection(): boolean { return this.isSection; } }
https://github.com/openharmony-tpc/ohos_mpchart/blob/4fb43a7137320ef2fee2634598f53d93975dfb4a/entry/src/main/ets/pageconfig/ContentItem.ets#L16-L48
6b3b4bdc17b479a4b528b3b64d089a436c926d72
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/services/ai/AIAssistantService.ets
arkts
对话消息接口
export interface ChatMessage { id: string; content: string; type: MessageType; sender: MessageSender; timestamp: string; metadata?: Record<string, string | number | boolean>; attachments?: MessageAttachment[]; replyTo?: string; reactions?: MessageReaction[]; }
AST#export_declaration#Left export AST#interface_declaration#Left interface ChatMessage 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 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 type : AST#type_annotation#Left AST#primary_type#Left MessageType AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left sender : AST#type_annotation#Left AST#primary_type#Left MessageSender AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left timestamp : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left metadata ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Record AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left number AST#primary_type#Right | AST#primary_type#Left boolean AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left attachments ? : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left MessageAttachment [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left replyTo ? : 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 reactions ? : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left MessageReaction [ ] 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 ChatMessage { id: string; content: string; type: MessageType; sender: MessageSender; timestamp: string; metadata?: Record<string, string | number | boolean>; attachments?: MessageAttachment[]; replyTo?: string; reactions?: MessageReaction[]; }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/services/ai/AIAssistantService.ets#L18-L28
4061198df78263cb74a5b6e41e49eabc98f3a41a
github
Leeson-Wong/ark-layer.git
9efa3553414a6b1eee890e3858c8cdcb308535d7
core/PhaseExample.ets
arkts
示例 4: 动态创建多个阶段
export async function example4_DynamicPhases() { console.log('========== Example 4: Dynamically Creating Phases ==========') // 动态创建阶段配置 const phaseConfigs = [ { name: 'PHASE_1', priority: 10, waitForComplete: true, description: '' } as PhaseConfig, { name: 'PHASE_2', priority: 20, waitForComplete: true, description: '' } as PhaseConfig, { name: 'PHASE_3', priority: 30, waitForComplete: false, description: '' } as PhaseConfig, { name: 'PHASE_4', priority: 40, waitForComplete: false, description: '' } as PhaseConfig, { name: 'PHASE_5', priority: 50, waitForComplete: false, description: '' } as PhaseConfig ] // 为每个阶段加载服务 phaseConfigs.forEach((config, index) => { const phase = createPhase({ name: config.name, priority: config.priority, waitForComplete: config.waitForComplete, description: `动态阶段 ${index + 1}` }) serviceManager.load({ phase: phase, sceneList: [ new LogService() // 示例服务 ] }) }) await serviceManager.loginCallback() console.log('========== Example 4 Complete ==========\n') }
AST#export_declaration#Left export AST#function_declaration#Left async function example4_DynamicPhases AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '========== Example 4: Dynamically Creating Phases ==========' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right // 动态创建阶段配置 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left phaseConfigs = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#as_expression#Left AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#as_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left name AST#property_name#Right : AST#expression#Left 'PHASE_1' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left priority AST#property_name#Right : AST#expression#Left 10 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left waitForComplete AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left description AST#property_name#Right : AST#expression#Left '' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left PhaseConfig AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right , AST#expression#Left AST#as_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left name AST#property_name#Right : AST#expression#Left 'PHASE_2' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left priority AST#property_name#Right : AST#expression#Left 20 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left waitForComplete AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left description AST#property_name#Right : AST#expression#Left '' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left PhaseConfig AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right , AST#expression#Left AST#as_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left name AST#property_name#Right : AST#expression#Left 'PHASE_3' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left priority AST#property_name#Right : AST#expression#Left 30 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left waitForComplete AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left description AST#property_name#Right : AST#expression#Left '' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left PhaseConfig AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right , AST#expression#Left AST#as_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left name AST#property_name#Right : AST#expression#Left 'PHASE_4' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left priority AST#property_name#Right : AST#expression#Left 40 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left waitForComplete AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left description AST#property_name#Right : AST#expression#Left '' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left PhaseConfig AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right , AST#expression#Left AST#as_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left name AST#property_name#Right : AST#expression#Left 'PHASE_5' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left priority AST#property_name#Right : AST#expression#Left 50 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left waitForComplete AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left description AST#property_name#Right : AST#expression#Left '' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left PhaseConfig AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right // 为每个阶段加载服务 AST#ERROR#Left ph AST#ERROR#Right as AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left eConfigs . forEach AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#as_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#Left index AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left phase = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left createPhase AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left name AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . name AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left priority AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . priority AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left waitForComplete AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left config AST#expression#Right . waitForComplete AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left description AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` 动态阶段 AST#template_substitution#Left $ { AST#expression#Left AST#binary_expression#Left AST#expression#Left index AST#expression#Right + AST#expression#Left 1 AST#expression#Right AST#binary_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#ERROR#Left serviceManager AST#ERROR#Right . load AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left phase AST#property_name#Right : AST#expression#Left phase AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left sceneList AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left LogService AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right // 示例服务 ] AST#array_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left serviceManager AST#expression#Right AST#await_expression#Right AST#expression#Right . loginCallback AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '========== Example 4 Complete ==========\n' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right AST#export_declaration#Right
export async function example4_DynamicPhases() { console.log('========== Example 4: Dynamically Creating Phases ==========') const phaseConfigs = [ { name: 'PHASE_1', priority: 10, waitForComplete: true, description: '' } as PhaseConfig, { name: 'PHASE_2', priority: 20, waitForComplete: true, description: '' } as PhaseConfig, { name: 'PHASE_3', priority: 30, waitForComplete: false, description: '' } as PhaseConfig, { name: 'PHASE_4', priority: 40, waitForComplete: false, description: '' } as PhaseConfig, { name: 'PHASE_5', priority: 50, waitForComplete: false, description: '' } as PhaseConfig ] phaseConfigs.forEach((config, index) => { const phase = createPhase({ name: config.name, priority: config.priority, waitForComplete: config.waitForComplete, description: `动态阶段 ${index + 1}` }) serviceManager.load({ phase: phase, sceneList: [ new LogService() ] }) }) await serviceManager.loginCallback() console.log('========== Example 4 Complete ==========\n') }
https://github.com/Leeson-Wong/ark-layer.git/blob/9efa3553414a6b1eee890e3858c8cdcb308535d7/core/PhaseExample.ets#L310-L341
04ce3e51e67b0c957b73a9f3a7820675119976fd
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/common/types/SettingsTypes.ets
arkts
应用设置接口 (兼容SettingsService)
export interface AppSettings { version: string; language: LanguageSettings; theme: ThemeSettings; notification: NotificationSettings; reminder: ReminderSettings; privacy: PrivacySettings; ai: AISettings; data: DataSettings; security: SecuritySettings; accessibility: AccessibilitySettings; createdAt: string; updatedAt: string; }
AST#export_declaration#Left export AST#interface_declaration#Left interface AppSettings AST#object_type#Left { AST#type_member#Left version : 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 language : AST#type_annotation#Left AST#primary_type#Left LanguageSettings AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left theme : AST#type_annotation#Left AST#primary_type#Left ThemeSettings AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left notification : AST#type_annotation#Left AST#primary_type#Left NotificationSettings AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left reminder : AST#type_annotation#Left AST#primary_type#Left ReminderSettings AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left privacy : AST#type_annotation#Left AST#primary_type#Left PrivacySettings AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left ai : AST#type_annotation#Left AST#primary_type#Left AISettings AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left data : AST#type_annotation#Left AST#primary_type#Left DataSettings AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left security : AST#type_annotation#Left AST#primary_type#Left SecuritySettings AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left accessibility : AST#type_annotation#Left AST#primary_type#Left AccessibilitySettings AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left createdAt : 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 updatedAt : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
export interface AppSettings { version: string; language: LanguageSettings; theme: ThemeSettings; notification: NotificationSettings; reminder: ReminderSettings; privacy: PrivacySettings; ai: AISettings; data: DataSettings; security: SecuritySettings; accessibility: AccessibilitySettings; createdAt: string; updatedAt: string; }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/common/types/SettingsTypes.ets#L13-L26
d7a72924e3eb2cec1c64f0b0af866816b90de76e
github
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
feature/main/src/main/ets/viewmodel/CategoryViewModel.ets
arkts
@file 分类页面 ViewModel @author Joker.X
@ObservedV2 export default class CategoryViewModel extends BaseNetWorkViewModel<Category[]> { /** * 商品仓库 */ private goodsRepository: GoodsRepository = new GoodsRepository(); /** * 分类树数据 */ @Trace categoryTrees: CategoryTree[] = []; /** * 左侧分类标题列表 */ @Trace categoryTitles: string[] = []; /** * 当前选中的分类索引 */ @Trace selectedCategoryIndex: number = -1; /** * 是否正在执行侧边栏联动滚动 */ @Trace isSideBarScrolling: boolean = false; /** * 侧边栏上一次选中索引 */ @Trace lastSideBarIndex: number = 0; /** * 侧边栏联动滚动解锁计时器 */ private sideBarUnlockTimer: number = -1; /** * 重写请求方法来实现网络请求 * * @return 商品分类 */ protected requestRepository(): Promise<NetworkResponse<Category[]>> { return this.goodsRepository.getGoodsTypeList(); } /** * 请求成功后处理分类树数据 * @param {Category[]} data - 分类列表 * @returns {void} 无返回值 */ protected onRequestSuccess(data: Category[]): void { this.categoryTrees = this.convertToTree(data); this.categoryTitles = this.categoryTrees.map((item: CategoryTree): string => item.name); this.isSideBarScrolling = false; this.lastSideBarIndex = 0; this.clearSideBarUnlockTimer(); if (this.categoryTrees.length > 0) { if (this.selectedCategoryIndex < 0 || this.selectedCategoryIndex >= this.categoryTrees.length) { this.selectedCategoryIndex = 0; } } else { this.selectedCategoryIndex = -1; } super.onRequestSuccess(data); } /** * 处理侧边栏选中事件 * @param {number} index - 目标索引 * @returns {number} 实际滚动目标索引 */ onSideBarSelected(index: number): number { const targetIndex: number = this.clampIndex(index); this.isSideBarScrolling = true; this.selectedCategoryIndex = targetIndex; this.startSideBarUnlockTimer(targetIndex); return targetIndex; } /** * 结束侧边栏联动滚动 * @returns {void} 无返回值 */ finishSideBarScroll(): void { this.isSideBarScrolling = false; } /** * 处理右侧列表滚动事件 * @param {number} startIndex - 当前可见起始索引 * @returns {void} 无返回值 */ onRightListScroll(startIndex: number): void { if (startIndex < 0) { return; } if (this.isSideBarScrolling) { return; } if (startIndex !== this.selectedCategoryIndex) { this.selectedCategoryIndex = startIndex; } } /** * 获取侧边栏当前激活索引 * @returns {number} 当前激活索引 */ getActiveIndex(): number { return this.selectedCategoryIndex < 0 ? 0 : this.selectedCategoryIndex; } /** * 校验侧边栏索引合法性 * @param {number} index - 原始索引 * @returns {number} 合法索引,不合法返回 -1 */ private clampIndex(index: number): number { const total: number = this.categoryTrees.length; if (total <= 0) { return 0; } if (index < 0) { return 0; } if (index >= total) { return total - 1; } return index; } /** * 计算联动解锁时长 * @param {number} targetIndex - 目标索引 * @returns {number} 解锁时长(毫秒) */ private calculateUnlockDuration(targetIndex: number): number { const distance: number = Math.abs(targetIndex - this.lastSideBarIndex); this.lastSideBarIndex = targetIndex; return Math.min(1200, Math.max(240, distance * 120)); } /** * 启动侧边栏联动解锁计时器 * @param {number} targetIndex - 目标索引 * @returns {void} 无返回值 */ private startSideBarUnlockTimer(targetIndex: number): void { this.clearSideBarUnlockTimer(); const duration: number = this.calculateUnlockDuration(targetIndex); this.sideBarUnlockTimer = setTimeout((): void => { this.finishSideBarScroll(); this.sideBarUnlockTimer = -1; }, duration); } /** * 清理侧边栏联动解锁计时器 * @returns {void} 无返回值 */ private clearSideBarUnlockTimer(): void { if (this.sideBarUnlockTimer >= 0) { clearTimeout(this.sideBarUnlockTimer); this.sideBarUnlockTimer = -1; } } /** * 页面隐藏时清理计时器 * @returns {void} 无返回值 */ aboutToDisappear(): void { this.clearSideBarUnlockTimer(); } /** * 页面销毁时清理计时器 * @returns {void} 无返回值 */ aboutToBeDeleted(): void { this.clearSideBarUnlockTimer(); } /** * 将分类列表转换为树形结构 * @param {Category[]} categories - 原始分类列表 * @returns {CategoryTree[]} 树形结构的分类列表 * @example * const tree = this.convertToTree(list); */ private convertToTree(categories: Category[]): CategoryTree[] { if (!categories || categories.length === 0) { return []; } const nestedTrees: CategoryTree[] = this.tryBuildTreeFromNested(categories); if (nestedTrees.length > 0) { return nestedTrees; } const sortedList: Category[] = [...categories].sort((a: Category, b: Category): number => a.sortNum - b.sortNum); const categoryTrees: CategoryTree[] = sortedList.map((item: Category): CategoryTree => CategoryTree.fromCategory(item)); const rootCategories: CategoryTree[] = []; const childrenMap: Map<number, CategoryTree[]> = new Map<number, CategoryTree[]>(); categoryTrees.forEach((categoryTree: CategoryTree): void => { const parentId: number | null | undefined = categoryTree.parentId; if (parentId === null || parentId === undefined || parentId === 0) { rootCategories.push(categoryTree); return; } const children: CategoryTree[] = childrenMap.get(parentId) ?? []; children.push(categoryTree); childrenMap.set(parentId, children); }); return rootCategories.map((rootCategory: CategoryTree): CategoryTree => this.buildCategoryTree(rootCategory, childrenMap)); } /** * 递归构建分类树 * @param {CategoryTree} categoryTree - 当前分类节点 * @param {Map<number, CategoryTree[]>} childrenMap - 子分类映射 * @returns {CategoryTree} 构建完成的分类节点 */ private buildCategoryTree(categoryTree: CategoryTree, childrenMap: Map<number, CategoryTree[]>): CategoryTree { const children: CategoryTree[] = childrenMap.get(categoryTree.id) ?? []; if (children.length === 0) { return categoryTree; } categoryTree.children = children.map((child: CategoryTree): CategoryTree => this.buildCategoryTree(child, childrenMap)); return categoryTree; } /** * 尝试从已包含 children 的数据中构建树 * @param {Category[]} categories - 原始分类列表 * @returns {CategoryTree[]} 构建后的树结构 */ private tryBuildTreeFromNested(categories: Category[]): CategoryTree[] { const hasChildren: boolean = categories.some((item: Category): boolean => { return (item.children ?? []).length > 0; }); if (!hasChildren) { return []; } return categories.map((item: Category): CategoryTree => this.convertNestedNode(item)); } /** * 递归转换带 children 的节点 * @param {Category} category - 原始分类节点 * @returns {CategoryTree} 转换后的分类树节点 */ private convertNestedNode(category: Category): CategoryTree { const node: CategoryTree = CategoryTree.fromCategory(category); const children: Category[] = category.children ?? []; if (children.length > 0) { node.children = children.map((child: Category): CategoryTree => this.convertNestedNode(child)); } return node; } }
AST#decorated_export_declaration#Left AST#decorator#Left @ ObservedV2 AST#decorator#Right export default AST#class_declaration#Left class CategoryViewModel extends AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left BaseNetWorkViewModel AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Category [ ] 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#class_body#Left { /** * 商品仓库 */ AST#property_declaration#Left private goodsRepository : AST#type_annotation#Left AST#primary_type#Left GoodsRepository 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 GoodsRepository 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 categoryTrees : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left CategoryTree [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right ; AST#property_declaration#Right /** * 左侧分类标题列表 */ AST#property_declaration#Left AST#decorator#Left @ Trace AST#decorator#Right categoryTitles : 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 /** * 当前选中的分类索引 */ AST#property_declaration#Left AST#decorator#Left @ Trace AST#decorator#Right selectedCategoryIndex : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * 是否正在执行侧边栏联动滚动 */ AST#property_declaration#Left AST#decorator#Left @ Trace AST#decorator#Right isSideBarScrolling : 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 lastSideBarIndex : 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 sideBarUnlockTimer : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right ; AST#property_declaration#Right /** * 重写请求方法来实现网络请求 * * @return 商品分类 */ 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 AST#array_type#Left Category [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { 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 . goodsRepository AST#member_expression#Right AST#expression#Right . getGoodsTypeList AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 请求成功后处理分类树数据 * @param {Category[]} data - 分类列表 * @returns {void} 无返回值 */ AST#method_declaration#Left protected onRequestSuccess AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Category [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . categoryTrees AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . convertToTree 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#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 . categoryTitles AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . categoryTrees AST#member_expression#Right AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left CategoryTree AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right => AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . name AST#member_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isSideBarScrolling AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . lastSideBarIndex 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#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . clearSideBarUnlockTimer AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . categoryTrees 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#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#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 . selectedCategoryIndex 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 . selectedCategoryIndex AST#member_expression#Right AST#expression#Right >= AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . categoryTrees AST#member_expression#Right AST#expression#Right . length 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 . selectedCategoryIndex 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 } else { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedCategoryIndex AST#member_expression#Right = AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left super AST#expression#Right . onRequestSuccess AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left data AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right /** * 处理侧边栏选中事件 * @param {number} index - 目标索引 * @returns {number} 实际滚动目标索引 */ AST#method_declaration#Left onSideBarSelected AST#parameter_list#Left ( AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left targetIndex : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . clampIndex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left index AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isSideBarScrolling 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 . selectedCategoryIndex AST#member_expression#Right = AST#expression#Left targetIndex 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 . startSideBarUnlockTimer AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left targetIndex 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 targetIndex AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 结束侧边栏联动滚动 * @returns {void} 无返回值 */ AST#method_declaration#Left finishSideBarScroll 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 . isSideBarScrolling 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#builder_function_body#Right AST#method_declaration#Right /** * 处理右侧列表滚动事件 * @param {number} startIndex - 当前可见起始索引 * @returns {void} 无返回值 */ AST#method_declaration#Left onRightListScroll AST#parameter_list#Left ( AST#parameter#Left startIndex : 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#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left startIndex AST#expression#Right < AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . isSideBarScrolling AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left startIndex AST#expression#Right !== AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . selectedCategoryIndex 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 . selectedCategoryIndex AST#member_expression#Right = AST#expression#Left startIndex 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 /** * 获取侧边栏当前激活索引 * @returns {number} 当前激活索引 */ AST#method_declaration#Left getActiveIndex 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#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . selectedCategoryIndex AST#member_expression#Right AST#expression#Right < AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left 0 AST#expression#Right : AST#expression#Left this AST#expression#Right AST#conditional_expression#Right AST#expression#Right . selectedCategoryIndex AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 校验侧边栏索引合法性 * @param {number} index - 原始索引 * @returns {number} 合法索引,不合法返回 -1 */ AST#method_declaration#Left private clampIndex AST#parameter_list#Left ( AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left total : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . categoryTrees AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left total 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 0 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 index 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 0 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 index AST#expression#Right >= AST#expression#Left total 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 total AST#expression#Right - AST#expression#Left 1 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 index AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 计算联动解锁时长 * @param {number} targetIndex - 目标索引 * @returns {number} 解锁时长(毫秒) */ AST#method_declaration#Left private calculateUnlockDuration AST#parameter_list#Left ( AST#parameter#Left targetIndex : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left distance : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . abs AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left targetIndex AST#expression#Right - AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . lastSideBarIndex 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#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . lastSideBarIndex AST#member_expression#Right = AST#expression#Left targetIndex AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . min AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 1200 AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . max AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 240 AST#expression#Right , AST#expression#Left AST#binary_expression#Left AST#expression#Left distance AST#expression#Right * AST#expression#Left 120 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#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 启动侧边栏联动解锁计时器 * @param {number} targetIndex - 目标索引 * @returns {void} 无返回值 */ AST#method_declaration#Left private startSideBarUnlockTimer AST#parameter_list#Left ( AST#parameter#Left targetIndex : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . clearSideBarUnlockTimer 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 const AST#variable_declarator#Left duration : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . calculateUnlockDuration AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left targetIndex AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . sideBarUnlockTimer AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left setTimeout AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . finishSideBarScroll AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . sideBarUnlockTimer AST#member_expression#Right = AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right , AST#expression#Left duration AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 清理侧边栏联动解锁计时器 * @returns {void} 无返回值 */ AST#method_declaration#Left private clearSideBarUnlockTimer AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . sideBarUnlockTimer AST#member_expression#Right AST#expression#Right >= AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left clearTimeout ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . sideBarUnlockTimer AST#member_expression#Right AST#expression#Right ) AST#ui_component#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#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . sideBarUnlockTimer AST#member_expression#Right = AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right /** * 页面隐藏时清理计时器 * @returns {void} 无返回值 */ AST#method_declaration#Left aboutToDisappear AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . clearSideBarUnlockTimer 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 /** * 页面销毁时清理计时器 * @returns {void} 无返回值 */ AST#method_declaration#Left aboutToBeDeleted AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . clearSideBarUnlockTimer 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 {Category[]} categories - 原始分类列表 * @returns {CategoryTree[]} 树形结构的分类列表 * @example * const tree = this.convertToTree(list); */ AST#method_declaration#Left private convertToTree AST#parameter_list#Left ( AST#parameter#Left categories : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Category [ ] 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 CategoryTree [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left categories AST#expression#Right AST#unary_expression#Right AST#expression#Right || AST#expression#Left categories AST#expression#Right AST#binary_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#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#variable_declaration#Left const AST#variable_declarator#Left nestedTrees : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left CategoryTree [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . tryBuildTreeFromNested AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left categories 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 nestedTrees 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 nestedTrees AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left sortedList : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Category [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#array_literal#Left [ ... AST#expression#Left categories AST#expression#Right ] AST#array_literal#Right AST#expression#Right . sort 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 a : AST#type_annotation#Left AST#primary_type#Left Category AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left b : AST#type_annotation#Left AST#primary_type#Left Category 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#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left a AST#expression#Right . sortNum AST#member_expression#Right AST#expression#Right - AST#expression#Left b AST#expression#Right AST#binary_expression#Right AST#expression#Right . sortNum AST#member_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left categoryTrees : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left CategoryTree [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left sortedList AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left Category AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left CategoryTree 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 CategoryTree AST#expression#Right . fromCategory AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left item AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_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 rootCategories : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left CategoryTree [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left childrenMap : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Map AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left CategoryTree [ ] 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#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 number AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left CategoryTree [ ] AST#array_type#Right 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 categoryTrees 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 categoryTree : AST#type_annotation#Left AST#primary_type#Left CategoryTree 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 parentId : 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#primary_type#Left undefined AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left categoryTree AST#expression#Right . parentId AST#member_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left parentId 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 parentId 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#expression#Left AST#binary_expression#Left AST#expression#Left parentId AST#expression#Right === AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left rootCategories AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left categoryTree AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left children : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left CategoryTree [ ] AST#array_type#Right 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 childrenMap AST#expression#Right . get AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left parentId AST#expression#Right ) AST#argument_list#Right AST#call_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#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 children AST#expression#Right . push AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left categoryTree 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 childrenMap AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left parentId AST#expression#Right , AST#expression#Left children AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left rootCategories AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left rootCategory : AST#type_annotation#Left AST#primary_type#Left CategoryTree AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left CategoryTree 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 . buildCategoryTree AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left rootCategory AST#expression#Right , AST#expression#Left childrenMap AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 递归构建分类树 * @param {CategoryTree} categoryTree - 当前分类节点 * @param {Map<number, CategoryTree[]>} childrenMap - 子分类映射 * @returns {CategoryTree} 构建完成的分类节点 */ AST#method_declaration#Left private buildCategoryTree AST#parameter_list#Left ( AST#parameter#Left categoryTree : AST#type_annotation#Left AST#primary_type#Left CategoryTree AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left childrenMap : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Map AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left CategoryTree [ ] 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#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left CategoryTree AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left children : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left CategoryTree [ ] AST#array_type#Right 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 childrenMap 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 categoryTree AST#expression#Right . id AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ?? AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left children 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 categoryTree AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left categoryTree AST#expression#Right . children AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left children AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left child : AST#type_annotation#Left AST#primary_type#Left CategoryTree AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left CategoryTree 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 . buildCategoryTree AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left child AST#expression#Right , AST#expression#Left childrenMap AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left categoryTree AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right /** * 尝试从已包含 children 的数据中构建树 * @param {Category[]} categories - 原始分类列表 * @returns {CategoryTree[]} 构建后的树结构 */ AST#method_declaration#Left private tryBuildTreeFromNested AST#parameter_list#Left ( AST#parameter#Left categories : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Category [ ] 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 CategoryTree [ ] 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 hasChildren : AST#type_annotation#Left AST#primary_type#Left boolean 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 categories AST#expression#Right . some AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left Category AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right => AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#parenthesized_expression#Left ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . children 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#parenthesized_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#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#unary_expression#Left ! AST#expression#Left hasChildren AST#expression#Right AST#unary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#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#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left categories AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left Category AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left CategoryTree 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 . convertNestedNode AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left item AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#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 /** * 递归转换带 children 的节点 * @param {Category} category - 原始分类节点 * @returns {CategoryTree} 转换后的分类树节点 */ AST#method_declaration#Left private convertNestedNode AST#parameter_list#Left ( AST#parameter#Left category : AST#type_annotation#Left AST#primary_type#Left Category AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left CategoryTree AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left node : AST#type_annotation#Left AST#primary_type#Left CategoryTree 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 CategoryTree AST#expression#Right . fromCategory AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left category 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 children : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left Category [ ] AST#array_type#Right 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 category AST#expression#Right . children 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#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 children AST#expression#Right . length AST#member_expression#Right AST#expression#Right > AST#expression#Left 0 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left node AST#expression#Right . children AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left children AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left child : AST#type_annotation#Left AST#primary_type#Left Category AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left CategoryTree 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 . convertNestedNode AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left child AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left node 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#decorated_export_declaration#Right
@ObservedV2 export default class CategoryViewModel extends BaseNetWorkViewModel<Category[]> { private goodsRepository: GoodsRepository = new GoodsRepository(); @Trace categoryTrees: CategoryTree[] = []; @Trace categoryTitles: string[] = []; @Trace selectedCategoryIndex: number = -1; @Trace isSideBarScrolling: boolean = false; @Trace lastSideBarIndex: number = 0; private sideBarUnlockTimer: number = -1; protected requestRepository(): Promise<NetworkResponse<Category[]>> { return this.goodsRepository.getGoodsTypeList(); } protected onRequestSuccess(data: Category[]): void { this.categoryTrees = this.convertToTree(data); this.categoryTitles = this.categoryTrees.map((item: CategoryTree): string => item.name); this.isSideBarScrolling = false; this.lastSideBarIndex = 0; this.clearSideBarUnlockTimer(); if (this.categoryTrees.length > 0) { if (this.selectedCategoryIndex < 0 || this.selectedCategoryIndex >= this.categoryTrees.length) { this.selectedCategoryIndex = 0; } } else { this.selectedCategoryIndex = -1; } super.onRequestSuccess(data); } onSideBarSelected(index: number): number { const targetIndex: number = this.clampIndex(index); this.isSideBarScrolling = true; this.selectedCategoryIndex = targetIndex; this.startSideBarUnlockTimer(targetIndex); return targetIndex; } finishSideBarScroll(): void { this.isSideBarScrolling = false; } onRightListScroll(startIndex: number): void { if (startIndex < 0) { return; } if (this.isSideBarScrolling) { return; } if (startIndex !== this.selectedCategoryIndex) { this.selectedCategoryIndex = startIndex; } } getActiveIndex(): number { return this.selectedCategoryIndex < 0 ? 0 : this.selectedCategoryIndex; } private clampIndex(index: number): number { const total: number = this.categoryTrees.length; if (total <= 0) { return 0; } if (index < 0) { return 0; } if (index >= total) { return total - 1; } return index; } private calculateUnlockDuration(targetIndex: number): number { const distance: number = Math.abs(targetIndex - this.lastSideBarIndex); this.lastSideBarIndex = targetIndex; return Math.min(1200, Math.max(240, distance * 120)); } private startSideBarUnlockTimer(targetIndex: number): void { this.clearSideBarUnlockTimer(); const duration: number = this.calculateUnlockDuration(targetIndex); this.sideBarUnlockTimer = setTimeout((): void => { this.finishSideBarScroll(); this.sideBarUnlockTimer = -1; }, duration); } private clearSideBarUnlockTimer(): void { if (this.sideBarUnlockTimer >= 0) { clearTimeout(this.sideBarUnlockTimer); this.sideBarUnlockTimer = -1; } } aboutToDisappear(): void { this.clearSideBarUnlockTimer(); } aboutToBeDeleted(): void { this.clearSideBarUnlockTimer(); } private convertToTree(categories: Category[]): CategoryTree[] { if (!categories || categories.length === 0) { return []; } const nestedTrees: CategoryTree[] = this.tryBuildTreeFromNested(categories); if (nestedTrees.length > 0) { return nestedTrees; } const sortedList: Category[] = [...categories].sort((a: Category, b: Category): number => a.sortNum - b.sortNum); const categoryTrees: CategoryTree[] = sortedList.map((item: Category): CategoryTree => CategoryTree.fromCategory(item)); const rootCategories: CategoryTree[] = []; const childrenMap: Map<number, CategoryTree[]> = new Map<number, CategoryTree[]>(); categoryTrees.forEach((categoryTree: CategoryTree): void => { const parentId: number | null | undefined = categoryTree.parentId; if (parentId === null || parentId === undefined || parentId === 0) { rootCategories.push(categoryTree); return; } const children: CategoryTree[] = childrenMap.get(parentId) ?? []; children.push(categoryTree); childrenMap.set(parentId, children); }); return rootCategories.map((rootCategory: CategoryTree): CategoryTree => this.buildCategoryTree(rootCategory, childrenMap)); } private buildCategoryTree(categoryTree: CategoryTree, childrenMap: Map<number, CategoryTree[]>): CategoryTree { const children: CategoryTree[] = childrenMap.get(categoryTree.id) ?? []; if (children.length === 0) { return categoryTree; } categoryTree.children = children.map((child: CategoryTree): CategoryTree => this.buildCategoryTree(child, childrenMap)); return categoryTree; } private tryBuildTreeFromNested(categories: Category[]): CategoryTree[] { const hasChildren: boolean = categories.some((item: Category): boolean => { return (item.children ?? []).length > 0; }); if (!hasChildren) { return []; } return categories.map((item: Category): CategoryTree => this.convertNestedNode(item)); } private convertNestedNode(category: Category): CategoryTree { const node: CategoryTree = CategoryTree.fromCategory(category); const children: Category[] = category.children ?? []; if (children.length > 0) { node.children = children.map((child: Category): CategoryTree => this.convertNestedNode(child)); } return node; } }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/main/src/main/ets/viewmodel/CategoryViewModel.ets#L9-L274
c227d4add52ed320826777661e9ea51c528499cc
github
sedlei/Smart-park-system.git
253228f73e419e92fd83777f564889d202f7c699
src/main/ets/utils/IoTUtil.ets
arkts
initAll
初始化连接
public async initAll(): Promise<void> { await this.loadConfigs(); this.url = `ssl://${this.IotConfig.host}:${this.IotConfig.port}`; for (const cfg of this.deviceConfig) { const client = new IoTDevice(this.url, cfg.deviceId, cfg.secret, 'GlobalSign-rootca.pem'); console.log('正在连接:' + cfg.key); try { if (await client.init()) this.clients[cfg.key] = client; } catch (err) { console.error(cfg.key + " 连接失败", err.message); this.isConnecting = false this.connectingSuccess = true return; }
AST#method_declaration#Left public async initAll 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#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 . loadConfigs AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . url AST#member_expression#Right = AST#expression#Left AST#template_literal#Left ` ssl:// AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . IotConfig AST#member_expression#Right AST#expression#Right . host AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right : AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . IotConfig AST#member_expression#Right AST#expression#Right . port AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#ERROR#Left for ( AST#variable_declaration#Left const AST#variable_declarator#Left cfg AST#ERROR#Left of AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . deviceConfig AST#member_expression#Right AST#expression#Right ) { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left client = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left IoTDevice 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 . url AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left cfg AST#expression#Right . deviceId AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left cfg AST#expression#Right . secret AST#member_expression#Right AST#expression#Right , AST#expression#Left 'GlobalSign-rootca.pem' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . log AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left '正在连接:' AST#expression#Right + AST#expression#Left cfg AST#expression#Right AST#binary_expression#Right AST#expression#Right . key 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 try { 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#await_expression#Left await AST#expression#Left client AST#expression#Right AST#await_expression#Right AST#expression#Right . init AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . clients AST#member_expression#Right AST#expression#Right [ AST#expression#Left AST#member_expression#Left AST#expression#Left cfg AST#expression#Right . key AST#member_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#if_statement#Right AST#statement#Right AST#ERROR#Right = AST#expression#Left client AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#ERROR#Left } catch AST#parameter_list#Left ( AST#parameter#Left err AST#parameter#Right ) AST#parameter_list#Right AST#ERROR#Right AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left console AST#property_assignment#Right AST#object_literal#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 AST#member_expression#Left AST#expression#Left cfg AST#expression#Right . key AST#member_expression#Right AST#expression#Right + AST#expression#Left " 连接失败" AST#expression#Right AST#binary_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left err AST#expression#Right . message AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#member_expression#Left AST#expression#Left this AST#expression#Right . isConnecting AST#member_expression#Right = AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#ERROR#Left this AST#ERROR#Right . connectingSuccess AST#member_expression#Right = AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#assignment_expression#Right AST#ERROR#Right AST#statement#Left AST#return_statement#Left return ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
public async initAll(): Promise<void> { await this.loadConfigs(); this.url = `ssl://${this.IotConfig.host}:${this.IotConfig.port}`; for (const cfg of this.deviceConfig) { const client = new IoTDevice(this.url, cfg.deviceId, cfg.secret, 'GlobalSign-rootca.pem'); console.log('正在连接:' + cfg.key); try { if (await client.init()) this.clients[cfg.key] = client; } catch (err) { console.error(cfg.key + " 连接失败", err.message); this.isConnecting = false this.connectingSuccess = true return; }
https://github.com/sedlei/Smart-park-system.git/blob/253228f73e419e92fd83777f564889d202f7c699/src/main/ets/utils/IoTUtil.ets#L45-L58
992726e34a5dcd5bb59a317e07a7d351bc9ffddd
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/models/managers/user/UserManager.ets
arkts
initPreferences
=== 3. 数据持久化(Swift UserDefaults → ArkTS Preferences)===
private initPreferences() { this.prefs = preferences.getPreferencesSync(this.context, {name: Prefs.Name}); this.loadPreference(); }
AST#method_declaration#Left private 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 . prefs AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left preferences AST#expression#Right . getPreferencesSync 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 . context AST#member_expression#Right 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 Prefs AST#expression#Right . Name 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#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . loadPreference 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
private initPreferences() { this.prefs = preferences.getPreferencesSync(this.context, {name: Prefs.Name}); this.loadPreference(); }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/managers/user/UserManager.ets#L68-L71
0b3a4516030afa5cc834451e77e73f30337d3ee0
github
harmonyos-cases/cases
eccdb71f1cee10fa6ff955e16c454c1b59d3ae13
CommonAppDevelopment/feature/customscan/src/main/ets/viewmodel/CustomScanViewModel.ets
arkts
initCustomScan
初始化自定义扫码 @returns {void}
initCustomScan(): void { logger.info('initCustomScan'); try { this.initScanData() customScan.init(this.customScanInitOptions); this.startCustomScan(); } catch (error) { logger.error('init fail, error: ' + JSON.stringify(error)); } }
AST#method_declaration#Left initCustomScan AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left logger AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'initCustomScan' 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 this AST#expression#Right . initScanData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left customScan AST#expression#Right . init AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . customScanInitOptions 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 . startCustomScan AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 'init fail, error: ' AST#expression#Right + AST#expression#Left JSON AST#expression#Right AST#binary_expression#Right AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
initCustomScan(): void { logger.info('initCustomScan'); try { this.initScanData() customScan.init(this.customScanInitOptions); this.startCustomScan(); } catch (error) { logger.error('init fail, error: ' + JSON.stringify(error)); } }
https://github.com/harmonyos-cases/cases/blob/eccdb71f1cee10fa6ff955e16c454c1b59d3ae13/CommonAppDevelopment/feature/customscan/src/main/ets/viewmodel/CustomScanViewModel.ets#L290-L299
bddbc83a5d31b229c6fd6f63643971c22ebf00b8
gitee
ThePivotPoint/ArkTS-LSP-Server-Plugin.git
6231773905435f000d00d94b26504433082ba40b
packages/declarations/ets/api/@ohos.arkui.advanced.EditableTitleBar.d.ets
arkts
@file @kit ArkUI Declaration of the menu item on the right side. @syscap SystemCapability.ArkUI.ArkUI.Full @since 10 Declaration of the menu item on the right side. @syscap SystemCapability.ArkUI.ArkUI.Full @atomicservice @since 11
export declare class EditableTitleBarMenuItem { /** * Icon resource for this menu item. * @type { ResourceStr }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 10 */ /** * Icon resource for this menu item. * @type { ResourceStr }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 11 */ value: ResourceStr; /** * Icon label for this menu item. * @type { ?ResourceStr }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ label?: ResourceStr; /** * Whether to enable this menu item. * @type { ?boolean }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 10 */ /** * Whether to enable this menu item. * @type { ?boolean }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 11 */ isEnabled?: boolean; /** * Callback function when click on this menu item. * @type { ?() => void }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 10 */ /** * Callback function when click on this menu item. * @type { ?() => void }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 11 */ action?: () => void; }
AST#export_declaration#Left export AST#ERROR#Left declare AST#ERROR#Right AST#class_declaration#Left class EditableTitleBarMenuItem AST#class_body#Left { /** * Icon resource for this menu item. * @type { ResourceStr }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 10 */ /** * Icon resource for this menu item. * @type { ResourceStr }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 11 */ AST#property_declaration#Left value : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Icon label for this menu item. * @type { ?ResourceStr }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 12 */ AST#property_declaration#Left label ? : AST#type_annotation#Left AST#primary_type#Left ResourceStr AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Whether to enable this menu item. * @type { ?boolean }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 10 */ /** * Whether to enable this menu item. * @type { ?boolean }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 11 */ AST#property_declaration#Left isEnabled ? : AST#type_annotation#Left AST#primary_type#Left boolean AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Callback function when click on this menu item. * @type { ?() => void }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 10 */ /** * Callback function when click on this menu item. * @type { ?() => void }. * @syscap SystemCapability.ArkUI.ArkUI.Full * @atomicservice * @since 11 */ AST#property_declaration#Left action ? : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export declare class EditableTitleBarMenuItem { value: ResourceStr; label?: ResourceStr; isEnabled?: boolean; action?: () => void; }
https://github.com/ThePivotPoint/ArkTS-LSP-Server-Plugin.git/blob/6231773905435f000d00d94b26504433082ba40b/packages/declarations/ets/api/@ohos.arkui.advanced.EditableTitleBar.d.ets#L30-L81
ab25132cd8d2fb26b3dd3a1f8ab5fbe7fe40d8b0
github
openharmony/applications_app_samples
a826ab0e75fe51d028c1c5af58188e908736b53b
code/DocsSample/NetWork_Kit/NetWorkKit_Datatransmission/Socket/entry/src/main/ets/workers/TlsServerWorker.ets
arkts
startTLSserver
[Start application_transmits_encrypted_data_via_tls_socket_server]
function startTLSserver(message: TlsServerMessage) { try { const tlsSecureOptions: socket.TLSSecureOptions = { key: message.serverKey, cert: message.serverCert, ca: message.caCert, protocols: socket.Protocol.TLSv12, useRemoteCipherPrefer: true, signatureAlgorithms: 'rsa_pss_rsae_sha256:ECDSA+SHA256', cipherSuite: 'AES256-SHA256' }; const tlsConnectOptions: socket.TLSConnectOptions = { address: { address: message.serverIp!, port: message.serverPort }, secureOptions: tlsSecureOptions, ALPNProtocols: ['spdy/1', 'http/1.1'] }; tlsServer.listen(tlsConnectOptions).then(() => { workerPort.postMessage({ type: 'serverStarted', status: 'TLS server started successfully' }); tlsServer.on('connect', (client: socket.TLSSocketConnection) => { handleClientConnection(client); }); }).catch((err: BusinessError) => { workerPort.postMessage({ type: 'error', message: `Failed to start TLS server: ${err.message}` }); }); } catch (err) { workerPort.postMessage({ type: 'error', message: `Error starting server: ${err.message}` }); } }
AST#function_declaration#Left function startTLSserver AST#parameter_list#Left ( AST#parameter#Left message : AST#type_annotation#Left AST#primary_type#Left TlsServerMessage 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 const AST#variable_declarator#Left tlsSecureOptions : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left socket . TLSSecureOptions AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left key AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left message AST#expression#Right . serverKey AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left cert AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left message AST#expression#Right . serverCert AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left ca AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left message AST#expression#Right . caCert AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left protocols AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left socket AST#expression#Right . Protocol AST#member_expression#Right AST#expression#Right . TLSv12 AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left useRemoteCipherPrefer AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left signatureAlgorithms AST#property_name#Right : AST#expression#Left 'rsa_pss_rsae_sha256:ECDSA+SHA256' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left cipherSuite AST#property_name#Right : AST#expression#Left 'AES256-SHA256' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left tlsConnectOptions : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left socket . TLSConnectOptions AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left address AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left address AST#property_name#Right : AST#expression#Left AST#non_null_assertion_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left message AST#expression#Right . serverIp AST#member_expression#Right AST#expression#Right ! AST#non_null_assertion_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left port AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left message AST#expression#Right . serverPort AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left secureOptions AST#property_name#Right : AST#expression#Left tlsSecureOptions AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left ALPNProtocols AST#property_name#Right : AST#expression#Left AST#array_literal#Left [ AST#expression#Left 'spdy/1' AST#expression#Right , AST#expression#Left 'http/1.1' AST#expression#Right ] AST#array_literal#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left tlsServer AST#expression#Right . listen AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left tlsConnectOptions 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 workerPort AST#expression#Right . postMessage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left type AST#property_name#Right : AST#expression#Left 'serverStarted' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left status AST#property_name#Right : AST#expression#Left 'TLS server started successfully' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left tlsServer AST#expression#Right . on AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'connect' AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left client : AST#type_annotation#Left AST#primary_type#Left AST#qualified_type#Left socket . TLSSocketConnection AST#qualified_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left handleClientConnection AST#expression#Right AST#argument_list#Left ( AST#expression#Left client AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . 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 workerPort AST#expression#Right . postMessage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left type AST#property_name#Right : AST#expression#Left 'error' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` Failed to start TLS server: 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#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#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 workerPort AST#expression#Right . postMessage AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left type AST#property_name#Right : AST#expression#Left 'error' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left AST#template_literal#Left ` Error starting server: 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#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#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#function_declaration#Right
function startTLSserver(message: TlsServerMessage) { try { const tlsSecureOptions: socket.TLSSecureOptions = { key: message.serverKey, cert: message.serverCert, ca: message.caCert, protocols: socket.Protocol.TLSv12, useRemoteCipherPrefer: true, signatureAlgorithms: 'rsa_pss_rsae_sha256:ECDSA+SHA256', cipherSuite: 'AES256-SHA256' }; const tlsConnectOptions: socket.TLSConnectOptions = { address: { address: message.serverIp!, port: message.serverPort }, secureOptions: tlsSecureOptions, ALPNProtocols: ['spdy/1', 'http/1.1'] }; tlsServer.listen(tlsConnectOptions).then(() => { workerPort.postMessage({ type: 'serverStarted', status: 'TLS server started successfully' }); tlsServer.on('connect', (client: socket.TLSSocketConnection) => { handleClientConnection(client); }); }).catch((err: BusinessError) => { workerPort.postMessage({ type: 'error', message: `Failed to start TLS server: ${err.message}` }); }); } catch (err) { workerPort.postMessage({ type: 'error', message: `Error starting server: ${err.message}` }); } }
https://github.com/openharmony/applications_app_samples/blob/a826ab0e75fe51d028c1c5af58188e908736b53b/code/DocsSample/NetWork_Kit/NetWorkKit_Datatransmission/Socket/entry/src/main/ets/workers/TlsServerWorker.ets#L42-L72
aa7c8230261f75a6f9a6de959ebd28f690bce955
gitee
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/common/utils/strings/StringDealUtility.ets
arkts
clipIfNeedsFull
/ 对于太长的翻译,截取指定长度[按分隔符]的部分
public static clipIfNeedsFull( srcStr : string, seperator : string, subSeperator : string, maxParts : number ): string | null { const tempList: Array<string> = []; return StringDealUtility.deal( srcStr, seperator, subSeperator, new ClipTransform(tempList, maxParts) ); }
AST#method_declaration#Left public static clipIfNeedsFull AST#parameter_list#Left ( AST#parameter#Left srcStr : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left seperator : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left subSeperator : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left maxParts : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left string AST#primary_type#Right | AST#primary_type#Left null AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left tempList : 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#array_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left StringDealUtility AST#expression#Right . deal AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left srcStr AST#expression#Right , AST#expression#Left seperator AST#expression#Right , AST#expression#Left subSeperator AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left ClipTransform AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left tempList AST#expression#Right , AST#expression#Left maxParts 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
public static clipIfNeedsFull( srcStr : string, seperator : string, subSeperator : string, maxParts : number ): string | null { const tempList: Array<string> = []; return StringDealUtility.deal( srcStr, seperator, subSeperator, new ClipTransform(tempList, maxParts) ); }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/utils/strings/StringDealUtility.ets#L102-L116
f62a65bf5e8cd34e49a2358e67ba3f4a3eff6e3b
github
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/common/utils/strings/StringCrypto.ets
arkts
_toHexString
私有方法:字节数组转十六进制字符串 @param bytes Uint8Array字节数组 @returns 十六进制字符串
private static _toHexString(bytes: Uint8Array): string { return Array.from(bytes) .map(byte => byte.toString(16).padStart(2, '0')) .join(''); }
AST#method_declaration#Left private static _toHexString AST#parameter_list#Left ( AST#parameter#Left bytes : AST#type_annotation#Left AST#primary_type#Left Uint8Array AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#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#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 bytes AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . map AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left byte => 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 byte AST#expression#Right . toString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 16 AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . 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#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . join AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
private static _toHexString(bytes: Uint8Array): string { return Array.from(bytes) .map(byte => byte.toString(16).padStart(2, '0')) .join(''); }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/common/utils/strings/StringCrypto.ets#L80-L84
0e2d69f1cf5a099122231fa48e531ca1f91e287a
github
BohanSu/LumosAgent-HarmonyOS.git
9eee81c93b67318d9c1c5d5a831ffc1c1fa08e76
entry/src/main/ets/viewmodel/MainViewModel.ets
arkts
deleteMemo
Delete a memo @param memoId - ID of memo to delete
async deleteMemo(memoId: number): Promise<void> { try { await this.rdbHelper.deleteMemo(memoId); await this.refreshData(); } catch (error) { console.error(`[MainViewModel] Failed to delete memo: ${JSON.stringify(error)}`); } }
AST#method_declaration#Left async deleteMemo AST#parameter_list#Left ( AST#parameter#Left memoId : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 . rdbHelper AST#member_expression#Right AST#expression#Right . deleteMemo AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left memoId AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . refreshData AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#template_literal#Left ` [MainViewModel] Failed to delete memo: AST#template_substitution#Left $ { AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async deleteMemo(memoId: number): Promise<void> { try { await this.rdbHelper.deleteMemo(memoId); await this.refreshData(); } catch (error) { console.error(`[MainViewModel] Failed to delete memo: ${JSON.stringify(error)}`); } }
https://github.com/BohanSu/LumosAgent-HarmonyOS.git/blob/9eee81c93b67318d9c1c5d5a831ffc1c1fa08e76/entry/src/main/ets/viewmodel/MainViewModel.ets#L508-L515
b40b8b4e176a9a53b6c2f7f4f470fa8fa972f9fa
github
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/pages/SearchPage.ets
arkts
buildGreetingResults
构建祝福语搜索结果
@Builder buildGreetingResults() { Column({ space: 12 }) { Text(`祝福语 (${this.searchResult.greetings.length})`) .fontSize(16) .fontWeight(FontWeight.Medium) .fontColor('#333333') .alignSelf(ItemAlign.Start) Column({ space: 1 }) { ForEach(this.searchResult.greetings.slice(0, this.activeTab === 'greetings' ? 50 : 3), (greeting: Greeting) => { this.buildGreetingResultItem(greeting) }) if (this.activeTab === 'all' && this.searchResult.greetings.length > 3) { Row() { Text(`查看全部${this.searchResult.greetings.length}条祝福语`) .fontSize(14) .fontColor('#007AFF') } .width('100%') .height('48vp') .justifyContent(FlexAlign.Center) .backgroundColor('#f8f9fa') .onClick(() => { this.onTabChange('greetings'); }) } } .backgroundColor('#ffffff') .borderRadius(12) .shadow({ radius: 8, color: 'rgba(0,0,0,0.1)', offsetX: 0, offsetY: 2 }) } }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildGreetingResults AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 12 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#template_literal#Left ` 祝福语 ( AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . searchResult AST#member_expression#Right AST#expression#Right . greetings AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ) ` AST#template_literal#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 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#Left . fontColor ( AST#expression#Left '#333333' AST#expression#Right ) AST#modifier_chain_expression#Left . alignSelf ( AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 1 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#ui_control_flow#Left AST#for_each_statement#Left ForEach ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . searchResult AST#member_expression#Right AST#expression#Right . greetings AST#member_expression#Right AST#expression#Right . slice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 0 AST#expression#Right , AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . activeTab AST#member_expression#Right AST#expression#Right === AST#expression#Left 'greetings' AST#expression#Right AST#binary_expression#Right AST#expression#Right ? AST#expression#Left 50 AST#expression#Right : AST#expression#Left 3 AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#ui_builder_arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left greeting : AST#type_annotation#Left AST#primary_type#Left Greeting AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#ui_arrow_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . buildGreetingResultItem AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left greeting AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right } AST#ui_arrow_function_body#Right AST#ui_builder_arrow_function#Right ) AST#for_each_statement#Right AST#ui_control_flow#Right AST#ui_control_flow#Left AST#ui_if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 . activeTab AST#member_expression#Right AST#expression#Right === AST#expression#Left 'all' AST#expression#Right AST#binary_expression#Right AST#expression#Right && AST#expression#Left this AST#expression#Right AST#binary_expression#Right AST#expression#Right . searchResult AST#member_expression#Right AST#expression#Right . greetings AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right > AST#expression#Left 3 AST#expression#Right AST#binary_expression#Right AST#expression#Right ) { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#template_literal#Left ` 查看全部 AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . searchResult AST#member_expression#Right AST#expression#Right . greetings AST#member_expression#Right AST#expression#Right . length AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right 条祝福语 ` AST#template_literal#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 14 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#007AFF' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '48vp' AST#expression#Right ) AST#modifier_chain_expression#Left . justifyContent ( AST#expression#Left AST#member_expression#Left AST#expression#Left FlexAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#f8f9fa' AST#expression#Right ) AST#modifier_chain_expression#Left . onClick ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . onTabChange AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'greetings' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#ffffff' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 12 AST#expression#Right ) AST#modifier_chain_expression#Left . shadow ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left radius AST#property_name#Right : AST#expression#Left 8 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left 'rgba(0,0,0,0.1)' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offsetX AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left offsetY AST#property_name#Right : AST#expression#Left 2 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
@Builder buildGreetingResults() { Column({ space: 12 }) { Text(`祝福语 (${this.searchResult.greetings.length})`) .fontSize(16) .fontWeight(FontWeight.Medium) .fontColor('#333333') .alignSelf(ItemAlign.Start) Column({ space: 1 }) { ForEach(this.searchResult.greetings.slice(0, this.activeTab === 'greetings' ? 50 : 3), (greeting: Greeting) => { this.buildGreetingResultItem(greeting) }) if (this.activeTab === 'all' && this.searchResult.greetings.length > 3) { Row() { Text(`查看全部${this.searchResult.greetings.length}条祝福语`) .fontSize(14) .fontColor('#007AFF') } .width('100%') .height('48vp') .justifyContent(FlexAlign.Center) .backgroundColor('#f8f9fa') .onClick(() => { this.onTabChange('greetings'); }) } } .backgroundColor('#ffffff') .borderRadius(12) .shadow({ radius: 8, color: 'rgba(0,0,0,0.1)', offsetX: 0, offsetY: 2 }) } }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/SearchPage.ets#L545-L583
f8a3b1f7a91458a15992275b050f8ef4777e09e0
github
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_axios/src/main/ets/axios/EfClientApi.ets
arkts
post
post请求 - json格式 @param efClientParams post请求入参实体 @package cls入参实体转换对象 @returns 响应结果
async post<F, E>(efClientParams: efClientParams<F>, cls?: ClassConstructor<E>): Promise<E | EfAxiosError> { try { //如果当前请求efClientParams.loadingTxt传入参数 则 更改当前的loading文本 if (efClientParams.loadingTxt) { efAxiosParams.loadingTxt = efClientParams.loadingTxt; } //发送请求 let response: AxiosResponse<E> = await efAxios.post<E, AxiosResponse<E>, F>(efClientParams.url, efClientParams.query, { headers: EfClientApi.appendHeader(efClientParams.headers), baseURL: EfClientApi.appendBaseURL(efClientParams.baseUrl) }); //如果当前请求更改过loading文字的话 - 更改默认值 if (efClientParams.loadingTxt) { efAxiosParams.loadingTxt = EfAxiosConst.loadingTxt; } //需要转换类型解决状态变量监听的问题 if (cls) { return plainToClass(cls, response.data); } //返回response的数据 return response.data; } catch (error) { //如果当前请求更改过loading文字的话 - 更改默认值 if (efClientParams.loadingTxt) { efAxiosParams.loadingTxt = EfAxiosConst.loadingTxt; } let e: AxiosError = error as AxiosError; //将异常抛出 return new EfAxiosError(Number(e.code), e.name, e.message, e.stack); } }
AST#method_declaration#Left async post AST#type_parameters#Left < AST#type_parameter#Left F AST#type_parameter#Right , AST#type_parameter#Left E AST#type_parameter#Right > AST#type_parameters#Right AST#parameter_list#Left ( AST#parameter#Left efClientParams : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left efClientParams AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left F 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 cls ? : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left ClassConstructor AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left E AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#union_type#Left AST#primary_type#Left E AST#primary_type#Right | AST#primary_type#Left EfAxiosError AST#primary_type#Right AST#union_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { //如果当前请求efClientParams.loadingTxt传入参数 则 更改当前的loading文本 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left efClientParams AST#expression#Right . loadingTxt 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 efAxiosParams AST#expression#Right . loadingTxt AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left efClientParams AST#expression#Right . loadingTxt AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right //发送请求 AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left response : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left AxiosResponse AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left E 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 efAxios AST#expression#Right AST#await_expression#Right AST#expression#Right . post AST#member_expression#Right AST#expression#Right AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left E AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left AxiosResponse AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left E 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_annotation#Left AST#primary_type#Left F AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left efClientParams AST#expression#Right . url AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left efClientParams AST#expression#Right . query AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left headers AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left EfClientApi AST#expression#Right . appendHeader AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left efClientParams AST#expression#Right . headers AST#member_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 baseURL AST#property_name#Right : AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left EfClientApi AST#expression#Right . appendBaseURL AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left efClientParams AST#expression#Right . baseUrl AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right //如果当前请求更改过loading文字的话 - 更改默认值 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left efClientParams AST#expression#Right . loadingTxt 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 efAxiosParams AST#expression#Right . loadingTxt AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left EfAxiosConst AST#expression#Right . loadingTxt AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right //需要转换类型解决状态变量监听的问题 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left cls AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left plainToClass AST#expression#Right AST#argument_list#Left ( AST#expression#Left cls AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . data AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right //返回response的数据 AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#member_expression#Left AST#expression#Left response AST#expression#Right . data AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Left catch ( error ) AST#block_statement#Left { //如果当前请求更改过loading文字的话 - 更改默认值 AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left efClientParams AST#expression#Right . loadingTxt 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 efAxiosParams AST#expression#Right . loadingTxt AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left EfAxiosConst AST#expression#Right . loadingTxt AST#member_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left let AST#variable_declarator#Left e : AST#type_annotation#Left AST#primary_type#Left AxiosError AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#as_expression#Left AST#expression#Left error AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left AxiosError 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#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left EfAxiosError AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left Number AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left e AST#expression#Right . code AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left e AST#expression#Right . name AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left e AST#expression#Right . message AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left e AST#expression#Right . stack 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#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async post<F, E>(efClientParams: efClientParams<F>, cls?: ClassConstructor<E>): Promise<E | EfAxiosError> { try { if (efClientParams.loadingTxt) { efAxiosParams.loadingTxt = efClientParams.loadingTxt; } let response: AxiosResponse<E> = await efAxios.post<E, AxiosResponse<E>, F>(efClientParams.url, efClientParams.query, { headers: EfClientApi.appendHeader(efClientParams.headers), baseURL: EfClientApi.appendBaseURL(efClientParams.baseUrl) }); if (efClientParams.loadingTxt) { efAxiosParams.loadingTxt = EfAxiosConst.loadingTxt; } if (cls) { return plainToClass(cls, response.data); } return response.data; } catch (error) { if (efClientParams.loadingTxt) { efAxiosParams.loadingTxt = EfAxiosConst.loadingTxt; } let e: AxiosError = error as AxiosError; return new EfAxiosError(Number(e.code), e.name, e.message, e.stack); } }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_axios/src/main/ets/axios/EfClientApi.ets#L77-L108
6b1a05ca234e2600013bd9587fcf186d3377ed75
gitee
KoStudio/ArkTS-WordTree.git
78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324
entry/src/main/ets/models/managers/plan/plancurve/PlanManager.ets
arkts
定义通知相关的常量
export class PlanManagerNotification { static readonly namePlanUpdated = "PlanManager.Plan.updated.with_book_id" static readonly kPlanId = "PlanIdKey" }
AST#export_declaration#Left export AST#class_declaration#Left class PlanManagerNotification AST#class_body#Left { AST#property_declaration#Left static readonly namePlanUpdated = AST#expression#Left "PlanManager.Plan.updated.with_book_id" AST#expression#Right AST#property_declaration#Right AST#property_declaration#Left static readonly kPlanId = AST#expression#Left "PlanIdKey" AST#expression#Right AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class PlanManagerNotification { static readonly namePlanUpdated = "PlanManager.Plan.updated.with_book_id" static readonly kPlanId = "PlanIdKey" }
https://github.com/KoStudio/ArkTS-WordTree.git/blob/78c2a8f8ef6cf4c6be8bab2212f04bfcfa7e7324/entry/src/main/ets/models/managers/plan/plancurve/PlanManager.ets#L27-L33
d3017bf7ac46e8d92edb075dfa5fb310a3a78ced
github
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
feature/launch/src/main/ets/view/SplashPage.ets
arkts
SplashContent
启动页内容视图 @returns {void} 无返回值
@Builder private SplashContent() { Text("启动页内容视图") }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right private SplashContent 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 Text ( AST#expression#Left "启动页内容视图" AST#expression#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 SplashContent() { Text("启动页内容视图") }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/feature/launch/src/main/ets/view/SplashPage.ets#L33-L36
c6003b727b2508d84e62f6f0935a1ee5f6068601
github
liuchao0739/arkTS_universal_starter.git
0ca845f5ae0e78db439dc09f712d100c0dd46ed3
entry/src/main/ets/services/MockDataService.ets
arkts
getChatMessages
获取聊天消息
static getChatMessages(conversationId: string): ChatMessage[] { const conversations = MockDataService.getConversations(); const conversation = conversations.find(c => c.id === conversationId); const otherName = conversation?.name || '用户'; const otherAvatar = conversation?.avatar || 'https://via.placeholder.com/40x40?text=U'; return [ { id: '1', senderId: conversationId, senderName: otherName, senderAvatar: otherAvatar, content: '你好,请问商品什么时候发货?', type: 'text', timestamp: Date.now() - 1000 * 60 * 10 }, { id: '2', senderId: 'me', senderName: '我', senderAvatar: 'https://via.placeholder.com/40x40?text=ME', content: '明天就可以发货', type: 'text', timestamp: Date.now() - 1000 * 60 * 9 }, { id: '3', senderId: conversationId, senderName: otherName, senderAvatar: otherAvatar, content: '好的,谢谢!', type: 'text', timestamp: Date.now() - 1000 * 60 * 8 } ]; }
AST#method_declaration#Left static getChatMessages AST#parameter_list#Left ( AST#parameter#Left conversationId : 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#array_type#Left ChatMessage [ ] 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 conversations = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left MockDataService AST#expression#Right . getConversations 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 conversation = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left conversations AST#expression#Right . find AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left c => AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left c AST#expression#Right . id AST#member_expression#Right AST#expression#Right === AST#expression#Left conversationId 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#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left otherName = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left conversation AST#expression#Right ?. name AST#member_expression#Right AST#expression#Right || AST#expression#Left '用户' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left otherAvatar = AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left conversation AST#expression#Right ?. avatar AST#member_expression#Right AST#expression#Right || AST#expression#Left 'https://via.placeholder.com/40x40?text=U' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left id AST#property_name#Right : AST#expression#Left '1' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left senderId AST#property_name#Right : AST#expression#Left conversationId AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left senderName AST#property_name#Right : AST#expression#Left otherName AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left senderAvatar AST#property_name#Right : AST#expression#Left otherAvatar AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left content AST#property_name#Right : AST#expression#Left '你好,请问商品什么时候发货?' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left type AST#property_name#Right : AST#expression#Left 'text' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left timestamp 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 . now 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#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 1000 AST#expression#Right * AST#expression#Left 60 AST#expression#Right AST#binary_expression#Right AST#expression#Right * AST#expression#Left 10 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left id AST#property_name#Right : AST#expression#Left '2' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left senderId AST#property_name#Right : AST#expression#Left 'me' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left senderName AST#property_name#Right : AST#expression#Left '我' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left senderAvatar AST#property_name#Right : AST#expression#Left 'https://via.placeholder.com/40x40?text=ME' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left content AST#property_name#Right : AST#expression#Left '明天就可以发货' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left type AST#property_name#Right : AST#expression#Left 'text' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left timestamp 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 . now 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#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 1000 AST#expression#Right * AST#expression#Left 60 AST#expression#Right AST#binary_expression#Right AST#expression#Right * AST#expression#Left 9 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left id AST#property_name#Right : AST#expression#Left '3' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left senderId AST#property_name#Right : AST#expression#Left conversationId AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left senderName AST#property_name#Right : AST#expression#Left otherName AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left senderAvatar AST#property_name#Right : AST#expression#Left otherAvatar AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left content AST#property_name#Right : AST#expression#Left '好的,谢谢!' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left type AST#property_name#Right : AST#expression#Left 'text' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left timestamp 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 . now 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#binary_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left 1000 AST#expression#Right * AST#expression#Left 60 AST#expression#Right AST#binary_expression#Right AST#expression#Right * AST#expression#Left 8 AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static getChatMessages(conversationId: string): ChatMessage[] { const conversations = MockDataService.getConversations(); const conversation = conversations.find(c => c.id === conversationId); const otherName = conversation?.name || '用户'; const otherAvatar = conversation?.avatar || 'https://via.placeholder.com/40x40?text=U'; return [ { id: '1', senderId: conversationId, senderName: otherName, senderAvatar: otherAvatar, content: '你好,请问商品什么时候发货?', type: 'text', timestamp: Date.now() - 1000 * 60 * 10 }, { id: '2', senderId: 'me', senderName: '我', senderAvatar: 'https://via.placeholder.com/40x40?text=ME', content: '明天就可以发货', type: 'text', timestamp: Date.now() - 1000 * 60 * 9 }, { id: '3', senderId: conversationId, senderName: otherName, senderAvatar: otherAvatar, content: '好的,谢谢!', type: 'text', timestamp: Date.now() - 1000 * 60 * 8 } ]; }
https://github.com/liuchao0739/arkTS_universal_starter.git/blob/0ca845f5ae0e78db439dc09f712d100c0dd46ed3/entry/src/main/ets/services/MockDataService.ets#L265-L300
cae08077dda17f99084f08fb15fc419b327684bd
github
wenfujing/honms-super-market.git
0858abecd8be5db7b8dcf88dcd77b7c66d37517a
common/src/main/ets/utils/LocalDataManager.ets
arkts
updateOrder
Update order data. @param props: update props @returns Order[]
updateOrder(props: updateOrderProps) { const result: Order = this.orderData.filter(item => item.orderId === props.orderId)[0]; const newOrder: Order = { orderId: props.orderId, commodityId: result.commodityId, price: result.price, count: result.count, specifications: result.specifications, image: result.image, description: result.description, title: result.title, uid: result.uid, status: props.status, createTime: result.createTime } this.orderData.splice(this.orderData.indexOf(result), 1, newOrder); return this.orderData; }
AST#method_declaration#Left updateOrder AST#parameter_list#Left ( AST#parameter#Left props : AST#type_annotation#Left AST#primary_type#Left updateOrderProps 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#type_annotation#Left AST#primary_type#Left Order AST#primary_type#Right AST#type_annotation#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 AST#member_expression#Left AST#expression#Left this AST#expression#Right . orderData AST#member_expression#Right AST#expression#Right . filter AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left item => AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left item AST#expression#Right . orderId AST#member_expression#Right AST#expression#Right === AST#expression#Left props AST#expression#Right AST#binary_expression#Right AST#expression#Right . orderId AST#member_expression#Right AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right [ AST#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 const AST#variable_declarator#Left newOrder : AST#type_annotation#Left AST#primary_type#Left Order AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left orderId AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left props AST#expression#Right . orderId AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left commodityId AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . commodityId AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left price AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . price AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left count AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . count AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left specifications AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . specifications AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left image AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . image AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left description AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . description AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left title AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . title AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left uid AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . uid AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left status AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left props AST#expression#Right . status AST#member_expression#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left createTime AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left result AST#expression#Right . createTime AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#ERROR#Left this AST#ERROR#Right . orderData AST#member_expression#Right AST#expression#Right . splice AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . orderData AST#member_expression#Right AST#expression#Right . indexOf AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left result AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right , AST#expression#Left 1 AST#expression#Right , AST#expression#Left newOrder 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 this AST#expression#Right . orderData AST#member_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
updateOrder(props: updateOrderProps) { const result: Order = this.orderData.filter(item => item.orderId === props.orderId)[0]; const newOrder: Order = { orderId: props.orderId, commodityId: result.commodityId, price: result.price, count: result.count, specifications: result.specifications, image: result.image, description: result.description, title: result.title, uid: result.uid, status: props.status, createTime: result.createTime } this.orderData.splice(this.orderData.indexOf(result), 1, newOrder); return this.orderData; }
https://github.com/wenfujing/honms-super-market.git/blob/0858abecd8be5db7b8dcf88dcd77b7c66d37517a/common/src/main/ets/utils/LocalDataManager.ets#L170-L187
8df7aafe5dbc1cf4cc3b30ec1804abf2ac1eaaa8
github
harmonyos_samples/BestPracticeSnippets
490ea539a6d4427dd395f3dac3cf4887719f37af
FoldableGuilde/entry/src/main/ets/modules/PinchImage.ets
arkts
PinchImage
[Start PinchImage]
@Component export struct PinchImage { list: string[] = ['image1', 'image2', 'image3', 'image4', 'image5', 'image6']; @State GridColumn: string = '1fr 1fr 1fr'; @State GridRow: string = '1fr 1fr'; build() { Column() { Grid() { ForEach(this.list, (item: string) => { GridItem() { Text(item) }.backgroundColor(Color.Grey) }, (item: string) => item) } .columnsTemplate(this.GridColumn) .rowsTemplate(this.GridRow) .rowsGap(12) .columnsGap(12) } // Change the layout of the Grid when two-finger scaling is triggered .gesture(PinchGesture({ fingers: 2 }).onActionUpdate((event: GestureEvent) => { if (event.scale > 1) { // Increase animation effect this.getUIContext().animateTo({ duration: 500 }, () => { // When the two-finger scaling ratio is > 1, the number of Grid columns becomes 2 this.GridColumn = '1fr 1fr'; }) } else { this.getUIContext().animateTo({ duration: 500 }, () => { // When the two-finger scaling ratio is < =1, the number of Grid columns becomes 3 this.GridColumn = '1fr 1fr 1fr'; }) } })) } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct PinchImage AST#component_body#Left { AST#property_declaration#Left list : 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 'image1' AST#expression#Right , AST#expression#Left 'image2' AST#expression#Right , AST#expression#Left 'image3' AST#expression#Right , AST#expression#Left 'image4' AST#expression#Right , AST#expression#Left 'image5' AST#expression#Right , AST#expression#Left 'image6' AST#expression#Right ] AST#array_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right GridColumn : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '1fr 1fr 1fr' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ State AST#decorator#Right GridRow : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '1fr 1fr' AST#expression#Right ; AST#property_declaration#Right AST#build_method#Left build ( ) AST#build_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Grid ( ) AST#container_content_body#Left { AST#ui_control_flow#Left AST#for_each_statement#Left ForEach ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . list AST#member_expression#Right AST#expression#Right , AST#ui_builder_arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#ui_arrow_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left GridItem ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left item AST#expression#Right ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#member_expression#Left AST#expression#Left Color AST#expression#Right . Grey AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#ui_arrow_function_body#Right AST#ui_builder_arrow_function#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left item : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#expression#Left item AST#expression#Right AST#arrow_function#Right AST#expression#Right ) AST#for_each_statement#Right AST#ui_control_flow#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . columnsTemplate ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . GridColumn AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . rowsTemplate ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . GridRow AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . rowsGap ( AST#expression#Left 12 AST#expression#Right ) AST#modifier_chain_expression#Left . columnsGap ( AST#expression#Left 12 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right // Change the layout of the Grid when two-finger scaling is triggered AST#modifier_chain_expression#Left . gesture ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left PinchGesture AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left fingers AST#property_name#Right : AST#expression#Left 2 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 . onActionUpdate 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 event : AST#type_annotation#Left AST#primary_type#Left GestureEvent AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#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 event AST#expression#Right . scale 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 { // Increase animation effect 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 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 . animateTo 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 duration AST#property_name#Right : AST#expression#Left 500 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { // When the two-finger scaling ratio is > 1, the number of Grid columns becomes 2 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 . GridColumn AST#member_expression#Right = AST#expression#Left '1fr 1fr' 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 else AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#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 . animateTo 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 duration AST#property_name#Right : AST#expression#Left 500 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right , AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( ) AST#parameter_list#Right => AST#block_statement#Left { // When the two-finger scaling ratio is < =1, the number of Grid columns becomes 3 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . GridColumn AST#member_expression#Right = AST#expression#Left '1fr 1fr 1fr' 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#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#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 PinchImage { list: string[] = ['image1', 'image2', 'image3', 'image4', 'image5', 'image6']; @State GridColumn: string = '1fr 1fr 1fr'; @State GridRow: string = '1fr 1fr'; build() { Column() { Grid() { ForEach(this.list, (item: string) => { GridItem() { Text(item) }.backgroundColor(Color.Grey) }, (item: string) => item) } .columnsTemplate(this.GridColumn) .rowsTemplate(this.GridRow) .rowsGap(12) .columnsGap(12) } .gesture(PinchGesture({ fingers: 2 }).onActionUpdate((event: GestureEvent) => { if (event.scale > 1) { this.getUIContext().animateTo({ duration: 500 }, () => { this.GridColumn = '1fr 1fr'; }) } else { this.getUIContext().animateTo({ duration: 500 }, () => { this.GridColumn = '1fr 1fr 1fr'; }) } })) } }
https://github.com/harmonyos_samples/BestPracticeSnippets/blob/490ea539a6d4427dd395f3dac3cf4887719f37af/FoldableGuilde/entry/src/main/ets/modules/PinchImage.ets#L17-L57
9f2d30158cd3480ff991e6be0976d6c496bb7303
gitee
openharmony/developtools_profiler
73d26bb5acfcafb2b1f4f94ead5640241d1e5f73
host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/components/YAxis.ets
arkts
setMinWidth
Sets the minimum width that the axis should take (in dp). @param minWidth
public setMinWidth(minWidth: number): void { this.mMinWidth = minWidth; }
AST#method_declaration#Left public setMinWidth AST#parameter_list#Left ( AST#parameter#Left minWidth : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . mMinWidth AST#member_expression#Right = AST#expression#Left minWidth AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#builder_function_body#Right AST#method_declaration#Right
public setMinWidth(minWidth: number): void { this.mMinWidth = minWidth; }
https://github.com/openharmony/developtools_profiler/blob/73d26bb5acfcafb2b1f4f94ead5640241d1e5f73/host/smartperf/client/client_ui/entry/src/main/ets/common/ui/detail/chart/components/YAxis.ets#L151-L153
d46ee164fb8750ff5fac4bb559258ddaf911ab10
gitee
Joker-x-dev/HarmonyKit.git
f97197ce157df7f303244fba42e34918306dfb08
entry/src/main/ets/entryability/EntryAbility.ets
arkts
onForeground
应用进入前台时调用 刷新应用状态、重新注册路由 @returns {void} 无返回值
onForeground(): void { }
AST#method_declaration#Left onForeground AST#parameter_list#Left ( ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#builder_function_body#Left { } AST#builder_function_body#Right AST#method_declaration#Right
onForeground(): void { }
https://github.com/Joker-x-dev/HarmonyKit.git/blob/f97197ce157df7f303244fba42e34918306dfb08/entry/src/main/ets/entryability/EntryAbility.ets#L73-L74
7f8501cb1faae80e9880e11fa05f28046eab20c4
github
pangpang20/wavecast.git
d3da8a0009eb44a576a2b9d9d9fe6195a2577e32
entry/src/main/ets/service/SettingsService.ets
arkts
init
初始化设置
async init(context: Context): Promise<void> { try { this.context = context; this.preferences = await preferences.getPreferences(context, Constants.PREF_SETTINGS); await this.loadSettings(); // 初始化时应用主题 this.applyTheme(this.settings.themeMode); } catch (error) { console.error('[SettingsService] Failed to initialize settings:', error); } }
AST#method_declaration#Left async init AST#parameter_list#Left ( AST#parameter#Left context : AST#type_annotation#Left AST#primary_type#Left Context AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . context AST#member_expression#Right = AST#expression#Left context AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . preferences AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left preferences AST#expression#Right AST#await_expression#Right AST#expression#Right . getPreferences AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left context AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left Constants AST#expression#Right . PREF_SETTINGS AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . loadSettings AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right // 初始化时应用主题 AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . applyTheme AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . settings AST#member_expression#Right AST#expression#Right . themeMode AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#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 '[SettingsService] Failed to initialize settings:' AST#expression#Right , AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
async init(context: Context): Promise<void> { try { this.context = context; this.preferences = await preferences.getPreferences(context, Constants.PREF_SETTINGS); await this.loadSettings(); this.applyTheme(this.settings.themeMode); } catch (error) { console.error('[SettingsService] Failed to initialize settings:', error); } }
https://github.com/pangpang20/wavecast.git/blob/d3da8a0009eb44a576a2b9d9d9fe6195a2577e32/entry/src/main/ets/service/SettingsService.ets#L27-L37
9eda563d3ae5349e96ff295a668610a1e37b5659
github
awa_Liny/LinysBrowser_NEXT
a5cd96a9aa8114cae4972937f94a8967e55d4a10
home/src/main/ets/hosts/bunch_of_tabs.ets
arkts
refresh_onWorkingTab
Refreshes current main tab.
refresh_onWorkingTab() { this.Tabs[this.main_tab_idx].controller?.refresh(); this.Tabs[this.main_tab_idx].update_url(true); }
AST#method_declaration#Left refresh_onWorkingTab AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . Tabs AST#member_expression#Right AST#expression#Right [ AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . main_tab_idx AST#member_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . controller AST#member_expression#Right AST#expression#Right ?. refresh 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#subscript_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . Tabs AST#member_expression#Right AST#expression#Right [ AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . main_tab_idx AST#member_expression#Right AST#expression#Right ] AST#subscript_expression#Right AST#expression#Right . update_url 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
refresh_onWorkingTab() { this.Tabs[this.main_tab_idx].controller?.refresh(); this.Tabs[this.main_tab_idx].update_url(true); }
https://github.com/awa_Liny/LinysBrowser_NEXT/blob/a5cd96a9aa8114cae4972937f94a8967e55d4a10/home/src/main/ets/hosts/bunch_of_tabs.ets#L86-L89
d3bf39e5e914c3f2bc7e3bae64fd0a4739a995a8
gitee
Joker-x-dev/CoolMallArkTS.git
9f3fabf89fb277692cb82daf734c220c7282919c
core/navigation/src/main/ets/common/CommonParam.ets
arkts
@file 公共模块导航参数定义 @author Joker.X WebView 页面参数
export interface CommonWebParam { /** * 页面 URL */ url: string; /** * 页面标题 */ title?: string; }
AST#export_declaration#Left export AST#interface_declaration#Left interface CommonWebParam AST#object_type#Left { /** * 页面 URL */ AST#type_member#Left url : 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 title ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
export interface CommonWebParam { url: string; title?: string; }
https://github.com/Joker-x-dev/CoolMallArkTS.git/blob/9f3fabf89fb277692cb82daf734c220c7282919c/core/navigation/src/main/ets/common/CommonParam.ets#L9-L18
dcf01554fc40127a7fb7219919f2ca41961d9f10
github
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_core/src/main/ets/core/util/DateUtil.ets
arkts
parse
将输入的日期字符串转换为Date日期类型 @param dateString @returns
static parse(dateString: string): Date { return new Date(dateString); }
AST#method_declaration#Left static parse AST#parameter_list#Left ( AST#parameter#Left dateString : 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 Date AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left Date AST#expression#Right AST#new_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left dateString 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 parse(dateString: string): Date { return new Date(dateString); }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_core/src/main/ets/core/util/DateUtil.ets#L30-L32
abd651af07655fa6da726dae464b26d98d4dfeb3
gitee
harmonyos/samples
f5d967efaa7666550ee3252d118c3c73a77686f5
ETSUI/CategoryListSample/entry/src/main/ets/common/bean/Category.ets
arkts
Category item information.
export class Category { /** * Category title. */ title: Resource; /** * Category content(a list). */ categoryContent: Array<ListItemData>; }
AST#export_declaration#Left export AST#class_declaration#Left class Category AST#class_body#Left { /** * Category title. */ AST#property_declaration#Left title : AST#type_annotation#Left AST#primary_type#Left Resource AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right /** * Category content(a list). */ AST#property_declaration#Left categoryContent : 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 ListItemData AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right ; AST#property_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class Category { title: Resource; categoryContent: Array<ListItemData>; }
https://github.com/harmonyos/samples/blob/f5d967efaa7666550ee3252d118c3c73a77686f5/ETSUI/CategoryListSample/entry/src/main/ets/common/bean/Category.ets#L6-L17
ffbaf2c3eb085307e01fa9a82d4446dc2a71454c
gitee
chongzi/Lucky-ArkTs.git
84fc104d4a68def780a483e2543ebf9f53e793fd
entry/src/main/ets/model/OfferModel.ets
arkts
isExpired
检查Offer是否已过期
isExpired(): boolean { if (!this.expiryDate) return false; const expiryTime = new Date(this.expiryDate).getTime(); const now = new Date().getTime(); return expiryTime < now; }
AST#method_declaration#Left isExpired 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#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . expiryDate 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#variable_declaration#Left const AST#variable_declarator#Left expiryTime = 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#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . expiryDate AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . getTime AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left now = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left 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 . 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#return_statement#Left return AST#expression#Left AST#binary_expression#Left AST#expression#Left expiryTime AST#expression#Right < AST#expression#Left now 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
isExpired(): boolean { if (!this.expiryDate) return false; const expiryTime = new Date(this.expiryDate).getTime(); const now = new Date().getTime(); return expiryTime < now; }
https://github.com/chongzi/Lucky-ArkTs.git/blob/84fc104d4a68def780a483e2543ebf9f53e793fd/entry/src/main/ets/model/OfferModel.ets#L205-L210
c2183e3d2ecc424db3dcca796a3df2aa20679336
github
wasd09090030/MyHongmengProject.git
a8ed386b658ceeac69ef5bc42a92d78c7980821c
entry/src/main/ets/models/UserModel.ets
arkts
register
注册新用户
static async register(username: string, password: string): Promise<OperationResult> { if (!username || !password) { const result: OperationResult = { success: false, message: '用户名和密码不能为空' }; return result; } if (username.length < 3) { const result: OperationResult = { success: false, message: '用户名至少3个字符' }; return result; } if (password.length < 6) { const result: OperationResult = { success: false, message: '密码至少6个字符' }; return result; } try { const users = await UserManager.getAllUsers(); // 检查用户名是否已存在 if (users[username]) { const result: OperationResult = { success: false, message: '用户名已存在' }; return result; } // 创建新用户 const newUser: UserInfo = { username, password, createdAt: Date.now(), lastLoginAt: Date.now() }; users[username] = newUser; await UserManager.saveUsers(users); await UserManager.setCurrentUser(username); const result: OperationResult = { success: true, message: '注册成功' }; return result; } catch (error) { console.error('Register error:', error); const result: OperationResult = { success: false, message: '注册失败,请重试' }; return result; } }
AST#method_declaration#Left static async register AST#parameter_list#Left ( AST#parameter#Left username : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left password : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left OperationResult 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#unary_expression#Left ! AST#expression#Left username AST#expression#Right AST#unary_expression#Right AST#expression#Right || AST#expression#Left AST#unary_expression#Left ! AST#expression#Left password AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left result : AST#type_annotation#Left AST#primary_type#Left OperationResult AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left success AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left '用户名和密码不能为空' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left result AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left username AST#expression#Right . length AST#member_expression#Right AST#expression#Right < AST#expression#Left 3 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 result : AST#type_annotation#Left AST#primary_type#Left OperationResult AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left success AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left '用户名至少3个字符' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left result AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left password AST#expression#Right . length AST#member_expression#Right AST#expression#Right < AST#expression#Left 6 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 result : AST#type_annotation#Left AST#primary_type#Left OperationResult AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left success AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left '密码至少6个字符' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left result AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left users = 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 UserManager AST#expression#Right AST#await_expression#Right AST#expression#Right . getAllUsers 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#subscript_expression#Left AST#expression#Left users AST#expression#Right [ AST#expression#Left username AST#expression#Right ] AST#subscript_expression#Right AST#expression#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 OperationResult AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left success AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left '用户名已存在' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left result AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right // 创建新用户 AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left newUser : AST#type_annotation#Left AST#primary_type#Left UserInfo AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left username AST#property_assignment#Right , AST#property_assignment#Left password AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left createdAt 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 . now 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 lastLoginAt 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 . now AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#subscript_expression#Left AST#expression#Left users AST#expression#Right [ AST#expression#Left username 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 newUser AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left UserManager AST#expression#Right AST#await_expression#Right AST#expression#Right . saveUsers AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left users AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left UserManager AST#expression#Right AST#await_expression#Right AST#expression#Right . setCurrentUser AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left username AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left result : AST#type_annotation#Left AST#primary_type#Left OperationResult AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left success AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left true AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left '注册成功' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#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#catch_clause#Left catch ( error ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'Register error:' AST#expression#Right , AST#expression#Left error AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left result : AST#type_annotation#Left AST#primary_type#Left OperationResult AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left success AST#property_name#Right : AST#expression#Left AST#boolean_literal#Left false AST#boolean_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left message AST#property_name#Right : AST#expression#Left '注册失败,请重试' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left result AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#catch_clause#Right AST#try_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static async register(username: string, password: string): Promise<OperationResult> { if (!username || !password) { const result: OperationResult = { success: false, message: '用户名和密码不能为空' }; return result; } if (username.length < 3) { const result: OperationResult = { success: false, message: '用户名至少3个字符' }; return result; } if (password.length < 6) { const result: OperationResult = { success: false, message: '密码至少6个字符' }; return result; } try { const users = await UserManager.getAllUsers(); if (users[username]) { const result: OperationResult = { success: false, message: '用户名已存在' }; return result; } const newUser: UserInfo = { username, password, createdAt: Date.now(), lastLoginAt: Date.now() }; users[username] = newUser; await UserManager.saveUsers(users); await UserManager.setCurrentUser(username); const result: OperationResult = { success: true, message: '注册成功' }; return result; } catch (error) { console.error('Register error:', error); const result: OperationResult = { success: false, message: '注册失败,请重试' }; return result; } }
https://github.com/wasd09090030/MyHongmengProject.git/blob/a8ed386b658ceeac69ef5bc42a92d78c7980821c/entry/src/main/ets/models/UserModel.ets#L37-L81
bef1280962ea1ac1eaab29ce78659c1b443947e5
github
yunkss/ef-tool
75f6761a0f2805d97183504745bf23c975ae514d
ef_core/src/main/ets/core/util/StrUtil.ets
arkts
toUpper
转换整个字符串的字符为大写 @param str 要转换的字符串 @returns 返回小写的字符串
static toUpper(str: string = ''): string { return str.toUpperCase(); }
AST#method_declaration#Left static toUpper 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#expression#Left '' AST#expression#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left str AST#expression#Right . toUpperCase AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static toUpper(str: string = ''): string { return str.toUpperCase(); }
https://github.com/yunkss/ef-tool/blob/75f6761a0f2805d97183504745bf23c975ae514d/ef_core/src/main/ets/core/util/StrUtil.ets#L223-L225
7e0c3f982d11765e6af6dceb2648b1eb2cc45fd0
gitee
bigbear20240612/birthday_reminder.git
647c411a6619affd42eb5d163ff18db4b34b27ff
entry/src/main/ets/pages/contacts/ContactEditPage.ets
arkts
buildBasicInfoSection
构建基本信息区域
@Builder buildBasicInfoSection() { Column({ space: 16 }) { Text('基本信息') .fontSize(20) .fontWeight(FontWeight.Bold) .fontColor('#333333') .alignSelf(ItemAlign.Start) // 姓名 Column({ space: 8 }) { Row() { Text('姓名') .fontSize(16) .fontColor('#333333') Text('*') .fontSize(16) .fontColor('#FF6B6B') } .width('100%') TextInput({ placeholder: '请输入姓名(必填)', text: this.name }) .fontSize(16) .backgroundColor(this.name.trim() ? '#ffffff' : '#fef0f0') .onChange((value: string) => { this.name = value; }) } // 关系 Column({ space: 8 }) { Text('关系') .fontSize(16) .fontColor('#333333') .alignSelf(ItemAlign.Start) Select([ {value: '家人', text: '家人'} as SelectOptionItem, {value: '朋友', text: '朋友'} as SelectOptionItem, {value: '同事', text: '同事'} as SelectOptionItem, {value: '其他', text: '其他'} as SelectOptionItem ] as SelectOptionItem[]) .selected(this.getRelationIndex(this.relation)) .value(this.getRelationText(this.relation)) .font({ size: 16, weight: FontWeight.Normal }) .fontColor('#333333') .selectedOptionFont({ size: 16, weight: FontWeight.Normal }) .optionFont({ size: 16, weight: FontWeight.Normal }) .width('100%') .height('48vp') .onSelect((index: number, value: string) => { if (value === '家人') { this.relation = RelationType.FAMILY; } else if (value === '朋友') { this.relation = RelationType.FRIEND; } else if (value === '同事') { this.relation = RelationType.COLLEAGUE; } else { this.relation = RelationType.OTHER; } }) } // 性别 Column({ space: 8 }) { Text('性别') .fontSize(16) .fontColor('#333333') .alignSelf(ItemAlign.Start) Select([ {value: '男', text: '男'} as SelectOptionItem, {value: '女', text: '女'} as SelectOptionItem, {value: '未知', text: '未知'} as SelectOptionItem ] as SelectOptionItem[]) .selected(this.getGenderIndex(this.gender)) .value(this.getGenderText(this.gender)) .font({ size: 16, weight: FontWeight.Normal }) .fontColor('#333333') .selectedOptionFont({ size: 16, weight: FontWeight.Normal }) .optionFont({ size: 16, weight: FontWeight.Normal }) .width('100%') .height('48vp') .onSelect((index: number, value: string) => { if (value === '男') { this.gender = Gender.MALE; } else if (value === '女') { this.gender = Gender.FEMALE; } else { this.gender = Gender.UNKNOWN; } }) } // 联系方式 Column({ space: 8 }) { Text('手机号') .fontSize(16) .fontColor('#333333') .alignSelf(ItemAlign.Start) TextInput({ placeholder: '请输入手机号', text: this.phone }) .fontSize(16) .type(InputType.PhoneNumber) .onChange((value: string) => { this.phone = value; }) } Column({ space: 8 }) { Text('邮箱') .fontSize(16) .fontColor('#333333') .alignSelf(ItemAlign.Start) TextInput({ placeholder: '请输入邮箱', text: this.email }) .fontSize(16) .type(InputType.Email) .onChange((value: string) => { this.email = value; }) } // 亲密度 Column({ space: 8 }) { Text(`亲密度: ${this.intimacyLevel}`) .fontSize(16) .fontColor('#333333') .alignSelf(ItemAlign.Start) Slider({ value: this.intimacyLevel, min: 1, max: 5, step: 1, style: SliderStyle.OutSet }) .width('100%') .selectedColor('#4ECDC4') .onChange((value: number) => { this.intimacyLevel = Math.round(value); }) Row() { Text('1') .fontSize(12) .fontColor('#999999') Blank() Text('5') .fontSize(12) .fontColor('#999999') } .width('100%') } } .width('100%') .padding(16) .backgroundColor('#ffffff') .borderRadius(12) }
AST#method_declaration#Left AST#decorator#Left @ Builder AST#decorator#Right buildBasicInfoSection AST#parameter_list#Left ( ) AST#parameter_list#Right AST#builder_function_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 16 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '基本信息' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 20 AST#expression#Right ) AST#modifier_chain_expression#Left . fontWeight ( AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Bold AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#333333' AST#expression#Right ) AST#modifier_chain_expression#Left . alignSelf ( AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 姓名 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 8 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '姓名' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#333333' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '*' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#FF6B6B' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#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 TextInput ( AST#component_parameters#Left { AST#component_parameter#Left placeholder : AST#expression#Left '请输入姓名(必填)' AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left text : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . name AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left AST#conditional_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 . name AST#member_expression#Right AST#expression#Right . trim AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ? AST#expression#Left '#ffffff' AST#expression#Right : AST#expression#Left '#fef0f0' AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onChange ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . name AST#member_expression#Right = AST#expression#Left value AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 关系 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 8 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '关系' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#333333' AST#expression#Right ) AST#modifier_chain_expression#Left . alignSelf ( AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Select ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#as_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left value AST#property_name#Right : AST#expression#Left '家人' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left text AST#property_name#Right : AST#expression#Left '家人' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left SelectOptionItem AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right , AST#expression#Left AST#as_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left value AST#property_name#Right : AST#expression#Left '朋友' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left text AST#property_name#Right : AST#expression#Left '朋友' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left SelectOptionItem AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right , AST#expression#Left AST#as_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left value AST#property_name#Right : AST#expression#Left '同事' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left text AST#property_name#Right : AST#expression#Left '同事' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left SelectOptionItem AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right , AST#expression#Left AST#as_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left value AST#property_name#Right : AST#expression#Left '其他' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left text AST#property_name#Right : AST#expression#Left '其他' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left SelectOptionItem AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left SelectOptionItem [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . selected ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getRelationIndex 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 . relation AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . value ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getRelationText 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 . relation AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . font ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left size AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left weight AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Normal 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 '#333333' AST#expression#Right ) AST#modifier_chain_expression#Left . selectedOptionFont ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left size AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left weight AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Normal AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . optionFont ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left size AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left weight AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Normal AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '48vp' AST#expression#Right ) AST#modifier_chain_expression#Left . onSelect ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left value AST#expression#Right === AST#expression#Left '家人' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#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 . relation AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left RelationType AST#expression#Right . FAMILY 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 value AST#expression#Right === AST#expression#Left '朋友' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . relation AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left RelationType AST#expression#Right . FRIEND 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 value AST#expression#Right === AST#expression#Left '同事' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . relation AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left RelationType AST#expression#Right . COLLEAGUE 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 . relation AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left RelationType AST#expression#Right . OTHER 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#if_statement#Right AST#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 性别 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 8 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '性别' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#333333' AST#expression#Right ) AST#modifier_chain_expression#Left . alignSelf ( AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Select ( AST#expression#Left AST#as_expression#Left AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#as_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left value AST#property_name#Right : AST#expression#Left '男' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left text AST#property_name#Right : AST#expression#Left '男' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left SelectOptionItem AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right , AST#expression#Left AST#as_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left value AST#property_name#Right : AST#expression#Left '女' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left text AST#property_name#Right : AST#expression#Left '女' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left SelectOptionItem AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right , AST#expression#Left AST#as_expression#Left AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left value AST#property_name#Right : AST#expression#Left '未知' AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left text AST#property_name#Right : AST#expression#Left '未知' AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left SelectOptionItem AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right as AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left SelectOptionItem [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right AST#as_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . selected ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getGenderIndex 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 . gender AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . value ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . getGenderText 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 . gender AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . font ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left size AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left weight AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Normal 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 '#333333' AST#expression#Right ) AST#modifier_chain_expression#Left . selectedOptionFont ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left size AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left weight AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Normal AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . optionFont ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left size AST#property_name#Right : AST#expression#Left 16 AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left weight AST#property_name#Right : AST#expression#Left AST#member_expression#Left AST#expression#Left FontWeight AST#expression#Right . Normal AST#member_expression#Right AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '48vp' AST#expression#Right ) AST#modifier_chain_expression#Left . onSelect ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left index : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left value AST#expression#Right === AST#expression#Left '男' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#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 . gender AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left Gender AST#expression#Right . MALE 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 value AST#expression#Right === AST#expression#Left '女' AST#expression#Right AST#binary_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . gender AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left Gender AST#expression#Right . FEMALE 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 . gender AST#member_expression#Right = AST#expression#Left AST#member_expression#Left AST#expression#Left Gender AST#expression#Right . UNKNOWN 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#if_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 联系方式 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 8 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '手机号' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#333333' AST#expression#Right ) AST#modifier_chain_expression#Left . alignSelf ( AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left TextInput ( AST#component_parameters#Left { AST#component_parameter#Left placeholder : AST#expression#Left '请输入手机号' AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left text : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . phone AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . type ( AST#expression#Left AST#member_expression#Left AST#expression#Left InputType AST#expression#Right . PhoneNumber AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onChange ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . phone AST#member_expression#Right = AST#expression#Left value AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 8 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '邮箱' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#333333' AST#expression#Right ) AST#modifier_chain_expression#Left . alignSelf ( AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left TextInput ( AST#component_parameters#Left { AST#component_parameter#Left placeholder : AST#expression#Left '请输入邮箱' AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left text : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . email AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . type ( AST#expression#Left AST#member_expression#Left AST#expression#Left InputType AST#expression#Right . Email AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onChange ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . email AST#member_expression#Right = AST#expression#Left value AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right // 亲密度 AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Column ( AST#component_parameters#Left { AST#component_parameter#Left space : AST#expression#Left 8 AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#template_literal#Left ` 亲密度: AST#template_substitution#Left $ { AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . intimacyLevel AST#member_expression#Right AST#expression#Right } AST#template_substitution#Right ` AST#template_literal#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#333333' AST#expression#Right ) AST#modifier_chain_expression#Left . alignSelf ( AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Start AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Slider ( AST#component_parameters#Left { AST#component_parameter#Left value : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . intimacyLevel AST#member_expression#Right AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left min : AST#expression#Left 1 AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left max : AST#expression#Left 5 AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left step : AST#expression#Left 1 AST#expression#Right AST#component_parameter#Right , AST#component_parameter#Left style : AST#expression#Left AST#member_expression#Left AST#expression#Left SliderStyle AST#expression#Right . OutSet AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . selectedColor ( AST#expression#Left '#4ECDC4' AST#expression#Right ) AST#modifier_chain_expression#Left . onChange ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left value : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . intimacyLevel AST#member_expression#Right = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Math AST#expression#Right . round 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#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Row ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '1' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 12 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#999999' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Blank ( ) AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left '5' AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 12 AST#expression#Right ) AST#modifier_chain_expression#Left . fontColor ( AST#expression#Left '#999999' AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left 16 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left '#ffffff' AST#expression#Right ) AST#modifier_chain_expression#Left . borderRadius ( AST#expression#Left 12 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#builder_function_body#Right AST#method_declaration#Right
@Builder buildBasicInfoSection() { Column({ space: 16 }) { Text('基本信息') .fontSize(20) .fontWeight(FontWeight.Bold) .fontColor('#333333') .alignSelf(ItemAlign.Start) Column({ space: 8 }) { Row() { Text('姓名') .fontSize(16) .fontColor('#333333') Text('*') .fontSize(16) .fontColor('#FF6B6B') } .width('100%') TextInput({ placeholder: '请输入姓名(必填)', text: this.name }) .fontSize(16) .backgroundColor(this.name.trim() ? '#ffffff' : '#fef0f0') .onChange((value: string) => { this.name = value; }) } Column({ space: 8 }) { Text('关系') .fontSize(16) .fontColor('#333333') .alignSelf(ItemAlign.Start) Select([ {value: '家人', text: '家人'} as SelectOptionItem, {value: '朋友', text: '朋友'} as SelectOptionItem, {value: '同事', text: '同事'} as SelectOptionItem, {value: '其他', text: '其他'} as SelectOptionItem ] as SelectOptionItem[]) .selected(this.getRelationIndex(this.relation)) .value(this.getRelationText(this.relation)) .font({ size: 16, weight: FontWeight.Normal }) .fontColor('#333333') .selectedOptionFont({ size: 16, weight: FontWeight.Normal }) .optionFont({ size: 16, weight: FontWeight.Normal }) .width('100%') .height('48vp') .onSelect((index: number, value: string) => { if (value === '家人') { this.relation = RelationType.FAMILY; } else if (value === '朋友') { this.relation = RelationType.FRIEND; } else if (value === '同事') { this.relation = RelationType.COLLEAGUE; } else { this.relation = RelationType.OTHER; } }) } Column({ space: 8 }) { Text('性别') .fontSize(16) .fontColor('#333333') .alignSelf(ItemAlign.Start) Select([ {value: '男', text: '男'} as SelectOptionItem, {value: '女', text: '女'} as SelectOptionItem, {value: '未知', text: '未知'} as SelectOptionItem ] as SelectOptionItem[]) .selected(this.getGenderIndex(this.gender)) .value(this.getGenderText(this.gender)) .font({ size: 16, weight: FontWeight.Normal }) .fontColor('#333333') .selectedOptionFont({ size: 16, weight: FontWeight.Normal }) .optionFont({ size: 16, weight: FontWeight.Normal }) .width('100%') .height('48vp') .onSelect((index: number, value: string) => { if (value === '男') { this.gender = Gender.MALE; } else if (value === '女') { this.gender = Gender.FEMALE; } else { this.gender = Gender.UNKNOWN; } }) } Column({ space: 8 }) { Text('手机号') .fontSize(16) .fontColor('#333333') .alignSelf(ItemAlign.Start) TextInput({ placeholder: '请输入手机号', text: this.phone }) .fontSize(16) .type(InputType.PhoneNumber) .onChange((value: string) => { this.phone = value; }) } Column({ space: 8 }) { Text('邮箱') .fontSize(16) .fontColor('#333333') .alignSelf(ItemAlign.Start) TextInput({ placeholder: '请输入邮箱', text: this.email }) .fontSize(16) .type(InputType.Email) .onChange((value: string) => { this.email = value; }) } Column({ space: 8 }) { Text(`亲密度: ${this.intimacyLevel}`) .fontSize(16) .fontColor('#333333') .alignSelf(ItemAlign.Start) Slider({ value: this.intimacyLevel, min: 1, max: 5, step: 1, style: SliderStyle.OutSet }) .width('100%') .selectedColor('#4ECDC4') .onChange((value: number) => { this.intimacyLevel = Math.round(value); }) Row() { Text('1') .fontSize(12) .fontColor('#999999') Blank() Text('5') .fontSize(12) .fontColor('#999999') } .width('100%') } } .width('100%') .padding(16) .backgroundColor('#ffffff') .borderRadius(12) }
https://github.com/bigbear20240612/birthday_reminder.git/blob/647c411a6619affd42eb5d163ff18db4b34b27ff/entry/src/main/ets/pages/contacts/ContactEditPage.ets#L351-L510
ba07d01851550f327b8e76400bdcd4b715ad3d0f
github
Autumnker/ArkTS_FreeKnowledgeChat.git
cfbe354ba6ac3bc03f23484aa102dfc41c8b64e7
entry/src/main/ets/commonViews/comInput.ets
arkts
comInput
通用输入框
@Component export struct comInput{ @Prop title:string @Prop placeholder:string @Prop type:InputType @Link value:string build() { Flex(){ Flex({alignItems:ItemAlign.Center}){ Text(this.title) .width(120) .fontSize(20) TextInput({ placeholder: this.placeholder }) .type(this.type) .flexShrink(1) .backgroundColor('transparent') .fontSize(this.type===InputType.Password?15:20) .placeholderFont({size:20}) .onChange((value)=>{ this.value=value }) } .width('100%') .height('100%') .padding({left:10,right:10}) .border({width:{bottom:1},color:{bottom:'#ffcbcbcb'}}) } .height(60) .padding({left:10,right:10}) } }
AST#decorated_export_declaration#Left AST#decorator#Left @ Component AST#decorator#Right export struct comInput AST#component_body#Left { AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right title : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right placeholder : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Prop AST#decorator#Right type : AST#type_annotation#Left AST#primary_type#Left InputType AST#primary_type#Right AST#type_annotation#Right AST#property_declaration#Right AST#property_declaration#Left AST#decorator#Left @ Link AST#decorator#Right value : AST#type_annotation#Left AST#primary_type#Left string 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 Flex ( ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Flex ( AST#component_parameters#Left { AST#component_parameter#Left alignItems : AST#expression#Left AST#member_expression#Left AST#expression#Left ItemAlign AST#expression#Right . Center AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#container_content_body#Left { AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left Text ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . title AST#member_expression#Right AST#expression#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left 120 AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left 20 AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right AST#arkts_ui_element#Left AST#ui_element_with_modifiers#Left AST#ui_component#Left TextInput ( AST#component_parameters#Left { AST#component_parameter#Left placeholder : AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . placeholder AST#member_expression#Right AST#expression#Right AST#component_parameter#Right } AST#component_parameters#Right ) AST#ui_component#Right AST#modifier_chain_expression#Left . type ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . type AST#member_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . flexShrink ( AST#expression#Left 1 AST#expression#Right ) AST#modifier_chain_expression#Left . backgroundColor ( AST#expression#Left 'transparent' AST#expression#Right ) AST#modifier_chain_expression#Left . fontSize ( AST#expression#Left AST#conditional_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . type AST#member_expression#Right AST#expression#Right === AST#expression#Left InputType AST#expression#Right AST#binary_expression#Right AST#expression#Right . Password AST#member_expression#Right AST#expression#Right ? AST#expression#Left 15 AST#expression#Right : AST#expression#Left 20 AST#expression#Right AST#conditional_expression#Right AST#expression#Right ) AST#modifier_chain_expression#Left . placeholderFont ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left size AST#property_name#Right : AST#expression#Left 20 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#modifier_chain_expression#Left . onChange ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left value AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . value AST#member_expression#Right = AST#expression#Left value AST#expression#Right AST#assignment_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#arrow_function#Right AST#expression#Right ) AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . width ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . height ( AST#expression#Left '100%' AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 10 AST#expression#Right AST#property_assignment#Right , AST#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 . border ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left width AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left 1 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left color AST#property_name#Right : AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left bottom AST#property_name#Right : AST#expression#Left '#ffcbcbcb' 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#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#modifier_chain_expression#Right AST#ui_element_with_modifiers#Right AST#arkts_ui_element#Right } AST#container_content_body#Right AST#ui_component#Right AST#modifier_chain_expression#Left . height ( AST#expression#Left 60 AST#expression#Right ) AST#modifier_chain_expression#Left . padding ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left left AST#property_name#Right : AST#expression#Left 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#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 comInput{ @Prop title:string @Prop placeholder:string @Prop type:InputType @Link value:string build() { Flex(){ Flex({alignItems:ItemAlign.Center}){ Text(this.title) .width(120) .fontSize(20) TextInput({ placeholder: this.placeholder }) .type(this.type) .flexShrink(1) .backgroundColor('transparent') .fontSize(this.type===InputType.Password?15:20) .placeholderFont({size:20}) .onChange((value)=>{ this.value=value }) } .width('100%') .height('100%') .padding({left:10,right:10}) .border({width:{bottom:1},color:{bottom:'#ffcbcbcb'}}) } .height(60) .padding({left:10,right:10}) } }
https://github.com/Autumnker/ArkTS_FreeKnowledgeChat.git/blob/cfbe354ba6ac3bc03f23484aa102dfc41c8b64e7/entry/src/main/ets/commonViews/comInput.ets#L2-L32
270cba36b3a85fa9ab29db3f59f0ab04e1a7b7ba
github
IceYuanyyy/OxHornCampus.git
bb5686f77fa36db89687502e35898cda218d601f
entry/src/main/ets/common/utils/HttpUtils.ets
arkts
用户信息结构
export interface UserInfo { id: number; username: string; phone?: string; createTime?: string; }
AST#export_declaration#Left export AST#interface_declaration#Left interface UserInfo AST#object_type#Left { AST#type_member#Left id : AST#type_annotation#Left AST#primary_type#Left number AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left username : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; AST#type_member#Left phone ? : 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 createTime ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#type_member#Right ; } AST#object_type#Right AST#interface_declaration#Right AST#export_declaration#Right
export interface UserInfo { id: number; username: string; phone?: string; createTime?: string; }
https://github.com/IceYuanyyy/OxHornCampus.git/blob/bb5686f77fa36db89687502e35898cda218d601f/entry/src/main/ets/common/utils/HttpUtils.ets#L33-L38
4fa9b49acc2d75ee9b7007d3308e4292e0a94146
github
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_utils/src/main/ets/utils/SnapshotUtil.ets
arkts
removeSnapshotListener
关闭系统截屏事件的监听 @param callback 监听事件,不传关闭所有监听。
static removeSnapshotListener(callback?: VoidCallback): void { if (callback) { AppUtil.getMainWindow().off('screenshot', callback); } else { AppUtil.getMainWindow().off('screenshot'); } }
AST#method_declaration#Left static removeSnapshotListener AST#parameter_list#Left ( AST#parameter#Left callback ? : AST#type_annotation#Left AST#primary_type#Left VoidCallback 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 callback AST#expression#Right ) { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . off AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'screenshot' AST#expression#Right , AST#expression#Left callback AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } else { AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AppUtil AST#expression#Right . getMainWindow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . off AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'screenshot' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right } AST#ui_if_statement#Right AST#ui_control_flow#Right } AST#builder_function_body#Right AST#method_declaration#Right
static removeSnapshotListener(callback?: VoidCallback): void { if (callback) { AppUtil.getMainWindow().off('screenshot', callback); } else { AppUtil.getMainWindow().off('screenshot'); } }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_utils/src/main/ets/utils/SnapshotUtil.ets#L86-L92
aee8dfcaa3b741514a221b81801e8e4c7291fe18
gitee
awa_Liny/LinysBrowser_NEXT
a5cd96a9aa8114cae4972937f94a8967e55d4a10
home/src/main/ets/hosts/bunch_of_history_index_lite.ets
arkts
log_head
The head of logging information. @returns "[Meow][bunch_of_history_index_indexer_only]"
static log_head() { return '[Meow][bunch_of_history_index_indexer_only]'; }
AST#method_declaration#Left static log_head AST#parameter_list#Left ( ) AST#parameter_list#Right AST#block_statement#Left { AST#statement#Left AST#return_statement#Left return AST#expression#Left '[Meow][bunch_of_history_index_indexer_only]' AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#method_declaration#Right
static log_head() { return '[Meow][bunch_of_history_index_indexer_only]'; }
https://github.com/awa_Liny/LinysBrowser_NEXT/blob/a5cd96a9aa8114cae4972937f94a8967e55d4a10/home/src/main/ets/hosts/bunch_of_history_index_lite.ets#L182-L184
f8fa95011089836cb9ab7b13278023dd727a2c83
gitee
azhuge233/ASFShortcut-HN.git
d1669c920c56317611b5b0375aa5315c1b91211b
entry/src/main/ets/common/utils/DB.ets
arkts
getAllSettings
debug 方法
async getAllSettings(): Promise<Map<string, string>> { await this.waitForReady(); const settings = new Map<string, string>(); if (!this.rdbStore) { Logger.error(this.LOG_TAG, "数据库实例不存在"); return settings; } try { const predicates = new relationalStore.RdbPredicates(this.TN_HostInfo); const resultSet = await this.rdbStore.query(predicates, [this.KEY_HostInfo_KEY, this.KEY_HostInfo_VALUE]); if (resultSet.rowCount > 0) { while (resultSet.goToNextRow()) { const key = resultSet.getString(resultSet.getColumnIndex(this.KEY_HostInfo_KEY)); const value = resultSet.getString(resultSet.getColumnIndex(this.KEY_HostInfo_VALUE)); settings.set(key, value); } } resultSet.close(); return settings; } catch (err) { Logger.error(this.LOG_TAG, `无法获取全部设置信息, ${err}`); return settings; } }
AST#method_declaration#Left async getAllSettings 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 Map AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right , AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right > AST#type_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#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . waitForReady 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 const AST#variable_declarator#Left settings = 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 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#if_statement#Left if ( AST#expression#Left AST#member_expression#Left AST#expression#Left AST#unary_expression#Left ! AST#expression#Left this AST#expression#Right AST#unary_expression#Right AST#expression#Right . rdbStore AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left Logger AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . LOG_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left "数据库实例不存在" AST#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 settings AST#expression#Right ; AST#return_statement#Right AST#statement#Right } AST#block_statement#Right AST#if_statement#Right AST#statement#Right AST#statement#Left AST#try_statement#Left try AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left predicates = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#new_expression#Left new AST#expression#Left relationalStore AST#expression#Right AST#new_expression#Right AST#expression#Right . RdbPredicates AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . TN_HostInfo AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left resultSet = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#await_expression#Left await AST#expression#Left this AST#expression#Right AST#await_expression#Right AST#expression#Right . rdbStore AST#member_expression#Right AST#expression#Right . query AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left predicates AST#expression#Right , AST#expression#Left AST#array_literal#Left [ AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . KEY_HostInfo_KEY AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . KEY_HostInfo_VALUE AST#member_expression#Right AST#expression#Right ] AST#array_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#if_statement#Left if ( AST#expression#Left AST#binary_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resultSet AST#expression#Right . rowCount 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#while_statement#Left while ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resultSet AST#expression#Right . goToNextRow AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#variable_declaration#Left const AST#variable_declarator#Left key = AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resultSet AST#expression#Right . getString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resultSet AST#expression#Right . getColumnIndex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . KEY_HostInfo_KEY AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#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 resultSet AST#expression#Right . getString AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left resultSet AST#expression#Right . getColumnIndex AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . KEY_HostInfo_VALUE AST#member_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#variable_declarator#Right ; AST#variable_declaration#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left settings AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left key AST#expression#Right , AST#expression#Left value AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#while_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 resultSet AST#expression#Right . close AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#return_statement#Left return AST#expression#Left settings 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 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 this AST#expression#Right . LOG_TAG AST#member_expression#Right AST#expression#Right , AST#expression#Left AST#template_literal#Left ` 无法获取全部设置信息, AST#template_substitution#Left $ { AST#expression#Left 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#statement#Left AST#return_statement#Left return AST#expression#Left settings 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 getAllSettings(): Promise<Map<string, string>> { await this.waitForReady(); const settings = new Map<string, string>(); if (!this.rdbStore) { Logger.error(this.LOG_TAG, "数据库实例不存在"); return settings; } try { const predicates = new relationalStore.RdbPredicates(this.TN_HostInfo); const resultSet = await this.rdbStore.query(predicates, [this.KEY_HostInfo_KEY, this.KEY_HostInfo_VALUE]); if (resultSet.rowCount > 0) { while (resultSet.goToNextRow()) { const key = resultSet.getString(resultSet.getColumnIndex(this.KEY_HostInfo_KEY)); const value = resultSet.getString(resultSet.getColumnIndex(this.KEY_HostInfo_VALUE)); settings.set(key, value); } } resultSet.close(); return settings; } catch (err) { Logger.error(this.LOG_TAG, `无法获取全部设置信息, ${err}`); return settings; } }
https://github.com/azhuge233/ASFShortcut-HN.git/blob/d1669c920c56317611b5b0375aa5315c1b91211b/entry/src/main/ets/common/utils/DB.ets#L155-L183
605069a7e94b5043ada10a14d979c3af8ed98d01
github
pangpang20/wavecast.git
d3da8a0009eb44a576a2b9d9d9fe6195a2577e32
entry/src/main/ets/common/UIUtils.ets
arkts
Dialog配置
export class DialogOptions { title: string = ''; message: string = ''; buttons: ButtonOptions[] = []; constructor(title?: string, message?: string, buttons?: ButtonOptions[]) { this.title = title || ''; this.message = message || ''; this.buttons = buttons || []; } }
AST#export_declaration#Left export AST#class_declaration#Left class DialogOptions AST#class_body#Left { AST#property_declaration#Left title : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left message : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left '' AST#expression#Right ; AST#property_declaration#Right AST#property_declaration#Left buttons : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left ButtonOptions [ ] AST#array_type#Right AST#primary_type#Right AST#type_annotation#Right = AST#expression#Left AST#array_literal#Left [ ] AST#array_literal#Right AST#expression#Right ; AST#property_declaration#Right AST#constructor_declaration#Left constructor AST#parameter_list#Left ( AST#parameter#Left title ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left message ? : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left buttons ? : AST#type_annotation#Left AST#primary_type#Left AST#array_type#Left ButtonOptions [ ] 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 . title AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left title AST#expression#Right || AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . message AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left message AST#expression#Right || AST#expression#Left '' AST#expression#Right AST#binary_expression#Right AST#expression#Right AST#assignment_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#assignment_expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . buttons AST#member_expression#Right = AST#expression#Left AST#binary_expression#Left AST#expression#Left buttons 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 } AST#block_statement#Right AST#constructor_declaration#Right } AST#class_body#Right AST#class_declaration#Right AST#export_declaration#Right
export class DialogOptions { title: string = ''; message: string = ''; buttons: ButtonOptions[] = []; constructor(title?: string, message?: string, buttons?: ButtonOptions[]) { this.title = title || ''; this.message = message || ''; this.buttons = buttons || []; } }
https://github.com/pangpang20/wavecast.git/blob/d3da8a0009eb44a576a2b9d9d9fe6195a2577e32/entry/src/main/ets/common/UIUtils.ets#L33-L43
3c784c7f52b6f218a56b57ec4c2c69bca6090b8b
github
sedlei/Smart-park-system.git
253228f73e419e92fd83777f564889d202f7c699
src/main/ets/utils/MqttUtil.ets
arkts
subscribe
订阅消息
public async subscribe( topic: string, callback: (data: string) => void ): Promise<void>{ if (!this.mqttClient) { console.warn('MQTT 客户端未创建'); return; } // 启动监听(订阅任意数据,因系统默认转发所有配置过的订阅) await this.mqttClient.subscribe({ topic: topic, qos: 0 }).then((data) => { this.callbackMap.set(topic, callback); console.info('订阅:', topic, '成功:', JSON.stringify(data)) }).catch((err: object) => { console.error('订阅失败:', JSON.stringify(err)) }) }
AST#method_declaration#Left public async subscribe AST#parameter_list#Left ( AST#parameter#Left topic : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right , AST#parameter#Left callback : AST#type_annotation#Left AST#function_type#Left AST#parameter_list#Left ( AST#parameter#Left data : AST#type_annotation#Left AST#primary_type#Left string AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right AST#function_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right : AST#type_annotation#Left AST#primary_type#Left AST#generic_type#Left Promise AST#type_arguments#Left < AST#type_annotation#Left AST#primary_type#Left void AST#primary_type#Right AST#type_annotation#Right > AST#type_arguments#Right AST#generic_type#Right AST#primary_type#Right AST#type_annotation#Right AST#block_statement#Left { AST#statement#Left AST#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 . mqttClient AST#member_expression#Right AST#expression#Right ) AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . warn AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left 'MQTT 客户端未创建' AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#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#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 . mqttClient AST#member_expression#Right AST#expression#Right . subscribe AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#object_literal#Left { AST#property_assignment#Left AST#property_name#Left topic AST#property_name#Right : AST#expression#Left topic AST#expression#Right AST#property_assignment#Right , AST#property_assignment#Left AST#property_name#Left qos AST#property_name#Right : AST#expression#Left 0 AST#expression#Right AST#property_assignment#Right } AST#object_literal#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right . then AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left AST#arrow_function#Left AST#parameter_list#Left ( AST#parameter#Left data AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left this AST#expression#Right . callbackMap AST#member_expression#Right AST#expression#Right . set AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left topic AST#expression#Right , AST#expression#Left callback AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ; AST#expression_statement#Right AST#statement#Right AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . info AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '订阅:' AST#expression#Right , AST#expression#Left topic AST#expression#Right , AST#expression#Left '成功:' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left data AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#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 object AST#primary_type#Right AST#type_annotation#Right AST#parameter#Right ) AST#parameter_list#Right => AST#block_statement#Left { AST#statement#Left AST#expression_statement#Left AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left console AST#expression#Right . error AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left '订阅失败:' AST#expression#Right , AST#expression#Left AST#call_expression#Left AST#expression#Left AST#member_expression#Left AST#expression#Left JSON AST#expression#Right . stringify AST#member_expression#Right AST#expression#Right AST#argument_list#Left ( AST#expression#Left err AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right ) AST#argument_list#Right AST#call_expression#Right AST#expression#Right AST#expression_statement#Right AST#statement#Right } AST#block_statement#Right AST#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
public async subscribe( topic: string, callback: (data: string) => void ): Promise<void>{ if (!this.mqttClient) { console.warn('MQTT 客户端未创建'); return; } await this.mqttClient.subscribe({ topic: topic, qos: 0 }).then((data) => { this.callbackMap.set(topic, callback); console.info('订阅:', topic, '成功:', JSON.stringify(data)) }).catch((err: object) => { console.error('订阅失败:', JSON.stringify(err)) }) }
https://github.com/sedlei/Smart-park-system.git/blob/253228f73e419e92fd83777f564889d202f7c699/src/main/ets/utils/MqttUtil.ets#L123-L141
81e32f9866cbcdcbad1a846f8612bb9ab379553f
github
tongyuyan/harmony-utils
697472f011a43e783eeefaa28ef9d713c4171726
harmony_dialog/src/main/ets/utils/constraint.ets
arkts
弹框按钮的Action类型(从左往右,最多四个按钮)
export enum DialogAction { ONE = -1, //第一个按钮 - 取消。 TWO = -2, //第二个按钮 - 确定。 THREE = -3, //第三个按钮。 FOUR = -4, //第四个按钮。 FIVE = -5, //第五个按钮。 SIX = -6, //第六个按钮。 CANCEL = ONE, //第一个按钮 - 取消。 SURE = TWO, //第二个按钮 - 确定。 }
AST#export_declaration#Left export AST#enum_declaration#Left enum DialogAction AST#enum_body#Left { AST#enum_member#Left ONE = AST#expression#Left AST#unary_expression#Left - AST#expression#Left 1 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#enum_member#Right , //第一个按钮 - 取消。 AST#enum_member#Left TWO = AST#expression#Left AST#unary_expression#Left - AST#expression#Left 2 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#enum_member#Right , //第二个按钮 - 确定。 AST#enum_member#Left THREE = AST#expression#Left AST#unary_expression#Left - AST#expression#Left 3 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#enum_member#Right , //第三个按钮。 AST#enum_member#Left FOUR = AST#expression#Left AST#unary_expression#Left - AST#expression#Left 4 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#enum_member#Right , //第四个按钮。 AST#enum_member#Left FIVE = AST#expression#Left AST#unary_expression#Left - AST#expression#Left 5 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#enum_member#Right , //第五个按钮。 AST#enum_member#Left SIX = AST#expression#Left AST#unary_expression#Left - AST#expression#Left 6 AST#expression#Right AST#unary_expression#Right AST#expression#Right AST#enum_member#Right , //第六个按钮。 AST#enum_member#Left CANCEL = AST#expression#Left ONE AST#expression#Right AST#enum_member#Right , //第一个按钮 - 取消。 AST#enum_member#Left SURE = AST#expression#Left TWO AST#expression#Right AST#enum_member#Right , //第二个按钮 - 确定。 } AST#enum_body#Right AST#enum_declaration#Right AST#export_declaration#Right
export enum DialogAction { ONE = -1, TWO = -2, THREE = -3, FOUR = -4, FIVE = -5, SIX = -6, CANCEL = ONE, SURE = TWO, }
https://github.com/tongyuyan/harmony-utils/blob/697472f011a43e783eeefaa28ef9d713c4171726/harmony_dialog/src/main/ets/utils/constraint.ets#L39-L48
0c483171e9e0c2a9b3d09a4ecb2b574d63b27cb0
gitee